- Unfortunately, the JMX removal does not work (parent is null if used from JMX)...
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 3 Aug 2006 08:34:21 +0000 (08:34 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 3 Aug 2006 08:34:21 +0000 (08:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@428282 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/StandardContext.java

index c93e0fd..0fb2d4b 100644 (file)
@@ -33,6 +33,7 @@ import java.util.Iterator;
 import java.util.Stack;
 import java.util.TreeMap;
 
+import javax.management.AttributeNotFoundException;
 import javax.management.ListenerNotFoundException;
 import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanRegistrationException;
@@ -4168,16 +4169,18 @@ public class StandardContext
         }
         
         // Initialize annotation processor
-        if (ok && !getIgnoreAnnotations() && annotationProcessor == null) {
-            if (isUseNaming() && namingContextListener != null) {
-                annotationProcessor = 
-                    new DefaultAnnotationProcessor(namingContextListener.getEnvContext());
-            } else {
-                annotationProcessor = new DefaultAnnotationProcessor(null);
+        if (ok && !getIgnoreAnnotations()) {
+            if (annotationProcessor == null) {
+                if (isUseNaming() && namingContextListener != null) {
+                    annotationProcessor = 
+                        new DefaultAnnotationProcessor(namingContextListener.getEnvContext());
+                } else {
+                    annotationProcessor = new DefaultAnnotationProcessor(null);
+                }
             }
+            getServletContext().setAttribute
+                (Globals.ANNOTATION_PROCESSOR_ATTR, annotationProcessor);
         }
-        getServletContext().setAttribute
-            (Globals.ANNOTATION_PROCESSOR_ATTR, annotationProcessor);
 
         // Standard container startup
         if (log.isDebugEnabled())
@@ -5246,7 +5249,12 @@ public class StandardContext
             // Add the main configuration listener
             LifecycleListener config = null;
             try {
-                String configClassName = ((Host)getParent()).getConfigClass();
+                String configClassName = null;
+                try {
+                    configClassName = String.valueOf(mserver.getAttribute(parentName, "configClass"));
+                } catch (AttributeNotFoundException e) {
+                    // Ignore, it's normal a host may not have this optional attribute
+                }
                 if (configClassName != null) {
                     Class clazz = Class.forName(configClassName);
                     config = (LifecycleListener) clazz.newInstance();
@@ -5263,7 +5271,8 @@ public class StandardContext
                 log.debug("AddChild " + parentName + " " + this);
             }
             try {
-                ((Host)getParent()).addChild(this);
+                mserver.invoke(parentName, "addChild", new Object[] { this },
+                        new String[] {"org.apache.catalina.Container"});
             } catch (Exception e) {
                 destroy();
                 throw e;