【RESTEasy 介紹】

lijieshare發表於2018-01-30

RESTEasy is a JBoss project that 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是JBoss的開源專案之一,是一個RESTful Web Services框架,RESTEasy的開發者Bill Burke同時也是JAX-RS的J2EE標準制定者之一。JAX-RS是一個JCP制訂的新標準,用於規範基於HTTP的RESTful Web Services的API。

RESTEasy相對SOAP來說,REST比SOAP更具優勢,架構比SOA更簡單輕便。

 

 

常用註解

RESTEasy以jaxrs-api.jar包為基礎對JAX-RS進行實現,該包中包含了JAX-RS規範所宣告的註解。

 

註解列表

註解 描述 引數

@ApplicationPath 標註資源的root路徑,載入子資原始檔 value

@Path 標註普通資源路徑 value

@GET 獲取

@POST 新增

@PUT 整體更新

@PATCH 部分更新(resteasy中並沒有)

@DELETE 刪除

@PathParam 資源路徑引數 value

@QueryParam 資源請求引數 value

@MatrixParam 標註請求資源key-value型別的引數 value

@FormParam 標註表單引數 value

@Encoded 標註需要UrlEncode的元素

@Context 在引數列表注入系統級別引數javax.ws.rs.core.HttpHeaders, javax.ws.rs.core.UriInfo, javax.ws.rs.core.Request, javax.servlet.HttpServletRequest, javax.servlet.HttpServletResponse, javax.servlet.ServletConfig, javax.servlet.ServletContext, and javax.ws.rs.core.SecurityContext objects

@CookieParam 標註需要獲取的cookie引數 value

@Consumes 指定client請求資料型別,與client的Content-Type匹配 value[]

@Produces 指定client接收資料型別,與client的Accept匹配 value[]

@HeaderParam 標註需要獲取的header引數 value

@DefaultValue 標註預設值 value

@Form 標註表單物件,物件中的表單屬性需要@FormParam進行標註

 

 

 

Features

  • Portable to Tomcat and many other app-server
  • Embeddedable server implementation for JUnit testing
  • Enhanced client framework
  • 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, Spring MVC and Spring Boot integration