JVM 上各种 Web 框架的抽象层 Asity

码农软件 · 软件分类 · Web框架 · 2019-03-24 14:59:32

软件介绍

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

本文地址:https://codercto.com/soft/d/2055.html

模糊数学基础及实用算法

模糊数学基础及实用算法

李鸿吉编 / 科学出版社 / 2005-1 / 55.00元

本书开发了模糊数学常用的计算机程序,并以大量的算例系统地介绍了模糊数学的实用算法。本书可以作为模糊数学的应用程序包,在详细解释源代码的同时,对应用程序开发所用到的Visual Basic 6.0方法做了系统介绍,其目的是为读者做进一步的自主开发提供便利。本书所提供的源程序可以作为读者自主开发的素材。本书配有光盘,分章节提供程序源代码。 本书可以作为大专院校、培训班的教学参考书。对需......一起来看看 《模糊数学基础及实用算法》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

URL 编码/解码
URL 编码/解码

URL 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具