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 void
addListener(LifecycleListener listener)
Add a service lifecycle listener.S
awaitValue()
Deprecated.S
awaitValue(long time, TimeUnit unit)
Deprecated.boolean
compareAndSetMode(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.Mode
getMode()
Get the service controller's current mode.ServiceName
getName()
Deprecated.ServiceController<?>
getParent()
Get this service's parent service, ornull
if there is none.Service<S>
getService()
Get the service.ServiceContainer
getServiceContainer()
Get the service container associated with this controller.StartException
getStartException()
Get the reason why the last start failed.ServiceController.State
getState()
Get the current service controller state.Collection<ServiceName>
getUnavailableDependencies()
Deprecated.S
getValue()
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.void
removeListener(LifecycleListener listener)
Remove a lifecycle listener.Set<ServiceName>
requires()
Get the names of all values this service require.void
retry()
Retry a failed service.void
setMode(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, ornull
if there is none.- Specified by:
getParent
in interfaceServiceController<S>
- Returns:
- the parent service or
null
if this service has no parent
-
getServiceContainer
public ServiceContainer getServiceContainer()
Get the service container associated with this controller.- Specified by:
getServiceContainer
in interfaceServiceController<S>
- Returns:
- the container
-
getMode
public ServiceController.Mode getMode()
Get the service controller's current mode.- Specified by:
getMode
in 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 istrue
when the mode was matched and changed.- Specified by:
compareAndSetMode
in interfaceServiceController<S>
- Parameters:
expected
- the expected modenewMode
- the new mode- Returns:
true
if 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:
setMode
in interfaceServiceController<S>
- Parameters:
mode
- the new controller mode
-
getState
public ServiceController.State getState()
Get the current service controller state.- Specified by:
getState
in interfaceServiceController<S>
- Returns:
- the current state
-
getService
public Service<S> getService() throws IllegalStateException
Get the service.- Specified by:
getService
in 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:
requires
in interfaceServiceController<S>
- Returns:
- names of required values
-
provides
public Set<ServiceName> provides()
Get the names of all values this service provide.- Specified by:
provides
in interfaceServiceController<S>
- Returns:
- names of provided values
-
missing
public Set<ServiceName> missing()
Get the names of all missing values this service require.- Specified by:
missing
in interfaceServiceController<S>
- Returns:
- names of missing values
-
addListener
public void addListener(LifecycleListener listener)
Add a service lifecycle listener.- Specified by:
addListener
in interfaceServiceController<S>
- Parameters:
listener
- the lifecycle listener
-
removeListener
public void removeListener(LifecycleListener listener)
Remove a lifecycle listener.- Specified by:
removeListener
in interfaceServiceController<S>
- Parameters:
listener
- the lifecycle listener to remove
-
getStartException
public StartException getStartException()
Get the reason why the last start failed.- Specified by:
getStartException
in interfaceServiceController<S>
- Returns:
- the last start exception, or
null
if 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:
retry
in 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:
awaitValue
in 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:
awaitValue
in 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:
getAliases
in 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:
getName
in interfaceServiceController<S>
- Returns:
- the name, or
null
if none was specified. - See Also:
ServiceController.provides()
-
getValue
@Deprecated public S getValue() throws IllegalStateException
Deprecated.Get the service value.- Specified by:
getValue
in interfaceServiceController<S>
- Specified by:
getValue
in 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:
getUnavailableDependencies
in interfaceServiceController<S>
- Returns:
- a set containing the names of all unavailable dependencies
-
-