Search in sources :

Example 21 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class Tomcat method setHost.

/**
     * Sets the current host - all future webapps will
     * be added to this host. When tomcat starts, the
     * host will be the default host.
     *
     * @param host The current host
     */
public void setHost(Host host) {
    Engine engine = getEngine();
    boolean found = false;
    for (Container engineHost : engine.findChildren()) {
        if (engineHost == host) {
            found = true;
        }
    }
    if (!found) {
        engine.addChild(host);
    }
}
Also used : Container(org.apache.catalina.Container) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine)

Example 22 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class ContainerBase method toString.

@Override
public final String toString() {
    StringBuilder sb = new StringBuilder();
    Container parent = getParent();
    if (parent != null) {
        sb.append(parent.toString());
        sb.append('.');
    }
    sb.append(this.getClass().getSimpleName());
    sb.append('[');
    sb.append(getName());
    sb.append(']');
    return sb.toString();
}
Also used : Container(org.apache.catalina.Container)

Example 23 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class ContainerBase method getMBeanKeyProperties.

@Override
public String getMBeanKeyProperties() {
    Container c = this;
    StringBuilder keyProperties = new StringBuilder();
    int containerCount = 0;
    // each container
    while (!(c instanceof Engine)) {
        if (c instanceof Wrapper) {
            keyProperties.insert(0, ",servlet=");
            keyProperties.insert(9, c.getName());
        } else if (c instanceof Context) {
            keyProperties.insert(0, ",context=");
            ContextName cn = new ContextName(c.getName(), false);
            keyProperties.insert(9, cn.getDisplayName());
        } else if (c instanceof Host) {
            keyProperties.insert(0, ",host=");
            keyProperties.insert(6, c.getName());
        } else if (c == null) {
            // May happen in unit testing and/or some embedding scenarios
            keyProperties.append(",container");
            keyProperties.append(containerCount++);
            keyProperties.append("=null");
            break;
        } else {
            // Should never happen...
            keyProperties.append(",container");
            keyProperties.append(containerCount++);
            keyProperties.append('=');
            keyProperties.append(c.getName());
        }
        c = c.getParent();
    }
    return keyProperties.toString();
}
Also used : Context(org.apache.catalina.Context) Wrapper(org.apache.catalina.Wrapper) Container(org.apache.catalina.Container) Host(org.apache.catalina.Host) Engine(org.apache.catalina.Engine) ContextName(org.apache.catalina.util.ContextName)

Example 24 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class ContainerBase method setParent.

/**
     * Set the parent Container to which this Container is being added as a
     * child.  This Container may refuse to become attached to the specified
     * Container by throwing an exception.
     *
     * @param container Container to which this Container is being added
     *  as a child
     *
     * @exception IllegalArgumentException if this Container refuses to become
     *  attached to the specified Container
     */
@Override
public void setParent(Container container) {
    Container oldParent = this.parent;
    this.parent = container;
    support.firePropertyChange("parent", oldParent, this.parent);
}
Also used : Container(org.apache.catalina.Container)

Example 25 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class ContainerBase method destroyInternal.

@Override
protected void destroyInternal() throws LifecycleException {
    Realm realm = getRealmInternal();
    if (realm instanceof Lifecycle) {
        ((Lifecycle) realm).destroy();
    }
    Cluster cluster = getClusterInternal();
    if (cluster instanceof Lifecycle) {
        ((Lifecycle) cluster).destroy();
    }
    // Stop the Valves in our pipeline (including the basic), if any
    if (pipeline instanceof Lifecycle) {
        ((Lifecycle) pipeline).destroy();
    }
    // Remove children now this container is being destroyed
    for (Container child : findChildren()) {
        removeChild(child);
    }
    // Required if the child is destroyed directly.
    if (parent != null) {
        parent.removeChild(this);
    }
    // If init fails, this may be null
    if (startStopExecutor != null) {
        startStopExecutor.shutdownNow();
    }
    super.destroyInternal();
}
Also used : Container(org.apache.catalina.Container) Lifecycle(org.apache.catalina.Lifecycle) Cluster(org.apache.catalina.Cluster) Realm(org.apache.catalina.Realm)

Aggregations

Container (org.apache.catalina.Container)163 Context (org.apache.catalina.Context)28 IOException (java.io.IOException)24 Host (org.apache.catalina.Host)22 StandardContext (org.apache.catalina.core.StandardContext)21 Engine (org.apache.catalina.Engine)18 LifecycleException (org.apache.catalina.LifecycleException)17 File (java.io.File)15 ObjectName (javax.management.ObjectName)15 Wrapper (org.apache.catalina.Wrapper)13 StandardHost (org.apache.catalina.core.StandardHost)13 ArrayList (java.util.ArrayList)12 ServletException (javax.servlet.ServletException)11 MalformedURLException (java.net.MalformedURLException)10 Valve (org.apache.catalina.Valve)10 StandardWrapper (org.apache.catalina.core.StandardWrapper)10 SecurityConstraint (org.apache.tomcat.util.descriptor.web.SecurityConstraint)10 NamingException (javax.naming.NamingException)9 Lifecycle (org.apache.catalina.Lifecycle)9 Realm (org.apache.catalina.Realm)9