Class ShutdownHookRegistry

java.lang.Object
com.mastfrog.giulius.ShutdownHookRegistry
All Implemented Interfaces:
ShutdownHooks

@Deprecated public abstract class ShutdownHookRegistry extends Object implements ShutdownHooks
Deprecated.
use com.mastfrog.shutdown.hooks.ShutdownHookRegistry directly - the code has been moved there, and this class simply delegates to it.
Thing you can add runnables to to be run on orderly vm shutdown (close connections, etc.)
Author:
Tim Boudreau
  • Constructor Details

    • ShutdownHookRegistry

      public ShutdownHookRegistry()
      Deprecated.
    • ShutdownHookRegistry

      public ShutdownHookRegistry(long ms)
      Deprecated.
  • Method Details

    • install

      protected void install()
      Deprecated.
    • deinstall

      protected void deinstall()
      Deprecated.
    • add

      public void add(Runnable toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add a Runnable to the default batch.
      Specified by:
      add in interface ShutdownHooks
      Parameters:
      toRun - A runnable
    • addFirst

      public ShutdownHookRegistry addFirst(Runnable toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add a Runnable to the batch which runs first.
      Specified by:
      addFirst in interface ShutdownHooks
      Parameters:
      toRun - A runnable
      Returns:
      this
    • addLast

      public ShutdownHookRegistry addLast(Runnable toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add a Runnable to the batch which runs last.
      Specified by:
      addLast in interface ShutdownHooks
      Parameters:
      toRun - A runnable
      Returns:
      this
    • addWeak

      public ShutdownHookRegistry addWeak(Runnable toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add a Runnable to the default batch, without keeping it strongly referenced.
      Specified by:
      addWeak in interface ShutdownHooks
      Parameters:
      toRun - A runnable
    • addFirstWeak

      public ShutdownHookRegistry addFirstWeak(Runnable toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add a Runnable to the batch which runs first, without keeping it strongly referenced.
      Specified by:
      addFirstWeak in interface ShutdownHooks
      Parameters:
      toRun - A runnable
    • addLastWeak

      public ShutdownHookRegistry addLastWeak(Runnable toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add a Runnable to the batch which runs first, without keeping it strongly referenced.
      Specified by:
      addLastWeak in interface ShutdownHooks
      Parameters:
      toRun - A runnable
    • add

      public ShutdownHookRegistry add(Callable<?> toRun)
      Deprecated.
      Specified by:
      add in interface ShutdownHooks
    • addFirst

      public ShutdownHookRegistry addFirst(Callable<?> toRun)
      Deprecated.
      Specified by:
      addFirst in interface ShutdownHooks
    • addLast

      public ShutdownHookRegistry addLast(Callable<?> toRun)
      Deprecated.
      Specified by:
      addLast in interface ShutdownHooks
    • addWeak

      public ShutdownHookRegistry addWeak(Callable<?> toRun)
      Deprecated.
      Specified by:
      addWeak in interface ShutdownHooks
    • addFirstWeak

      public ShutdownHookRegistry addFirstWeak(Callable<?> toRun)
      Deprecated.
      Specified by:
      addFirstWeak in interface ShutdownHooks
    • addLastWeak

      public ShutdownHookRegistry addLastWeak(Callable<?> toRun)
      Deprecated.
      Specified by:
      addLastWeak in interface ShutdownHooks
    • add

      public void add(Timer toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add a timer to be cancelled to the default batch; the timer will be weakly referenced.
      Specified by:
      add in interface ShutdownHooks
      Parameters:
      toRun - A timer
    • addFirst

      public ShutdownHookRegistry addFirst(Timer toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add a timer to be cancelled to the batch which runs first; the timer will be weakly referenced.
      Specified by:
      addFirst in interface ShutdownHooks
      Parameters:
      toRun - A timer
      Returns:
      this
    • addLast

      public ShutdownHookRegistry addLast(Timer toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add a timer to be cancelled to the batch which runs last; the timer will be weakly referenced.
      Specified by:
      addLast in interface ShutdownHooks
      Parameters:
      toRun - A timer
      Returns:
      this
    • add

      public void add(AutoCloseable toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add an AutoCloseable to be cancelled to the default batch; the AutoCloseable will be weakly referenced.
      Specified by:
      add in interface ShutdownHooks
      Parameters:
      toRun - A resource to be closed
    • addFirst

      public ShutdownHookRegistry addFirst(AutoCloseable toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add an AutoCloseable to be cancelled to the batch which runs first; the AutoCloseable will be weakly referenced.
      Specified by:
      addFirst in interface ShutdownHooks
      Parameters:
      toRun - A resource to be closed
      Returns:
      this
    • addLast

      public ShutdownHookRegistry addLast(AutoCloseable toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add an AutoCloseable to be cancelled to the batch which runs last; the AutoCloseable will be weakly referenced.
      Specified by:
      addLast in interface ShutdownHooks
      Parameters:
      toRun - A resource to be closed
      Returns:
      this
    • add

      Deprecated.
      Description copied from interface: ShutdownHooks
      Add an executor service to the default batch; the executor service will be strongly referenced; when hooks are run, all executors are first shut down, and then in a separate pass, awaited for termination en-banc up to the expiration of a timeout.
      Specified by:
      add in interface ShutdownHooks
      Parameters:
      toRun - An ExecutorService
      Returns:
      this
    • addFirst

      public ShutdownHookRegistry addFirst(ExecutorService toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add an executor service to the batch which runs first; the executor service will be strongly referenced; when hooks are run, all executors are first shut down, and then in a separate pass, awaited for termination en-banc up to the expiration of a timeout.
      Specified by:
      addFirst in interface ShutdownHooks
      Parameters:
      toRun - An ExecutorService
      Returns:
      this
    • addLast

      public ShutdownHookRegistry addLast(ExecutorService toRun)
      Deprecated.
      Description copied from interface: ShutdownHooks
      Add an executor service to the batch which runs last; the executor service will be strongly referenced; when hooks are run, all executors are first shut down, and then in a separate pass, awaited for termination en-banc up to the expiration of a timeout.
      Specified by:
      addLast in interface ShutdownHooks
      Parameters:
      toRun - An ExecutorService
      Returns:
      this
    • addThrowing

      public ShutdownHooks addThrowing(com.mastfrog.function.throwing.ThrowingRunnable toRun)
      Deprecated.
      Specified by:
      addThrowing in interface ShutdownHooks
    • addFirstThrowing

      public ShutdownHooks addFirstThrowing(com.mastfrog.function.throwing.ThrowingRunnable toRun)
      Deprecated.
      Specified by:
      addFirstThrowing in interface ShutdownHooks
    • addLastThrowing

      public ShutdownHooks addLastThrowing(com.mastfrog.function.throwing.ThrowingRunnable toRun)
      Deprecated.
      Specified by:
      addLastThrowing in interface ShutdownHooks
    • shutdown

      public int shutdown()
      Deprecated.
      Description copied from interface: ShutdownHooks
      Imperatively run shutdown tasks, clearing the set of tasks and deregistering the ShutdownHooks as a VM shutdown hook if it has been registered.

      In general this should only be called by test frameworks and a few rare cases of applications that cleanly shut down all their state and reload themselves, or things run inside an isolating classloader whose shutdown tasks must run before the classloader is closed.

      Specified by:
      shutdown in interface ShutdownHooks
      Returns:
      The count of tasks run during shutdown
    • runShutdownHooks

      protected int runShutdownHooks()
      Deprecated.
    • isRunningShutdownHooks

      public boolean isRunningShutdownHooks()
      Deprecated.
      Description copied from interface: ShutdownHooks
      Returns true if shutdown hooks are currently being run.
      Specified by:
      isRunningShutdownHooks in interface ShutdownHooks
      Returns:
      True if hooks are running
    • get

      public static ShutdownHookRegistry get()
      Deprecated.
      Get a shutdown hook registry instance. This method is only for use in things like ServletContextListeners where there is no control over lifecycle. The returned instance is not a singleton.
      Returns:
      A registry of shutdown hooks.
    • get

      public static ShutdownHookRegistry get(int msToWait)
      Deprecated.
      Get a shutdown hook registry instance. This method is only for use in things like ServletContextListeners where there is no control over lifecycle. The returned instance is not a singleton.
      Returns:
      A registry of shutdown hooks.
    • current

      public static Optional<ShutdownHookRegistry> current()
      Deprecated.