Package io.dropwizard.lifecycle
Class AutoCloseableManager
java.lang.Object
io.dropwizard.lifecycle.AutoCloseableManager
- All Implemented Interfaces:
Managed
An implementation of the Managed Interface for
AutoCloseable instances. Adding an
AutoCloseableManager instance to the application's environment ties that object’s lifecycle to
that of the application’s HTTP server. After the server has stopped (and after its graceful
shutdown period) the stop() method is called, which will trigger the call to AutoCloseable.close()
Usage :
AutoCloseable client = ...;
AutoCloseableManager clientManager = new AutoCloseableManager(client);
environment.lifecycle().manage(clientManager);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidstop()CallsAutoCloseable.close()on the closable provided inAutoCloseableManager(AutoCloseable).
-
Constructor Details
-
AutoCloseableManager
- Parameters:
autoCloseable- instance to close when the HTTP server stops.
-
-
Method Details
-
stop
CallsAutoCloseable.close()on the closable provided inAutoCloseableManager(AutoCloseable).- Specified by:
stopin interfaceManaged- Throws:
Exception- propagatesAutoCloseable.close()exception
-