Package org.jboss.msc.service
Class DelegatingServiceController<S>
- java.lang.Object
-
- org.jboss.msc.service.DelegatingServiceController<S>
-
- All Implemented Interfaces:
ServiceController<S>,Value<S>
public class DelegatingServiceController<S> extends Object implements ServiceController<S>
A service controller which delegates to another service controller.- Author:
- Richard Opalka
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.msc.service.ServiceController
ServiceController.Mode, ServiceController.State
-
-
Constructor Summary
Constructors Constructor Description DelegatingServiceController(ServiceController<S> delegate)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddListener(LifecycleListener listener)Add a service lifecycle listener.SawaitValue()Deprecated.SawaitValue(long time, TimeUnit unit)Deprecated.booleancompareAndSetMode(ServiceController.Mode expected, ServiceController.Mode newMode)Compare the current mode againstexpected; if it matches, change it tonewMode.ServiceName[]getAliases()Deprecated.protected ServiceController<S>getDelegate()Get the ServiceController delegate.ServiceController.ModegetMode()Get the service controller's current mode.ServiceNamegetName()Deprecated.ServiceController<?>getParent()Get this service's parent service, ornullif there is none.Service<S>getService()Get the service.ServiceContainergetServiceContainer()Get the service container associated with this controller.StartExceptiongetStartException()Get the reason why the last start failed.ServiceController.StategetState()Get the current service controller state.Collection<ServiceName>getUnavailableDependencies()Deprecated.SgetValue()Deprecated.Set<ServiceName>missing()Get the names of all missing values this service require.Set<ServiceName>provides()Get the names of all values this service provide.voidremoveListener(LifecycleListener listener)Remove a lifecycle listener.Set<ServiceName>requires()Get the names of all values this service require.voidretry()Retry a failed service.voidsetMode(ServiceController.Mode mode)Change the service controller's current mode.
-
-
-
Constructor Detail
-
DelegatingServiceController
public DelegatingServiceController(ServiceController<S> delegate)
Construct a new instance.- Parameters:
delegate- the controller to delegate to
-
-
Method Detail
-
getDelegate
protected ServiceController<S> getDelegate()
Get the ServiceController delegate.- Returns:
- ServiceController delegate
-
getParent
public ServiceController<?> getParent()
Get this service's parent service, ornullif there is none.- Specified by:
getParentin interfaceServiceController<S>- Returns:
- the parent service or
nullif this service has no parent
-
getServiceContainer
public ServiceContainer getServiceContainer()
Get the service container associated with this controller.- Specified by:
getServiceContainerin interfaceServiceController<S>- Returns:
- the container
-
getMode
public ServiceController.Mode getMode()
Get the service controller's current mode.- Specified by:
getModein interfaceServiceController<S>- Returns:
- the controller mode
-
compareAndSetMode
public boolean compareAndSetMode(ServiceController.Mode expected, ServiceController.Mode newMode)
Compare the current mode againstexpected; if it matches, change it tonewMode. The return value istruewhen the mode was matched and changed.- Specified by:
compareAndSetModein interfaceServiceController<S>- Parameters:
expected- the expected modenewMode- the new mode- Returns:
trueif the mode was changed
-
setMode
public void setMode(ServiceController.Mode mode)
Change the service controller's current mode. Might result in the service starting or stopping. The mode may only be changed if it was not already set toServiceController.Mode.REMOVE. Calling this method with the controller's current mode has no effect and is always allowed.- Specified by:
setModein interfaceServiceController<S>- Parameters:
mode- the new controller mode
-
getState
public ServiceController.State getState()
Get the current service controller state.- Specified by:
getStatein interfaceServiceController<S>- Returns:
- the current state
-
getService
public Service<S> getService() throws IllegalStateException
Get the service.- Specified by:
getServicein interfaceServiceController<S>- Returns:
- the service
- Throws:
IllegalStateException- if the service is not available (i.e. it is not up)
-
requires
public Set<ServiceName> requires()
Get the names of all values this service require.- Specified by:
requiresin interfaceServiceController<S>- Returns:
- names of required values
-
provides
public Set<ServiceName> provides()
Get the names of all values this service provide.- Specified by:
providesin interfaceServiceController<S>- Returns:
- names of provided values
-
missing
public Set<ServiceName> missing()
Get the names of all missing values this service require.- Specified by:
missingin interfaceServiceController<S>- Returns:
- names of missing values
-
addListener
public void addListener(LifecycleListener listener)
Add a service lifecycle listener.- Specified by:
addListenerin interfaceServiceController<S>- Parameters:
listener- the lifecycle listener
-
removeListener
public void removeListener(LifecycleListener listener)
Remove a lifecycle listener.- Specified by:
removeListenerin interfaceServiceController<S>- Parameters:
listener- the lifecycle listener to remove
-
getStartException
public StartException getStartException()
Get the reason why the last start failed.- Specified by:
getStartExceptionin interfaceServiceController<S>- Returns:
- the last start exception, or
nullif the last start succeeded or the service has not yet started
-
retry
public void retry()
Retry a failed service. Does nothing if the state is notServiceController.State.START_FAILED.- Specified by:
retryin interfaceServiceController<S>
-
awaitValue
@Deprecated public S awaitValue() throws IllegalStateException, InterruptedException
Deprecated.Wait for a service to come up, and then return its value.- Specified by:
awaitValuein interfaceServiceController<S>- Returns:
- the service value
- Throws:
IllegalStateException- if the service is not available (i.e. it was removed or failed)InterruptedException- if the wait operation was interrupted
-
awaitValue
@Deprecated public S awaitValue(long time, TimeUnit unit) throws IllegalStateException, InterruptedException, TimeoutException
Deprecated.Wait for a service to come up for a certain amount of time, and then return its value.- Specified by:
awaitValuein interfaceServiceController<S>- Parameters:
time- the amount of time to waitunit- the unit of time to wait- Returns:
- the service value
- Throws:
IllegalStateException- if the service is not available (i.e. it was removed or failed)InterruptedException- if the wait operation was interruptedTimeoutException
-
getAliases
@Deprecated public ServiceName[] getAliases()
Deprecated.Get other names this service is known as.- Specified by:
getAliasesin interfaceServiceController<S>- Returns:
- the aliases
- See Also:
ServiceController.provides()
-
getName
@Deprecated public ServiceName getName()
Deprecated.Get the name of this service, if any.- Specified by:
getNamein interfaceServiceController<S>- Returns:
- the name, or
nullif none was specified. - See Also:
ServiceController.provides()
-
getValue
@Deprecated public S getValue() throws IllegalStateException
Deprecated.Get the service value.- Specified by:
getValuein interfaceServiceController<S>- Specified by:
getValuein interfaceValue<S>- Returns:
- the service value
- Throws:
IllegalStateException- if the service is not available (i.e. it is not up)
-
getUnavailableDependencies
@Deprecated public Collection<ServiceName> getUnavailableDependencies()
Deprecated.Get the complete list of dependencies that are unavailable.- Specified by:
getUnavailableDependenciesin interfaceServiceController<S>- Returns:
- a set containing the names of all unavailable dependencies
-
-