Class Service.Listener

java.lang.Object
dev.mccue.guava.concurrent.Service.Listener
Enclosing interface:
Service

public abstract static class Service.Listener extends Object
A listener for the various state changes that a Service 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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    failed(Service.State from, Throwable failure)
    Called when the service transitions to the State#FAILED FAILED state.
    void
    Called when the service transitions from State#STARTING STARTING to State#RUNNING RUNNING.
    void
    Called when the service transitions from State#NEW NEW to State#STARTING STARTING.
    void
    Called when the service transitions to the State#STOPPING STOPPING state.
    void
    Called when the service transitions to the State#TERMINATED TERMINATED state.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Listener

      public Listener()
  • Method Details

    • starting

      public void starting()
      Called when the service transitions from State#NEW NEW to State#STARTING STARTING. This occurs when Service#startAsync is called the first time.
    • running

      public void running()
      Called when the service transitions from State#STARTING STARTING to State#RUNNING RUNNING. This occurs when a service has successfully started.
    • stopping

      public void stopping(Service.State from)
      Called when the service transitions to the State#STOPPING STOPPING state. The only valid values for from are State#STARTING STARTING or State#RUNNING RUNNING. This occurs when Service#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 State#TERMINATED TERMINATED state. The State#TERMINATED TERMINATED state is a terminal state in the transition diagram. Therefore, if this method is called, no other methods will be called on the Listener.
      Parameters:
      from - The previous state that is being transitioned from. Failure can occur in any state with the exception of State#FAILED FAILED and State#TERMINATED TERMINATED.
    • failed

      public void failed(Service.State from, Throwable failure)
      Called when the service transitions to the State#FAILED FAILED state. The State#FAILED FAILED state is a terminal state in the transition diagram. Therefore, if this method is called, no other methods will be called on the Listener.
      Parameters:
      from - The previous state that is being transitioned from. Failure can occur in any state with the exception of State#NEW NEW or State#TERMINATED TERMINATED.
      failure - The exception that caused the failure.