Interface ManagedShutdownListener
- All Superinterfaces:
io.dropwizard.lifecycle.Managed
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface ManagedShutdownListener
extends io.dropwizard.lifecycle.Managed
Functional interface to implement a
Managed
as lambda if only Managed.stop()
should be handled.-
Method Summary
Modifier and TypeMethodDescriptionvoid
Stops the object.static ManagedShutdownListener
onShutdown
(ManagedShutdownListener managedShutdownListener) To be used with lifecycle manage to avoid casting.default void
start()
default void
stop()
-
Method Details
-
onShutdown
To be used with lifecycle manage to avoid casting.environment.lifecycle().manage(onShutdown(myResource::close));
environment.lifecycle().manage(onShutdown(() -> {resourceA.close(); resourceB.close;}));
- Parameters:
managedShutdownListener
- the consumer to call on application shutdown after no more requests are accepted- Returns:
- the given
managedShutdownListener
-
onShutdown
Stops the object. Called after the application is no longer accepting requests. Will be invoked bystop()
.- Throws:
Exception
- if something goes wrong.
-
start
default void start()- Specified by:
start
in interfaceio.dropwizard.lifecycle.Managed
-
stop
- Specified by:
stop
in interfaceio.dropwizard.lifecycle.Managed
- Throws:
Exception
-