轻量级web容器undertow
所属分类 java
浏览量 1425
Undertow 是红帽公司(RedHat)的开源产品,是 WildFly8(JBoos) 默认的 Web 服务器。
Undertow is a flexible performant web server written in java,
providing both blocking and non-blocking API’s based on NIO.
高性能Web服务器,提供阻塞和非阻塞API。
轻量级,核心jar包不到1Mb
支持嵌入应用运行
undertow-core.jar undertow-servlet.jar
https://github.com/undertow-io/undertow/releases
io.undertow:undertow-core:2.0.18.Final
import java.util.Date;
import io.undertow.Undertow;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.util.Headers;
public class Hello {
public static void main(final String[] args) {
Undertow server = Undertow.builder()
.addHttpListener(8050, "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,"+new Date());
}
}).build();
server.start();
}
}
完整例子工程
https://gitee.com/dyyx/hellocode/tree/master/project/undertow
上一篇
下一篇
aerospike写入失败处理queue too deep
aerospike写块大小设置FAQ
五大最佳开源java性能监控工具
aerospike数据分布
图论术语表
zookeeper的一些缺点