camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/4] git commit: CAMEL-6695: ManagementAgent should use a thread safe map for housekeeping of registered mbeans.
Date Tue, 03 Sep 2013 11:49:45 GMT
CAMEL-6695: ManagementAgent should use a thread safe map for housekeeping of registered mbeans.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/44905ef4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/44905ef4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/44905ef4

Branch: refs/heads/camel-2.10.x
Commit: 44905ef4de80f146073397b297c77ea4e078b522
Parents: b368b05
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Sep 3 13:48:19 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Sep 3 13:49:13 2013 +0200

----------------------------------------------------------------------
 .../camel/management/DefaultManagementAgent.java    | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/44905ef4/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
b/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
index bd44b93..5f4edad 100644
--- a/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
+++ b/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
@@ -25,9 +25,9 @@ import java.rmi.RemoteException;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
 import java.rmi.server.UnicastRemoteObject;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import javax.management.JMException;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
@@ -62,7 +62,7 @@ public class DefaultManagementAgent extends ServiceSupport implements Management
     private CamelContext camelContext;
     private MBeanServer server;
     // need a name -> actual name mapping as some servers changes the names (such as WebSphere)
-    private final Map<ObjectName, ObjectName> mbeansRegistered = new HashMap<ObjectName,
ObjectName>();
+    private final ConcurrentMap<ObjectName, ObjectName> mbeansRegistered = new ConcurrentHashMap<ObjectName,
ObjectName>();
     private JMXConnectorServer cs;
     private Registry registry;
 
@@ -238,15 +238,17 @@ public class DefaultManagementAgent extends ServiceSupport implements
Management
 
     public void unregister(ObjectName name) throws JMException {
         if (isRegistered(name)) {
-            server.unregisterMBean(mbeansRegistered.get(name));
+            ObjectName on = mbeansRegistered.remove(name);
+            server.unregisterMBean(on);
             LOG.debug("Unregistered MBean with ObjectName: {}", name);
+        } else {
+            mbeansRegistered.remove(name);
         }
-        mbeansRegistered.remove(name);
     }
 
     public boolean isRegistered(ObjectName name) {
-        return (mbeansRegistered.containsKey(name) 
-                && server.isRegistered(mbeansRegistered.get(name))) 
+        ObjectName on = mbeansRegistered.get(name);
+        return (on != null && server.isRegistered(on))
                 || server.isRegistered(name);
     }
 


Mime
View raw message