public class DefaultShutdownCallbackRegistry extends Object implements ShutdownCallbackRegistry, LifeCycle, Runnable, Serializable
Runtime.addShutdownHook(Thread). If no strategy is specified,
this one is used for shutdown hook registration.LifeCycle.State| Modifier and Type | Field and Description |
|---|---|
protected static Logger |
LOGGER |
SHUTDOWN_CALLBACK_REGISTRY, SHUTDOWN_HOOK_ENABLED, SHUTDOWN_HOOK_MARKER| Modifier | Constructor and Description |
|---|---|
|
DefaultShutdownCallbackRegistry()
Constructs a DefaultShutdownRegistrationStrategy.
|
protected |
DefaultShutdownCallbackRegistry(ThreadFactory threadFactory)
Constructs a DefaultShutdownRegistrationStrategy using the given
ThreadFactory. |
| Modifier and Type | Method and Description |
|---|---|
Cancellable |
addShutdownCallback(Runnable callback)
Adds a Runnable shutdown callback to this class.
|
LifeCycle.State |
getState()
Gets the life-cycle state
|
boolean |
isStarted()
Indicates if this can accept shutdown hooks.
|
boolean |
isStopped() |
void |
run()
Executes the registered shutdown callbacks.
|
void |
start()
Registers the shutdown thread only if this is initialized.
|
void |
stop()
Cancels the shutdown thread only if this is started.
|
protected static final Logger LOGGER
public DefaultShutdownCallbackRegistry()
protected DefaultShutdownCallbackRegistry(ThreadFactory threadFactory)
ThreadFactory.threadFactory - the ThreadFactory to use to create a Runtime shutdown hook threadpublic void run()
public Cancellable addShutdownCallback(Runnable callback)
ShutdownCallbackRegistryaddShutdownCallback in interface ShutdownCallbackRegistrycallback - the shutdown callback to be executed upon shutdown.null if the shutdown hook is disabled and
cannot be added.public void start()
public void stop()
public LifeCycle.State getState()
LifeCyclepublic boolean isStarted()
Copyright © 1999-2021 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.