Interface LifeCycle
-
- All Known Implementing Classes:
AbstractLifeCycle,StopLifeCycle
public interface LifeCycleThe lifecycle interface for generic components.Classes implementing this interface have a defined life cycle defined by the methods of this interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceLifeCycle.ListenerA listener for Lifecycle events.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddLifeCycleListener(LifeCycle.Listener listener)booleanisFailed()booleanisRunning()booleanisStarted()booleanisStarting()booleanisStopped()booleanisStopping()voidremoveLifeCycleListener(LifeCycle.Listener listener)voidstart()Starts the component.static voidstart(java.lang.Object object)Utility to start an object if it is a LifeCycle and to convert any exception thrown to aRuntimeException.voidstop()Stops the component.static voidstop(java.lang.Object object)Utility to stop an object if it is a LifeCycle and to convert any exception thrown to aRuntimeException.
-
-
-
Field Detail
-
STOPPED
static final java.lang.String STOPPED
- See Also:
- Constant Field Values
-
FAILED
static final java.lang.String FAILED
- See Also:
- Constant Field Values
-
STARTING
static final java.lang.String STARTING
- See Also:
- Constant Field Values
-
STARTED
static final java.lang.String STARTED
- See Also:
- Constant Field Values
-
STOPPING
static final java.lang.String STOPPING
- See Also:
- Constant Field Values
-
RUNNING
static final java.lang.String RUNNING
- See Also:
- Constant Field Values
-
-
Method Detail
-
start
void start() throws java.lang.ExceptionStarts the component.- Throws:
java.lang.Exception- If the component fails to start- See Also:
isStarted(),stop(),isFailed()
-
stop
void stop() throws java.lang.Exception
Stops the component. The component may wait for current activities to complete normally, but it can be interrupted.- Throws:
java.lang.Exception- If the component fails to stop- See Also:
isStopped(),start(),isFailed()
-
isRunning
boolean isRunning()
- Returns:
- true if the component is starting or has been started
-
isStarted
boolean isStarted()
- Returns:
- true if the component has been started.
- See Also:
start(),isStarting()
-
isStarting
boolean isStarting()
- Returns:
- true if the component is starting
- See Also:
isStarted()
-
isStopping
boolean isStopping()
- Returns:
- true if the component is stopping
- See Also:
isStopped()
-
isStopped
boolean isStopped()
- Returns:
- true if the component has been stopped
- See Also:
stop(),isStopping()
-
isFailed
boolean isFailed()
- Returns:
- true if the component has failed to start or has failed to stop
-
addLifeCycleListener
void addLifeCycleListener(LifeCycle.Listener listener)
-
removeLifeCycleListener
void removeLifeCycleListener(LifeCycle.Listener listener)
-
start
static void start(java.lang.Object object)
Utility to start an object if it is a LifeCycle and to convert any exception thrown to aRuntimeException.- Parameters:
object- the instance to start.- Throws:
java.lang.RuntimeException- if the call to start throws an exception
-
stop
static void stop(java.lang.Object object)
Utility to stop an object if it is a LifeCycle and to convert any exception thrown to aRuntimeException.- Parameters:
object- the instance to stop.- Throws:
java.lang.RuntimeException- if the call to stop throws an exception
-
-