Package org.apache.catalina
Interface Lifecycle
- All Known Subinterfaces:
- Container,- Context,- Engine,- Executor,- Host,- Server,- Service,- WebResourceRoot,- WebResourceSet,- Wrapper
- All Known Implementing Classes:
- AbstractAccessLogValve,- AbstractArchiveResourceSet,- AbstractFileResourceSet,- AbstractResourceSet,- AbstractSingleArchiveResourceSet,- AccessLogValve,- AuthenticatedUserRealm,- AuthenticatorBase,- BackupManager,- BasicAuthenticator,- ClusterManagerBase,- ClusterSingleSignOn,- CombinedRealm,- Connector,- ContainerBase,- CrawlerSessionManagerValve,- DataSourceRealm,- DataSourceStore,- DeltaManager,- DigestAuthenticator,- DirResourceSet,- EmptyResourceSet,- ErrorReportValve,- ExtendedAccessLogValve,- ExtractingRoot,- FailedContext,- FileResourceSet,- FileStore,- FormAuthenticator,- HealthCheckValve,- JAASMemoryLoginModule,- JAASRealm,- JarResourceSet,- JarWarResourceSet,- JDBCAccessLogValve,- JNDIRealm,- JsonAccessLogValve,- JsonErrorReportValve,- JvmRouteBinderValve,- LifecycleBase,- LifecycleMBeanBase,- LoadBalancerDrainingValve,- LockOutRealm,- ManagerBase,- MapperListener,- MemoryRealm,- NamingResourcesImpl,- NonLoginAuthenticator,- NullRealm,- ParallelWebappClassLoader,- PersistentManager,- PersistentManagerBase,- PersistentValve,- ProxyErrorReportValve,- RealmBase,- RemoteAddrValve,- RemoteCIDRValve,- RemoteHostValve,- RemoteIpValve,- ReplicatedContext,- ReplicationValve,- RequestFilterValve,- RewriteValve,- SemaphoreValve,- SessionIdGeneratorBase,- SimpleTcpCluster,- SingleSignOn,- SpnegoAuthenticator,- SSLAuthenticator,- SSLValve,- StandardContext,- StandardEngine,- StandardHost,- StandardManager,- StandardPipeline,- StandardRoot,- StandardServer,- StandardService,- StandardSessionIdGenerator,- StandardThreadExecutor,- StandardVirtualThreadExecutor,- StandardWrapper,- StoreBase,- StuckThreadDetectionValve,- Tomcat.ExistingStandardWrapper,- UserDatabaseRealm,- ValveBase,- WarResourceSet,- WebappClassLoader,- WebappClassLoaderBase,- WebappLoader
public interface Lifecycle
Common interface for component life cycle methods.  Catalina components
 may implement this interface (as well as the appropriate interface(s) for
 the functionality they support) in order to provide a consistent mechanism
 to start and stop the component.
 
The valid state transitions for components that support
The valid state transitions for components that support
Lifecycle
 are:
 
            start()
  -----------------------------
  |                           |
  | init()                    |
 NEW -»-- INITIALIZING        |
 | |           |              |     ------------------«-----------------------
 | |           |auto          |     |                                        |
 | |          \|/    start() \|/   \|/     auto          auto         stop() |
 | |      INITIALIZED --»-- STARTING_PREP --»- STARTING --»- STARTED --»---  |
 | |         |                                                            |  |
 | |destroy()|                                                            |  |
 | --»-----«--    ------------------------«--------------------------------  ^
 |     |          |                                                          |
 |     |         \|/          auto                 auto              start() |
 |     |     STOPPING_PREP ----»---- STOPPING ------»----- STOPPED -----»-----
 |    \|/                               ^                     |  ^
 |     |               stop()           |                     |  |
 |     |       --------------------------                     |  |
 |     |       |                                              |  |
 |     |       |    destroy()                       destroy() |  |
 |     |    FAILED ----»------ DESTROYING ---«-----------------  |
 |     |                        ^     |                          |
 |     |     destroy()          |     |auto                      |
 |     --------»-----------------    \|/                         |
 |                                 DESTROYED                     |
 |                                                               |
 |                            stop()                             |
 ----»-----------------------------»------------------------------
 Any state can transition to FAILED.
 Calling start() while a component is in states STARTING_PREP, STARTING or
 STARTED has no effect.
 Calling start() while a component is in state NEW will cause init() to be
 called immediately after the start() method is entered.
 Calling stop() while a component is in states STOPPING_PREP, STOPPING or
 STOPPED has no effect.
 Calling stop() while a component is in state NEW transitions the component
 to STOPPED. This is typically encountered when a component fails to start and
 does not start all its sub-components. When the component is stopped, it will
 try to stop all sub-components - even those it didn't start.
 Attempting any other transition will throw LifecycleException.
 
 The LifecycleEvents fired during state changes are defined in the
 methods that trigger the changed. No LifecycleEvents are fired if the
 attempted transition is not valid.- Author:
