Class ShutdownHookUtil


  • public class ShutdownHookUtil
    extends Object
    Utils class for dealing with JVM shutdown hooks.
    • Method Detail

      • addShutdownHook

        public static Thread addShutdownHook​(AutoCloseable service,
                                             String serviceName,
                                             org.slf4j.Logger logger)
        Adds a shutdown hook to the JVM and returns the Thread, which has been registered.
      • addShutdownHookThread

        public static boolean addShutdownHookThread​(Thread shutdownHook,
                                                    String serviceName,
                                                    org.slf4j.Logger logger)
        Adds a shutdown hook to the JVM.
        Parameters:
        shutdownHook - Shutdown hook to be registered.
        serviceName - The name of service.
        logger - The logger to log.
        Returns:
        Whether the hook has been successfully registered.
      • removeShutdownHook

        public static void removeShutdownHook​(Thread shutdownHook,
                                              String serviceName,
                                              org.slf4j.Logger logger)
        Removes a shutdown hook from the JVM.