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