Search in sources :

Example 11 with Service

use of org.apache.catalina.Service in project tomcat70 by apache.

the class ServiceMBean method findExecutors.

/**
 * Retrieves all executors
 * @throws MBeanException
 */
public String[] findExecutors() throws MBeanException {
    Service service;
    try {
        service = (Service) getManagedResource();
    } catch (InstanceNotFoundException e) {
        throw new MBeanException(e);
    } catch (RuntimeOperationsException e) {
        throw new MBeanException(e);
    } catch (InvalidTargetObjectTypeException e) {
        throw new MBeanException(e);
    }
    Executor[] executors = service.findExecutors();
    String[] str = new String[executors.length];
    for (int i = 0; i < executors.length; i++) {
        str[i] = executors[i].toString();
    }
    return str;
}
Also used : Executor(org.apache.catalina.Executor) InstanceNotFoundException(javax.management.InstanceNotFoundException) Service(org.apache.catalina.Service) MBeanException(javax.management.MBeanException) InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 12 with Service

use of org.apache.catalina.Service in project tomcat70 by apache.

the class StandardServer method getDomainInternal.

/**
 * Obtain the MBean domain for this server. The domain is obtained using
 * the following search order:
 * <ol>
 * <li>Name of first {@link org.apache.catalina.Engine}.</li>
 * <li>Name of first {@link Service}.</li>
 * </ol>
 */
@Override
protected String getDomainInternal() {
    String domain = null;
    Service[] services = findServices();
    if (services.length > 0) {
        Service service = services[0];
        if (service != null) {
            domain = MBeanUtils.getDomain(service);
        }
    }
    return domain;
}
Also used : Service(org.apache.catalina.Service)

Example 13 with Service

use of org.apache.catalina.Service in project tomcat70 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 14 with Service

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

the class ContextConfig method getServer.

private Server getServer() {
    Container c = context;
    while (c != null && !(c instanceof Engine)) {
        c = c.getParent();
    }
    if (c == null) {
        return null;
    }
    Service s = ((Engine) c).getService();
    if (s == null) {
        return null;
    }
    return s.getServer();
}
Also used : Container(org.apache.catalina.Container) ContextService(org.apache.tomcat.util.descriptor.web.ContextService) ExecutorService(java.util.concurrent.ExecutorService) Service(org.apache.catalina.Service) Engine(org.apache.catalina.Engine)

Example 15 with Service

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

the class Tomcat method setConnector.

/**
 * Set the specified connector in the service, if it is not already
 * present.
 * @param connector The connector instance to add
 */
public void setConnector(Connector connector) {
    Service service = getService();
    boolean found = false;
    for (Connector serviceConnector : service.findConnectors()) {
        if (connector == serviceConnector) {
            found = true;
            break;
        }
    }
    if (!found) {
        service.addConnector(connector);
    }
}
Also used : Connector(org.apache.catalina.connector.Connector) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service)

Aggregations

Service (org.apache.catalina.Service)62 StandardService (org.apache.catalina.core.StandardService)25 Engine (org.apache.catalina.Engine)20 Connector (org.apache.catalina.connector.Connector)20 StandardEngine (org.apache.catalina.core.StandardEngine)16 ObjectName (javax.management.ObjectName)13 StandardHost (org.apache.catalina.core.StandardHost)12 Container (org.apache.catalina.Container)8 Executor (org.apache.catalina.Executor)8 Server (org.apache.catalina.Server)8 MBeanServer (javax.management.MBeanServer)7 InstanceNotFoundException (javax.management.InstanceNotFoundException)6 MBeanException (javax.management.MBeanException)6 Host (org.apache.catalina.Host)6 File (java.io.File)5 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)5 RuntimeOperationsException (javax.management.RuntimeOperationsException)5 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)5 StandardContext (org.apache.catalina.core.StandardContext)5 JarFile (java.util.jar.JarFile)3