Class ServerLifecycleHook

java.lang.Object
com.mastfrog.acteur.server.ServerLifecycleHook

public abstract class ServerLifecycleHook extends Object
Implement and bind as an eager singleton if you have code that should run only in the case of (and after) the server is started.

Note: in the case you start the server instance repeatedly on several ports (say, ssl and non ssl), initialization code is run once the first port is opened.

A hook may throw an exception, which will be logged via the usual mechanism (ApplicationControl.internalOnError()). This will not prevent other hooks from being called.

Author:
Tim Boudreau
  • Constructor Details

  • Method Details

    • onStartup

      protected abstract void onStartup(Application application, io.netty.channel.Channel channel) throws Exception
      Called when the first server channel (socket) is opened.
      Parameters:
      application - The application
      channel - The server socket channel
      Throws:
      Exception - If something goes wrong
    • onShutdown

      protected void onShutdown() throws Exception
      Called immediately after shutdown, when the server socket is closed.
      Throws:
      Exception