public final class Lifecycle
extends java.lang.Object
Constructor and Description |
---|
Lifecycle()
Creates an anonymous lifecycle.
|
Lifecycle(java.util.logging.Logger log)
Creates an lifecycle with logger and name.
|
Lifecycle(java.util.logging.Logger log,
java.lang.String name)
Creates an lifecycle with logger and name.
|
Lifecycle(java.util.logging.Logger log,
java.lang.String name,
java.util.logging.Level level)
Creates an lifecycle with logger, a name, and a level.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(LifecycleListener listener)
Adds a listener to detect lifecycle changes.
|
void |
copyState(Lifecycle source)
Copies from a target state.
|
long |
getActiveCount()
Returns the number of times the lifecycle has switched to active.
|
long |
getFailCount()
Returns the number of times the lifecycle has switched to failing.
|
long |
getLastChangeTime()
Returns the last lifecycle change time.
|
long |
getLastFailTime()
Returns the last failure time.
|
java.util.logging.Level |
getLevel()
Gets the lifecycle logging level.
|
java.lang.String |
getName()
Gets the lifecycle name.
|
LifecycleState |
getState() |
java.lang.String |
getStateName()
Returns the current state name.
|
int |
getStateOrdinal()
Returns the current state.
|
boolean |
isActive()
Returns true for the active state.
|
boolean |
isAfterInit()
True for any state after initialization.
|
boolean |
isAfterStopping()
Returns true for the closing states
|
boolean |
isAllowStopFromRestart()
True if a stop for a restart would be allowed.
|
boolean |
isBeforeActive()
Returns true for the initializing state.
|
boolean |
isBeforeInit()
Returns true for the init state.
|
boolean |
isDestroyed()
Returns true if the state is closed
|
boolean |
isDestroying()
Returns true if the state is closed
|
boolean |
isError()
Returns true for the failed state.
|
boolean |
isFailed()
Returns true for the failed state.
|
boolean |
isIdle()
True for an idle state, where any request would transition to an
active state.
|
boolean |
isInit()
Returns true for the init state.
|
boolean |
isInitializing()
Returns true for the initializing state.
|
boolean |
isRunnable()
Returns true for the a runnable state, including warmup
|
boolean |
isStarting()
Returns true if the service is starting.
|
boolean |
isStopped()
Returns true if the state is stopping.
|
boolean |
isStopping()
Returns true if the state is stopping.
|
boolean |
isWarmup()
Returns true for the warmup state.
|
void |
removeListener(LifecycleListener listener)
Removes a listener.
|
void |
setLevel(java.util.logging.Level level)
Sets the lifecycle logging level.
|
void |
setName(java.lang.String name)
Sets the lifecycle name, and the level to Level.INFO.
|
boolean |
toActive()
Changes to the active state.
|
boolean |
toDestroy()
Changes to the closed state.
|
boolean |
toDestroying()
Changes to the destroying state.
|
boolean |
toError()
Changes to the error state.
|
boolean |
toFail()
Changes to the failed state.
|
boolean |
toIdle()
Changes to the idle (stopped) state.
|
boolean |
toInit()
Changes to the init state.
|
boolean |
toInitializing()
Changes to the initializing state.
|
boolean |
toPostInit()
Changes to the init from the stopped state.
|
boolean |
toStarting()
Changes to the starting state.
|
boolean |
toStop()
Changes to the stopped state.
|
boolean |
toStopping()
Changes to the stopping state.
|
java.lang.String |
toString()
Debug string value.
|
boolean |
waitForActive(long timeout)
Wait for a period of time until the service starts.
|
public Lifecycle()
public Lifecycle(java.util.logging.Logger log)
public Lifecycle(java.util.logging.Logger log, java.lang.String name)
public Lifecycle(java.util.logging.Logger log, java.lang.String name, java.util.logging.Level level)
public java.lang.String getName()
public void setName(java.lang.String name)
public java.util.logging.Level getLevel()
public void setLevel(java.util.logging.Level level)
public final LifecycleState getState()
public int getStateOrdinal()
public java.lang.String getStateName()
public long getLastChangeTime()
public long getLastFailTime()
public long getActiveCount()
public long getFailCount()
public boolean isInitializing()
public boolean isInit()
public boolean isBeforeInit()
public boolean isAfterInit()
public boolean isIdle()
public boolean isStarting()
public boolean isWarmup()
public boolean isBeforeActive()
public boolean waitForActive(long timeout)
public boolean isActive()
public boolean isRunnable()
public boolean isAfterStopping()
public boolean isError()
public boolean isFailed()
public boolean isAllowStopFromRestart()
public boolean isStopping()
public boolean isStopped()
public boolean isDestroying()
public boolean isDestroyed()
public boolean toInitializing()
public boolean toInit()
public boolean toPostInit()
public boolean toStarting()
public boolean toActive()
public boolean toError()
public boolean toFail()
public boolean toStopping()
public boolean toIdle()
public boolean toStop()
public boolean toDestroying()
public boolean toDestroy()
public void addListener(LifecycleListener listener)
public void removeListener(LifecycleListener listener)
public void copyState(Lifecycle source)
public java.lang.String toString()
toString
in class java.lang.Object