Java Code Examples for org.apache.catalina.Engine#getService()

The following examples show how to use org.apache.catalina.Engine#getService() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThreadLocalLeakPreventionListener.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * 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();
            }

        }
    }
}
 
Example 2
Source File: ThreadLocalLeakPreventionListener.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
            }

        }
    }
}
 
Example 3
Source File: ThreadLocalLeakPreventionListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
            }

        }
    }
}
 
Example 4
Source File: ManagerServlet.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
private Connector[] getConnectors() {
    Engine e = (Engine) host.getParent();
    Service s = e.getService();
    return s.findConnectors();
}