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
AServicethat 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) Serviceservice(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 voidfailed(Service.State from, java.lang.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 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.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
public void stopping(Service.State from)
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
public void terminated(Service.State from)
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
public void failed(Service.State from, java.lang.Throwable failure)
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.
-
-