Package io.dropwizard.lifecycle
Class AutoCloseableManager
- java.lang.Object
-
- io.dropwizard.lifecycle.AutoCloseableManager
-
- All Implemented Interfaces:
Managed
public class AutoCloseableManager extends Object implements Managed
An implementation of the Managed Interface forAutoCloseable
instances. Adding anAutoCloseableManager
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) thestop()
method is called, which will trigger the call toAutoCloseable.close()
Usage :
AutoCloseable client = ...; AutoCloseableManager clientManager = new AutoCloseableManager(client); environment.lifecycle().manage(clientManager);
-
-
Constructor Summary
Constructors Constructor Description AutoCloseableManager(AutoCloseable autoCloseable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
stop()
CallsAutoCloseable.close()
on the closable provided inAutoCloseableManager(AutoCloseable)
.
-
-
-
Constructor Detail
-
AutoCloseableManager
public AutoCloseableManager(AutoCloseable autoCloseable)
- Parameters:
autoCloseable
- instance to close when the HTTP server stops.
-
-
Method Detail
-
stop
public void stop() throws Exception
CallsAutoCloseable.close()
on the closable provided inAutoCloseableManager(AutoCloseable)
.- Specified by:
stop
in interfaceManaged
- Throws:
Exception
- propagatesAutoCloseable.close()
exception
-
-