Package org.eclipse.jetty.util.component
Class AbstractLifeCycle
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- All Implemented Interfaces:
LifeCycle
- Direct Known Subclasses:
AbstractLeakPreventer
,AcceptRateLimit
,BaseHolder
,CompressionPool
,ConnectionLimit
,ConnectionStatistics
,ConnectorServer
,ConnectorStatistics
,ContainerLifeCycle
,DebugListener
,HouseKeeper
,JAASLoginService
,LeakDetector
,PathWatcher
,RequestLogWriter
,ReservedThreadExecutor
,Scanner
,ScheduledExecutorScheduler
,Slf4jRequestLogWriter
,SpnegoLoginService
,SslContextFactory
,StopLifeCycle
,Sweeper
,TimerScheduler
,UserStore
@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
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.CopyOnWriteArrayList<LifeCycle.Listener>
_listeners
private java.lang.Object
_lock
private int
_state
private long
_stopTimeout
static java.lang.String
FAILED
private static Logger
LOG
static java.lang.String
RUNNING
static java.lang.String
STARTED
static java.lang.String
STARTING
private static int
STATE_FAILED
private static int
STATE_STARTED
private static int
STATE_STARTING
private static int
STATE_STOPPED
private static int
STATE_STOPPING
static java.lang.String
STOPPED
static java.lang.String
STOPPING
-
Constructor Summary
Constructors Constructor Description AbstractLifeCycle()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLifeCycleListener(LifeCycle.Listener listener)
protected void
doStart()
protected void
doStop()
java.lang.String
getState()
static java.lang.String
getState(LifeCycle lc)
long
getStopTimeout()
boolean
isFailed()
boolean
isRunning()
boolean
isStarted()
boolean
isStarting()
boolean
isStopped()
boolean
isStopping()
void
removeLifeCycleListener(LifeCycle.Listener listener)
private void
setFailed(java.lang.Throwable th)
private void
setStarted()
private void
setStarting()
private void
setStopped()
private void
setStopping()
void
setStopTimeout(long stopTimeout)
void
start()
Starts the component.void
stop()
Stops the component.java.lang.String
toString()
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
STOPPED
public static final java.lang.String STOPPED
- See Also:
- Constant Field Values
-
FAILED
public static final java.lang.String FAILED
- See Also:
- Constant Field Values
-
STARTING
public static final java.lang.String STARTING
- See Also:
- Constant Field Values
-
STARTED
public static final java.lang.String STARTED
- See Also:
- Constant Field Values
-
STOPPING
public static final java.lang.String STOPPING
- See Also:
- Constant Field Values
-
RUNNING
public static final java.lang.String RUNNING
- See Also:
- Constant Field Values
-
_listeners
private final java.util.concurrent.CopyOnWriteArrayList<LifeCycle.Listener> _listeners
-
_lock
private final java.lang.Object _lock
-
STATE_FAILED
private static final int STATE_FAILED
- See Also:
- Constant Field Values
-
STATE_STOPPED
private static final int STATE_STOPPED
- See Also:
- Constant Field Values
-
STATE_STARTING
private static final int STATE_STARTING
- See Also:
- Constant Field Values
-
STATE_STARTED
private static final int STATE_STARTED
- See Also:
- Constant Field Values
-
STATE_STOPPING
private static final int STATE_STOPPING
- See Also:
- Constant Field Values
-
_state
private volatile int _state
-
_stopTimeout
private long _stopTimeout
-
-
Method Detail
-
doStart
protected void doStart() throws java.lang.Exception
- Throws:
java.lang.Exception
-
doStop
protected void doStop() throws java.lang.Exception
- Throws:
java.lang.Exception
-
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()
-
addLifeCycleListener
public void addLifeCycleListener(LifeCycle.Listener listener)
- Specified by:
addLifeCycleListener
in interfaceLifeCycle
-
removeLifeCycleListener
public void removeLifeCycleListener(LifeCycle.Listener listener)
- Specified by:
removeLifeCycleListener
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)
-
setStarted
private void setStarted()
-
setStarting
private void setStarting()
-
setStopping
private void setStopping()
-
setStopped
private void setStopped()
-
setFailed
private void setFailed(java.lang.Throwable th)
-
getStopTimeout
@ManagedAttribute("The stop timeout in milliseconds") public long getStopTimeout()
-
setStopTimeout
public void setStopTimeout(long stopTimeout)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-