AsityJVM 上各种 Web 框架的抽象层
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
评论
AuthenticRoastJava Web层验证框架
AuthenticRoast让你建立高度灵活的JavaWeb层验证机制。包括HTTP基本身份验证与OpenID身份验证、facebook或您公司的Kerberos设置。验证模块可合并起来,甚至在将在运
AuthenticRoastJava Web层验证框架
0
PyFilesystemPython 文件系统抽象层
PyFilesystem 是一个为所有文件系统提供的通用 Pythonic接口。它是文件系统的抽象层,任何包含文件和目录的东西(硬盘,压缩文件,FTP服务器等等)都可以封装成一个共同的接口。使用这个模
PyFilesystemPython 文件系统抽象层
0
DBSlayer数据库抽象层
DBSlayer是一个轻量级的用于高负荷的网站的数据库抽象层,基于HTTP+JSON协议,当你需要一个可伸缩的连接池时,你会需要用到DBSplayer。DBSlayer采用C语言编写,具有非常高的性能
DBSlayer数据库抽象层
0
Dratini简洁的网络抽象层
Dratini是一个简洁的网络抽象层。通过编写Class/Struct来描述Request和Response;使用Block监听Response,通过requestID监听单一Response,通过类
Dratini简洁的网络抽象层
0
GaufrettePHP文件系统抽象层
Gaufrette提供了一个文件系统的抽象层的PHP5库。它使得以相同方式操控本地文件,FTP服务器,亚马逊S3等等。它允许你开发程序时,不用了解未来你将怎么访问你的文件。示例代码:<?phpu
GaufrettePHP文件系统抽象层
0