Java Code Examples for org.apache.catalina.LifecycleState#STOPPED

The following examples show how to use org.apache.catalina.LifecycleState#STOPPED . 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: TomcatBaseTest.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@After
@Override
public void tearDown() throws Exception {
    try {
        // Some tests may call tomcat.destroy(), some tests may just call
        // tomcat.stop(), some not call either method. Make sure that stop()
        // & destroy() are called as necessary.
        if (tomcat.server != null
                && tomcat.server.getState() != LifecycleState.DESTROYED) {
            if (tomcat.server.getState() != LifecycleState.STOPPED) {
                tomcat.stop();
            }
            tomcat.destroy();
        }
    } finally {
        super.tearDown();
    }
}
 
Example 2
Source File: WebappClassLoaderBase.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Stop the class loader.
 *
 * @exception LifecycleException if a lifecycle error occurs
 */
@Override
public void stop() throws LifecycleException {

    state = LifecycleState.STOPPING_PREP;

    // Clearing references should be done before setting started to
    // false, due to possible side effects
    clearReferences();

    state = LifecycleState.STOPPING;

    resourceEntries.clear();
    jarModificationTimes.clear();
    resources = null;

    permissionList.clear();
    loaderPC.clear();

    state = LifecycleState.STOPPED;
}
 
Example 3
Source File: CRUDClientServerTest.java    From TeaStore with Apache License 2.0 5 votes vote down vote up
/**
 * Dismantles the embedded Tomcat.
 * @throws Throwable Throws uncaught throwables for test to fail.
 */
@After
public void dismantle() throws Throwable {
	if (testTomcat.getServer() != null && testTomcat.getServer().getState() != LifecycleState.DESTROYED) {
        if (testTomcat.getServer().getState() != LifecycleState.STOPPED) {
        	testTomcat.stop();
        }
        testTomcat.destroy();
    }
}
 
