com.caucho.lifecycle
Class Lifecycle

java.lang.Object
  extended by com.caucho.lifecycle.Lifecycle
All Implemented Interfaces:
LifecycleState

public final class Lifecycle
extends java.lang.Object
implements LifecycleState

Lifecycle class.


Field Summary
 
Fields inherited from interface com.caucho.lifecycle.LifecycleState
IS_ACTIVE, IS_DESTROYED, IS_DESTROYING, IS_FAILED, IS_INIT, IS_INITIALIZING, IS_NEW, IS_STANDBY, IS_STARTING, IS_STOPPED, IS_STOPPING, IS_WARMUP
 
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.
 int getState()
          Returns the current state.
 java.lang.String getStateName()
          Returns the current state name.
static java.lang.String getStateName(int state)
          Returns the state name for the passed state.
 boolean isActive()
          Returns true for the active state.
 boolean isAfterActive()
          Returns true for the closing states
 boolean isAfterInit()
          Returns true for the init state.
 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 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 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.


addListener

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


removeListener

public void removeListener(LifecycleListener listener)
Removes a listener.


getState

public int getState()
Returns the current state.

Specified by:
getState in interface LifecycleState

getStateName

public static java.lang.String getStateName(int state)
Returns the state name for the passed state.


getStateName

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

Specified by:
getStateName in interface LifecycleState

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.

Specified by:
isInitializing in interface LifecycleState

isInit

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

Specified by:
isInit in interface LifecycleState

isBeforeInit

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

Specified by:
isBeforeInit in interface LifecycleState

isAfterInit

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

Specified by:
isAfterInit in interface LifecycleState

isStarting

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

Specified by:
isStarting in interface LifecycleState

isWarmup

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

Specified by:
isWarmup in interface LifecycleState

isBeforeActive

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

Specified by:
isBeforeActive in interface LifecycleState

isAfterActive

public boolean isAfterActive()
Returns true for the closing states

Specified by:
isAfterActive in interface LifecycleState

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.

Specified by:
isActive in interface LifecycleState

isRunnable

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


isError

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

Specified by:
isError in interface LifecycleState

isFailed

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


isStopping

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

Specified by:
isStopping in interface LifecycleState

isStopped

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

Specified by:
isStopped in interface LifecycleState

isDestroying

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

Specified by:
isDestroying in interface LifecycleState

isDestroyed

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

Specified by:
isDestroyed in interface LifecycleState

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

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

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