private static final class ServiceManager.ServiceListener extends Service.Listener
Service that wraps another service and times how long it takes for it to start and
also calls the ServiceManagerState#transitionService(Service, State, State), to record
the state transitions.| Modifier and Type | Field and Description |
|---|---|
(package private) Service |
service |
(package private) java.lang.ref.WeakReference<ServiceManager.ServiceManagerState> |
state |
| Constructor and Description |
|---|
ServiceListener(Service service,
java.lang.ref.WeakReference<ServiceManager.ServiceManagerState> state) |
| Modifier and Type | Method and Description |
|---|---|
void |
failed(Service.State from,
java.lang.Throwable failure)
Called when the service transitions to the FAILED state.
|
void |
running()
|
void |
starting()
|
void |
stopping(Service.State from)
Called when the service transitions to the STOPPING state.
|
void |
terminated(Service.State from)
Called when the service transitions to the TERMINATED state.
|
final Service service
final java.lang.ref.WeakReference<ServiceManager.ServiceManagerState> state
ServiceListener(Service service, java.lang.ref.WeakReference<ServiceManager.ServiceManagerState> state)
public void starting()
Service.ListenerService.startAsync() is called the first
time.starting in class Service.Listenerpublic void running()
Service.Listenerrunning in class Service.Listenerpublic void stopping(Service.State from)
Service.Listenerfrom are STARTING or RUNNING. This occurs when Service.stopAsync() is called.stopping in class Service.Listenerfrom - The previous state that is being transitioned from.public void terminated(Service.State from)
Service.ListenerService.Listener.terminated in class Service.Listenerfrom - The previous state that is being transitioned from. Failure can occur in any
state with the exception of FAILED and TERMINATED.public void failed(Service.State from, java.lang.Throwable failure)
Service.ListenerService.Listener.failed in class Service.Listenerfrom - The previous state that is being transitioned from. Failure can occur in any
state with the exception of NEW or TERMINATED.failure - The exception that caused the failure.