Class LifeCycleManager


  • public final class LifeCycleManager
    extends Object
    Manages PostConstruct and PreDestroy life cycles
    • Constructor Detail

      • LifeCycleManager

        public LifeCycleManager​(List<Object> managedInstances,
                                io.airlift.bootstrap.LifeCycleMethodsMap methodsMap)
                         throws LifeCycleStartException
        Parameters:
        managedInstances - list of objects that have life cycle annotations
        methodsMap - existing or new methods map
        Throws:
        LifeCycleStartException - exceptions starting instances (depending on mode)
    • Method Detail

      • size

        public int size()
        Returns the number of managed instances
        Returns:
        qty
      • stopWithoutFailureLogging

        public void stopWithoutFailureLogging()
                                       throws LifeCycleStopException
        Stop the life cycle - all instances will have their PreDestroy method(s) called and any exceptions raised will be collected and thrown in a wrapped LifeCycleStopException as suppressed exceptions. Those failures will not be logged and are the responsibility of the caller to handle appropriately.
        Throws:
        LifeCycleStopException - If any failure occurs during the clean up process
      • stop

        public void stop()
                  throws LifeCycleStopException
        Stop the life cycle - all instances will have their PreDestroy method(s) called and any exceptions raised will be immediately logged. If any such exceptions occur, a single LifeCycleStopException will be raised at the end of processing which will not contain any reference to exceptions already logged.
        Throws:
        LifeCycleStopException - If any failure occurs during the clean up process