|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microsoft.tfs.util.shutdown.ShutdownManager
public final class ShutdownManager
The general use case for this class is that objects that implement the lifecycle event listener interfaces will register themselves on creation with this manager (via add*EventListener()). These events are fired on the registered objects when the Java virtual machine is shutting down.
To register events with the shutdown manager, simply get a reference via
getInstance()
and call
addShutdownEventListener(ShutdownEventListener, Priority)
and
removeShutdownEventListener(ShutdownEventListener, Priority)
.
Application should manually invoke shutdown()
when they exit (read
the Javadoc on the method). Because of how the JVM handles its shutdown
process, this class's shutdown event can be fired from any thread.
This class is a singleton (use getInstance()
).
Nested Class Summary | |
---|---|
static class |
ShutdownManager.Priority
|
Method Summary | |
---|---|
void |
addShutdownEventListener(ShutdownEventListener listener,
ShutdownManager.Priority priority)
Add a listener for the event fired when core is being shut down. |
static ShutdownManager |
getInstance()
Gets the single instance of ShutdownManager for any process. |
void |
removeShutdownEventListener(ShutdownEventListener listener,
ShutdownManager.Priority priority)
Remove a listener for the event fired when core is being shut down. |
void |
shutdown()
Instructs all registered listeners to shutdown. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ShutdownManager getInstance()
public void shutdown()
Using the shutdown manager for the first time causes it to establish a
link with the Java virtual machine that ensures it will be invoked during
JVM shutdown. However, when an application exits normally, the shutdown
hooks may not be called. Applications that use ShutdownManager
should call shutdown()
directly as part of their application
exit procedure to ensure all listeners are invoked before the JVM exits.
public void addShutdownEventListener(ShutdownEventListener listener, ShutdownManager.Priority priority)
listener
- the listener to add (not null.priority
- the priority of the listener (not null).public void removeShutdownEventListener(ShutdownEventListener listener, ShutdownManager.Priority priority)
listener
- the listener to remove (not null).priority
- the priority of the listener to remove (not null). Must match the
original priority supplied to be removed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |