public class ShutdownManager extends Object
getInstance().| Modifier and Type | Field and Description |
|---|---|
static int |
CLIENT_SEQUENCE
Shutdown sequence value for client hooks.
|
static int |
HUB_SEQUENCE
Shutdown sequence value for hub hooks.
|
static int |
PREPARE_SEQUENCE
Shutdown sequence for preparatory hooks.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
forceLog(Logger logger,
Level level,
String msg,
Throwable error)
Writes a log-like message directly to standard error if it has
an appropriate level.
|
static ShutdownManager |
getInstance()
Returns sole instance of this class.
|
void |
registerHook(Object key,
int iseq,
Runnable runnable)
Register a runnable to be run on shutdown with a given key and sequence.
|
void |
unregisterHook(Object key)
Unregisters a key earlier registered using
registerHook(java.lang.Object, int, java.lang.Runnable). |
public static final int PREPARE_SEQUENCE
public static final int CLIENT_SEQUENCE
public static final int HUB_SEQUENCE
public void registerHook(Object key, int iseq, Runnable runnable)
iseq
are run earlier at shutdown.
Suitable sequence values are given by HUB_SEQUENCE and
CLIENT_SEQUENCE.
The key is kept in a WeakHashMap, so if it is GC'd,
the runnable will never execute.key - key which can be used to unregister the hook lateriseq - value indicating position in shutdown sequencerunnable - to be run on shutdownpublic void unregisterHook(Object key)
registerHook(java.lang.Object, int, java.lang.Runnable).key - registration keypublic static ShutdownManager getInstance()
public static void forceLog(Logger logger, Level level, String msg, Throwable error)
logger - loggerlevel - level of message to logmsg - text of logging messageerror - associated throwable if any; may be nullCopyright © 2008–2024. All rights reserved.