Package org.jboss.msc.service
Class DelegatingServiceContainer
java.lang.Object
org.jboss.msc.service.DelegatingServiceContainer
- All Implemented Interfaces:
ServiceContainer,ServiceRegistry,ServiceTarget
A delegating container for things which depend on a service container rather than a specific
target or registry instance.
- Author:
- David M. Lloyd, Richard Opalka
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jboss.msc.service.ServiceContainer
ServiceContainer.Factory, ServiceContainer.TerminateListener -
Constructor Summary
ConstructorsConstructorDescriptionDelegatingServiceContainer(ServiceTarget serviceTargetDelegate, ServiceRegistry serviceRegistryDelegate) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionaddDependency(ServiceName dependency) Deprecated.addListener(LifecycleListener listener) Add a service lifecycle listener that will be added to this service.addMonitor(StabilityMonitor monitor) Deprecated.Get a builder which can be used to add a service to this target.addService(ServiceName name) Deprecated.<T> ServiceBuilder<T>addService(ServiceName name, Service<T> service) Deprecated.voidAdd a terminate listener to this container.voidCauses the current thread to wait until the container is stable.booleanawaitStability(long timeout, TimeUnit unit) Causes the current thread to wait until the container is stable.booleanawaitStability(long timeout, TimeUnit unit, Set<? super ServiceController<?>> failed, Set<? super ServiceController<?>> problem) Causes the current thread to wait until the container is stable.voidawaitStability(Set<? super ServiceController<?>> failed, Set<? super ServiceController<?>> problem) Causes the current thread to wait until the container is stable.voidCauses the current thread to wait until the container is shutdown.voidawaitTermination(long timeout, TimeUnit unit) Causes the current thread to wait until the container is shutdown.voidDump a complete list of services toSystem.out.voiddumpServices(PrintStream stream) Dump a complete list of services to the given stream.getName()Get the name of this service container.getRequiredService(ServiceName serviceName) Get a service, throwing an exception if it is not found.getService(ServiceName serviceName) Get a service, returningnullif it is not found.Get a list of service names installed in this registry.protected ServiceRegistryGet the ServiceRegistry delegate.protected ServiceTargetGet the ServiceTarget delegate.booleanWhether container have been shut down.booleanDetermine whether the container is completely shut down.removeListener(LifecycleListener listener) Remove a lifecycle listener from this target, if it exists.removeMonitor(StabilityMonitor monitor) Deprecated.voidshutdown()Stop all services within this container.Create a sub-target using this as the parent target.
-
Constructor Details
-
DelegatingServiceContainer
public DelegatingServiceContainer(ServiceTarget serviceTargetDelegate, ServiceRegistry serviceRegistryDelegate) Construct a new instance.- Parameters:
serviceTargetDelegate- the delegate to forward service target requests toserviceRegistryDelegate- the delegate to forward registry requests to
-
-
Method Details
-
getServiceTargetDelegate
Get the ServiceTarget delegate.- Returns:
- ServiceTarget delegate
-
getServiceRegistryDelegate
Get the ServiceRegistry delegate.- Returns:
- ServiceRegistry delegate
-
addService
Get a builder which can be used to add a service to this target.- Specified by:
addServicein interfaceServiceTarget- Returns:
- new service configurator
-
addListener
Add a service lifecycle listener that will be added to this service.- Specified by:
addListenerin interfaceServiceTarget- Parameters:
listener- the lifecycle listener to add to the service- Returns:
- this target
-
removeListener
Remove a lifecycle listener from this target, if it exists.- Specified by:
removeListenerin interfaceServiceTarget- Parameters:
listener- the lifecycle listener to remove- Returns:
- this target
-
subTarget
Create a sub-target using this as the parent target.- Specified by:
subTargetin interfaceServiceTarget- Returns:
- the new service target
-
getRequiredService
public ServiceController<?> getRequiredService(ServiceName serviceName) throws ServiceNotFoundException Get a service, throwing an exception if it is not found.- Specified by:
getRequiredServicein interfaceServiceRegistry- Parameters:
serviceName- the service name- Returns:
- the service controller for the corresponding service
- Throws:
ServiceNotFoundException- if the service is not present in the registry
-
getService
Get a service, returningnullif it is not found.- Specified by:
getServicein interfaceServiceRegistry- Parameters:
serviceName- the service name- Returns:
- the service controller for the corresponding service, or
nullif it is not found
-
getServiceNames
Get a list of service names installed in this registry.- Specified by:
getServiceNamesin interfaceServiceRegistry- Returns:
- the list
-
getName
Get the name of this service container.- Specified by:
getNamein interfaceServiceContainer- Returns:
- the container name
-
shutdown
public void shutdown()Stop all services within this container.- Specified by:
shutdownin interfaceServiceContainer
-
isShutdown
public boolean isShutdown()Whether container have been shut down.- Specified by:
isShutdownin interfaceServiceContainer- Returns:
trueif container is shutting down
-
isShutdownComplete
public boolean isShutdownComplete()Determine whether the container is completely shut down.- Specified by:
isShutdownCompletein interfaceServiceContainer- Returns:
trueif shutdown is complete
-
dumpServices
public void dumpServices()Dump a complete list of services toSystem.out.- Specified by:
dumpServicesin interfaceServiceContainer
-
dumpServices
Dump a complete list of services to the given stream.- Specified by:
dumpServicesin interfaceServiceContainer- Parameters:
stream- the stream to which the service list should be written
-
addTerminateListener
Add a terminate listener to this container. The addedlistenerwill be invoked when this container shutdown process is complete.- Specified by:
addTerminateListenerin interfaceServiceContainer- Parameters:
listener- the listener
-
awaitTermination
public void awaitTermination()Causes the current thread to wait until the container is shutdown.- Specified by:
awaitTerminationin interfaceServiceContainer
-
awaitTermination
Causes the current thread to wait until the container is shutdown.- Specified by:
awaitTerminationin interfaceServiceContainer- Parameters:
timeout- the maximum time to waitunit- the time unit of thetimeoutargument- Throws:
InterruptedException- if the current thread is interrupted while waiting
-
awaitStability
Causes the current thread to wait until the container is stable.- Specified by:
awaitStabilityin interfaceServiceContainer- Throws:
InterruptedException- if the current thread is interrupted while waiting
-
awaitStability
Causes the current thread to wait until the container is stable.- Specified by:
awaitStabilityin interfaceServiceContainer- Parameters:
timeout- the maximum time to waitunit- the time unit of thetimeoutargument- Returns:
- true if this container achieved stability, false if the timeout elapsed before stability
- Throws:
InterruptedException- if the current thread is interrupted while waiting
-
awaitStability
public void awaitStability(Set<? super ServiceController<?>> failed, Set<? super ServiceController<?>> problem) throws InterruptedException Causes the current thread to wait until the container is stable.- Specified by:
awaitStabilityin interfaceServiceContainer- Parameters:
failed- a set into which failed services should be copiedproblem- a set into which problem services should be copied- Throws:
InterruptedException- if the current thread is interrupted while waiting
-
awaitStability
public boolean awaitStability(long timeout, TimeUnit unit, Set<? super ServiceController<?>> failed, Set<? super ServiceController<?>> problem) throws InterruptedException Causes the current thread to wait until the container is stable.- Specified by:
awaitStabilityin interfaceServiceContainer- Parameters:
timeout- the maximum time to waitunit- the time unit of thetimeoutargumentfailed- a set into which failed services should be copiedproblem- a set into which problem services should be copied- Returns:
- true if this container achieved stability, false if the timeout elapsed before stability
- Throws:
InterruptedException- if the current thread is interrupted while waiting
-
addService
Deprecated.Get a builder which can be used to add a service to this target.- Specified by:
addServicein interfaceServiceTarget- Parameters:
name- the service name- Returns:
- new service configurator
-
addService
Deprecated.Get a builder which can be used to add a service to this target.- Specified by:
addServicein interfaceServiceTarget- Parameters:
name- the service nameservice- the service- Returns:
- the builder for the service
-
addMonitor
Deprecated.Add a stability monitor that will be added to all the ServiceBuilders installed in this target.- Specified by:
addMonitorin interfaceServiceTarget- Parameters:
monitor- the monitor to add to the target- Returns:
- this target
-
removeMonitor
Deprecated.Remove a monitor from this target, if it exists.- Specified by:
removeMonitorin interfaceServiceTarget- Parameters:
monitor- the monitor to remove- Returns:
- this target
-
addDependency
Deprecated.Add a dependency that will be added to the all ServiceBuilders installed in this target.- Specified by:
addDependencyin interfaceServiceTarget- Parameters:
dependency- the dependency to add to the target- Returns:
- this target
-