Package org.digidoc4j

Class ShutdownHook

java.lang.Object
java.lang.Thread
org.digidoc4j.ShutdownHook
All Implemented Interfaces:
Runnable

public class ShutdownHook extends Thread
Shutdown hook for a clean shutdown

There's a good chance that some non-daemon threads handled by some sort of ExecutorService are preventing JVM from a clean shutdown.

How to use it exactly depends on the situation.

For example when dealing a simple Java "main" program, which has only a single context then registering this hook by Runtime.addShutdownHook(Thread) should be sufficient.

In case of some sort of webapp in a servlet container where there are multiple levels of contexts the recommended way to use it is to register a

invalid reference
jakarta.servlet.ServletContextListener
and call run() method inside
invalid reference
jakarta.servlet.ServletContextListener#contextDestroyed(ServletContextEvent)

NB! As the usage method of this hook is dependant on the system/situation and may vary, so in consequence it's still in experimental status Created by Janar Rahumeel (CGI Estonia)

  • Constructor Details

    • ShutdownHook

      public ShutdownHook()
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread