Search in sources :

Example 1 with Engine

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

the class SingleSignOn method startInternal.

@Override
protected synchronized void startInternal() throws LifecycleException {
    Container c = getContainer();
    while (c != null && !(c instanceof Engine)) {
        c = c.getParent();
    }
    if (c instanceof Engine) {
        engine = (Engine) c;
    }
    super.startInternal();
}
Also used : Container(org.apache.catalina.Container) Engine(org.apache.catalina.Engine)

Example 2 with Engine

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

the class FarmWarDeployer method start.

/*--Logic---------------------------------------------------*/
@Override
public void start() throws Exception {
    if (started)
        return;
    Container hcontainer = getCluster().getContainer();
    if (!(hcontainer instanceof Host)) {
        log.error(sm.getString("farmWarDeployer.hostOnly"));
        return;
    }
    host = (Host) hcontainer;
    // Check to correct engine and host setup
    Container econtainer = host.getParent();
    if (!(econtainer instanceof Engine)) {
        log.error(sm.getString("farmWarDeployer.hostParentEngine", host.getName()));
        return;
    }
    Engine engine = (Engine) econtainer;
    String hostname = null;
    hostname = host.getName();
    try {
        oname = new ObjectName(engine.getName() + ":type=Deployer,host=" + hostname);
    } catch (Exception e) {
        log.error(sm.getString("farmWarDeployer.mbeanNameFail", engine.getName(), hostname), e);
        return;
    }
    if (watchEnabled) {
        watcher = new WarWatcher(this, getWatchDirFile());
        if (log.isInfoEnabled()) {
            log.info(sm.getString("farmWarDeployer.watchDir", getWatchDir()));
        }
    }
    configBase = host.getConfigBaseFile();
    // Retrieve the MBean server
    mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
    started = true;
    count = 0;
    getCluster().addClusterListener(this);
    if (log.isInfoEnabled())
        log.info(sm.getString("farmWarDeployer.started"));
}
Also used : Container(org.apache.catalina.Container) Host(org.apache.catalina.Host) Engine(org.apache.catalina.Engine) LifecycleException(org.apache.catalina.LifecycleException) IOException(java.io.IOException) ObjectName(javax.management.ObjectName)

Example 3 with Engine

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

the class ThreadLocalLeakPreventionListener method stopIdleThreads.

/**
     * Updates each ThreadPoolExecutor with the current time, which is the time
     * when a context is being stopped.
     *
     * @param context
     *            the context being stopped, used to discover all the Connectors
     *            of its parent Service.
     */
private void stopIdleThreads(Context context) {
    if (serverStopping)
        return;
    if (!(context instanceof StandardContext) || !((StandardContext) context).getRenewThreadsWhenStoppingContext()) {
        log.debug("Not renewing threads when the context is stopping. " + "It is not configured to do it.");
        return;
    }
    Engine engine = (Engine) context.getParent().getParent();
    Service service = engine.getService();
    Connector[] connectors = service.findConnectors();
    if (connectors != null) {
        for (Connector connector : connectors) {
            ProtocolHandler handler = connector.getProtocolHandler();
            Executor executor = null;
            if (handler != null) {
                executor = handler.getExecutor();
            }
            if (executor instanceof ThreadPoolExecutor) {
                ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executor;
                threadPoolExecutor.contextStopping();
            } else if (executor instanceof StandardThreadExecutor) {
                StandardThreadExecutor stdThreadExecutor = (StandardThreadExecutor) executor;
                stdThreadExecutor.contextStopping();
            }
        }
    }
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) Connector(org.apache.catalina.connector.Connector) Executor(java.util.concurrent.Executor) ThreadPoolExecutor(org.apache.tomcat.util.threads.ThreadPoolExecutor) Service(org.apache.catalina.Service) ThreadPoolExecutor(org.apache.tomcat.util.threads.ThreadPoolExecutor) Engine(org.apache.catalina.Engine)

Example 4 with Engine

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

