Enum Class ServiceState

java.lang.Object
java.lang.Enum<ServiceState>
org.oddjob.state.ServiceState
All Implemented Interfaces:
Serializable, Comparable<ServiceState>, Constable, State

public enum ServiceState extends Enum<ServiceState> implements State
Encapsulate the allowed states for a service.
Author:
Rob Gordon
  • Enum Constant Details

    • STARTABLE

      public static final ServiceState STARTABLE
      The service can be started.

      Note that this state is needed in addition to STOPPED to tie in with state transitions of job states. Without this state, an EXCEPTION state would reset to STOPPED which could cause a parent sequence to complete which would be counter intuitive compared to the behaviour of job states.

    • STARTING

      public static final ServiceState STARTING
      Indicates the service is starting. The execution thread is still in the start method.
    • INITIALISING

      public static final ServiceState INITIALISING
      Indicates the service is starting. The execution thread is not in the start method. Used by asynchronous services where initialisation is done on a separate thread.
    • STARTED

      public static final ServiceState STARTED
      Indicates the service has started and is now available to service requests.
    • STOPPED

      public static final ServiceState STOPPED
      The service is stopped.
    • EXCEPTION

      public static final ServiceState EXCEPTION
      Indicates an exception has occurred. This is generally when trying to start the service. But may also happen at other times.
    • DESTROYED

      public static final ServiceState DESTROYED
      The service has been destroyed. It can no longer be used.
  • Method Details

    • values

      public static ServiceState[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ServiceState valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • stateFor

      public static ServiceState stateFor(String state)
      Utility function to convert a state text to to the JobState.
      Parameters:
      state - Case insensitive text.
      Returns:
      The corresponding jobState or null if it's invalid.