From bdec01e02d0790e0e5cb9b635bd200bd2ed0312b Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Mon, 09 Oct 2006 12:54:14 +0000
Subject: [PATCH] Update the JMX connection handler to ensure that it invokes the post-connect plugins at the appropriate time. Update the JMX client connection to ensure that it invokes the post-disconnect plugins at the appropriate time. Add unit-test to check that post-connect and post-disconnect plugins are called.
---
opends/src/server/org/opends/server/protocols/jmx/JmxClientConnection.java | 56 +++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 41 insertions(+), 15 deletions(-)
diff --git a/opends/src/server/org/opends/server/protocols/jmx/JmxClientConnection.java b/opends/src/server/org/opends/server/protocols/jmx/JmxClientConnection.java
index 4711435..b0052f1 100644
--- a/opends/src/server/org/opends/server/protocols/jmx/JmxClientConnection.java
+++ b/opends/src/server/org/opends/server/protocols/jmx/JmxClientConnection.java
@@ -88,6 +88,11 @@
*/
private JmxConnectionHandler jmxConnectionHandler;
+ /**
+ * Indicate that the disconnect process is started.
+ */
+ private Boolean disconnectStarted = new Boolean(false);
+
/**
* Creates a new Jmx client connection that will be authenticated as
@@ -181,7 +186,7 @@
//
// Ok, we can perform the unbind: call finalize
- finalize();
+ disconnect(DisconnectReason.CLIENT_DISCONNECT, false, null, -1);
}
@@ -884,7 +889,40 @@
String.valueOf(sendNotification), String.valueOf(message),
String.valueOf(messageID));
- // No implementation is required since there is nothing to disconnect.
+ // we are already performing a disconnect
+ if (disconnectStarted)
+ {
+ return;
+ }
+ disconnectStarted = true ;
+
+
+
+ // unbind the underlying connection
+ try
+ {
+ UnbindOperation unbindOp = new UnbindOperation((ClientConnection) this,
+ this.nextOperationID(), this.nextMessageID(), null);
+ unbindOp.run();
+ }
+ catch (Exception e)
+ {
+ // TODO print a message ?
+ assert debugException(CLASS_NAME, "disconnect", e);
+ }
+
+ // Call postDisconnectPlugins
+ try
+ {
+ PluginConfigManager pluginManager =
+ DirectoryServer.getPluginConfigManager();
+ pluginManager.invokePostDisconnectPlugins(this, disconnectReason,
+ messageID, message);
+ }
+ catch (Exception e)
+ {
+ assert debugException(CLASS_NAME, "disconnect", e);
+ }
}
@@ -1067,19 +1105,7 @@
*/
protected void finalize()
{
- try
- {
- ArrayList<Control> requestControls = new ArrayList<Control>(0);
- UnbindOperation unbindOp = new UnbindOperation((ClientConnection) this,
- this.nextOperationID(), this.nextMessageID(), requestControls);
-
- unbindOp.run();
- }
- catch (Exception e)
- {
- // TODO print a message ?
- assert debugException(CLASS_NAME, "bind", e);
- }
+ disconnect(DisconnectReason.OTHER, false, null, -1);
}
}
--
Gitblit v1.10.0