Java Code Examples for org.apache.catalina.Executor#start()

The following examples show how to use org.apache.catalina.Executor#start() . 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: StandardService.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Adds a named executor to the service
 * @param ex Executor
 */
@Override
public void addExecutor(Executor ex) {
    synchronized (executors) {
        if (!executors.contains(ex)) {
            executors.add(ex);
            if (getState().isAvailable()) {
                try {
                    ex.start();
                } catch (LifecycleException x) {
                    log.error("Executor.start", x);
                }
            }
        }
    }
}
 
Example 2
Source File: StandardService.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a named executor to the service
 * @param ex Executor
 */
@Override
public void addExecutor(Executor ex) {
    synchronized (executors) {
        if (!executors.contains(ex)) {
            executors.add(ex);
            if (getState().isAvailable())
                try {
                    ex.start();
                } catch (LifecycleException x) {
                    log.error("Executor.start", x);
                }
        }
    }
}
 
Example 3
Source File: StandardService.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Start nested components ({@link Executor}s, {@link Connector}s and
 * {@link Container}s) and implement the requirements of
 * {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {

    if(log.isInfoEnabled())
        log.info(sm.getString("standardService.start.name", this.name));
    setState(LifecycleState.STARTING);

    // Start our defined Container first
    if (container != null) {
        synchronized (container) {
            container.start();
        }
    }

    synchronized (executors) {
        for (Executor executor: executors) {
            executor.start();
        }
    }

    // Start our defined Connectors second
    synchronized (connectors) {
        for (Connector connector: connectors) {
            try {
                // If it has already failed, don't try and start it
                if (connector.getState() != LifecycleState.FAILED) {
                    connector.start();
                }
            } catch (Exception e) {
                log.error(sm.getString(
                        "standardService.connector.startFailed",
                        connector), e);
            }
        }
    }
}
 
Example 4
Source File: StandardService.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
/**
 *
 * 1.BootStrap反射调用Catalina的start。
 * 2.Catalina去调用了StandardServer的start方法。
 * 3.StandardServer调用StandardService的start方法。
 * 4.StandardService调用StandarEngine的start方法。
 *
 *
 * MapperListener start。
 * Connector start。
 * Start nested components ({@link Executor}s, {@link Connector}s and
 * {@link Container}s) and implement the requirements of
 * {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 * 启动:Executors, Connectors。
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected void startInternal() throws LifecycleException {

    if(log.isInfoEnabled())
        log.info(sm.getString("standardService.start.name", this.name));
    setState(LifecycleState.STARTING);

    // Start our defined Container first
    /***
     * 1.{@link StandardEngine#startInternal()}
     */
    if (engine != null) {
        synchronized (engine) {
            /** Engin引擎启动。
             * {@link StandardEngine#startInternal()}
             */
            engine.start();
        }
    }

    synchronized (executors) {
        for (Executor executor: executors) {
            /**
             * 线程池的启动。
             */
            executor.start();
        }
    }
    /**
     * Connector和Container之间的映射器的启动。
     * {@link MapperListener#startInternal()}
     */
    mapperListener.start();

    // Start our defined Connectors second
    synchronized (connectorsLock) {
        for (Connector connector: connectors) {
            try {
                // If it has already failed, don't try and start it
                if (connector.getState() != LifecycleState.FAILED) {
                    /**
                     * {@link Connector#startInternal()}
                     */
                    connector.start();
                }
            } catch (Exception e) {
                log.error(sm.getString(
                        "standardService.connector.startFailed",
                        connector), e);
            }
        }
    }
}