Class ServiceManager.ServiceListener
java.lang.Object
com.google.common.util.concurrent.Service.Listener
com.google.common.util.concurrent.ServiceManager.ServiceListener
- Enclosing class:
ServiceManager
A
Service
that wraps another service and times how long it takes for it to start and
also calls the ServiceManager.ServiceManagerState.transitionService(Service, State, State)
, to record
the state transitions.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final Service
(package private) final WeakReference
<ServiceManager.ServiceManagerState> -
Constructor Summary
ConstructorsConstructorDescriptionServiceListener
(Service service, WeakReference<ServiceManager.ServiceManagerState> state) -
Method Summary
Modifier and TypeMethodDescriptionvoid
failed
(Service.State from, 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.
-
Field Details
-
service
-
state
-
-
Constructor Details
-
ServiceListener
ServiceListener(Service service, WeakReference<ServiceManager.ServiceManagerState> state)
-
-
Method Details
-
starting
public void starting()Description copied from class:Service.Listener
Called when the service transitions from NEW to STARTING. This occurs whenService.startAsync()
is called the first time.- Overrides:
starting
in classService.Listener
-
running
public void running()Description copied from class:Service.Listener
Called when the service transitions from STARTING to RUNNING. This occurs when a service has successfully started.- Overrides:
running
in classService.Listener
-
stopping
Description copied from class:Service.Listener
Called when the service transitions to the STOPPING state. The only valid values forfrom
are STARTING or RUNNING. This occurs whenService.stopAsync()
is called.- Overrides:
stopping
in classService.Listener
- Parameters:
from
- The previous state that is being transitioned from.
-
terminated
Description copied from class:Service.Listener
Called when the service transitions to the TERMINATED state. The TERMINATED state is a terminal state in the transition diagram. Therefore, if this method is called, no other methods will be called on theService.Listener
.- Overrides:
terminated
in classService.Listener
- Parameters:
from
- The previous state that is being transitioned from. Failure can occur in any state with the exception of FAILED and TERMINATED.
-
failed
Description copied from class:Service.Listener
Called when the service transitions to the FAILED state. The FAILED state is a terminal state in the transition diagram. Therefore, if this method is called, no other methods will be called on theService.Listener
.- Overrides:
failed
in classService.Listener
- Parameters:
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.
-