public interface ShutdownManager
| Modifier and Type | Method and Description |
|---|---|
void |
register(StoppableService service)
Registers a service to be notified when the system shuts down
The ShutdownManager will hold a strong reference to this object, preventing it from being garbage collected until shutdown. |
void |
shutdown()
Request that all registered services perform an orderly shutdown.
|
void register(StoppableService service)
service - the service to register (must not be null)IllegalArgumentException - if the service provided is null, or if this ShutdownManager has already been shutdownvoid shutdown()
StoppableService.shutdown() method on each registered service in the
reverse registration order (that is, the most recently registered service becomes the first to be shutdown).
Before the StoppableService.shutdown() method is called on any StoppableServices, the StoppableService.preShutdown() method will be called on all services in the same order, allowing them to prepare for the
shutdown if they wish.
Services are given an unlimited amount of time to complete their shutdown (although taking a long time to shutdown is not advisable - a user may decide the service has crashed and kill the process).
The shutdown method returns when the shutdown method on each of the StoppableServices has been called and has
returned (whether normally or by throwing an exception)
Copyright © 2016. All rights reserved.