- Craig R. McClanahan
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic interfaceMarker interface used to indicate that the instance should only be used once.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThe LifecycleEvent type for the "component after destroy" event.static final StringThe LifecycleEvent type for the "component after init" event.static final StringThe LifecycleEvent type for the "component after start" event.static final StringThe LifecycleEvent type for the "component after stop" event.static final StringThe LifecycleEvent type for the "component before destroy" event.static final StringThe LifecycleEvent type for the "component before init" event.static final StringThe LifecycleEvent type for the "component before start" event.static final StringThe LifecycleEvent type for the "component before stop" event.static final StringThe LifecycleEvent type for the "configure_start" event.static final StringThe LifecycleEvent type for the "configure_stop" event.static final StringThe LifecycleEvent type for the "periodic" event.static final StringThe LifecycleEvent type for the "component start" event.static final StringThe LifecycleEvent type for the "component stop" event.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddLifecycleListener(LifecycleListener listener) Add a LifecycleEvent listener to this component.voiddestroy()Prepare to discard the object.Get the life cycle listeners associated with this life cycle.getState()Obtain the current state of the source component.Obtain a textual representation of the current component state.voidinit()Prepare the component for starting.voidremoveLifecycleListener(LifecycleListener listener) Remove a LifecycleEvent listener from this component.voidstart()Prepare for the beginning of active use of the public methods other than property getters/setters and life cycle methods of this component.voidstop()Gracefully terminate the active use of the public methods other than property getters/setters and life cycle methods of this component.
- 
Field Details- 
BEFORE_INIT_EVENTThe LifecycleEvent type for the "component before init" event.- See Also:
 
- 
AFTER_INIT_EVENTThe LifecycleEvent type for the "component after init" event.- See Also:
 
- 
START_EVENTThe LifecycleEvent type for the "component start" event.- See Also:
 
- 
BEFORE_START_EVENTThe LifecycleEvent type for the "component before start" event.- See Also:
 
- 
AFTER_START_EVENTThe LifecycleEvent type for the "component after start" event.- See Also:
 
- 
STOP_EVENTThe LifecycleEvent type for the "component stop" event.- See Also:
 
- 
BEFORE_STOP_EVENTThe LifecycleEvent type for the "component before stop" event.- See Also:
 
- 
AFTER_STOP_EVENTThe LifecycleEvent type for the "component after stop" event.- See Also:
 
- 
AFTER_DESTROY_EVENTThe LifecycleEvent type for the "component after destroy" event.- See Also:
 
- 
BEFORE_DESTROY_EVENTThe LifecycleEvent type for the "component before destroy" event.- See Also:
 
- 
PERIODIC_EVENTThe LifecycleEvent type for the "periodic" event.- See Also:
 
- 
CONFIGURE_START_EVENTThe LifecycleEvent type for the "configure_start" event. Used by those components that use a separate component to perform configuration and need to signal when configuration should be performed - usually afterBEFORE_START_EVENTand beforeSTART_EVENT.- See Also:
 
