Package com.mastfrog.giulius
Class ShutdownHookRegistry
java.lang.Object
com.mastfrog.giulius.ShutdownHookRegistry
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(AutoCloseable toRun) Deprecated.Add an AutoCloseable to be cancelled to the default batch; the AutoCloseable will be weakly referenced.voidDeprecated.Add a Runnable to the default batch.Deprecated.add(ExecutorService toRun) Deprecated.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.voidDeprecated.Add a timer to be cancelled to the default batch; the timer will be weakly referenced.addFirst(AutoCloseable toRun) Deprecated.Add an AutoCloseable to be cancelled to the batch which runs first; the AutoCloseable will be weakly referenced.Deprecated.Add a Runnable to the batch which runs first.Deprecated.addFirst(ExecutorService toRun) Deprecated.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.Deprecated.Add a timer to be cancelled to the batch which runs first; the timer will be weakly referenced.addFirstThrowing(com.mastfrog.function.throwing.ThrowingRunnable toRun) Deprecated.addFirstWeak(Runnable toRun) Deprecated.Add a Runnable to the batch which runs first, without keeping it strongly referenced.addFirstWeak(Callable<?> toRun) Deprecated.addLast(AutoCloseable toRun) Deprecated.Add an AutoCloseable to be cancelled to the batch which runs last; the AutoCloseable will be weakly referenced.Deprecated.Add a Runnable to the batch which runs last.Deprecated.addLast(ExecutorService toRun) Deprecated.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.Deprecated.Add a timer to be cancelled to the batch which runs last; the timer will be weakly referenced.addLastThrowing(com.mastfrog.function.throwing.ThrowingRunnable toRun) Deprecated.addLastWeak(Runnable toRun) Deprecated.Add a Runnable to the batch which runs first, without keeping it strongly referenced.addLastWeak(Callable<?> toRun) Deprecated.addThrowing(com.mastfrog.function.throwing.ThrowingRunnable toRun) Deprecated.Deprecated.Add a Runnable to the default batch, without keeping it strongly referenced.Deprecated.static Optional<ShutdownHookRegistry>current()Deprecated.protected voidDeprecated.static ShutdownHookRegistryget()Deprecated.Get a shutdown hook registry instance.static ShutdownHookRegistryget(int msToWait) Deprecated.Get a shutdown hook registry instance.protected voidinstall()Deprecated.booleanDeprecated.Returns true if shutdown hooks are currently being run.protected intDeprecated.intshutdown()Deprecated.Imperatively run shutdown tasks, clearing the set of tasks and deregistering the ShutdownHooks as a VM shutdown hook if it has been registered.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.mastfrog.giulius.ShutdownHooks
addFirstWeakThrowing, addLastWeakThrowing, addWeakThrowing
-
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
Deprecated.Description copied from interface:ShutdownHooksAdd a Runnable to the default batch.- Specified by:
addin interfaceShutdownHooks- Parameters:
toRun- A runnable
-
addFirst
Deprecated.Description copied from interface:ShutdownHooksAdd a Runnable to the batch which runs first.- Specified by:
addFirstin interfaceShutdownHooks- Parameters:
toRun- A runnable- Returns:
- this
-
addLast
Deprecated.Description copied from interface:ShutdownHooksAdd a Runnable to the batch which runs last.- Specified by:
addLastin interfaceShutdownHooks- Parameters:
toRun- A runnable- Returns:
- this
-
addWeak
Deprecated.Description copied from interface:ShutdownHooksAdd a Runnable to the default batch, without keeping it strongly referenced.- Specified by:
addWeakin interfaceShutdownHooks- Parameters:
toRun- A runnable
-
addFirstWeak
Deprecated.Description copied from interface:ShutdownHooksAdd a Runnable to the batch which runs first, without keeping it strongly referenced.- Specified by:
addFirstWeakin interfaceShutdownHooks- Parameters:
toRun- A runnable
-
addLastWeak
Deprecated.Description copied from interface:ShutdownHooksAdd a Runnable to the batch which runs first, without keeping it strongly referenced.- Specified by:
addLastWeakin interfaceShutdownHooks- Parameters:
toRun- A runnable
-
add
Deprecated.- Specified by:
addin interfaceShutdownHooks
-
addFirst
Deprecated.- Specified by:
addFirstin interfaceShutdownHooks
-
addLast
Deprecated.- Specified by:
addLastin interfaceShutdownHooks
-
addWeak
Deprecated.- Specified by:
addWeakin interfaceShutdownHooks
-
addFirstWeak
Deprecated.- Specified by:
addFirstWeakin interfaceShutdownHooks
-
addLastWeak
Deprecated.- Specified by:
addLastWeakin interfaceShutdownHooks
-
add
Deprecated.Description copied from interface:ShutdownHooksAdd a timer to be cancelled to the default batch; the timer will be weakly referenced.- Specified by:
addin interfaceShutdownHooks- Parameters:
toRun- A timer
-
addFirst
Deprecated.Description copied from interface:ShutdownHooksAdd a timer to be cancelled to the batch which runs first; the timer will be weakly referenced.- Specified by:
addFirstin interfaceShutdownHooks- Parameters:
toRun- A timer- Returns:
- this
-
addLast
Deprecated.Description copied from interface:ShutdownHooksAdd a timer to be cancelled to the batch which runs last; the timer will be weakly referenced.- Specified by:
addLastin interfaceShutdownHooks- Parameters:
toRun- A timer- Returns:
- this
-
add
Deprecated.Description copied from interface:ShutdownHooksAdd an AutoCloseable to be cancelled to the default batch; the AutoCloseable will be weakly referenced.- Specified by:
addin interfaceShutdownHooks- Parameters:
toRun- A resource to be closed
-
addFirst
Deprecated.Description copied from interface:ShutdownHooksAdd an AutoCloseable to be cancelled to the batch which runs first; the AutoCloseable will be weakly referenced.- Specified by:
addFirstin interfaceShutdownHooks- Parameters:
toRun- A resource to be closed- Returns:
- this
-
addLast
Deprecated.Description copied from interface:ShutdownHooksAdd an AutoCloseable to be cancelled to the batch which runs last; the AutoCloseable will be weakly referenced.- Specified by:
addLastin interfaceShutdownHooks- Parameters:
toRun- A resource to be closed- Returns:
- this
-
add
Deprecated.Description copied from interface:ShutdownHooksAdd 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:
addin interfaceShutdownHooks- Parameters:
toRun- An ExecutorService- Returns:
- this
-
addFirst
Deprecated.Description copied from interface:ShutdownHooksAdd 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:
addFirstin interfaceShutdownHooks- Parameters:
toRun- An ExecutorService- Returns:
- this
-
addLast
Deprecated.Description copied from interface:ShutdownHooksAdd 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:
addLastin interfaceShutdownHooks- Parameters:
toRun- An ExecutorService- Returns:
- this
-
addThrowing
Deprecated.- Specified by:
addThrowingin interfaceShutdownHooks
-
addFirstThrowing
Deprecated.- Specified by:
addFirstThrowingin interfaceShutdownHooks
-
addLastThrowing
Deprecated.- Specified by:
addLastThrowingin interfaceShutdownHooks
-
shutdown
public int shutdown()Deprecated.Description copied from interface:ShutdownHooksImperatively 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:
shutdownin interfaceShutdownHooks- Returns:
- The count of tasks run during shutdown
-
runShutdownHooks
protected int runShutdownHooks()Deprecated. -
isRunningShutdownHooks
public boolean isRunningShutdownHooks()Deprecated.Description copied from interface:ShutdownHooksReturns true if shutdown hooks are currently being run.- Specified by:
isRunningShutdownHooksin interfaceShutdownHooks- Returns:
- True if hooks are running
-
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
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
Deprecated.
-