commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cost...@covalent.net
Subject [modeler] Use existing server
Date Mon, 29 Jul 2002 20:51:03 GMT

There is a problem when the modeler is used togheter with dynamic
or static mbeans ( that don't use modeler ). The problem is that 
modeler will _create_ an mbean server, and those other beans will
use a different server.

Here's the patch, let me know if it's ok:

Costin

Index: src/java/org/apache/commons/modeler/Registry.java
===================================================================
RCS file: 
/home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/Registry.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Registry.java
--- src/java/org/apache/commons/modeler/Registry.java   30 Apr 2002 
20:58:52 -0000      1.1.1.1
+++ src/java/org/apache/commons/modeler/Registry.java   29 Jul 2002 
20:27:52 -0000
@@ -241,8 +241,13 @@
     public synchronized static MBeanServer getServer() {

         if (server == null) {
-            log.info("Creating MBeanServer");
-            server = MBeanServerFactory.createMBeanServer();
+            if( MBeanServerFactory.findMBeanServer(null).size() > 0 ) {
+                log.info("Using existing MBeanServer");
+                
server=(MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);
+            } else {
+                log.info("Creating MBeanServer");
+                server=MBeanServerFactory.createMBeanServer();
+            }
         }
         return (server);

Costin


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message