Example 4
Source File: SpringTest.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private static void shutdownServer(Tomcat server) {
    try {
        if (server != null && server.getServer() != null
            && server.getServer().getState() != LifecycleState.DESTROYED) {
            if (server.getServer().getState() != LifecycleState.STOPPED) {
                server.stop();
            }
            server.destroy();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 5
Source File: SAMLSSOTest.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private static void shutdownServer(Tomcat server) {
    try {
        if (server != null && server.getServer() != null
            && server.getServer().getState() != LifecycleState.DESTROYED) {
            if (server.getServer().getState() != LifecycleState.STOPPED) {
                server.stop();
            }
            server.destroy();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 6
Source File: TomcatTestServer.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
public void stop() throws LifecycleException {
  if (tomcat.getServer() != null
      && tomcat.getServer().getState() != LifecycleState.DESTROYED) {
    if (tomcat.getServer().getState() != LifecycleState.STOPPED) {
      tomcat.stop();
    }
    tomcat.destroy();
  }
}
 
Example 7
Source File: LazyValve.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() throws LifecycleException {
    if (instance() != null && Lifecycle.class.isInstance(delegate)) {
        Lifecycle.class.cast(delegate).stop();
    }
    state = LifecycleState.STOPPED;
}
 
Example 8
Source File: WSFedTest.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private static void shutdownServer(Tomcat server) {
    try {
        if (server != null && server.getServer() != null
            && server.getServer().getState() != LifecycleState.DESTROYED) {
            if (server.getServer().getState() != LifecycleState.STOPPED) {
                server.stop();
            }
            server.destroy();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 9
Source File: CXFTest.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private static void shutdownServer(Tomcat server) {
    try {
        if (server != null && server.getServer() != null
            && server.getServer().getState() != LifecycleState.DESTROYED) {
            if (server.getServer().getState() != LifecycleState.STOPPED) {
                server.stop();
            }
            server.destroy();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 10
Source File: AbstractWebServiceTest.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@AfterAll
public static void destroy() throws Exception {
	if (tomcat.getServer() != null && tomcat.getServer().getState() != LifecycleState.DESTROYED) {
		if (tomcat.getServer().getState() != LifecycleState.STOPPED) {
			tomcat.stop();
		}
		tomcat.destroy();
	}
}
 
Example 11
Source File: WSFedTest.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private static void shutdownServer(Tomcat server) {
    try {
        if (server != null && server.getServer() != null
            && server.getServer().getState() != LifecycleState.DESTROYED) {
            if (server.getServer().getState() != LifecycleState.STOPPED) {
                server.stop();
            }
            server.destroy();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 12
Source File: TomcatLauncher.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private static void shutdownServer(Tomcat server) throws LifecycleException {
    if (server != null && server.getServer() != null
        && server.getServer().getState() != LifecycleState.DESTROYED) {
        if (server.getServer().getState() != LifecycleState.STOPPED) {
            server.stop();
        }
        server.destroy();
    }
}
 
Example 13
Source File: IdpTest.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private static void shutdownServer(Tomcat server) {
    try {
        if (server != null && server.getServer() != null
            && server.getServer().getState() != LifecycleState.DESTROYED) {
            if (server.getServer().getState() != LifecycleState.STOPPED) {
                server.stop();
            }
            server.destroy();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 14
Source File: TomcatTestHandler.java    From TeaStore with Apache License 2.0 5 votes vote down vote up
/**
 * Dismantle Tomcat with index.
 * @param index The tomcat index.
 */
public void dismantle(int index) {
	try {
		if (tomcats[index].getServer() != null
				&& tomcats[index].getServer().getState() != LifecycleState.DESTROYED) {
	        if (tomcats[index].getServer().getState() != LifecycleState.STOPPED) {
	        	tomcats[index].stop();
	        }
	        tomcats[index].destroy();
	    }
	} catch (LifecycleException e) {
		System.out.println("Exception shutting down Testing Tomcat (this may happen a lot): " + e.getMessage());
	}
}
 
Example 15
Source File: FederationTest.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private static void shutdownServer(Tomcat server) {
    try {
        if (server != null && server.getServer() != null
            && server.getServer().getState() != LifecycleState.DESTROYED) {
            if (server.getServer().getState() != LifecycleState.STOPPED) {
                server.stop();
            }
            server.destroy();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 16
Source File: AbstractTomcatMetricsTest.java    From tomcat_exporter with Apache License 2.0 5 votes vote down vote up
public static void shutDownTomcat() throws LifecycleException {
    if (tomcat.getServer() != null
            && tomcat.getServer().getState() != LifecycleState.DESTROYED) {
        if (tomcat.getServer().getState() != LifecycleState.STOPPED) {
            tomcat.stop();
        }
        tomcat.destroy();
    }
}
 
Example 17
Source File: TomcatUtils.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
public static void stopIdpServer() throws Exception {
    if (idpServer != null && idpServer.getServer() != null
        && idpServer.getServer().getState() != LifecycleState.DESTROYED) {
        if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
            idpServer.stop();
        }
        idpServer.destroy();
    }
}
 
Example 18
Source File: JettyTest.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void cleanup() throws Exception {
    if (idpServer != null && idpServer.getServer() != null
        && idpServer.getServer().getState() != LifecycleState.DESTROYED) {
        if (idpServer.getServer().getState() != LifecycleState.STOPPED) {
            idpServer.stop();
        }
        idpServer.destroy();
    }

    JettyUtils.stopRpServer();
}
 
Example 19
Source File: LDAPTest.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
private static void shutdownServer(Tomcat server) {
    try {
        if (server != null && server.getServer() != null
            && server.getServer().getState() != LifecycleState.DESTROYED) {
            if (server.getServer().getState() != LifecycleState.STOPPED) {
                server.stop();
            }
            server.destroy();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 20
Source File: LifecycleBase.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
/**
 * 1.检查容器状态。
 * 2.设置停止状态。
 * 3.容器(包括子类)销毁操作。
 * {@inheritDoc}
 */
@Override
public final synchronized void stop() throws LifecycleException {

    if (LifecycleState.STOPPING_PREP.equals(state) || LifecycleState.STOPPING.equals(state) ||
            LifecycleState.STOPPED.equals(state)) {

        if (log.isDebugEnabled()) {
            Exception e = new LifecycleException();
            log.debug(sm.getString("lifecycleBase.alreadyStopped", toString()), e);
        } else if (log.isInfoEnabled()) {
            log.info(sm.getString("lifecycleBase.alreadyStopped", toString()));
        }

        return;
    }

    if (state.equals(LifecycleState.NEW)) {
        state = LifecycleState.STOPPED;
        return;
    }

    if (!state.equals(LifecycleState.STARTED) && !state.equals(LifecycleState.FAILED)) {
        invalidTransition(Lifecycle.BEFORE_STOP_EVENT);
    }

    try {
        if (state.equals(LifecycleState.FAILED)) {
            // Don't transition to STOPPING_PREP as that would briefly mark the
            // component as available but do ensure the BEFORE_STOP_EVENT is
            // fired
            fireLifecycleEvent(BEFORE_STOP_EVENT, null);
        } else {
            setStateInternal(LifecycleState.STOPPING_PREP, null, false);
        }

        stopInternal();

        // Shouldn't be necessary but acts as a check that sub-classes are
        // doing what they are supposed to.
        if (!state.equals(LifecycleState.STOPPING) && !state.equals(LifecycleState.FAILED)) {
            invalidTransition(Lifecycle.AFTER_STOP_EVENT);
        }

        setStateInternal(LifecycleState.STOPPED, null, false);
    } catch (Throwable t) {
        handleSubClassException(t, "lifecycleBase.stopFail", toString());
    } finally {
        if (this instanceof Lifecycle.SingleUse) {
            // Complete stop process first
            setStateInternal(LifecycleState.STOPPED, null, false);
            destroy();
        }
    }
}