the class MBeanFactory method createStandardContext.

/**
     * Create a new StandardContext.
     *
     * @param parent MBean Name of the associated parent component
     * @param path The context path for this Context
     * @param docBase Document base directory (or WAR) for this Context
     * @param xmlValidation if XML descriptors should be validated
     * @param xmlNamespaceAware if the XML processor should namespace aware
     * @return the object name of the created context
     *
     * @exception Exception if an MBean cannot be created or registered
     */
public String createStandardContext(String parent, String path, String docBase, boolean xmlValidation, boolean xmlNamespaceAware) throws Exception {
    // Create a new StandardContext instance
    StandardContext context = new StandardContext();
    path = getPathStr(path);
    context.setPath(path);
    context.setDocBase(docBase);
    context.setXmlValidation(xmlValidation);
    context.setXmlNamespaceAware(xmlNamespaceAware);
    ContextConfig contextConfig = new ContextConfig();
    context.addLifecycleListener(contextConfig);
    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ObjectName deployer = new ObjectName(pname.getDomain() + ":type=Deployer,host=" + pname.getKeyProperty("host"));
    if (mserver.isRegistered(deployer)) {
        String contextName = context.getName();
        mserver.invoke(deployer, "addServiced", new Object[] { contextName }, new String[] { "java.lang.String" });
        String configPath = (String) mserver.getAttribute(deployer, "configBaseName");
        String baseName = context.getBaseName();
        File configFile = new File(new File(configPath), baseName + ".xml");
        if (configFile.isFile()) {
            context.setConfigFile(configFile.toURI().toURL());
        }
        mserver.invoke(deployer, "manageApp", new Object[] { context }, new String[] { "org.apache.catalina.Context" });
        mserver.invoke(deployer, "removeServiced", new Object[] { contextName }, new String[] { "java.lang.String" });
    } else {
        log.warn("Deployer not found for " + pname.getKeyProperty("host"));
        Service service = getService(pname);
        Engine engine = service.getContainer();
        Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
        host.addChild(context);
    }
    // Return the corresponding MBean name
    return context.getObjectName().toString();
}
Also used : ContextConfig(org.apache.catalina.startup.ContextConfig) StandardContext(org.apache.catalina.core.StandardContext) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service) StandardHost(org.apache.catalina.core.StandardHost) Host(org.apache.catalina.Host) File(java.io.File) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine) ObjectName(javax.management.ObjectName)

Example 5 with Engine

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

the class MBeanFactory method createStandardHost.

/**
     * Create a new StandardHost.
     *
     * @param parent MBean Name of the associated parent component
     * @param name Unique name of this Host
     * @param appBase Application base directory name
     * @param autoDeploy Should we auto deploy?
     * @param deployOnStartup Deploy on server startup?
     * @param deployXML Should we deploy Context XML config files property?
     * @param unpackWARs Should we unpack WARs when auto deploying?
     * @return the object name of the created host
     *
     * @exception Exception if an MBean cannot be created or registered
     */
public String createStandardHost(String parent, String name, String appBase, boolean autoDeploy, boolean deployOnStartup, boolean deployXML, boolean unpackWARs) throws Exception {
    // Create a new StandardHost instance
    StandardHost host = new StandardHost();
    host.setName(name);
    host.setAppBase(appBase);
    host.setAutoDeploy(autoDeploy);
    host.setDeployOnStartup(deployOnStartup);
    host.setDeployXML(deployXML);
    host.setUnpackWARs(unpackWARs);
    // add HostConfig for active reloading
    HostConfig hostConfig = new HostConfig();
    host.addLifecycleListener(hostConfig);
    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    Service service = getService(pname);
    Engine engine = service.getContainer();
    engine.addChild(host);
    // Return the corresponding MBean name
    return (host.getObjectName().toString());
}
Also used : StandardHost(org.apache.catalina.core.StandardHost) HostConfig(org.apache.catalina.startup.HostConfig) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine) ObjectName(javax.management.ObjectName)

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