Package adams.core.shutdownbuiltin
Class AbstractBuiltInShutdownHook
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.core.shutdownbuiltin.AbstractBuiltInShutdownHook
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,Serializable
- Direct Known Subclasses:
SetShutdownFlag
,StopBackgroundScriptingEngines
public abstract class AbstractBuiltInShutdownHook extends AbstractOptionHandler
Ancestor for built-in/automatic shutdown hooks for the JVM.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Thread
m_Hook
the installed hook.protected static List<AbstractBuiltInShutdownHook>
m_Hooks
the hooks.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractBuiltInShutdownHook()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
check()
Hook method before generating the runnable and installing it.abstract Runnable
configure()
Configures the runnable that gets executed when shutting down.String
install()
Installs the hook, if possible.static void
installAll()
Installs all the built-in shutdown hooks.boolean
remove()
Removes the hook, if possible.static void
removeAll()
Removes all the installed built-in shutdown hooks.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Hook
protected Thread m_Hook
the installed hook.
-
m_Hooks
protected static List<AbstractBuiltInShutdownHook> m_Hooks
the hooks.
-
-
Method Detail
-
check
public String check()
Hook method before generating the runnable and installing it.
Default implementation just returns null.- Returns:
- null if successful, otherwise error message
-
configure
public abstract Runnable configure()
Configures the runnable that gets executed when shutting down.- Returns:
- the runnable
-
install
public String install()
Installs the hook, if possible.- Returns:
- null if successful, otherwise error message
-
remove
public boolean remove()
Removes the hook, if possible.- Returns:
- true if successfully removed (or not installed)
-
installAll
public static void installAll()
Installs all the built-in shutdown hooks.
-
removeAll
public static void removeAll()
Removes all the installed built-in shutdown hooks.
-
-