|
Apache Tomcat 7.0.28 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 Lifecycle
are:
start() ----------------------------- | | | init() | NEW ->-- INITIALIZING | | | | | ------------------<----------------------- | | |auto | | | | | \|/ start() \|/ \|/ auto auto stop() | | | INITIALIZED -->-- STARTING_PREP -->- STARTING -->- STARTED -->--- | | | | | | | | | | | | | | | | | | | | |destroy()| | | | | -->-----<-- auto auto | | | | | ---------<----- MUST_STOP ---------------------<-- | | | | | | | | \|/ ---------------------------<-------------------------------- ^ | | | | | | \|/ auto auto start() | | | STOPPING_PREP ------>----- STOPPING ------>----- STOPPED ---->------ | | ^ | | ^ | | stop() | | | | | | -------------------------- | | | | | | auto | | | | | | MUST_DESTROY------<------- | | | | | | | | | | | |auto | | | | | 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. MUST_STOP is used to indicate that theThestop()
should be called on the component as soon asstart()
exits. It is typically used when a component has failed to start. MUST_DESTROY is used to indicate that thestop()
should be called on the component as soon asstop()
exits. It is typically used when a component is not designed to be restarted. Attempting any other transition will throwLifecycleException
.
LifecycleEvent
s fired during state changes are defined in the
methods that trigger the changed. No LifecycleEvent
s are fired if the
attempted transition is not valid.
TODO: Not all components may transition from STOPPED to STARTING_PREP. These
components should use MUST_DESTROY to signal this.
Field Summary | |
---|---|
static String |
AFTER_DESTROY_EVENT
The LifecycleEvent type for the "component after destroy" event. |
static String |
AFTER_INIT_EVENT
The LifecycleEvent type for the "component after init" event. |
static String |
AFTER_START_EVENT
The LifecycleEvent type for the "component after start" event. |
static String |
AFTER_STOP_EVENT
The LifecycleEvent type for the "component after stop" event. |
static String |
BEFORE_DESTROY_EVENT
The LifecycleEvent type for the "component before destroy" event. |
static String |
BEFORE_INIT_EVENT
The LifecycleEvent type for the "component after init" event. |
static String |
BEFORE_START_EVENT
The LifecycleEvent type for the "component before start" event. |
static String |
BEFORE_STOP_EVENT
The LifecycleEvent type for the "component before stop" event. |
static String |
CONFIGURE_START_EVENT
The LifecycleEvent type for the "configure_start" event. |
static String |
CONFIGURE_STOP_EVENT
The LifecycleEvent type for the "configure_stop" event. |
static String |
PERIODIC_EVENT
The LifecycleEvent type for the "periodic" event. |
static String |
START_EVENT
The LifecycleEvent type for the "component start" event. |
static String |
STOP_EVENT
The LifecycleEvent type for the "component stop" event. |
Method Summary | |
---|---|
void |
addLifecycleListener(LifecycleListener listener)
Add a LifecycleEvent listener to this component. |
void |
destroy()
Prepare to discard the object. |
LifecycleListener[] |
findLifecycleListeners()
Get the life cycle listeners associated with this life cycle. |
LifecycleState |
getState()
Obtain the current state of the source component. |
String |
getStateName()
Obtain a textual representation of the current component state. |
void |
init()
Prepare the component for starting. |
void |
removeLifecycleListener(LifecycleListener listener)
Remove a LifecycleEvent listener from this component. |
void |
start()
Prepare for the beginning of active use of the public methods other than property getters/setters and life cycle methods of this component. |
void |
stop()
Gracefully terminate the active use of the public methods other than property getters/setters and life cycle methods of this component. |
Field Detail |
---|
static final String BEFORE_INIT_EVENT
static final String AFTER_INIT_EVENT
static final String START_EVENT
static final String BEFORE_START_EVENT
static final String AFTER_START_EVENT
static final String STOP_EVENT
static final String BEFORE_STOP_EVENT
static final String AFTER_STOP_EVENT
static final String AFTER_DESTROY_EVENT
static final String BEFORE_DESTROY_EVENT
static final String PERIODIC_EVENT
static final String CONFIGURE_START_EVENT
BEFORE_START_EVENT
and before START_EVENT
.
static final String CONFIGURE_STOP_EVENT
STOP_EVENT
and before AFTER_STOP_EVENT
.
Method Detail |
---|
void addLifecycleListener(LifecycleListener listener)
listener
- The listener to addLifecycleListener[] findLifecycleListeners()
void removeLifecycleListener(LifecycleListener listener)
listener
- The listener to removevoid init() throws LifecycleException
LifecycleEvent
s will be fired in the following order:
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedvoid start() throws LifecycleException
LifecycleEvent
s will be fired in the
following order:
LifecycleState.STARTING_PREP
.LifecycleState.STARTING
and that the public methods other than property
getters/setters and life cycle methods may be
used.LifecycleState.STARTED
.
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedvoid stop() throws LifecycleException
LifecycleEvent
s will be fired in the following order:
LifecycleState.STOPPING_PREP
.LifecycleState.STOPPING
and that the public methods other than property
getters/setters and life cycle methods may no longer be
used.LifecycleState.STOPPED
.
LifecycleState.FAILED
then the
three events above will be fired but the component will transition
directly from LifecycleState.FAILED
to
LifecycleState.STOPPING
, bypassing
LifecycleState.STOPPING_PREP
LifecycleException
- if this component detects a fatal error
that needs to be reportedvoid destroy() throws LifecycleException
LifecycleEvent
s will
be fired in the following order:
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedLifecycleState getState()
String getStateName()
|
Apache Tomcat 7.0.28 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |