undertow介绍

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

###特点

  • 轻量级

  • 嵌入式

  • 灵活

  • 支持Websocket

  • 支持Servlet 3.1

  • 支持HTTP2

###Demo code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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