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 Details

    • onShutdown

      static ManagedShutdownListener onShutdown(ManagedShutdownListener managedShutdownListener)
      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

      void onShutdown() throws Exception
      Stops the object. Called after the application is no longer accepting requests. Will be invoked by stop().
      Throws:
      Exception - if something goes wrong.
    • start

      default void start()
      Specified by:
      start in interface io.dropwizard.lifecycle.Managed
    • stop

      default void stop() throws Exception
      Specified by:
      stop in interface io.dropwizard.lifecycle.Managed
      Throws:
      Exception