Package org.apache.sis.internal.system
Class Shutdown
java.lang.Object
java.lang.Thread
org.apache.sis.internal.system.Shutdown
- All Implemented Interfaces:
Runnable
A central place where to manage SIS shutdown process.
- Since:
- 0.3
- Version:
- 0.7
- Author:
- Martin Desruisseaux (Geomatys), Guilhem Legal (Geomatys)
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturns the value set by the last call tosetContainer(String).static voidRegisters a code to execute at JVM shutdown time, or if SIS library is unloaded from a container such as OSGi.voidrun()Invoked at JVM shutdown time.static voidsetContainer(String env) Invoked if the Apache SIS library is executed from an environment that provide its own shutdown hook.static voidUnregisters the supervisor MBean, executes the disposal tasks and shutdowns thesis-utilitythreads.static voidunregister(Callable<?> resource) Unregisters a code from execution at JVM shutdown time.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
-
Method Details
-
run
public void run()Invoked at JVM shutdown time. -
getContainer
Returns the value set by the last call tosetContainer(String).- Returns:
- typically
"OSGi","Servlet"ornull.
-
setContainer
Invoked if the Apache SIS library is executed from an environment that provide its own shutdown hook. Example of such environments are OSG and servlet containers. In such case, the shutdown hook will not be registered to the JVMRuntime.- Parameters:
env- a description of the container. Should contain version information if possible. Example:"OSGi"or"JavaServer Web Dev Kit/1.0".
-
register
Registers a code to execute at JVM shutdown time, or if SIS library is unloaded from a container such as OSGi. The resources will be disposed at shutdown time in reverse order (most recently added resources disposed first).The same resource shall not be added twice.
- Parameters:
resource- the resource disposal to register for execution at shutdown time.
-
unregister
Unregisters a code from execution at JVM shutdown time. This method uses identity comparison (it does not useObject.equals(Object)).- Parameters:
resource- the resource disposal to cancel execution.
-
stop
Unregisters the supervisor MBean, executes the disposal tasks and shutdowns thesis-utilitythreads. This method may be invoked at JVM shutdown, or if a container like OSGi is unloaded the SIS library.- Parameters:
caller- the class invoking this method, to be used only for logging purpose, ornullif the logging system is not available anymore (i.e. the JVM itself is shutting down).- Throws:
Exception- if an error occurred during unregistration of the supervisor MBean or during a resource disposal.
-