Interface Lifecycle

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  Lifecycle.SingleUse
      Marker interface used to indicate that the instance should only be used once.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String AFTER_DESTROY_EVENT
      The LifecycleEvent type for the "component after destroy" event.
      static java.lang.String AFTER_INIT_EVENT
      The LifecycleEvent type for the "component after init" event.
      static java.lang.String AFTER_START_EVENT
      The LifecycleEvent type for the "component after start" event.
      static java.lang.String AFTER_STOP_EVENT
      The LifecycleEvent type for the "component after stop" event.
      static java.lang.String BEFORE_DESTROY_EVENT
      The LifecycleEvent type for the "component before destroy" event.
      static java.lang.String BEFORE_INIT_EVENT
      The LifecycleEvent type for the "component before init" event.
      static java.lang.String BEFORE_START_EVENT
      The LifecycleEvent type for the "component before start" event.
      static java.lang.String BEFORE_STOP_EVENT
      The LifecycleEvent type for the "component before stop" event.
      static java.lang.String CONFIGURE_START_EVENT
      The LifecycleEvent type for the "configure_start" event.
      static java.lang.String CONFIGURE_STOP_EVENT
      The LifecycleEvent type for the "configure_stop" event.
      static java.lang.String PERIODIC_EVENT
      The LifecycleEvent type for the "periodic" event.
      static java.lang.String START_EVENT
      The LifecycleEvent type for the "component start" event.
      static java.lang.String STOP_EVENT
      The LifecycleEvent type for the "component stop" event.
    • Field Detail

      • BEFORE_INIT_EVENT

        static final java.lang.String BEFORE_INIT_EVENT
        The LifecycleEvent type for the "component before init" event.
        See Also:
        Constant Field Values
      • AFTER_INIT_EVENT

        static final java.lang.String AFTER_INIT_EVENT
        The LifecycleEvent type for the "component after init" event.
        See Also:
        Constant Field Values
      • START_EVENT

        static final java.lang.String START_EVENT
        The LifecycleEvent type for the "component start" event.
        See Also:
        Constant Field Values
      • BEFORE_START_EVENT

        static final java.lang.String BEFORE_START_EVENT
        The LifecycleEvent type for the "component before start" event.
        See Also:
        Constant Field Values
      • AFTER_START_EVENT

        static final java.lang.String AFTER_START_EVENT
        The LifecycleEvent type for the "component after start" event.
        See Also:
        Constant Field Values
      • STOP_EVENT

        static final java.lang.String STOP_EVENT
        The LifecycleEvent type for the "component stop" event.
        See Also:
        Constant Field Values
      • BEFORE_STOP_EVENT

        static final java.lang.String BEFORE_STOP_EVENT
        The LifecycleEvent type for the "component before stop" event.
        See Also:
        Constant Field Values
      • AFTER_STOP_EVENT

        static final java.lang.String AFTER_STOP_EVENT
        The LifecycleEvent type for the "component after stop" event.
        See Also:
        Constant Field Values
      • AFTER_DESTROY_EVENT

        static final java.lang.String AFTER_DESTROY_EVENT
        The LifecycleEvent type for the "component after destroy" event.
        See Also:
        Constant Field Values
      • BEFORE_DESTROY_EVENT

        static final java.lang.String BEFORE_DESTROY_EVENT
        The LifecycleEvent type for the "component before destroy" event.
        See Also:
        Constant Field Values
      • PERIODIC_EVENT

        static final java.lang.String PERIODIC_EVENT
        The LifecycleEvent type for the "periodic" event.
        See Also:
        Constant Field Values
      • CONFIGURE_START_EVENT

        static final java.lang.String CONFIGURE_START_EVENT
        The LifecycleEvent type for the "configure_start" event. Used by those components that use a separate component to perform configuration and need to signal when configuration should be performed - usually after BEFORE_START_EVENT and before START_EVENT.
        See Also:
        Constant Field Values
      • CONFIGURE_STOP_EVENT

        static final java.lang.String CONFIGURE_STOP_EVENT
        The LifecycleEvent type for the "configure_stop" event. Used by those components that use a separate component to perform configuration and need to signal when de-configuration should be performed - usually after STOP_EVENT and before AFTER_STOP_EVENT.
        See Also:
        Constant Field Values
    • Method Detail

      • addLifecycleListener

        void addLifecycleListener​(LifecycleListener listener)
        Add a LifecycleEvent listener to this component.
        Parameters:
        listener - The listener to add
      • findLifecycleListeners

        LifecycleListener[] findLifecycleListeners()
        Get the life cycle listeners associated with this life cycle.
        Returns:
        An array containing the life cycle listeners associated with this life cycle. If this component has no listeners registered, a zero-length array is returned.
      • removeLifecycleListener

        void removeLifecycleListener​(LifecycleListener listener)
        Remove a LifecycleEvent listener from this component.
        Parameters:
        listener - The listener to remove
      • init

        void init()
           throws LifecycleException
        Prepare the component for starting. This method should perform any initialization required post object creation. The following LifecycleEvents will be fired in the following order:
        1. INIT_EVENT: On the successful completion of component initialization.
        Throws:
        LifecycleException - if this component detects a fatal error that prevents this component from being used
      • start

        void start()
            throws LifecycleException
        Prepare for the beginning of active use of the public methods other than property getters/setters and life cycle methods of this component. This method should be called before any of the public methods other than property getters/setters and life cycle methods of this component are utilized. The following LifecycleEvents will be fired in the following order:
        1. BEFORE_START_EVENT: At the beginning of the method. It is as this point the state transitions to LifecycleState.STARTING_PREP.
        2. START_EVENT: During the method once it is safe to call start() for any child components. It is at this point that the state transitions to LifecycleState.STARTING and that the public methods other than property getters/setters and life cycle methods may be used.
        3. AFTER_START_EVENT: At the end of the method, immediately before it returns. It is at this point that the state transitions to LifecycleState.STARTED.
        Throws:
        LifecycleException - if this component detects a fatal error that prevents this component from being used
      • stop

        void stop()
           throws LifecycleException
        Gracefully terminate the active use of the public methods other than property getters/setters and life cycle methods of this component. Once the STOP_EVENT is fired, the public methods other than property getters/setters and life cycle methods should not be used. The following LifecycleEvents will be fired in the following order:
        1. BEFORE_STOP_EVENT: At the beginning of the method. It is at this point that the state transitions to LifecycleState.STOPPING_PREP.
        2. STOP_EVENT: During the method once it is safe to call stop() for any child components. It is at this point that the state transitions to LifecycleState.STOPPING and that the public methods other than property getters/setters and life cycle methods may no longer be used.
        3. AFTER_STOP_EVENT: At the end of the method, immediately before it returns. It is at this point that the state transitions to LifecycleState.STOPPED.
        Note that if transitioning from LifecycleState.FAILED then the three events above will be fired but the component will transition directly from LifecycleState.FAILED to LifecycleState.STOPPING, bypassing LifecycleState.STOPPING_PREP
        Throws:
        LifecycleException - if this component detects a fatal error that needs to be reported
      • destroy

        void destroy()
              throws LifecycleException
        Prepare to discard the object. The following LifecycleEvents will be fired in the following order:
        1. DESTROY_EVENT: On the successful completion of component destruction.
        Throws:
        LifecycleException - if this component detects a fatal error that prevents this component from being used
      • getState

        LifecycleState getState()
        Obtain the current state of the source component.
        Returns:
        The current state of the source component.
      • getStateName

        java.lang.String getStateName()
        Obtain a textual representation of the current component state. Useful for JMX. The format of this string may vary between point releases and should not be relied upon to determine component state. To determine component state, use getState().
        Returns:
        The name of the current component state.