tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r940284 - /tomcat/trunk/java/org/apache/catalina/core/StandardServer.java
Date Sun, 02 May 2010 18:13:34 GMT
Author: markt
Date: Sun May  2 18:13:34 2010
New Revision: 940284

URL: http://svn.apache.org/viewvc?rev=940284&view=rev
Log:
Register the MBeanFactory
Make sure all the objects registered are unregistered

Modified:
    tomcat/trunk/java/org/apache/catalina/core/StandardServer.java

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardServer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardServer.java?rev=940284&r1=940283&r2=940284&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardServer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardServer.java Sun May  2 18:13:34 2010
@@ -42,6 +42,7 @@ import org.apache.catalina.LifecycleStat
 import org.apache.catalina.Server;
 import org.apache.catalina.Service;
 import org.apache.catalina.deploy.NamingResources;
+import org.apache.catalina.mbeans.MBeanFactory;
 import org.apache.catalina.util.LifecycleBase;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.catalina.util.ServerInfo;
@@ -689,14 +690,24 @@ public final class StandardServer extend
         // present in the JVM (may happen when embedding) then the same cache
         // will be registered under multiple names
         try {
-            ObjectName oname2 = 
+            onameStringCache = 
                 new ObjectName(oname.getDomain() + ":type=StringCache");
             Registry.getRegistry(null, null)
-                .registerComponent(new StringCache(), oname2, null );
+                .registerComponent(new StringCache(), onameStringCache, null);
         } catch (Exception e) {
             log.error("Error registering ",e);
         }
 
+        // Register the MBeanFactory
+        try {
+            onameMBeanFactory = 
+                new ObjectName(oname.getDomain() + ":type=MBeanFactory");
+            Registry.getRegistry(null, null)
+                .registerComponent(new MBeanFactory(), onameMBeanFactory, null);
+        } catch (Exception e) {
+            log.error("Error registering ",e);
+        }
+        
         // Initialize our defined Services
         for (int i = 0; i < services.length; i++) {
             services[i].init();
@@ -705,13 +716,22 @@ public final class StandardServer extend
     
     @Override
     protected void destroyInternal() {
-        // NOOP
+        Registry registry = Registry.getRegistry(null, null);
+        
+        if (onameStringCache != null) {
+            registry.unregisterComponent(onameStringCache);
+        }
+        if (onameMBeanFactory != null) {
+            registry.unregisterComponent(onameMBeanFactory);
+        }
     }
 
     protected volatile String domain;
     protected volatile ObjectName oname;
     protected MBeanServer mserver;
-
+    private ObjectName onameStringCache;
+    private ObjectName onameMBeanFactory;
+    
     /**
      * Obtain the MBean domain for this server. The domain is obtained using
      * the following search order:



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message