public class DelegatingServiceContainer extends Object implements ServiceContainer
ServiceContainer.Factory, ServiceContainer.TerminateListener
Constructor and Description |
---|
DelegatingServiceContainer(ServiceTarget serviceTargetDelegate,
ServiceRegistry serviceRegistryDelegate)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
ServiceContainer |
addDependency(Collection<ServiceName> dependencies)
Deprecated.
|
ServiceContainer |
addDependency(ServiceName... dependencies)
Deprecated.
|
ServiceContainer |
addDependency(ServiceName dependency)
Deprecated.
|
ServiceContainer |
addListener(Collection<ServiceListener<Object>> listeners)
Deprecated.
|
ServiceContainer |
addListener(LifecycleListener listener)
Add a service lifecycle listener that will be added to this service.
|
ServiceContainer |
addListener(ServiceListener<Object>... listeners)
Deprecated.
|
ServiceContainer |
addListener(ServiceListener<Object> listener)
Deprecated.
|
ServiceTarget |
addMonitor(StabilityMonitor monitor)
Deprecated.
|
ServiceTarget |
addMonitors(StabilityMonitor... monitors)
Deprecated.
|
ServiceBuilder<?> |
addService(ServiceName name)
Get a builder which can be used to add a service to this target.
|
<T> ServiceBuilder<T> |
addService(ServiceName name,
Service<T> service)
Deprecated.
|
<T> ServiceBuilder<T> |
addServiceValue(ServiceName name,
Value<? extends Service<T>> value)
Deprecated.
|
void |
addTerminateListener(ServiceContainer.TerminateListener listener)
Add a terminate listener to this container.
|
void |
awaitStability()
Causes the current thread to wait until the container is stable.
|
boolean |
awaitStability(long timeout,
TimeUnit unit)
Causes the current thread to wait until the container is stable.
|
boolean |
awaitStability(long timeout,
TimeUnit unit,
Set<? super ServiceController<?>> failed,
Set<? super ServiceController<?>> problem)
Causes the current thread to wait until the container is stable.
|
void |
awaitStability(Set<? super ServiceController<?>> failed,
Set<? super ServiceController<?>> problem)
Causes the current thread to wait until the container is stable.
|
void |
awaitTermination()
Causes the current thread to wait until the container is shutdown.
|
void |
awaitTermination(long timeout,
TimeUnit unit)
Causes the current thread to wait until the container is shutdown.
|
BatchServiceTarget |
batchTarget()
Deprecated.
|
void |
dumpServices()
Dump a complete list of services to
System.out . |
void |
dumpServices(PrintStream stream)
Dump a complete list of services to the given stream.
|
Set<ServiceName> |
getDependencies()
Deprecated.
|
Set<ServiceListener<Object>> |
getListeners()
Deprecated.
|
Set<StabilityMonitor> |
getMonitors()
Deprecated.
|
String |
getName()
Get the name of this service container.
|
ServiceController<?> |
getRequiredService(ServiceName serviceName)
Get a service, throwing an exception if it is not found.
|
ServiceController<?> |
getService(ServiceName serviceName)
Get a service, returning
null if it is not found. |
List<ServiceName> |
getServiceNames()
Get a list of service names installed in this registry.
|
protected ServiceRegistry |
getServiceRegistryDelegate()
Get the ServiceRegistry delegate.
|
protected ServiceTarget |
getServiceTargetDelegate()
Get the ServiceTarget delegate.
|
boolean |
isShutdown()
Whether container have been shut down.
|
boolean |
isShutdownComplete()
Determine whether the container is completely shut down.
|
ServiceContainer |
removeDependency(ServiceName dependency)
Deprecated.
|
ServiceContainer |
removeListener(LifecycleListener listener)
Remove a lifecycle listener from this target, if it exists.
|
ServiceContainer |
removeListener(ServiceListener<Object> listener)
Deprecated.
|
ServiceTarget |
removeMonitor(StabilityMonitor monitor)
Deprecated.
|
void |
shutdown()
Stop all services within this container.
|
ServiceTarget |
subTarget()
Create a sub-target using this as the parent target.
|
public DelegatingServiceContainer(ServiceTarget serviceTargetDelegate, ServiceRegistry serviceRegistryDelegate)
serviceTargetDelegate
- the delegate to forward service target requests toserviceRegistryDelegate
- the delegate to forward registry requests toprotected ServiceTarget getServiceTargetDelegate()
protected ServiceRegistry getServiceRegistryDelegate()
public ServiceBuilder<?> addService(ServiceName name) throws IllegalArgumentException
addService
in interface ServiceTarget
name
- the service nameIllegalArgumentException
public ServiceContainer addListener(LifecycleListener listener)
addListener
in interface ServiceTarget
listener
- the lifecycle listener to add to the servicepublic ServiceContainer removeListener(LifecycleListener listener)
removeListener
in interface ServiceTarget
listener
- the lifecycle listener to removepublic ServiceTarget subTarget()
subTarget
in interface ServiceTarget
public ServiceController<?> getRequiredService(ServiceName serviceName) throws ServiceNotFoundException
getRequiredService
in interface ServiceRegistry
serviceName
- the service nameServiceNotFoundException
- if the service is not present in the registrypublic ServiceController<?> getService(ServiceName serviceName)
null
if it is not found.getService
in interface ServiceRegistry
serviceName
- the service namenull
if it is not foundpublic List<ServiceName> getServiceNames()
getServiceNames
in interface ServiceRegistry
public String getName()
getName
in interface ServiceContainer
public void shutdown()
shutdown
in interface ServiceContainer
public boolean isShutdown()
isShutdown
in interface ServiceContainer
true
if container is shutting downpublic boolean isShutdownComplete()
isShutdownComplete
in interface ServiceContainer
true
if shutdown is completepublic void dumpServices()
System.out
.dumpServices
in interface ServiceContainer
public void dumpServices(PrintStream stream)
dumpServices
in interface ServiceContainer
stream
- the stream to which the service list should be writtenpublic void addTerminateListener(ServiceContainer.TerminateListener listener)
listener
will be invoked when this container shutdown process is complete.addTerminateListener
in interface ServiceContainer
listener
- the listenerpublic void awaitTermination()
awaitTermination
in interface ServiceContainer
public void awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
awaitTermination
in interface ServiceContainer
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumentInterruptedException
- if the current thread is interrupted
while waitingpublic void awaitStability() throws InterruptedException
awaitStability
in interface ServiceContainer
InterruptedException
- if the current thread is interrupted
while waitingpublic boolean awaitStability(long timeout, TimeUnit unit) throws InterruptedException
awaitStability
in interface ServiceContainer
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumentInterruptedException
- if the current thread is interrupted
while waitingpublic void awaitStability(Set<? super ServiceController<?>> failed, Set<? super ServiceController<?>> problem) throws InterruptedException
awaitStability
in interface ServiceContainer
failed
- a set into which failed services should be copiedproblem
- a set into which problem services should be copiedInterruptedException
- if the current thread is interrupted
while waitingpublic boolean awaitStability(long timeout, TimeUnit unit, Set<? super ServiceController<?>> failed, Set<? super ServiceController<?>> problem) throws InterruptedException
awaitStability
in interface ServiceContainer
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumentfailed
- a set into which failed services should be copiedproblem
- a set into which problem services should be copiedInterruptedException
- if the current thread is interrupted
while waiting@Deprecated public <T> ServiceBuilder<T> addServiceValue(ServiceName name, Value<? extends Service<T>> value) throws IllegalArgumentException
addServiceValue
in interface ServiceTarget
name
- the service namevalue
- the service valueIllegalArgumentException
@Deprecated public <T> ServiceBuilder<T> addService(ServiceName name, Service<T> service) throws IllegalArgumentException
addService
in interface ServiceTarget
name
- the service nameservice
- the serviceIllegalArgumentException
@Deprecated public ServiceContainer addListener(ServiceListener<Object> listener)
addListener
in interface ServiceTarget
listener
- the listener to add to the target@Deprecated public ServiceContainer addListener(ServiceListener<Object>... listeners)
addListener
in interface ServiceTarget
listeners
- a list of listeners to add to the target@Deprecated public ServiceContainer addListener(Collection<ServiceListener<Object>> listeners)
addListener
in interface ServiceTarget
listeners
- a collection of listeners to add to the target@Deprecated public ServiceContainer removeListener(ServiceListener<Object> listener)
removeListener
in interface ServiceTarget
listener
- the listener to remove@Deprecated public Set<ServiceListener<Object>> getListeners()
getListeners
in interface ServiceTarget
@Deprecated public ServiceTarget addMonitor(StabilityMonitor monitor)
addMonitor
in interface ServiceTarget
monitor
- the monitor to add to the target@Deprecated public ServiceTarget addMonitors(StabilityMonitor... monitors)
addMonitors
in interface ServiceTarget
monitors
- the monitors to add to the target@Deprecated public ServiceTarget removeMonitor(StabilityMonitor monitor)
removeMonitor
in interface ServiceTarget
monitor
- the monitor to remove@Deprecated public Set<StabilityMonitor> getMonitors()
getMonitors
in interface ServiceTarget
@Deprecated public ServiceContainer addDependency(ServiceName dependency)
addDependency
in interface ServiceTarget
dependency
- the dependency to add to the target@Deprecated public ServiceContainer addDependency(ServiceName... dependencies)
addDependency
in interface ServiceTarget
dependencies
- a list of dependencies to add to the target@Deprecated public ServiceContainer addDependency(Collection<ServiceName> dependencies)
addDependency
in interface ServiceTarget
dependencies
- a collection of dependencies to add to this target@Deprecated public ServiceContainer removeDependency(ServiceName dependency)
removeDependency
in interface ServiceTarget
dependency
- the dependency@Deprecated public Set<ServiceName> getDependencies()
getDependencies
in interface ServiceTarget
@Deprecated public BatchServiceTarget batchTarget()
batchTarget
in interface ServiceTarget
Copyright © 2021 JBoss by Red Hat. All rights reserved.