- 
CONFIGURE_STOP_EVENTThe LifecycleEvent type for the "configure_stop" event. Used by those components that use a separate component to perform configuration and need to signal when de-configuration should be performed - usually afterSTOP_EVENTand beforeAFTER_STOP_EVENT.- See Also:
 
 
- 
- 
Method Details- 
addLifecycleListenerAdd a LifecycleEvent listener to this component.- Parameters:
- listener- The listener to add
 
- 
findLifecycleListenersLifecycleListener[] findLifecycleListeners()Get the life cycle listeners associated with this life cycle.- Returns:
- An array containing the life cycle listeners associated with this life cycle. If this component has no listeners registered, a zero-length array is returned.
 
- 
removeLifecycleListenerRemove a LifecycleEvent listener from this component.- Parameters:
- listener- The listener to remove
 
- 
initPrepare the component for starting. This method should perform any initialization required post object creation. The followingLifecycleEvents will be fired in the following order:- INIT_EVENT: On the successful completion of component initialization.
 - Throws:
- LifecycleException- if this component detects a fatal error that prevents this component from being used
 
- 
startPrepare for the beginning of active use of the public methods other than property getters/setters and life cycle methods of this component. This method should be called before any of the public methods other than property getters/setters and life cycle methods of this component are utilized. The followingLifecycleEvents will be fired in the following order:- BEFORE_START_EVENT: At the beginning of the method. It is as this
                           point the state transitions to
                           LifecycleState.STARTING_PREP.
- START_EVENT: During the method once it is safe to call start() for
                    any child components. It is at this point that the
                    state transitions to LifecycleState.STARTINGand that the public methods other than property getters/setters and life cycle methods may be used.
- AFTER_START_EVENT: At the end of the method, immediately before it
                          returns. It is at this point that the state
                          transitions to LifecycleState.STARTED.
 - Throws:
- LifecycleException- if this component detects a fatal error that prevents this component from being used
 
- BEFORE_START_EVENT: At the beginning of the method. It is as this
                           point the state transitions to
                           
- 
stopGracefully terminate the active use of the public methods other than property getters/setters and life cycle methods of this component. Once the STOP_EVENT is fired, the public methods other than property getters/setters and life cycle methods should not be used. The followingLifecycleEvents will be fired in the following order:- BEFORE_STOP_EVENT: At the beginning of the method. It is at this
                          point that the state transitions to
                          LifecycleState.STOPPING_PREP.
- STOP_EVENT: During the method once it is safe to call stop() for
                   any child components. It is at this point that the
                   state transitions to LifecycleState.STOPPINGand that the public methods other than property getters/setters and life cycle methods may no longer be used.
- AFTER_STOP_EVENT: At the end of the method, immediately before it
                         returns. It is at this point that the state
                         transitions to LifecycleState.STOPPED.
 LifecycleState.FAILEDthen the three events above will be fired but the component will transition directly fromLifecycleState.FAILEDtoLifecycleState.STOPPING, bypassingLifecycleState.STOPPING_PREP- Throws:
- LifecycleException- if this component detects a fatal error that needs to be reported
 
- BEFORE_STOP_EVENT: At the beginning of the method. It is at this
                          point that the state transitions to
                          
- 
destroyPrepare to discard the object. The followingLifecycleEvents will be fired in the following order:- DESTROY_EVENT: On the successful completion of component destruction.
 - Throws:
- LifecycleException- if this component detects a fatal error that prevents this component from being used
 
- 
getStateLifecycleState getState()Obtain the current state of the source component.- Returns:
- The current state of the source component.
 
- 
getStateNameString getStateName()Obtain a textual representation of the current component state. Useful for JMX. The format of this string may vary between point releases and should not be relied upon to determine component state. To determine component state, usegetState().- Returns:
- The name of the current component state.
 
 
-