Package org.jboss.msc.service
Interface ServiceController<S>
-
- Type Parameters:
S- the service type
- All Superinterfaces:
Value<S>
- All Known Implementing Classes:
DelegatingServiceController
public interface ServiceController<S> extends Value<S>
A controller for a single service instance.- Author:
- David M. Lloyd, Richard Opalka
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classServiceController.ModeThe controller mode for a service.static classServiceController.StateA possible state for a service controller.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidaddListener(LifecycleListener listener)Add a service lifecycle listener.SawaitValue()Deprecated.this method will be removed in a future releaseSawaitValue(long time, TimeUnit unit)Deprecated.this method will be removed in a future releasebooleancompareAndSetMode(ServiceController.Mode expected, ServiceController.Mode newMode)Compare the current mode againstexpected; if it matches, change it tonewMode.ServiceName[]getAliases()Get other names this service is known as.ServiceController.ModegetMode()Get the service controller's current mode.ServiceNamegetName()Get the name of this service, if any.ServiceController<?>getParent()Get this service's parent service, ornullif there is none.Service<S>getService()Deprecated.this method will be removed in a future releaseServiceContainergetServiceContainer()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()Get the complete list of dependencies that are unavailable.SgetValue()Deprecated.this method will be removed in a future releasevoidremoveListener(LifecycleListener listener)Remove a lifecycle listener.voidretry()Retry a failed service.voidsetMode(ServiceController.Mode mode)Change the service controller's current mode.
-
-
-
Method Detail
-
getParent
ServiceController<?> getParent()
Get this service's parent service, ornullif there is none.- Returns:
- the parent service or
nullif this service has no parent
-
getServiceContainer
ServiceContainer getServiceContainer()
Get the service container associated with this controller.- Returns:
- the container
-
getMode
ServiceController.Mode getMode()
Get the service controller's current mode.- Returns:
- the controller mode
-
compareAndSetMode
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.- Parameters:
expected- the expected modenewMode- the new mode- Returns:
trueif the mode was changed
-
setMode
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.- Parameters:
mode- the new controller mode- Throws:
IllegalStateException- if the mode given isnull, or the caller attempted to change the service's mode fromServiceController.Mode.REMOVEto a different mode
-
getState
ServiceController.State getState()
Get the current service controller state.- Returns:
- the current state
-
getValue
@Deprecated S getValue() throws IllegalStateException
Deprecated.this method will be removed in a future releaseGet the service value.- Specified by:
getValuein interfaceValue<S>- Returns:
- the service value
- Throws:
IllegalStateException- if the service is not available (i.e. it is not up)
-
awaitValue
@Deprecated S awaitValue() throws IllegalStateException, InterruptedException
Deprecated.this method will be removed in a future releaseWait for a service to come up, and then return its value.- 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 S awaitValue(long time, TimeUnit unit) throws IllegalStateException, InterruptedException, TimeoutException
Deprecated.this method will be removed in a future releaseWait for a service to come up for a certain amount of time, and then return its value.- 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
-
getService
@Deprecated Service<S> getService() throws IllegalStateException
Deprecated.this method will be removed in a future releaseGet the service.- Returns:
- the service
- Throws:
IllegalStateException- if the service is not available (i.e. it is not up)
-
getName
ServiceName getName()
Get the name of this service, if any.- Returns:
- the name, or
nullif none was specified.
-
getAliases
ServiceName[] getAliases()
Get other names this service is known as.- Returns:
- the aliases
-
addListener
void addListener(LifecycleListener listener)
Add a service lifecycle listener.- Parameters:
listener- the lifecycle listener
-
removeListener
void removeListener(LifecycleListener listener)
Remove a lifecycle listener.- Parameters:
listener- the lifecycle listener to remove
-
getStartException
StartException getStartException()
Get the reason why the last start failed.- Returns:
- the last start exception, or
nullif the last start succeeded or the service has not yet started
-
retry
void retry()
Retry a failed service. Does nothing if the state is notServiceController.State.START_FAILED.
-
getUnavailableDependencies
Collection<ServiceName> getUnavailableDependencies()
Get the complete list of dependencies that are unavailable.- Returns:
- a set containing the names of all unavailable dependencies
-
-