camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1327403 - in /camel/branches/camel-2.9.x: ./ camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java camel-core/src/test/java/org/apache/camel/management/DefaultManagementAgentMockTest.java
Date Wed, 18 Apr 2012 07:43:23 GMT
Author: davsclaus
Date: Wed Apr 18 07:43:22 2012
New Revision: 1327403

URL: http://svn.apache.org/viewvc?rev=1327403&view=rev
Log:
CAMEL-5187: Improved Camel JMX working with WebSphere. Thanks to Christian Ohr for the patch.

Added:
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/management/DefaultManagementAgentMockTest.java
      - copied unchanged from r1327402, camel/trunk/camel-core/src/test/java/org/apache/camel/management/DefaultManagementAgentMockTest.java
Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1327402

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java?rev=1327403&r1=1327402&r2=1327403&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
(original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
Wed Apr 18 07:43:22 2012
@@ -22,9 +22,9 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.rmi.RemoteException;
 import java.rmi.registry.LocateRegistry;
-import java.util.HashSet;
+import java.util.HashMap;
 import java.util.List;
-import java.util.Set;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import javax.management.JMException;
 import javax.management.MBeanServer;
@@ -60,7 +60,8 @@ public class DefaultManagementAgent exte
     private CamelContext camelContext;
     private ExecutorService executorService;
     private MBeanServer server;
-    private final Set<ObjectName> mbeansRegistered = new HashSet<ObjectName>();
+    // need a name -> actual name mapping as some servers changes the names (suc as WebSphere)
+    private final Map<ObjectName, ObjectName> mbeansRegistered = new HashMap<ObjectName,
ObjectName>();
     private JMXConnectorServer cs;
 
     private Integer registryPort;
@@ -240,15 +241,17 @@ public class DefaultManagementAgent exte
     }
 
     public void unregister(ObjectName name) throws JMException {
-        if (server.isRegistered(name)) {
-            server.unregisterMBean(name);
+        if (isRegistered(name)) {
+            server.unregisterMBean(mbeansRegistered.get(name));
             LOG.debug("Unregistered MBean with objectname: {}", name);
         }
         mbeansRegistered.remove(name);
     }
 
     public boolean isRegistered(ObjectName name) {
-        return server.isRegistered(name);
+        return (mbeansRegistered.containsKey(name) 
+                && server.isRegistered(mbeansRegistered.get(name))) 
+                || server.isRegistered(name);
     }
 
     protected void doStart() throws Exception {
@@ -280,11 +283,10 @@ public class DefaultManagementAgent exte
         }
 
         // Using the array to hold the busMBeans to avoid the CurrentModificationException
-        ObjectName[] mBeans = mbeansRegistered.toArray(new ObjectName[mbeansRegistered.size()]);
+        ObjectName[] mBeans = mbeansRegistered.keySet().toArray(new ObjectName[mbeansRegistered.size()]);
         int caught = 0;
         for (ObjectName name : mBeans) {
             try {
-                mbeansRegistered.remove(name);
                 unregister(name);
             } catch (Exception e) {
                 LOG.info("Exception unregistering MBean with name " + name, e);
@@ -302,7 +304,7 @@ public class DefaultManagementAgent exte
         throws JMException {
 
         // have we already registered the bean, there can be shared instances in the camel
routes
-        boolean exists = server.isRegistered(name);
+        boolean exists = isRegistered(name);
         if (exists) {
             if (forceRegistration) {
                 LOG.info("ForceRegistration enabled, unregistering existing MBean");
@@ -324,7 +326,7 @@ public class DefaultManagementAgent exte
             ObjectName registeredName = instance.getObjectName();
             LOG.debug("Registered MBean with objectname: {}", registeredName);
 
-            mbeansRegistered.add(registeredName);
+            mbeansRegistered.put(name, registeredName);
         }
     }
 



Mime
View raw message