- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- All Implemented Interfaces:
LifeCycle
- Direct Known Subclasses:
AbstractLeakPreventer
,CompressionPool
,ContainerLifeCycle
,LeakDetector
,PathWatcher
,ReservedThreadExecutor
,ScheduledExecutorScheduler
,SslContextFactory
,StopLifeCycle
,Sweeper
,TimerScheduler
@ManagedObject("Abstract Implementation of LifeCycle") public abstract class AbstractLifeCycle extends java.lang.Object implements LifeCycle
Basic implementation of the life cycle interface for components.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractLifeCycle.AbstractLifeCycleListener
class
AbstractLifeCycle.StopException
An exception, which if thrown by doStart will immediately stop the component-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Constructor Summary
Constructors Constructor Description AbstractLifeCycle()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addEventListener(java.util.EventListener listener)
protected void
doStart()
Method to override to start the lifecycleprotected void
doStop()
Method to override to stop the lifecyclejava.util.List<java.util.EventListener>
getEventListeners()
java.lang.String
getState()
static java.lang.String
getState(LifeCycle lc)
boolean
isFailed()
boolean
isRunning()
boolean
isStarted()
boolean
isStarting()
boolean
isStopped()
boolean
isStopping()
boolean
removeEventListener(java.util.EventListener listener)
void
setEventListeners(java.util.Collection<java.util.EventListener> eventListeners)
void
start()
Starts the component.void
stop()
Stops the component.java.lang.String
toString()
-
-
-
Method Detail
-
doStart
protected void doStart() throws java.lang.Exception
Method to override to start the lifecycle- Throws:
AbstractLifeCycle.StopException
- If thrown, the lifecycle will immediately be stopped.java.lang.Exception
- If there was a problem starting. Will cause a transition to FAILED state
-
doStop
protected void doStop() throws java.lang.Exception
Method to override to stop the lifecycle- Throws:
java.lang.Exception
- If there was a problem stopping. Will cause a transition to FAILED state
-
start
public final void start() throws java.lang.Exception
Description copied from interface:LifeCycle
Starts the component.- Specified by:
start
in interfaceLifeCycle
- Throws:
java.lang.Exception
- If the component fails to start- See Also:
LifeCycle.isStarted()
,LifeCycle.stop()
,LifeCycle.isFailed()
-
stop
public final void stop() throws java.lang.Exception
Description copied from interface:LifeCycle
Stops the component. The component may wait for current activities to complete normally, but it can be interrupted.- Specified by:
stop
in interfaceLifeCycle
- Throws:
java.lang.Exception
- If the component fails to stop- See Also:
LifeCycle.isStopped()
,LifeCycle.start()
,LifeCycle.isFailed()
-
isRunning
public boolean isRunning()
-
isStarted
public boolean isStarted()
- Specified by:
isStarted
in interfaceLifeCycle
- Returns:
- true if the component has been started.
- See Also:
LifeCycle.start()
,LifeCycle.isStarting()
-
isStarting
public boolean isStarting()
- Specified by:
isStarting
in interfaceLifeCycle
- Returns:
- true if the component is starting.
- See Also:
LifeCycle.isStarted()
-
isStopping
public boolean isStopping()
- Specified by:
isStopping
in interfaceLifeCycle
- Returns:
- true if the component is stopping.
- See Also:
LifeCycle.isStopped()
-
isStopped
public boolean isStopped()
- Specified by:
isStopped
in interfaceLifeCycle
- Returns:
- true if the component has been stopped.
- See Also:
LifeCycle.stop()
,LifeCycle.isStopping()
-
isFailed
public boolean isFailed()
-
getEventListeners
public java.util.List<java.util.EventListener> getEventListeners()
-
setEventListeners
public void setEventListeners(java.util.Collection<java.util.EventListener> eventListeners)
-
addEventListener
public boolean addEventListener(java.util.EventListener listener)
- Specified by:
addEventListener
in interfaceLifeCycle
-
removeEventListener
public boolean removeEventListener(java.util.EventListener listener)
- Specified by:
removeEventListener
in interfaceLifeCycle
-
getState
@ManagedAttribute(value="Lifecycle State for this instance", readonly=true) public java.lang.String getState()
-
getState
public static java.lang.String getState(LifeCycle lc)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-