In the Undertow documentation, the following example is presented as a very simple server:
public class HelloWorldServer {
public static void main(final String[] args) {
Undertow server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(new HttpHandler() {
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.getResponseSender().send("Hello World");
}
}).build();
server.start();
}
}
How does this server shutdown? There is a server.stop()
method that presumably would shutdown the server gracefully, but it is not used in this example. Should there be a shutdown hook associated with the runtime that would call the server.stop()
method?