Package com.mastfrog.acteur.server
Class ServerLifecycleHook
java.lang.Object
com.mastfrog.acteur.server.ServerLifecycleHook
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
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCalled immediately after shutdown, when the server socket is closed.protected abstract voidonStartup(Application application, io.netty.channel.Channel channel) Called when the first server channel (socket) is opened.
-
Constructor Details
-
ServerLifecycleHook
-
-
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 applicationchannel- The server socket channel- Throws:
Exception- If something goes wrong
-
onShutdown
Called immediately after shutdown, when the server socket is closed.- Throws:
Exception
-