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 | |||
| ) |
| 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 alma.acs.shutdown.ShutdownHookBase.run().
| void alma.acs.shutdown.ShutdownHookBase.regularTermination | ( | ) | [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 alma.acs.shutdown.ShutdownHookBase.logger, and alma.acs.shutdown.ShutdownHookBase.processName.
Referenced by alma.acs.shutdown.ShutdownHookBase.run().
| void alma.acs.shutdown.ShutdownHookBase.run | ( | ) |
References alma.acs.shutdown.ShutdownHookBase.interruptDetected(), alma.acs.shutdown.ShutdownHookBase.m_regularShutdownExpected, and alma.acs.shutdown.ShutdownHookBase.regularTermination().
| void alma.acs.shutdown.ShutdownHookBase.setRegularShutdownExpected | ( | ) |
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 alma.acs.shutdown.ShutdownHookBase.m_regularShutdownExpected.
Referenced by alma.acs.component.client.ComponentClient.tearDown().
final Logger alma.acs.shutdown.ShutdownHookBase.logger [protected] |
volatile boolean alma.acs.shutdown.ShutdownHookBase.m_regularShutdownExpected = false [protected] |
final String alma.acs.shutdown.ShutdownHookBase.processName [protected] |
Referenced by alma.acs.shutdown.ShutdownHookBase.regularTermination().
1.7.0