Spring RestTemplate 与 Jersey Rest Client 与 RestEasy 客户端 [英] Spring RestTemplate Vs Jersey Rest Client Vs RestEasy Client

查看:44
本文介绍了Spring RestTemplate 与 Jersey Rest Client 与 RestEasy 客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于来自客户端应用程序的异步 REST API 调用,推荐使用这些实现中的哪一种并且更健壮?

Which one of these implementation is recommended for asynchronous rest API calls from client applications and also more robust?

  1. Sprint 休息模板
  2. 泽西岛休息客户端
  3. 放心的客户

推荐答案

这里有一些指向文档和示例的链接,以帮助您按照我的个人建议从最佳到最佳的降序评估每个客户必须提供的服务常见的以及一些指向我发现的其他比较的链接.

Here are Some links to documentations and examples in order to help you evaluate what each client has to offer from in descending order of my personal recommendation from the best to the common and some links to other comparisons that I have found.

  1. RESTEasy 是一个 JBoss 项目 是我的第一选择,因为它有 缓存特性:客户端浏览器"缓存.支持 HTTP 1.1 缓存语义,包括对性能有巨大影响的缓存重新验证,而其他客户端实现不提供开箱即用的缓存,您需要编写额外的代码来获取它.RESTEasy 提供了各种框架来帮助您构建 RESTful Web 服务和 RESTful Java 应用程序.它是 JAX-RS 2.0 规范的完全认证和可移植实现,JCP 规范通过 HTTP 协议为 RESTful Web 服务提供 Java API.
  1. RESTEasy is a JBoss project is my first selection since it has Caching Features: Client "Browser" cache. Supports HTTP 1.1 caching semantics including cache revalidation that has huge impact on performance while other client implementations do not provide caching out of the box and you need to write extra code to get it. RESTEasy provides various frameworks to help you build RESTful Web Services and RESTful Java applications. It is a fully certified and portable implementation of the JAX-RS 2.0 specification, a JCP specification that provides a Java API for RESTful Web Services over the HTTP protocol.

RESTEasy 功能列表

RESTEasy Features List

  • Portable to Tomcat and many other app-server
  • Embeddedable server implementation for JUnit testing
  • Enhanced client framework
  • Caching Features: Client "Browser" cache. Supports HTTP 1.1 caching semantics including cache revalidation
  • Server in-memory cache. Local response cache. Automatically handles ETag generation and cache revalidation
  • Rich set of providers for: XML, JSON, YAML, Fastinfoset, Multipart, XOP, Atom, etc.
  • JAXB marshalling into XML, JSON, Jackson, Fastinfoset, and Atom as well as wrappers for maps, arrays, lists, and sets of JAXB Objects.
  • GZIP content-encoding
  • Asynchronous HTTP (Comet) abstractions for JBoss Web, Tomcat 6, and Servlet 3.0
  • Asynchronous Job Service.
  • Rich interceptor model.
  • OAuth2 and Distributed SSO with JBoss AS7
  • Digital Signature and encryption support with S/MIME and DOSETA
  • EJB, Seam, Guice, Spring, and Spring MVC integration
  • There was no RESTEasy Spring Boot starter out there, so PayPal team decided to create RESTEasy Spring Boot Starter and share it with the community.

RESTEasy 示例另见 RESTEasy Client 的三种形式

RESTEasy examples see also Three Forms of RESTEasy Client

  1. Jersey RESTful Web 服务框架是开源的、生产质量的、用于在 Java 中开发 RESTful Web 服务的框架提供对 JAX-RS API 的支持,并用作 JAX-RS (JSR 311 & JSR 339) 参考实现.
  1. Jersey RESTful Web Services framework is open source, production quality, framework for developing RESTful Web Services in Java that provides support for JAX-RS APIs and serves as a JAX-RS (JSR 311 & JSR 339) Reference Implementation.

Jersey 框架不仅仅是 JAX-RS 参考实现.Jersey 提供自己的 API,通过附加功能和实用程序扩展 JAX-RS 工具包,以进一步简化 RESTful 服务和客户端开发.Jersey 还公开了许多扩展 SPI,以便开发人员可以扩展 Jersey 以最适合他们的需求.

Jersey framework is more than the JAX-RS Reference Implementation. Jersey provides it’s own API that extend the JAX-RS toolkit with additional features and utilities to further simplify RESTful service and client development. Jersey also exposes numerous extension SPIs so that developers may extend Jersey to best suit their needs.

泽西岛项目的目标可以概括为以下几点:

Goals of Jersey project can be summarized in the following points:

  • 跟踪 JAX-RS API 并定期发布 GlassFish 附带的生产质量参考实现;
  • 提供 API 以扩展 Jersey &建立用户和开发者社区;以及 - 使用 Java 和 Java 虚拟机轻松构建 RESTful Web 服务.

有几个 Jersey 连接器可供选择,请参阅第 5 章.客户端 API5.5.客户端传输连接器而 Grizzly 看起来是最先进的,尤其是因为它使用 NIO 框架来帮助开发人员利用Java™ NIO API 参见 java.net 与 java.nioAsyncHttpClient progect 可能拥有您所需要的一切.

There are several Jersey Connectors to choose from see Chapter 5. Client API 5.5. Client Transport Connectors while Grizzly looks like the most advanced especially since it is using the NIO framework to help developers to take advantage of the Java™ NIO API see java.net versus java.nio it was used with AsyncHttpClient progect that might have all you need.

默认情况下,Jersey 中的传输层由 HttpUrlConnection 提供.这种传输是通过 HttpUrlConnectorProvider 在 Jersey 中实现的,HttpUrlConnectorProvider 实现了 Jersey 特定的连接器 SPI.您可以实现和/或注册您自己的连接器实例到 Jersey 客户端实现,这将替换默认的基于 HttpUrlConnection 的传输层.Jersey 提供了几种现成的备用客户端传输连接器实现.

By default, the transport layer in Jersey is provided by HttpUrlConnection. This transport is implemented in Jersey via HttpUrlConnectorProvider that implements Jersey-specific Connector SPI. You can implement and/or register your own Connector instance to the Jersey Client implementation, that will replace the default HttpUrlConnection-based transport layer. Jersey provides several alternative client transport connector implementations that are ready-to-use.

表 5.1.泽西岛连接器列表传输框架 Jersey Connector 实现 Maven 依赖

Table 5.1. List of Jersey Connectors Transport framework Jersey Connector implementation Maven dependency

  • Grizzly NIO framework GrizzlyConnectorProvider org.glassfish.jersey.connectors:jersey-grizzly-connector
  • Apache HTTP client ApacheConnectorProvider org.glassfish.jersey.connectors:jersey-apache-connector
  • Jetty HTTP client JettyConnectorProvider org.glassfish.jersey.connectors:jersey-jetty-connector
  • Netty NIO framework NettyConnectorProvider org.glassfish.jersey.connectors:jersey-netty-connector

Jersey 与 RESTEasy:JAX-RS 实现比较

  1. Spring RestTemplate 或异步 rest API 调用 AsyncRestTemplate 参见 Spring 4 AsyncRestTemplate + ListenableFuture 示例 是默认的 Spring Boot starter Restful api.在 PayPal 团队决定创建 RESTEasy Spring Boot Starter 之前,还没有 RESTEasy Spring Boot starter.并与社区分享.
  1. Spring RestTemplate or for asynchronous rest API calls AsyncRestTemplate see Spring 4 AsyncRestTemplate + ListenableFuture Example is the default Spring Boot starter Restful api. There was no RESTEasy Spring Boot starter out there until PayPal team decided to create RESTEasy Spring Boot Starter and share it with the community.

这篇关于Spring RestTemplate 与 Jersey Rest Client 与 RestEasy 客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