- 授权协议: Apache-2.0
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: http://asity.cettia.io/
- 软件文档: https://github.com/cettia/asity
- 官方下载: https://github.com/cettia/asity
软件介绍
Asity
Asity 是 Java 虚拟机上各种 Web 框架的抽象层,可以在 JVM 上构建 Web 框架不可知的应用程序。
Asity 是 Web 框架的一个轻量级抽象层,它被设计用来构建应用程序和框架,这些应用程序和框架可以在 JVM 上的任何全栈框架,任何微型框架或任何原始服务器上运行,而不会降低底层框架的性能。它提供了 HTTP 和 WebSocket 抽象。
HTTP
io.cettia.asity:asity-http 提供 HTTP 抽象,下边是 echo HTTP 服务器示例:
Action<ServerHttpExchange> httpAction = (ServerHttpExchange http) -> {
// Request properties
System.out.println(http.method() + " " + http.uri());
http.headerNames().stream().forEach(name -> System.out.println(name + ": " + http.header(name)));
// Sets 200 OK response status
http.setStatus(HttpStatus.OK);
// Copies the content-type header of the request to the response
http.setHeader("content-type", http.header("content-type"));
// When a chunk is read from the request body, writes it to the response body
http.onchunk((ByteBuffer bytes) -> http.write(bytes));
// When the request is fully read, ends the response
http.onend((Void v) -> http.end());
// Reads the request body as binary to circumvent encoding issue
http.readAsBinary();
// When the response is fully written and ends,
http.onfinish((Void v) -> System.out.println("on finish"));
// When some error happens in the request-response exchange,
http.onerror((Throwable t) -> t.printStackTrace());
// When the underlying connection is terminated,
http.onclose((Void v) -> System.out.println("on close"));
};WebSocket
io.cettia.asity:asity-websocket 提供 WebSocket 抽象,下边是 echo WebSocket 服务器示例:
Action<ServerWebSocket> wsAction = (ServerWebSocket ws) -> {
// Handshake request properties
System.out.println(HttpMethod.GET + " " + ws.uri());
ws.headerNames().stream().forEach(name -> System.out.println(name + ": " + ws.header(name)));
// When a text frame is arrived, sends it back
ws.ontext((String data) -> ws.send(data));
// When a binary frame is arrived, sends it back
ws.onbinary((ByteBuffer bytes) -> ws.send(bytes));
// When some error happens in the connection,
ws.onerror((Throwable t) -> t.printStackTrace());
// When the connection is closed for any reason,
ws.onclose((Void v) -> System.out.println("on close"));
};Bridge
io.cettia.asity:asity-bridge-xxx 是一个处理和转换框架特定资源到 Asity的 ServerHttpExchange 和 ServerWebSocket 的模块。下面这些 Bridge 都是可用的,也就是说基于 Asity 的应用程序或框架可以在以下框架中无缝地运行:
Atmosphere 2
Grizzly 2
Java Servlet 3
Java WebSocket API 1
Netty 4
Spring WebFlux 5
Vert.x 2 and 3
C++ Primer 中文版(第 5 版)
[美] Stanley B. Lippman、[美] Josée Lajoie、[美] Barbara E. Moo / 王刚、杨巨峰 / 电子工业出版社 / 2013-9-1 / CNY 128.00
这本久负盛名的 C++经典教程,时隔八年之久,终迎来史无前例的重大升级。除令全球无数程序员从中受益,甚至为之迷醉的——C++ 大师 Stanley B. Lippman 的丰富实践经验,C++标准委员会原负责人 Josée Lajoie 对C++标准的深入理解,以及C++ 先驱 Barbara E. Moo 在 C++教学方面的真知灼见外,更是基于全新的 C++11标准进行了全面而彻底的内容更新。......一起来看看 《C++ Primer 中文版(第 5 版)》 这本书的介绍吧!
