Class Service.Listener
- java.lang.Object
-
- com.google.common.util.concurrent.Service.Listener
-
- Enclosing interface:
- Service
public abstract static class Service.Listener extends Object
A listener for the various state changes that aService
goes through in its lifecycle.All methods are no-ops by default, implementors should override the ones they care about.
- Since:
- 15.0 (present as an interface in 13.0)
- Author:
- Luke Sandberg
-
-
Constructor Summary
Constructors Constructor Description Listener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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.
-
-
-
Constructor Detail
-
Listener
public Listener()
-
-
Method Detail
-
starting
public void starting()
Called when the service transitions from NEW to STARTING. This occurs whenService.startAsync()
is called the first time.
-
running
public void running()
-
stopping
public void stopping(Service.State from)
Called when the service transitions to the STOPPING state. The only valid values forfrom
are STARTING or RUNNING. This occurs whenService.stopAsync()
is called.- Parameters:
from
- The previous state that is being transitioned from.
-
terminated
public void terminated(Service.State from)
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
.- 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, Throwable failure)
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
.- 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.
-
-