Class LifecycleHelper


  • public final class LifecycleHelper
    extends Object
    Lifecycle helper is a tool for managing transitions between lifecycle phases.

    The lifecycle helper supports the following set of phases:

    • Initial
    • Starting
    • Running
    • Closing
    • Closed

    The lifecycle helper is thread-safe.

    • Constructor Detail

      • LifecycleHelper

        public LifecycleHelper()
    • Method Detail

      • beginStart

        public void beginStart()
        Performs transition from Initial to Starting phase.
        • In case the current phase is not Initial an exception is thrown.
      • endStart

        public void endStart​(boolean successful)
        Performs transition from Starting to Running phase in case the start was successful, otherwise performs transition to Closed phase.
        • In case the current phase is not Starting an exception is thrown.
        • In case this method is invoked by a thread different from the thread that invoked beginStart an exception is thrown.
        Parameters:
        successful - The flag showing whether the start was successful.
      • beginUserOperation

        public void beginUserOperation()
        Registers a user operation.
        • In case the current phase is not Running an exception is thrown.
      • endUserOperation

        public void endUserOperation()
        Deregisters a user operation.
        • In case the current phase is not Running an exception is thrown.
        • The method does not check if the operation was registered in the same thread or if it was registered at all, however, in case this method was invoked more times than the beginUserOperation was, an exception in thrown.
      • beginClose

        public void beginClose()
        Performs transition from Running to Closing phase. Waits till all the registered user operations are deregistered.
        • In case the current phase is not Running an exception is thrown.
      • endClose

        public void endClose()
        Performs transition from Closing to Closed phase.
        • In case the current phase is not Closing an exception is thrown.
        • In case this method is invoked by a thread different from the thread that invoked beginClose an exception is thrown.