com.twitter.common.application.modules
Class LifecycleModule

java.lang.Object
  extended by com.google.inject.AbstractModule
      extended by com.twitter.common.application.modules.LifecycleModule
All Implemented Interfaces:
Module

public class LifecycleModule
extends AbstractModule

Binding module for startup and shutdown controller and registries. Bindings provided by this module:

If you would like to register a startup action that starts a local network service, please consider using LocalServiceRegistry.


Nested Class Summary
static class LifecycleModule.LaunchException
          Thrown when a local service fails to launch.
static interface LifecycleModule.ServiceRunner
          Responsible for starting and stopping a local service.
 
Constructor Summary
LifecycleModule()
           
 
Method Summary
static void bindLocalService(Binder binder, LocalServiceRegistry.LocalService service)
          Binds a local service instance, without attaching an explicit lifecycle.
static void bindServiceRunner(Binder binder, Class<? extends LifecycleModule.ServiceRunner> launcher)
          Binds a service runner that will start and stop a local service.
static void bindStartupAction(Binder binder, Class<? extends ExceptionalCommand> actionClass)
          Adds a startup action to the startup registry binding.
protected  void configure()
           
 
Methods inherited from class com.google.inject.AbstractModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindScope, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LifecycleModule

public LifecycleModule()
Method Detail

configure

protected void configure()
Specified by:
configure in class AbstractModule

bindServiceRunner

public static void bindServiceRunner(Binder binder,
                                     Class<? extends LifecycleModule.ServiceRunner> launcher)
Binds a service runner that will start and stop a local service.

Parameters:
binder - Binder to bind against.
launcher - Launcher class for a service.

bindLocalService

public static void bindLocalService(Binder binder,
                                    LocalServiceRegistry.LocalService service)
Binds a local service instance, without attaching an explicit lifecycle.

Parameters:
binder - Binder to bind against.
service - Local service instance to bind.

bindStartupAction

public static void bindStartupAction(Binder binder,
                                     Class<? extends ExceptionalCommand> actionClass)
Adds a startup action to the startup registry binding.

Parameters:
binder - Binder to bind against.
actionClass - Class to bind (and instantiate via guice) for execution at startup.