geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r749113 - in /geronimo/server/trunk/framework: configs/rmi-naming/src/main/plan/plan.xml modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java
Date Sun, 01 Mar 2009 21:18:16 GMT
Author: djencks
Date: Sun Mar  1 21:18:15 2009
New Revision: 749113

URL: http://svn.apache.org/viewvc?rev=749113&view=rev
Log:
GERONIMO-4559 use platform mbean server by default

Modified:
    geronimo/server/trunk/framework/configs/rmi-naming/src/main/plan/plan.xml
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java

Modified: geronimo/server/trunk/framework/configs/rmi-naming/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/rmi-naming/src/main/plan/plan.xml?rev=749113&r1=749112&r2=749113&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/rmi-naming/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/framework/configs/rmi-naming/src/main/plan/plan.xml Sun Mar  1 21:18:15
2009
@@ -43,7 +43,10 @@
         <attribute name="nameInNamespace">ger:</attribute>
     </gbean>
 
-    <gbean name="MBeanServerReference" class="org.apache.geronimo.system.jmx.RealMBeanServerReference"/>
+    <gbean name="MBeanServerReference" class="org.apache.geronimo.system.jmx.RealMBeanServerReference">
+        <attribute name="usePlatformMBeanServer">true</attribute>
+    </gbean>
+
 
     <!-- MBean server service -->
     <gbean name="MBeanServerKernelBridge" class="org.apache.geronimo.system.jmx.MBeanServerKernelBridge">

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java?rev=749113&r1=749112&r2=749113&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/jmx/RealMBeanServerReference.java
Sun Mar  1 21:18:15 2009
@@ -16,33 +16,42 @@
  */
 package org.apache.geronimo.system.jmx;
 
+import java.lang.management.ManagementFactory;
 import java.util.ArrayList;
+
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
 
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
 
 /**
  * Creates a real mbean server of finds an existing one with the specified mbeanServerId
+ *
  * @version $Rev$ $Date$
  */
+@GBean
 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_DEFAULT_DOMAIN);
-        } else if (servers.size() > 1) {
-            throw new MBeanServerNotFound(servers.size() + " MBeanServers were found with
the agent id " + mbeanServerId);
+    public RealMBeanServerReference(@ParamAttribute(name="usePlatformMBeanServer") boolean
usePlatformMBeanServer,
+                                    @ParamAttribute(name="mbeanServerId")String mbeanServerId)
throws MBeanServerNotFound {
+        if (usePlatformMBeanServer) {
+            mbeanServer = ManagementFactory.getPlatformMBeanServer();
         } else {
-            mbeanServer = (MBeanServer) servers.get(0);
+            ArrayList servers = MBeanServerFactory.findMBeanServer(mbeanServerId);
+            if (servers.size() == 0) {
+                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.
@@ -50,14 +59,14 @@
     public RealMBeanServerReference() {
         // Find all MBeanServers
         ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
-        for(MBeanServer server: servers) {
+        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) {
+        if (mbeanServer == null) {
             // No MBeanServer with default domain GERONIMO_DEFAULT_DOMAIN exists. Create
one.
             mbeanServer = MBeanServerFactory.createMBeanServer(GERONIMO_DEFAULT_DOMAIN);
         }
@@ -67,16 +76,4 @@
         return mbeanServer;
     }
 
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(RealMBeanServerReference.class);
-        infoFactory.addAttribute("mbeanServerId", String.class, true);
-        //infoFactory.setConstructor(new String[]{"mbeanServerId"});
-        GBEAN_INFO = infoFactory.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
 }



Mime
View raw message