Package com.levigo.jadice.server.core
Class ShutdownWatchdog
- java.lang.Object
-
- com.levigo.jadice.server.core.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 Summary
Fields Modifier and Type Field Description protected org.jadice.util.log.Logger
logger
-
Constructor Summary
Constructors Constructor Description ShutdownWatchdog()
ShutdownWatchdog(int timeout)
Initializes the ShutdownWatchdog with a specified timeout that determines when the shutdown command will be issued after receiving the ContextClosedEvent.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getTimeout()
void
onApplicationEvent(org.springframework.context.ApplicationEvent event)
Listener for ContextClosedEvents.void
setTimeout(int timeout)
-
-
-
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 interfaceorg.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
- Parameters:
event
- an application event.
-
getTimeout
public int getTimeout()
-
setTimeout
public void setTimeout(int timeout)
-
-