com.twitter.common.application.modules
Class LocalServiceRegistry

java.lang.Object
  extended by com.twitter.common.application.modules.LocalServiceRegistry

public class LocalServiceRegistry
extends Object

Registry for services that should be exported from the application. Example of announcing and registering a port:

 class MyLauncher implements Provider {
   public LocalService get() {
     // Launch service.
   }
 }

 class MyServiceModule extends AbstractModule {
   public void configure() {
     LifeCycleModule.bindServiceLauncher(binder(), MyLauncher.class);
   }
 }
 


Nested Class Summary
static class LocalServiceRegistry.LocalService
          An individual local service.
 
Constructor Summary
LocalServiceRegistry(Provider<Set<LifecycleModule.ServiceRunner>> runnerProvider, ShutdownRegistry shutdownRegistry)
          Creates a new local service registry.
 
Method Summary
 Map<String,InetSocketAddress> getAuxiliarySockets()
          Gets the mapping from auxiliary port name to socket.
 Optional<InetSocketAddress> getPrimarySocket()
          Gets the optional primary socket address, and returns an unresolved local socket address representing that port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalServiceRegistry

@Inject
public LocalServiceRegistry(Provider<Set<LifecycleModule.ServiceRunner>> runnerProvider,
                                   ShutdownRegistry shutdownRegistry)
Creates a new local service registry.

Parameters:
runnerProvider - provider of registered local services.
shutdownRegistry - Shutdown registry to tear down launched services.
Method Detail

getAuxiliarySockets

public Map<String,InetSocketAddress> getAuxiliarySockets()
Gets the mapping from auxiliary port name to socket.

Returns:
Auxiliary port mapping.

getPrimarySocket

public Optional<InetSocketAddress> getPrimarySocket()
Gets the optional primary socket address, and returns an unresolved local socket address representing that port.

Returns:
Local socket address for the primary port.
Throws:
IllegalStateException - If the primary port was not set.