public abstract class LifecycleBase extends Object implements Lifecycle
Lifecycle interface that implements the
 state transition rules for Lifecycle.start() and
 Lifecycle.stop()Lifecycle.SingleUseAFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT| Constructor and Description | 
|---|
| LifecycleBase() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addLifecycleListener(LifecycleListener listener)Add a LifecycleEvent listener to this component. | 
| void | destroy()Prepare to discard the object. | 
| protected abstract void | destroyInternal()Sub-classes implement this method to perform any instance destruction
 required. | 
| LifecycleListener[] | findLifecycleListeners()Get the life cycle listeners associated with this life cycle. | 
| protected void | fireLifecycleEvent(String type,
                  Object data)Allow sub classes to fire  Lifecycleevents. | 
| LifecycleState | getState()Obtain the current state of the source component. | 
| String | getStateName()Obtain a textual representation of the current component state. | 
| boolean | getThrowOnFailure()Will a  LifecycleExceptionthrown by a sub-class duringinitInternal(),startInternal(),stopInternal()ordestroyInternal()be re-thrown for
 the caller to handle or will it be logged instead? | 
| void | init()Prepare the component for starting. | 
| protected abstract void | initInternal()Sub-classes implement this method to perform any instance initialisation
 required. | 
| void | removeLifecycleListener(LifecycleListener listener)Remove a LifecycleEvent listener from this component. | 
| protected void | setState(LifecycleState state)Provides a mechanism for sub-classes to update the component state. | 
| protected void | setState(LifecycleState state,
        Object data)Provides a mechanism for sub-classes to update the component state. | 
| void | setThrowOnFailure(boolean throwOnFailure)Configure if a  LifecycleExceptionthrown by a sub-class duringinitInternal(),startInternal(),stopInternal()ordestroyInternal()will be re-thrown
 for the caller to handle or if it will be logged instead. | 
| 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. | 
| protected abstract void | startInternal()Sub-classes must ensure that the state is changed to
  LifecycleState.STARTINGduring the execution of this method. | 
| void | stop()Gracefully terminate the active use of the public methods other than
 property getters/setters and life cycle methods of this component. | 
| protected abstract void | stopInternal()Sub-classes must ensure that the state is changed to
  LifecycleState.STOPPINGduring the execution of this method. | 
public boolean getThrowOnFailure()
LifecycleException thrown by a sub-class during
 initInternal(), startInternal(),
 stopInternal() or destroyInternal() be re-thrown for
 the caller to handle or will it be logged instead?true if the exception will be re-thrown, otherwise
         falsepublic void setThrowOnFailure(boolean throwOnFailure)
LifecycleException thrown by a sub-class during
 initInternal(), startInternal(),
 stopInternal() or destroyInternal() will be re-thrown
 for the caller to handle or if it will be logged instead.throwOnFailure - true if the exception should be re-thrown,
                       otherwise falsepublic void addLifecycleListener(LifecycleListener listener)
addLifecycleListener in interface Lifecyclelistener - The listener to addpublic LifecycleListener[] findLifecycleListeners()
findLifecycleListeners in interface Lifecyclepublic void removeLifecycleListener(LifecycleListener listener)
removeLifecycleListener in interface Lifecyclelistener - The listener to removeprotected void fireLifecycleEvent(String type, Object data)
Lifecycle events.type - Event typedata - Data associated with event.public final void init()
                throws LifecycleException
LifecycleLifecycleEvents will be fired in the following order:
 init in interface LifecycleLifecycleException - if this component detects a fatal error
  that prevents this component from being usedprotected abstract void initInternal()
                              throws LifecycleException
LifecycleException - If the initialisation failspublic final void start()
                 throws LifecycleException
LifecycleEvents 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.
                          start in interface LifecycleLifecycleException - if this component detects a fatal error
  that prevents this component from being usedprotected abstract void startInternal()
                               throws LifecycleException
LifecycleState.STARTING during the execution of this method.
 Changing state will trigger the Lifecycle.START_EVENT event.
 If a component fails to start it may either throw a
 LifecycleException which will cause it's parent to fail to start
 or it can place itself in the error state in which case stop()
 will be called on the failed component but the parent component will
 continue to start normally.LifecycleException - Start error occurredpublic final void stop()
                throws LifecycleException
LifecycleEvents 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_PREPstop in interface LifecycleLifecycleException - if this component detects a fatal error
  that needs to be reportedprotected abstract void stopInternal()
                              throws LifecycleException
LifecycleState.STOPPING during the execution of this method.
 Changing state will trigger the Lifecycle.STOP_EVENT event.LifecycleException - Stop error occurredpublic final void destroy()
                   throws LifecycleException
LifecycleLifecycleEvents will
 be fired in the following order:
 destroy in interface LifecycleLifecycleException - if this component detects a fatal error
  that prevents this component from being usedprotected abstract void destroyInternal()
                                 throws LifecycleException
LifecycleException - If the destruction failspublic LifecycleState getState()
public String getStateName()
Lifecycle.getState().getStateName in interface Lifecycleprotected void setState(LifecycleState state) throws LifecycleException
Lifecycle event. It will also check that any attempted state
 transition is valid for a sub-class.state - The new state for this componentLifecycleException - when attempting to set an invalid stateprotected void setState(LifecycleState state, Object data) throws LifecycleException
Lifecycle event. It will also check that any attempted state
 transition is valid for a sub-class.state - The new state for this componentdata - The data to pass to the associated Lifecycle eventLifecycleException - when attempting to set an invalid stateCopyright © 2000-2020 Apache Software Foundation. All Rights Reserved.