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 is server shutdown? There is a method server.stop()
that supposedly shuts down the server gracefully, but it is not used in this example. Should there be a runtime click disconnect click that will invoke the method server.stop()
?
source
share