com.twitter.common.application
Class Lifecycle

java.lang.Object
  extended by com.twitter.common.application.Lifecycle

public class Lifecycle
extends Object

Application lifecycle manager, which coordinates orderly shutdown of an application. This class is responsible for executing shutdown commands, and can also be used to allow threads to await application shutdown.


Constructor Summary
Lifecycle(Command shutdownRegistry, Thread.UncaughtExceptionHandler exceptionHandler)
           
 
Method Summary
 void awaitShutdown()
          Allows a caller to wait forever; typically used when all work is done in daemon threads.
 boolean isAlive()
          Checks whether this lifecycle is still considered alive.
 void shutdown()
          Initiates an orderly shutdown of the lifecycle's registered shutdown hooks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lifecycle

@Inject
public Lifecycle(Command shutdownRegistry,
                        Thread.UncaughtExceptionHandler exceptionHandler)
Method Detail

isAlive

public final boolean isAlive()
Checks whether this lifecycle is still considered alive. The lifecycle is still alive until shutdown() has been called and all of the actions registered with the shutdown controller have completed.

Returns:
true if the lifecycle is alive, false otherwise.

awaitShutdown

public final void awaitShutdown()
Allows a caller to wait forever; typically used when all work is done in daemon threads. Will exit on interrupts.


shutdown

public final void shutdown()
Initiates an orderly shutdown of the lifecycle's registered shutdown hooks.