cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1081451 - in /cxf/branches/2.3.x-fixes: ./ rt/management/src/main/java/org/apache/cxf/management/jmx/ rt/management/src/test/java/org/apache/cxf/management/jmx/ rt/management/src/test/resources/
Date Mon, 14 Mar 2011 16:31:12 GMT
Author: dkulp
Date: Mon Mar 14 16:31:12 2011
New Revision: 1081451

URL: http://svn.apache.org/viewvc?rev=1081451&view=rev
Log:
Merged revisions 1081445 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1081445 | dkulp | 2011-03-14 12:24:44 -0400 (Mon, 14 Mar 2011) | 5 lines
  
  [CXF-3396] Make sure the standalone MBeanServer lookups are done
  properly to prevent multiple MBeanServers from being created when they
  shouldn't be.
  
  Patch from Aki Yoshida applied.
........

Added:
    cxf/branches/2.3.x-fixes/rt/management/src/test/java/org/apache/cxf/management/jmx/BusRegistrationTest.java
      - copied unchanged from r1081445, cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/jmx/BusRegistrationTest.java
    cxf/branches/2.3.x-fixes/rt/management/src/test/resources/no-connector-spring.xml
      - copied unchanged from r1081445, cxf/trunk/rt/management/src/test/resources/no-connector-spring.xml
Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java?rev=1081451&r1=1081450&r2=1081451&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/management/src/main/java/org/apache/cxf/management/jmx/InstrumentationManagerImpl.java
Mon Mar 14 16:31:12 2011
@@ -21,8 +21,10 @@ package org.apache.cxf.management.jmx;
 
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -32,6 +34,7 @@ import javax.annotation.Resource;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.JMException;
 import javax.management.MBeanServer;
+import javax.management.MBeanServerDelegate;
 import javax.management.MBeanServerFactory;
 
 import javax.management.NotCompliantMBeanException;
@@ -60,6 +63,8 @@ public class InstrumentationManagerImpl 
     implements InstrumentationManager, BusLifeCycleListener {
     private static final Logger LOG = LogUtils.getL7dLogger(InstrumentationManagerImpl.class);
 
+    private static Map<String, String>mbeanServerIDMap = new HashMap<String, String>();
+
     private Bus bus;
     private MBServerConnectorFactory mcf;    
     private MBeanServer mbs;
@@ -119,10 +124,20 @@ public class InstrumentationManagerImpl 
                 if (usePlatformMBeanServer) {
                     mbs = ManagementFactory.getPlatformMBeanServer();
                 } else {
-                    List<MBeanServer> servers = CastUtils
-                        .cast(MBeanServerFactory.findMBeanServer(mbeanServerName));
-                    if (servers.size() <= 1) {
+                    String mbeanServerID = mbeanServerIDMap.get(mbeanServerName);
+                    List<MBeanServer> servers = null;
+                    if (mbeanServerID != null) {
+                        servers = CastUtils.cast(MBeanServerFactory.findMBeanServer(mbeanServerID));
+                    }
+                    if (servers == null || servers.size() == 0) {
                         mbs = MBeanServerFactory.createMBeanServer(mbeanServerName);
+                        try {
+                            mbeanServerID = (String) mbs.getAttribute(MBeanServerDelegate.DELEGATE_NAME,
+                                                                     "MBeanServerId");
+                            mbeanServerIDMap.put(mbeanServerName, mbeanServerID);
+                        } catch (JMException e) {
+                            // ignore
+                        }
                     } else {
                         mbs = (MBeanServer)servers.get(0);
                     }



Mime
View raw message