Class DefaultShutdownCallbackRegistry

    • Field Detail

      • LOGGER

        protected static final Logger LOGGER
        Status logger.
    • Constructor Detail

      • DefaultShutdownCallbackRegistry

        public DefaultShutdownCallbackRegistry()
        Constructs a DefaultShutdownRegistrationStrategy.
      • DefaultShutdownCallbackRegistry

        protected DefaultShutdownCallbackRegistry​(ThreadFactory threadFactory)
        Constructs a DefaultShutdownRegistrationStrategy using the given ThreadFactory.
        Parameters:
        threadFactory - the ThreadFactory to use to create a Runtime shutdown hook thread
    • Method Detail

      • run

        public void run()
        Executes the registered shutdown callbacks.
        Specified by:
        run in interface Runnable
      • addShutdownCallback

        public Cancellable addShutdownCallback​(Runnable callback)
        Description copied from interface: ShutdownCallbackRegistry
        Adds a Runnable shutdown callback to this class.
        Specified by:
        addShutdownCallback in interface ShutdownCallbackRegistry
        Parameters:
        callback - the shutdown callback to be executed upon shutdown.
        Returns:
        a Cancellable wrapper of the provided callback or null if the shutdown hook is disabled and cannot be added.
      • start

        public void start()
        Registers the shutdown thread only if this is initialized.
        Specified by:
        start in interface LifeCycle
      • stop

        public void stop()
        Specified by:
        stop in interface LifeCycle
      • stop

        public boolean stop​(long timeout,
                            TimeUnit timeUnit)
        Cancels the shutdown thread only if this is started.
        Specified by:
        stop in interface LifeCycle2
        Parameters:
        timeout - the maximum time to wait
        timeUnit - the time unit of the timeout argument
        Returns:
        true if the receiver was stopped cleanly and normally, false otherwise.
      • isStarted

        public boolean isStarted()
        Indicates if this can accept shutdown hooks.
        Specified by:
        isStarted in interface LifeCycle
        Returns:
        true if this can accept shutdown hooks