Search in sources :

Example 6 with Engine

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

the class StandardServiceSF method storeChildren.

/**
     * Store the specified service element children.
     *
     * @param aWriter Current output writer
     * @param indent Indentation level
     * @param aService Service to store
     * @param parentDesc The element description
     * @throws Exception Configuration storing error
     */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aService, StoreDescription parentDesc) throws Exception {
    if (aService instanceof StandardService) {
        StandardService service = (StandardService) aService;
        // Store nested <Listener> elements
        LifecycleListener[] listeners = ((Lifecycle) service).findLifecycleListeners();
        storeElementArray(aWriter, indent, listeners);
        // Store nested <Executor> elements
        Executor[] executors = service.findExecutors();
        storeElementArray(aWriter, indent, executors);
        Connector[] connectors = service.findConnectors();
        storeElementArray(aWriter, indent, connectors);
        // Store nested <Engine> element
        Engine container = service.getContainer();
        if (container != null) {
            StoreDescription elementDesc = getRegistry().findDescription(container.getClass());
            if (elementDesc != null) {
                IStoreFactory factory = elementDesc.getStoreFactory();
                factory.store(aWriter, indent, container);
            }
        }
    }
}
Also used : Connector(org.apache.catalina.connector.Connector) Executor(org.apache.catalina.Executor) Lifecycle(org.apache.catalina.Lifecycle) StandardService(org.apache.catalina.core.StandardService) LifecycleListener(org.apache.catalina.LifecycleListener) Engine(org.apache.catalina.Engine)

Example 7 with Engine

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

the class Tomcat method getEngine.

/**
     * Access to the engine, for further customization.
     * @return The engine
     */
public Engine getEngine() {
    Service service = getServer().findServices()[0];
    if (service.getContainer() != null) {
        return service.getContainer();
    }
    Engine engine = new StandardEngine();
    engine.setName("Tomcat");
    engine.setDefaultHost(hostname);
    engine.setRealm(createDefaultRealm());
    service.setContainer(engine);
    return engine;
}
Also used : StandardEngine(org.apache.catalina.core.StandardEngine) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine)

Example 8 with Engine

use of org.apache.catalina.Engine 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 9 with Engine

use of org.apache.catalina.Engine 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 10 with Engine

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

the class ApplicationContext method getContext.

@Override
public ServletContext getContext(String uri) {
    // Validate the format of the specified argument
    if (uri == null || !uri.startsWith("/")) {
        return null;
    }
    Context child = null;
    try {
        // Look for an exact match
        Container host = context.getParent();
        child = (Context) host.findChild(uri);
        // Non-running contexts should be ignored.
        if (child != null && !child.getState().isAvailable()) {
            child = null;
        }
        // Remove any version information and use the mapper
        if (child == null) {
            int i = uri.indexOf("##");
            if (i > -1) {
                uri = uri.substring(0, i);
            }
            // Note: This could be more efficient with a dedicated Mapper
            //       method but such an implementation would require some
            //       refactoring of the Mapper to avoid copy/paste of
            //       existing code.
            MessageBytes hostMB = MessageBytes.newInstance();
            hostMB.setString(host.getName());
            MessageBytes pathMB = MessageBytes.newInstance();
            pathMB.setString(uri);
            MappingData mappingData = new MappingData();
            ((Engine) host.getParent()).getService().getMapper().map(hostMB, pathMB, null, mappingData);
            child = mappingData.context;
        }
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        return null;
    }
    if (child == null) {
        return null;
    }
    if (context.getCrossContext()) {
        // If crossContext is enabled, can always return the context
        return child.getServletContext();
    } else if (child == context) {
        // Can still return the current context
        return context.getServletContext();
    } else {
        // Nothing to return
        return null;
    }
}
Also used : Context(org.apache.catalina.Context) ServletContext(javax.servlet.ServletContext) Container(org.apache.catalina.Container) MessageBytes(org.apache.tomcat.util.buf.MessageBytes) MappingData(org.apache.catalina.mapper.MappingData) Engine(org.apache.catalina.Engine)

Aggregations

Engine (org.apache.catalina.Engine)36 Container (org.apache.catalina.Container)18 Host (org.apache.catalina.Host)18 Service (org.apache.catalina.Service)12 Context (org.apache.catalina.Context)9 StandardEngine (org.apache.catalina.core.StandardEngine)8 StandardHost (org.apache.catalina.core.StandardHost)8 StandardService (org.apache.catalina.core.StandardService)7 ObjectName (javax.management.ObjectName)6 Connector (org.apache.catalina.connector.Connector)6 File (java.io.File)5 IOException (java.io.IOException)5 StandardContext (org.apache.catalina.core.StandardContext)4 ServletContext (javax.servlet.ServletContext)2 UnavailableException (javax.servlet.UnavailableException)2 LifecycleException (org.apache.catalina.LifecycleException)2 Server (org.apache.catalina.Server)2 Wrapper (org.apache.catalina.Wrapper)2 ContextName (org.apache.catalina.util.ContextName)2 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)1