org.apache.catalina.LifecycleState Java Examples
The following examples show how to use
org.apache.catalina.LifecycleState.
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: StandardManager.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Start this component 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 synchronized void startInternal() throws LifecycleException { super.startInternal(); // Load unloaded sessions, if any try { load(); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.error(sm.getString("standardManager.managerLoad"), t); } setState(LifecycleState.STARTING); }
Example #2
Source File: SimpleTcpCluster.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Start Cluster 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("Cluster is about to start"); try { checkDefaults(); registerClusterValve(); channel.addMembershipListener(this); channel.addChannelListener(this); if (channel instanceof GroupChannel) ((GroupChannel)channel).setName(getClusterName() + "-Channel"); channel.start(channelStartOptions); if (clusterDeployer != null) clusterDeployer.start(); registerMember(channel.getLocalMember(false)); } catch (Exception x) { log.error("Unable to start cluster.", x); throw new LifecycleException(x); } setState(LifecycleState.STARTING); }
Example #3
Source File: Connector.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Terminate processing requests via this Connector. * * @exception LifecycleException if a fatal shutdown error occurs */ @Override protected void stopInternal() throws LifecycleException { setState(LifecycleState.STOPPING); try { // 调用 protocolHandler 的stop方法 protocolHandler.stop(); } catch (Exception e) { throw new LifecycleException (sm.getString ("coyoteConnector.protocolHandlerStopFailed"), e); } mapperListener.stop(); }
Example #4
Source File: SimpleTcpCluster.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Stop Cluster and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected void stopInternal() throws LifecycleException { setState(LifecycleState.STOPPING); unregisterMember(channel.getLocalMember(false)); if (clusterDeployer != null) clusterDeployer.stop(); this.managers.clear(); try { if ( clusterDeployer != null ) clusterDeployer.setCluster(null); channel.stop(channelStartOptions); channel.removeChannelListener(this); channel.removeMembershipListener(this); this.unregisterClusterValve(); } catch (Exception x) { log.error("Unable to stop cluster.", x); } }
Example #5
Source File: TomcatBaseTest.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@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 #6
Source File: StandardPipeline.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Stop {@link Valve}s) in this pipeline and implement the requirements * of {@link LifecycleBase#stopInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void stopInternal() throws LifecycleException { setState(LifecycleState.STOPPING); // Stop the Valves in our pipeline (including the basic), if any Valve current = first; if (current == null) { current = basic; } while (current != null) { if (current instanceof Lifecycle) ((Lifecycle) current).stop(); current = current.getNext(); } }
Example #7
Source File: DeltaManager.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Stop this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void stopInternal() throws LifecycleException { if (log.isDebugEnabled()) log.debug(sm.getString("deltaManager.stopped", getName())); setState(LifecycleState.STOPPING); // Expire all active sessions if (log.isInfoEnabled()) log.info(sm.getString("deltaManager.expireSessions", getName())); Session sessions[] = findSessions(); for (int i = 0; i < sessions.length; i++) { DeltaSession session = (DeltaSession) sessions[i]; if (!session.isValid()) continue; try { session.expire(true, isExpireSessionsOnShutdown()); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); } } // Require a new random number generator if we are restarted super.stopInternal(); }
Example #8
Source File: BackupManager.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Start this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * Starts the cluster communication channel, this will connect with the * other nodes in the cluster, and request the current session state to be * transferred to this node. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void startInternal() throws LifecycleException { super.startInternal(); try { if (cluster == null) throw new LifecycleException(sm.getString("backupManager.noCluster", getName())); LazyReplicatedMap<String,Session> map = new LazyReplicatedMap<String,Session>(this, cluster.getChannel(), rpcTimeout, getMapName(), getClassLoaders(), terminateOnStartFailure); map.setChannelSendOptions(mapSendOptions); this.sessions = map; } catch ( Exception x ) { log.error(sm.getString("backupManager.startUnable", getName()),x); throw new LifecycleException(sm.getString("backupManager.startFailed", getName()),x); } setState(LifecycleState.STARTING); }
Example #9
Source File: ApplicationContext.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public boolean setInitParameter(String name, String value) { if (!context.getState().equals(LifecycleState.STARTING_PREP)) { throw new IllegalStateException( sm.getString("applicationContext.setInitParam.ise", getContextPath())); } return parameters.putIfAbsent(name, value) == null; }
Example #10
Source File: TestHostConfigAutomaticDeployment.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testDeploymentXmlExternalWarXmlFTF() throws Exception { File war = createWar(WAR_XML_SOURCE, false); createXmlInConfigBaseForExternal(war); doTestDeployment(false, true, false, LifecycleState.STARTED, XML_COOKIE_NAME, true, false, false); }
Example #11
Source File: TestHostConfigAutomaticDeployment.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Test public void testDeploymentXmlExternalDirXmlTFF() throws Exception { File dir = createDirInExternal(true); createXmlInConfigBaseForExternal(dir); doTestDeployment(true, false, false, LifecycleState.STARTED, XML_COOKIE_NAME, true, false, false); }
Example #12
Source File: LifecycleBase.java From Tomcat8-Source-Read with MIT License | 5 votes |
private synchronized void setStateInternal(LifecycleState state, Object data, boolean check) throws LifecycleException { if (log.isDebugEnabled()) { log.debug(sm.getString("lifecycleBase.setState", this, state)); } if (check) { // Must have been triggered by one of the abstract methods (assume // code in this class is correct) // null is never a valid state if (state == null) { invalidTransition("null"); // Unreachable code - here to stop eclipse complaining about // a possible NPE further down the method return; } // Any method can transition to failed // startInternal() permits STARTING_PREP to STARTING // stopInternal() permits STOPPING_PREP to STOPPING and FAILED to // STOPPING if (!(state == LifecycleState.FAILED || (this.state == LifecycleState.STARTING_PREP && state == LifecycleState.STARTING) || (this.state == LifecycleState.STOPPING_PREP && state == LifecycleState.STOPPING) || (this.state == LifecycleState.FAILED && state == LifecycleState.STOPPING))) { // No other transition permitted invalidTransition(state.name()); } } this.state = state; String lifecycleEvent = state.getLifecycleEvent(); if (lifecycleEvent != null) { fireLifecycleEvent(lifecycleEvent, data); } }
Example #13
Source File: WebappClassLoaderBase.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void destroy() { state = LifecycleState.DESTROYING; try { super.close(); } catch (IOException ioe) { log.warn(sm.getString("webappClassLoader.superCloseFail"), ioe); } state = LifecycleState.DESTROYED; }
Example #14
Source File: TestHostConfigAutomaticDeployment.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testDeploymentXmlExternalWarXmlTTF() throws Exception { File war = createWar(WAR_XML_SOURCE, false); createXmlInConfigBaseForExternal(war); doTestDeployment(true, true, false, LifecycleState.STARTED, XML_COOKIE_NAME, true, false, false); }
Example #15
Source File: TestHostConfigAutomaticDeployment.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private void doTestModify(boolean startXml, boolean startExternalWar, boolean startExternalDir, boolean startWar, boolean startDir, int toModify, boolean resultXml, boolean resultWar, boolean resultDir, String resultCookieName, int resultAction) throws Exception { doTestModify(startXml, startExternalWar, startExternalDir, startWar, startDir, toModify, resultXml, resultWar, resultDir, resultCookieName, resultAction, LifecycleState.STARTED); }
Example #16
Source File: TestHostConfigAutomaticDeployment.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Test public void testDeploymentXmlExternalDirXmlFTT() throws Exception { File dir = createDirInExternal(true); createXmlInConfigBaseForExternal(dir); doTestDeployment(false, true, true, LifecycleState.STARTED, XML_COOKIE_NAME, true, false, false); }
Example #17
Source File: Catalina.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Stop an existing server instance. */ public void stop() { try { // Remove the ShutdownHook first so that server.stop() // doesn't get invoked twice if (useShutdownHook) { Runtime.getRuntime().removeShutdownHook(shutdownHook); // If JULI is being used, re-enable JULI's shutdown to ensure // log messages are not lost LogManager logManager = LogManager.getLogManager(); if (logManager instanceof ClassLoaderLogManager) { ((ClassLoaderLogManager) logManager).setUseShutdownHook( true); } } } catch (Throwable t) { ExceptionUtils.handleThrowable(t); // This will fail on JDK 1.2. Ignoring, as Tomcat can run // fine without the shutdown hook. } // Shut down the server try { Server s = getServer(); LifecycleState state = s.getState(); if (LifecycleState.STOPPING_PREP.compareTo(state) <= 0 && LifecycleState.DESTROYED.compareTo(state) >= 0) { // Nothing to do. stop() was already called } else { s.stop(); s.destroy(); } } catch (LifecycleException e) { log.error("Catalina.stop", e); } }
Example #18
Source File: LazyValve.java From tomee with Apache License 2.0 | 5 votes |
@Override public void start() throws LifecycleException { if (instance() != null && Lifecycle.class.isInstance(delegate)) { Lifecycle.class.cast(delegate).start(); } else { start = true; } state = LifecycleState.STARTED; }
Example #19
Source File: TestHostConfigAutomaticDeployment.java From tomcatsrc with Apache License 2.0 | 5 votes |
private void doTestModify(boolean startXml, boolean startExternalWar, boolean startExternalDir, boolean startWar, boolean startDir, int toModify, boolean resultXml, boolean resultWar, boolean resultDir, String resultCookieName, int resultAction) throws Exception { doTestModify(startXml, startExternalWar, startExternalDir, startWar, startDir, toModify, resultXml, resultWar, resultDir, resultCookieName, resultAction, LifecycleState.STARTED); }
Example #20
Source File: ApplicationContext.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes) { if (!context.getState().equals(LifecycleState.STARTING_PREP)) { throw new IllegalStateException( sm.getString("applicationContext.setSessionTracking.ise", getContextPath())); } // Check that only supported tracking modes have been requested for (SessionTrackingMode sessionTrackingMode : sessionTrackingModes) { if (!supportedSessionTrackingModes.contains(sessionTrackingMode)) { throw new IllegalArgumentException(sm.getString( "applicationContext.setSessionTracking.iae.invalid", sessionTrackingMode.toString(), getContextPath())); } } // Check SSL has not be configured with anything else if (sessionTrackingModes.contains(SessionTrackingMode.SSL)) { if (sessionTrackingModes.size() > 1) { throw new IllegalArgumentException(sm.getString( "applicationContext.setSessionTracking.iae.ssl", getContextPath())); } } this.sessionTrackingModes = sessionTrackingModes; }
Example #21
Source File: StandardThreadExecutor.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Stop the component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}. * * @exception LifecycleException if this component detects a fatal error * that needs to be reported */ @Override protected void stopInternal() throws LifecycleException { setState(LifecycleState.STOPPING); if ( executor != null ) executor.shutdownNow(); executor = null; taskqueue = null; }
Example #22
Source File: ApplicationContext.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void setRequestCharacterEncoding(String encoding) { if (!context.getState().equals(LifecycleState.STARTING_PREP)) { throw new IllegalStateException( sm.getString("applicationContext.setRequestEncoding.ise", getContextPath())); } context.setRequestCharacterEncoding(encoding); }
Example #23
Source File: ApplicationContext.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void setResponseCharacterEncoding(String encoding) { if (!context.getState().equals(LifecycleState.STARTING_PREP)) { throw new IllegalStateException( sm.getString("applicationContext.setResponseEncoding.ise", getContextPath())); } context.setResponseCharacterEncoding(encoding); }
Example #24
Source File: TomcatPluginTest.java From cxf-fediz with Apache License 2.0 | 5 votes |
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 #25
Source File: StandardThreadExecutor.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Start the component 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 { taskqueue = new TaskQueue(maxQueueSize); TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority()); executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf); executor.setThreadRenewalDelay(threadRenewalDelay); if (prestartminSpareThreads) { executor.prestartAllCoreThreads(); } taskqueue.setParent(executor); setState(LifecycleState.STARTING); }
Example #26
Source File: CRUDClientServerTest.java From TeaStore with Apache License 2.0 | 5 votes |
/** * 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 #27
Source File: CometConnectionManagerValve.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Start this component 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 synchronized void startInternal() throws LifecycleException { if (container instanceof Context) { container.addLifecycleListener(this); } setState(LifecycleState.STARTING); }
Example #28
Source File: LifecycleBase.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private synchronized void setStateInternal(LifecycleState state, Object data, boolean check) throws LifecycleException { if (log.isDebugEnabled()) { log.debug(sm.getString("lifecycleBase.setState", this, state)); } if (check) { // Must have been triggered by one of the abstract methods (assume // code in this class is correct) // null is never a valid state if (state == null) { invalidTransition("null"); // Unreachable code - here to stop eclipse complaining about // a possible NPE further down the method return; } // Any method can transition to failed // startInternal() permits STARTING_PREP to STARTING // stopInternal() permits STOPPING_PREP to STOPPING and FAILED to // STOPPING if (!(state == LifecycleState.FAILED || (this.state == LifecycleState.STARTING_PREP && state == LifecycleState.STARTING) || (this.state == LifecycleState.STOPPING_PREP && state == LifecycleState.STOPPING) || (this.state == LifecycleState.FAILED && state == LifecycleState.STOPPING))) { // No other transition permitted invalidTransition(state.name()); } } this.state = state; String lifecycleEvent = state.getLifecycleEvent(); if (lifecycleEvent != null) { fireLifecycleEvent(lifecycleEvent, data); } }
Example #29
Source File: ApplicationSessionCookieConfig.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void setName(String name) { if (!context.getState().equals(LifecycleState.STARTING_PREP)) { throw new IllegalStateException(sm.getString( "applicationSessionCookieConfig.ise", "name", context.getPath())); } this.name = name; }
Example #30
Source File: ApplicationSessionCookieConfig.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public void setName(String name) { if (!context.getState().equals(LifecycleState.STARTING_PREP)) { throw new IllegalStateException(sm.getString( "applicationSessionCookieConfig.ise", "name", context.getPath())); } this.name = name; }