Class RegistrationLifecycleListener

  • All Implemented Interfaces:
    io.dropwizard.lifecycle.ServerLifecycleListener, EventListener, org.eclipse.jetty.util.component.LifeCycle.Listener

    public class RegistrationLifecycleListener
    extends org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
    implements io.dropwizard.lifecycle.ServerLifecycleListener
    Listener that registers and deregisters the service based on server start up and shutdown events. Note: This class implements the ServerLifecycleListener which is part of Dropwizard to provide access once Dropwizard has finished starting the server. This class also extends AbstractLifeCycle.AbstractLifeCycleListener from Jetty (which Dropwizard uses under the covers) to provide access when the server is starting to shutdown. To use this class you may have to register this listener in the following ways to get both actions:
      var listener = new RegistrationLifecycleListener(manager);
    
      // Registers the startup with dropwizard
      environment.lifecycle().addServerLifecycleListener(listener);
    
      // Registers the shutdown with Jetty
      environment.lifecycle().addLifecycleListener(listener);
     
    • Method Detail

      • serverStarted

        public void serverStarted​(org.eclipse.jetty.server.Server server)
        Specified by:
        serverStarted in interface io.dropwizard.lifecycle.ServerLifecycleListener
      • lifeCycleStopping

        public void lifeCycleStopping​(org.eclipse.jetty.util.component.LifeCycle event)
        Specified by:
        lifeCycleStopping in interface org.eclipse.jetty.util.component.LifeCycle.Listener
        Overrides:
        lifeCycleStopping in class org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener