com.caucho.lifecycle
Class Lifecycle

java.lang.Object
  extended by com.caucho.lifecycle.Lifecycle

public final class Lifecycle
extends java.lang.Object

Lifecycle class.


Constructor Summary
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.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Lifecycle

public Lifecycle()
Creates an anonymous lifecycle.


Lifecycle

public Lifecycle(java.util.logging.Logger log)
Creates an lifecycle with logger and name.


Lifecycle

public Lifecycle(java.util.logging.Logger log,
                 java.lang.String name)
Creates an lifecycle with logger and name.


Lifecycle

public 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.

Method Detail

getName

public java.lang.String getName()
Gets the lifecycle name.


setName

public void setName(java.lang.String name)
Sets the lifecycle name, and the level to Level.INFO.


getLevel

public java.util.logging.Level getLevel()
Gets the lifecycle logging level.


setLevel

public void setLevel(java.util.logging.Level level)
Sets the lifecycle logging level.


getState

public final LifecycleState getState()

getStateOrdinal

public int getStateOrdinal()
Returns the current state.


getStateName

public java.lang.String getStateName()
Returns the current state name.


getLastChangeTime

public long getLastChangeTime()
Returns the last lifecycle change time.


getLastFailTime

public long getLastFailTime()
Returns the last failure time.


getActiveCount

public long getActiveCount()
Returns the number of times the lifecycle has switched to active.


getFailCount

public long getFailCount()
Returns the number of times the lifecycle has switched to failing.


isInitializing

public boolean isInitializing()
Returns true for the initializing state.


isInit

public boolean isInit()
Returns true for the init state.


isBeforeInit

public boolean isBeforeInit()
Returns true for the init state.


isAfterInit

public boolean isAfterInit()
True for any state after initialization.


isIdle

public boolean isIdle()
True for an idle state, where any request would transition to an active state.


isStarting

public boolean isStarting()
Returns true if the service is starting.


isWarmup

public boolean isWarmup()
Returns true for the warmup state.


isBeforeActive

public boolean isBeforeActive()
Returns true for the initializing state.


waitForActive

public boolean waitForActive(long timeout)
Wait for a period of time until the service starts.


isActive

public boolean isActive()
Returns true for the active state.


isRunnable

public boolean isRunnable()
Returns true for the a runnable state, including warmup


isAfterStopping

public boolean isAfterStopping()
Returns true for the closing states


isError

public boolean isError()
Returns true for the failed state.


isFailed

public boolean isFailed()
Returns true for the failed state.


isAllowStopFromRestart

public boolean isAllowStopFromRestart()
True if a stop for a restart would be allowed.


isStopping

public boolean isStopping()
Returns true if the state is stopping.


isStopped

public boolean isStopped()
Returns true if the state is stopping.


isDestroying

public boolean isDestroying()
Returns true if the state is closed


isDestroyed

public boolean isDestroyed()
Returns true if the state is closed


toInitializing

public boolean toInitializing()
Changes to the initializing state.

Returns:
true if the transition is allowed

toInit

public boolean toInit()
Changes to the init state.

Returns:
true if the transition is allowed

toPostInit

public boolean toPostInit()
Changes to the init from the stopped state.

Returns:
true if the transition is allowed

toStarting

public boolean toStarting()
Changes to the starting state.

Returns:
true if the transition is allowed

toActive

public boolean toActive()
Changes to the active state.

Returns:
true if the transition is allowed

toError

public boolean toError()
Changes to the error state.

Returns:
true if the transition is allowed

toFail

public boolean toFail()
Changes to the failed state.

Returns:
true if the transition is allowed

toStopping

public boolean toStopping()
Changes to the stopping state.

Returns:
true if the transition is allowed

toIdle

public boolean toIdle()
Changes to the idle (stopped) state.

Returns:
true if the transition is allowed

toStop

public boolean toStop()
Changes to the stopped state.

Returns:
true if the transition is allowed

toDestroying

public boolean toDestroying()
Changes to the destroying state.

Returns:
true if the transition is allowed

toDestroy

public boolean toDestroy()
Changes to the closed state.

Returns:
true if the transition is allowed

addListener

public void addListener(LifecycleListener listener)
Adds a listener to detect lifecycle changes.


removeListener

public void removeListener(LifecycleListener listener)
Removes a listener.


copyState

public void copyState(Lifecycle source)
Copies from a target state.


toString

public java.lang.String toString()
Debug string value.

Overrides:
toString in class java.lang.Object