Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::acs::shutdown::ShutdownHookBase Class Reference

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
[inline]
 

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.

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.

void alma::acs::shutdown::ShutdownHookBase::run  )  [inline]
 

See also:
java.lang.Runnable#run()

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.


Member Data Documentation

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]
 


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:54:33 2009 for ACS Java API by doxygen 1.3.8