Package com.aspectran.utils.lifecycle
Interface LifeCycle
- All Known Subinterfaces:
TowServer
- All Known Implementing Classes:
AbstractLifeCycle
,AbstractTowServer
,DefaultTowServer
,HouseKeeper
,StopLifeCycle
public interface LifeCycle
The lifecycle interface for generic components.
Classes implementing this interface have a defined life cycle defined by the methods of this interface.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A listener for Lifecycle events. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addLifeCycleListener
(LifeCycle.Listener listener) getState()
boolean
isFailed()
boolean
boolean
boolean
boolean
boolean
void
removeLifeCycleListener
(LifeCycle.Listener listener) void
start()
Starts the component.static void
Utility to start an object if it is a LifeCycle and to convert any exception thrown to aRuntimeException
.void
stop()
Stops the component.static void
Utility to stop an object if it is a LifeCycle and to convert any exception thrown to aRuntimeException
.
-
Field Details
-
STOPPED
- See Also:
-
FAILED
- See Also:
-
STARTING
- See Also:
-
STARTED
- See Also:
-
STOPPING
- See Also:
-
RUNNING
- See Also:
-
-
Method Details
-
start
Starts the component.- Throws:
Exception
- If the component fails to start- See Also:
-
stop
Stops the component. The component may wait for current activities to complete normally, but it can be interrupted.- Throws:
Exception
- If the component fails to stop- See Also:
-
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:
-
isStarting
boolean isStarting()- Returns:
- true if the component is starting
- See Also:
-
isStopping
boolean isStopping()- Returns:
- true if the component is stopping
- See Also:
-
isStopped
boolean isStopped()- Returns:
- true if the component has been stopped
- See Also:
-
isFailed
boolean isFailed()- Returns:
- true if the component has failed to start or has failed to stop
-
addLifeCycleListener
-
removeLifeCycleListener
-
getState
String getState() -
start
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:
RuntimeException
- if the call to start throws an exception
-
stop
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:
RuntimeException
- if the call to stop throws an exception
-