Yet more ServerFactory removal. Make exception handling consistent.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 24 May 2009 17:48:27 +0000 (17:48 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 24 May 2009 17:48:27 +0000 (17:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@778198 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/mbeans/ServerLifecycleListener.java

index c6eb34a..64ffcf9 100644 (file)
@@ -36,7 +36,6 @@ import org.apache.catalina.Loader;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Realm;
 import org.apache.catalina.Server;
-import org.apache.catalina.ServerFactory;
 import org.apache.catalina.Service;
 import org.apache.catalina.connector.Connector;
 import org.apache.catalina.core.StandardContext;
@@ -125,22 +124,34 @@ public class ServerLifecycleListener
         Lifecycle lifecycle = event.getLifecycle();
         if (Lifecycle.START_EVENT.equals(event.getType())) {
 
-            if (lifecycle instanceof Server) {
-                createMBeans();
-            }
+            try {
 
-            // We are embedded.
-            if( lifecycle instanceof Service ) {
-                try {
+                if (lifecycle instanceof Server) {
+                    MBeanFactory factory = new MBeanFactory();
+                    createMBeans(factory);
+                    createMBeans((Server) lifecycle);
+                }
+
+                if( lifecycle instanceof Service ) {
                     MBeanFactory factory = new MBeanFactory();
                     createMBeans(factory);
                     createMBeans((Service)lifecycle);
-                } catch( Exception ex ) {
-                    log.error("Create mbean factory");
                 }
+
+            } catch (MBeanException t) {
+
+                Exception e = t.getTargetException();
+                if (e == null)
+                    e = t;
+                log.error("createMBeans: MBeanException", e);
+
+            } catch (Throwable t) {
+
+                log.error("createMBeans: Throwable", t);
+
             }
 
-            /*
+             /*
             // Ignore events from StandardContext objects to avoid
             // reregistering the context
             if (lifecycle instanceof StandardContext)
@@ -257,33 +268,6 @@ public class ServerLifecycleListener
 
 
     /**
-     * Create the MBeans that correspond to every existing node of our tree.
-     */
-    protected void createMBeans() {
-
-        try {
-
-            MBeanFactory factory = new MBeanFactory();
-            createMBeans(factory);
-            createMBeans(ServerFactory.getServer());
-
-        } catch (MBeanException t) {
-
-            Exception e = t.getTargetException();
-            if (e == null)
-                e = t;
-            log.error("createMBeans: MBeanException", e);
-
-        } catch (Throwable t) {
-
-            log.error("createMBeans: Throwable", t);
-
-        }
-
-    }
-
-
-    /**
      * Create the MBeans for the specified Connector and its nested components.
      *
      * @param connector Connector for which to create MBeans