- Add a flag to work around the double start problem for embedded (the most usual...
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 1 May 2007 16:31:58 +0000 (16:31 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 1 May 2007 16:31:58 +0000 (16:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@534147 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/ContainerBase.java

index d2e3dc7..eae2d8e 100644 (file)
@@ -257,6 +257,11 @@ public abstract class ContainerBase
     protected boolean initialized=false;
 
     /**
+     * Will children be started automatically when they are added.
+     */
+    protected boolean startChildren = true;
+
+    /**
      * The property change support for this component.
      */
     protected PropertyChangeSupport support = new PropertyChangeSupport(this);
@@ -538,6 +543,31 @@ public abstract class ContainerBase
 
 
     /**
+     * Return if children of this container will be started automatically when
+     * they are added to this container.
+     */
+    public boolean getStartChildren() {
+
+        return (startChildren);
+
+    }
+
+
+    /**
+     * Set if children of this container will be started automatically when
+     * they are added to this container.
+     *
+     * @param startChildren New value of the startChildren flag
+     */
+    public void setStartChildren(boolean startChildren) {
+
+        boolean oldStartChildren = this.startChildren;
+        this.startChildren = startChildren;
+        support.firePropertyChange("startChildren", oldStartChildren, this.startChildren);
+    }
+
+
+    /**
      * Return the Container for which this Container is a child, if there is
      * one.  If there is no defined parent, return <code>null</code>.
      */
@@ -755,7 +785,7 @@ public abstract class ContainerBase
             children.put(child.getName(), child);
 
             // Start child
-            if (started && (child instanceof Lifecycle)) {
+            if (started && startChildren && (child instanceof Lifecycle)) {
                 boolean success = false;
                 try {
                     ((Lifecycle) child).start();