com.twitter.common.application
Class ShutdownRegistry.ShutdownRegistryImpl

java.lang.Object
  extended by com.twitter.common.application.ShutdownRegistry.ShutdownRegistryImpl
All Implemented Interfaces:
ShutdownRegistry, Command, ExceptionalCommand<RuntimeException>
Enclosing interface:
ShutdownRegistry

public static class ShutdownRegistry.ShutdownRegistryImpl
extends Object
implements ShutdownRegistry, Command

Implementation of a shutdown registry.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.twitter.common.application.ShutdownRegistry
ShutdownRegistry.ShutdownRegistryImpl
 
Constructor Summary
ShutdownRegistry.ShutdownRegistryImpl()
           
 
Method Summary
<E extends Exception,T extends ExceptionalCommand<E>>
void
addAction(T action)
          Registers an action to execute during execute().
 void execute()
          Executes an application shutdown stage by executing all registered actions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShutdownRegistry.ShutdownRegistryImpl

public ShutdownRegistry.ShutdownRegistryImpl()
Method Detail

addAction

public <E extends Exception,T extends ExceptionalCommand<E>> void addAction(T action)
Registers an action to execute during execute(). It is an error to call this method after calling execute().

Specified by:
addAction in interface ShutdownRegistry
Type Parameters:
E - Exception type thrown by the action.
T - Type of command.
Parameters:
action - the action to add to the list of actions to execute during execution

execute

public void execute()
Executes an application shutdown stage by executing all registered actions. This method can be called multiple times but will only execute the registered actions the first time. This sends output to System.out because logging is unreliable during JVM shutdown, which this class may be used for.

Specified by:
execute in interface ExceptionalCommand<RuntimeException>