Class LifecycleHandler

java.lang.Object
io.awspring.cloud.sqs.LifecycleHandler

public class LifecycleHandler extends Object
Handler for lifecycle methods. The singleton instance should be retrieved by using the get() method. This class is thread-safe. Methods accept Object instances and apply lifecycle methods then the SmartLifecycle interface is implemented. Can handle lifecycle actions either sequentially or in parallel, according to the parallelLifecycle property.
Since:
3.0
Author:
Tomaz Fernandes
  • Method Details

    • get

      public static LifecycleHandler get()
      Get the singleton instance for this class.
      Returns:
      the instance.
    • setParallelLifecycle

      public void setParallelLifecycle(boolean parallelLifecycle)
      Set whether lifecycle management should be handled in parallel or sequentially.
      Parameters:
      parallelLifecycle - false to disable parallel lifecycle management.
    • manageLifecycle

      public void manageLifecycle(Consumer<SmartLifecycle> action, Object... objects)
      Execute the provided action if the provided objects are SmartLifecycle instances.
      Parameters:
      action - the action.
      objects - the objects.
    • start

      public void start(Object... objects)
      Starts the provided objects that are a SmartLifecycle instance.
      Parameters:
      objects - the objects.
    • stop

      public void stop(Object... objects)
      Starts the provided objects that are a SmartLifecycle instance.
      Parameters:
      objects - the objects.
    • isRunning

      public boolean isRunning(Object object)
      Check whether a object is running if it's an instance of SmartLifecycle.
      Parameters:
      object - the object to check.
      Returns:
      whether the object is running, or true if it's not a SmartLifecycle instance.
    • dispose

      public void dispose(Object destroyable)
      Execute the DisposableBean.destroy() method if the provided object is a DisposableBean instance.
      Parameters:
      destroyable - the object to destroy.