Class Shutdowner
java.lang.Object
java.lang.Thread
clazzfish.monitor.util.Shutdowner
- All Implemented Interfaces:
Shutdownable
,Runnable
- Direct Known Subclasses:
AbstractMonitor
,ClazzStatistic
The class Shutdowner has the necessary methods for registration a class
as shutdown hook. For this you must overwrite the
Thread.run()
method
which is called during shutdown.- Since:
- 2.3 (29.11.24)
- Author:
- oboehm
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
To be able to register the class as shutdown hook via JMX we can't use a static method - this is the reason why this additional method was added.boolean
Here you can ask if the class was already registered as shutdown hook.void
If you want to unregister the instance as shutdown hook you can use this (not static) method.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Constructor Details
-
Shutdowner
public Shutdowner()
-
-
Method Details
-
isShutdownHook
public boolean isShutdownHook()Here you can ask if the class was already registered as shutdown hook.- Specified by:
isShutdownHook
in interfaceShutdownable
- Returns:
- true if it is registered as shutdown hook.
-
addMeAsShutdownHook
public void addMeAsShutdownHook()To be able to register the class as shutdown hook via JMX we can't use a static method - this is the reason why this additional method was added.If this class is registered as shutdown hook from a web application a dump to a directory may not be possible because the application server (e.g. Tomcat) has been stopped already the web application instance. This was the problem as described in bugs/37.
In this situation it is not possible to add the class as shutdown hook.
- Specified by:
addMeAsShutdownHook
in interfaceShutdownable
-
removeMeAsShutdownHook
public void removeMeAsShutdownHook()If you want to unregister the instance as shutdown hook you can use this (not static) method.- Specified by:
removeMeAsShutdownHook
in interfaceShutdownable
-