Search in sources :

Example 26 with Engine

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

the class MBeanFactory method removeHost.

/**
     * Remove an existing Host.
     *
     * @param name MBean Name of the component to remove
     *
     * @exception Exception if a component cannot be removed
     */
public void removeHost(String name) throws Exception {
    // Acquire a reference to the component to be removed
    ObjectName oname = new ObjectName(name);
    String hostName = oname.getKeyProperty("host");
    Service service = getService(oname);
    Engine engine = service.getContainer();
    Host host = (Host) engine.findChild(hostName);
    // Remove this component from its parent component
    if (host != null) {
        engine.removeChild(host);
    }
}
Also used : StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service) StandardHost(org.apache.catalina.core.StandardHost) Host(org.apache.catalina.Host) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine) ObjectName(javax.management.ObjectName)

Example 27 with Engine

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

the class StandardHost method getConfigBaseFile.

/**
     * ({@inheritDoc}
     */
@Override
public File getConfigBaseFile() {
    if (hostConfigBase != null) {
        return hostConfigBase;
    }
    String path = null;
    if (getXmlBase() != null) {
        path = getXmlBase();
    } else {
        StringBuilder xmlDir = new StringBuilder("conf");
        Container parent = getParent();
        if (parent instanceof Engine) {
            xmlDir.append('/');
            xmlDir.append(parent.getName());
        }
        xmlDir.append('/');
        xmlDir.append(getName());
        path = xmlDir.toString();
    }
    File file = new File(path);
    if (!file.isAbsolute())
        file = new File(getCatalinaBase(), path);
    try {
        file = file.getCanonicalFile();
    } catch (IOException e) {
    // ignore
    }
    this.hostConfigBase = file;
    return file;
}
Also used : Container(org.apache.catalina.Container) IOException(java.io.IOException) File(java.io.File) Engine(org.apache.catalina.Engine)

Example 28 with Engine

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

the class ApplicationContext method populateSessionTrackingModes.

private void populateSessionTrackingModes() {
    // URL re-writing is always enabled by default
    defaultSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
    supportedSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
    if (context.getCookies()) {
        defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE);
        supportedSessionTrackingModes.add(SessionTrackingMode.COOKIE);
    }
    // SSL not enabled by default as it can only used on its own
    // Context > Host > Engine > Service
    Service s = ((Engine) context.getParent().getParent()).getService();
    Connector[] connectors = s.findConnectors();
    // Need at least one SSL enabled connector to use the SSL session ID.
    for (Connector connector : connectors) {
        if (Boolean.TRUE.equals(connector.getAttribute("SSLEnabled"))) {
            supportedSessionTrackingModes.add(SessionTrackingMode.SSL);
            break;
        }
    }
}
Also used : Connector(org.apache.catalina.connector.Connector) Service(org.apache.catalina.Service) Engine(org.apache.catalina.Engine)

Example 29 with Engine

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

the class RewriteValve method getHostConfigPath.

/**
     * Find the configuration path where the rewrite configuration file
     * will be stored.
     * @param resourceName The rewrite configuration file name
     * @return the full rewrite configuration path
     */
protected String getHostConfigPath(String resourceName) {
    StringBuffer result = new StringBuffer();
    Container container = getContainer();
    Container host = null;
    Container engine = null;
    while (container != null) {
        if (container instanceof Host)
            host = container;
        if (container instanceof Engine)
            engine = container;
        container = container.getParent();
    }
    if (engine != null) {
        result.append(engine.getName()).append('/');
    }
    if (host != null) {
        result.append(host.getName()).append('/');
    }
    result.append(resourceName);
    return result.toString();
}
Also used : Container(org.apache.catalina.Container) Host(org.apache.catalina.Host) Engine(org.apache.catalina.Engine)

Example 30 with Engine

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

the class StandardService method setContainer.

@Override
public void setContainer(Engine engine) {
    Engine oldEngine = this.engine;
    if (oldEngine != null) {
        oldEngine.setService(null);
    }
    this.engine = engine;
    if (this.engine != null) {
        this.engine.setService(this);
    }
    if (getState().isAvailable()) {
        if (this.engine != null) {
            try {
                this.engine.start();
            } catch (LifecycleException e) {
                log.warn(sm.getString("standardService.engine.startFailed"), e);
            }
        }
        // Restart MapperListener to pick up new engine.
        try {
            mapperListener.stop();
        } catch (LifecycleException e) {
            log.warn(sm.getString("standardService.mapperListener.stopFailed"), e);
        }
        try {
            mapperListener.start();
        } catch (LifecycleException e) {
            log.warn(sm.getString("standardService.mapperListener.startFailed"), e);
        }
        if (oldEngine != null) {
            try {
                oldEngine.stop();
            } catch (LifecycleException e) {
                log.warn(sm.getString("standardService.engine.stopFailed"), e);
            }
        }
    }
    // Report this property change to interested listeners
    support.firePropertyChange("container", oldEngine, this.engine);
}
Also used : LifecycleException(org.apache.catalina.LifecycleException) 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