Public Member Functions | Protected Member Functions | Protected Attributes

alma.acs.shutdown.ShutdownHookBase Class Reference

Inheritance diagram for alma.acs.shutdown.ShutdownHookBase:
alma.acs.container.ShutdownHook alma.acs.logging.dialogs.main.ShutdownHook

List of all members.

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

Detailed Description

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.

Author:
hsommer

Constructor & Destructor Documentation

alma.acs.shutdown.ShutdownHookBase.ShutdownHookBase ( Logger  logger,
String  processName 
)
Parameters:
logger The logger to be used by this object.
processName Used as the thread name, with "ShutdownHook" appended.

Member Function Documentation

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.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().


Member Data Documentation


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties