You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Neither the web server doc nor the migration guide explains how the 3.x WebServer.whenShutdown method has been functionally replaced by the ServerLifeCycle.afterStop method (also available via inheritance on Service and Handler).
The regular doc should at least briefly discuss beforeStart and afterStop and the migration guide should discuss how this 3.x construct in the SE QuickStart Main.startServer method
webserver.forSingle(ws -> {
System.out.println("WEB server is up! http://localhost:" + ws.port() + "/greet");
ws.whenShutdown().thenRun(() -> System.out.println("WEB server is DOWN. Good bye!"));
})
.exceptionallyAccept(t -> {
System.err.println("Startup failed: " + t.getMessage());
t.printStackTrace(System.err);
});
can be essentially replaced in 4.x by this in the QuickStart SE Main.main method (for announcing start-up - this code is in the example):
WebServerserver = WebServer.builder()
.config(config.get("server"))
.routing(Main::routing)
.build()
.start();
System.out.println("WEB server is up! http://localhost:" + server.port() + "/simple-greet");
and by this addition to Greeting.java (this snippet is not in the QuickStart example) for announcing shutdown:
@OverridepublicvoidafterStop() {
System.out.println("WEB server is DOWN. Good bye!");
}
(Or, for symmetry, the start-up announcement could be done in a new GreetServicebeforeStart method instead of in Main.main although the semantics of beforeStart are not quite the same as logging a message after invoking WebServer#start.)
The text was updated successfully, but these errors were encountered:
Environment Details
Problem Description
Neither the web server doc nor the migration guide explains how the 3.x
WebServer.whenShutdown
method has been functionally replaced by theServerLifeCycle.afterStop
method (also available via inheritance onService
andHandler
).The regular doc should at least briefly discuss
beforeStart
andafterStop
and the migration guide should discuss how this 3.x construct in the SE QuickStartMain.startServer
methodcan be essentially replaced in 4.x by this in the QuickStart SE
Main.main
method (for announcing start-up - this code is in the example):and by this addition to
Greeting.java
(this snippet is not in the QuickStart example) for announcing shutdown:(Or, for symmetry, the start-up announcement could be done in a new
GreetService
beforeStart
method instead of inMain.main
although the semantics ofbeforeStart
are not quite the same as logging a message after invokingWebServer#start
.)The text was updated successfully, but these errors were encountered: