geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamsic...@apache.org
Subject svn commit: r551483 - /geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java
Date Thu, 28 Jun 2007 07:29:33 GMT
Author: vamsic007
Date: Thu Jun 28 00:29:24 2007
New Revision: 551483

URL: http://svn.apache.org/viewvc?view=rev&rev=551483
Log:
GERONIMO-3268 RealMBeanServerReference unintentionally uses an MBeanServer not created by
Geronimo
  o Added a constructor so that Geronimo always uses an MBeanServer with default domain "geronimo".

Modified:
    geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java?view=diff&rev=551483&r1=551482&r2=551483
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java
Thu Jun 28 00:29:24 2007
@@ -28,18 +28,40 @@
  * @version $Rev$ $Date$
  */
 public class RealMBeanServerReference implements MBeanServerReference {
+    private static final String GERONIMO_DEFAULT_DOMAIN = "geronimo";
+    
     private MBeanServer mbeanServer;
 
     public RealMBeanServerReference(String mbeanServerId) throws MBeanServerNotFound {
         ArrayList servers = MBeanServerFactory.findMBeanServer(mbeanServerId);
         if (servers.size() == 0) {
-            mbeanServer = MBeanServerFactory.createMBeanServer("geronimo");
+            mbeanServer = MBeanServerFactory.createMBeanServer(GERONIMO_DEFAULT_DOMAIN);
         } else if (servers.size() > 1) {
             throw new MBeanServerNotFound(servers.size() + " MBeanServers were found with
the agent id " + mbeanServerId);
         } else {
             mbeanServer = (MBeanServer) servers.get(0);
         }
     }
+    
+    /**
+     * Finds an existing MBeanServer with default domain GERONIMO_DEFAULT_DOMAIN
+     * or creates a new one if there isn't any.
+     */
+    public RealMBeanServerReference() {
+        // Find all MBeanServers
+        ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
+        for(MBeanServer server: servers) {
+            // Look for one with default domain GERONIMO_DEFAULT_DOMAIN
+            if (GERONIMO_DEFAULT_DOMAIN.equals(server.getDefaultDomain())) {
+                mbeanServer = server;
+                break;
+            }
+        }
+        if(mbeanServer == null) {
+            // No MBeanServer with default domain GERONIMO_DEFAULT_DOMAIN exists. Create
one.
+            mbeanServer = MBeanServerFactory.createMBeanServer(GERONIMO_DEFAULT_DOMAIN);
+        }
+    }
 
     public MBeanServer getMBeanServer() {
         return mbeanServer;
@@ -50,7 +72,7 @@
     static {
         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(RealMBeanServerReference.class);
         infoFactory.addAttribute("mbeanServerId", String.class, true);
-        infoFactory.setConstructor(new String[]{"mbeanServerId"});
+        //infoFactory.setConstructor(new String[]{"mbeanServerId"});
         GBEAN_INFO = infoFactory.getBeanInfo();
     }
 



Mime
View raw message