undertow提供了blocking和non-blocking两种api,灵活高性能的服务器框架。

特点

  • 轻量级

  • 嵌入式

  • 灵活

  • 支持Websocket

  • 支持Servlet 3.1

  • 支持HTTP2

Demo code

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();
    }
}

更多example

更多特性待续……

Releated

undertow website
undertow cookdoc

undertow doc

github

issue