Class ShutdownWatchdog

  • All Implemented Interfaces:
    EventListener, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>

    public final class ShutdownWatchdog
    extends Object
    implements org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
    An instance of this class has the task to watch out for ContextClosedEvents of an ApplicationContext. Upon receiving a ContextClosedEvent the shutdown watchdog takes care of shutting down the server via a shutdown command.
    • Field Detail

      • logger

        protected final org.jadice.util.log.Logger logger
    • Constructor Detail

      • ShutdownWatchdog

        public ShutdownWatchdog()
      • ShutdownWatchdog

        public ShutdownWatchdog​(int timeout)
        Initializes the ShutdownWatchdog with a specified timeout that determines when the shutdown command will be issued after receiving the ContextClosedEvent.
        Parameters:
        timeout - the timeout after receiving the ContextClosedEvent and before the shutdown command will be executed.
      • ShutdownWatchdog

        public ShutdownWatchdog​(int timeout,
                                Runnable shutdownCommand)
        Initializes the ShutdownWatchdog with a specified timeout that determines when the shutdown command will be issued after receiving the ContextClosedEvent.
        Parameters:
        timeout - the timeout after receiving the ContextClosedEvent and before the shutdown command will be executed.
        shutdownCommand - the shutdown command that is intended to be executed after the timeout passed.
    • Method Detail

      • onApplicationEvent

        public void onApplicationEvent​(org.springframework.context.ApplicationEvent event)
        Listener for ContextClosedEvents.
        Specified by:
        onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
        Parameters:
        event - an application event.
      • getTimeout

        public int getTimeout()
      • setTimeout

        public void setTimeout​(int timeout)