Java API for RESTful Web Services

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Java API for RESTful Web Services (JAX-RS)
Developer(s)Oracle Corporation (initial code from Sun Microsystems)
Stable release
2.1.6 / September 10, 2019 (2019-09-10)
Written inJava
Operating systemCross-platform
PlatformJava Virtual Machine
TypeApplication framework
LicenseCDDL v1.1 and GPL v2
Websitegithub.com/jax-rs

Jakarta RESTful Web Services, (JAX-RS) is a Java programming language API spec that provides support in creating web services according to the Representational State Transfer (REST) architectural pattern.[1] JAX-RS uses annotations, introduced in Java SE 5, to simplify the development and deployment of web service clients and endpoints.

From version 1.1 on, JAX-RS is an official part of Java EE 6. A notable feature of being an official part of Java EE is that no configuration is necessary to start using JAX-RS. For non-Java EE 6 environments a small entry in the web.xml deployment descriptor is required. The project was previously named "Java API for RESTful Web Services", and was renamed and moved to the Eclipse Foundation, under the Jakarta EE banner, in April 2019.

Specification[edit]

JAX-RS provides some annotations to aid in mapping a resource class (a POJO) as a web resource. The annotations use the Java package javax.ws.rs. They include:

In addition, it provides further annotations to method parameters to pull information out of the request. All the @*Param annotations take a key of some form which is used to look up the value required.

  • @PathParam binds the method parameter to a path segment.
  • @QueryParam binds the method parameter to the value of an HTTP query parameter.
  • @MatrixParam binds the method parameter to the value of an HTTP matrix parameter.
  • @HeaderParam binds the method parameter to an HTTP header value.
  • @CookieParam binds the method parameter to a cookie value.
  • @FormParam binds the method parameter to a form value.
  • @DefaultValue specifies a default value for the above bindings when the key is not found.
  • @Context returns the entire context of the object (for example @Context HttpServletRequest request).

JAX-RS 2.0[edit]

In January 2011 the JCP formed the JSR 339 expert group to work on JAX-RS 2.0. The main targets are (among others) a common client API and support for Hypermedia following the HATEOAS-principle of REST. In May 2013, it reached the Final Release stage.[2]

On 2017-08-22 JAX-RS 2.1[3] specification final release was published. Main new supported features include server-sent events, reactive clients, and JSON-B [4].

Implementations[edit]

Implementations of JAX-RS include:[5]

Tutorials[edit]

References[edit]

  1. ^ Hadley, p. 1.
  2. ^ "JSR 339: JAX-RS 2.0: The Java API for RESTful Web Services". Java Community Process.
  3. ^ "JSR 370: Java API for RESTful Web Services (JAX-RS 2.1) Specification". Java Community Process.
  4. ^ "JSR 367: Java API for JSON Binding (JSON-B)". Java Community Process.
  5. ^ Little, Mark (October 1, 2008). "A Comparison of JAX-RS Implementations".