

Public Member Functions | |
| ShutdownHookBase (Logger logger, String processName) | |
| void | run () |
| void | setRegularShutdownExpected () |
Protected Member Functions | |
| void | regularTermination () |
| abstract void | interruptDetected () |
Protected Attributes | |
| volatile boolean | m_regularShutdownExpected = false |
| final Logger | logger |
| final String | processName |
A subclass can be registered to the JVM Runtime as a shutdown thread to be run at shutdown, both for regular termination and for interruption like Ctrl-C (SIGINT). Make sure to call setRegularShutdownExpected() before regularly exiting the JVM, as otherwise interruptDetected() would be called erroneously.
Recommended reading: http://www-106.ibm.com/developerworks/ibm/library/i-signalhandling/ (also talks about signals for tougher mishaps than Ctrl-c). See also java.lang.Runtime#addShutdownHook(Thread)
Abstracted from the java container's shutdown hook, to simplify registering such hooks also in jlog etc.
| alma::acs::shutdown::ShutdownHookBase::ShutdownHookBase | ( | Logger | logger, | |
| String | processName | |||
| ) | [inline] |
| logger | The logger to be used by this object. | |
| processName | Used as the thread name, with "ShutdownHook" appended. |
| abstract void alma::acs::shutdown::ShutdownHookBase::interruptDetected | ( | ) | [protected, pure virtual] |
Is called when the JVM is about to terminate due to an interrupt signal. Subclasses should perform emergency cleanup.
Implemented in alma::acs::container::ShutdownHook, and alma::acs::logging::dialogs::main::ShutdownHook.
Referenced by run().
| void alma::acs::shutdown::ShutdownHookBase::regularTermination | ( | ) | [inline, protected] |
Subclasses can override this method to log nothing or something else. No other action is expected in the overridden method.
Reimplemented in alma::acs::container::ShutdownHook.
References logger, and processName.
Referenced by run().
| void alma::acs::shutdown::ShutdownHookBase::run | ( | ) | [inline] |
References interruptDetected(), m_regularShutdownExpected, and regularTermination().
| void alma::acs::shutdown::ShutdownHookBase::setRegularShutdownExpected | ( | ) | [inline] |
Must be called right before the program ends. This helps the ShutdownHook to decide whether it's being called for a regular program termination or because of an interrupt.
References m_regularShutdownExpected.
Referenced by alma::acs::container::AcsContainerRunner::run().
final Logger alma::acs::shutdown::ShutdownHookBase::logger [protected] |
volatile boolean alma::acs::shutdown::ShutdownHookBase::m_regularShutdownExpected = false [protected] |
Referenced by run(), and setRegularShutdownExpected().
final String alma::acs::shutdown::ShutdownHookBase::processName [protected] |
Referenced by regularTermination().
1.6.2