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.Listener
Service.startAsync()
is called
the first time.starting
in class Service.Listener
public void running()
Service.Listener
running
in class Service.Listener
public void stopping(Service.State from)
Service.Listener
from
are STARTING or
RUNNING. This occurs when Service.stopAsync()
is called.stopping
in class Service.Listener
from
- The previous state that is being transitioned from.public void terminated(Service.State from)
Service.Listener
Service.Listener
.terminated
in class Service.Listener
from
- The previous state that is being transitioned from. The only valid values for
this are NEW, RUNNING or
STOPPING.public void failed(Service.State from, java.lang.Throwable failure)
Service.Listener
Service.Listener
.failed
in class Service.Listener
from
- 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.