Class ServiceManager.ServiceListener
- java.lang.Object
-
- com.google.common.util.concurrent.Service.Listener
-
- com.google.common.util.concurrent.ServiceManager.ServiceListener
-
- Enclosing class:
- ServiceManager
private static final class ServiceManager.ServiceListener extends Service.Listener
AService
that wraps another service and times how long it takes for it to start and also calls theServiceManager.ServiceManagerState.transitionService(Service, State, State)
, to record the state transitions.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Service
service
(package private) java.lang.ref.WeakReference<ServiceManager.ServiceManagerState>
state
-
Constructor Summary
Constructors Constructor Description ServiceListener(Service service, java.lang.ref.WeakReference<ServiceManager.ServiceManagerState> state)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Field Detail
-
service
final Service service
-
state
final java.lang.ref.WeakReference<ServiceManager.ServiceManagerState> state
-
-
Constructor Detail
-
ServiceListener
ServiceListener(Service service, java.lang.ref.WeakReference<ServiceManager.ServiceManagerState> state)
-
-
Method Detail
-
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
public void stopping(Service.State from)
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
public void terminated(Service.State from)
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
public void failed(Service.State from, java.lang.Throwable failure)
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.
-
-