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 TypeMethodDescriptionvoidfailed(Service.State from, Throwable failure) Called when the service transitions to the FAILED state.voidrunning()voidstarting()voidstopping(Service.State from) Called when the service transitions to the STOPPING state.voidterminated(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.ListenerCalled when the service transitions from NEW to STARTING. This occurs whenService.startAsync()is called the first time.- Overrides:
startingin classService.Listener
-
running
public void running()Description copied from class:Service.ListenerCalled when the service transitions from STARTING to RUNNING. This occurs when a service has successfully started.- Overrides:
runningin classService.Listener
-
stopping
Description copied from class:Service.ListenerCalled when the service transitions to the STOPPING state. The only valid values forfromare STARTING or RUNNING. This occurs whenService.stopAsync()is called.- Overrides:
stoppingin classService.Listener- Parameters:
from- The previous state that is being transitioned from.
-
terminated
Description copied from class:Service.ListenerCalled 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:
terminatedin 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.ListenerCalled 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:
failedin 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.
-