Java API for RESTful Web Services
JAX-RS: Java API for RESTful Web Services is a Java programming language API that provides support in creating web services according to the Representational State Transfer (REST) architectural style.[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.
Contents |
[edit] Specification
JAX-RS provides some annotations to aid in mapping a resource class (a POJO) as a web resource. The annotations include:
- @Path specifies the relative path for a resource class or method.
- @GET, @PUT, @POST, @DELETE and @HEAD specify the HTTP request type of a resource.
- @Produces specifies the response MIME media types.
- @Consumes specifies the accepted request media types.
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 parameter to a path segment.
- @QueryParam binds the parameter to the value of an HTTP query parameter.
- @MatrixParam binds the parameter to the value of an HTTP matrix parameter.
- @HeaderParam binds the parameter to an HTTP header value.
- @CookieParam binds the parameter to a cookie value.
- @FormParam binds the parameter to a form value.
- @DefaultValue specifies a default value for the above bindings when the key is not found.
[edit] JAX-RS 2.0
In January 2011 the JCP formed an expert group [1] 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. The reference implementation will be provided by the team surrounding Oracle's Paul Sandoz, after the former specification lead Marc Hadley had left Oracle shortly before. Public release (GA) is planned for spring 2012.
[edit] Implementation
Implementations of JAX-RS include:[2]
- Apache CXF, an open source Web service framework.
- Jersey, the reference implementation from Sun (now Oracle).
- RESTEasy, JBoss's implementation.
- Restlet, created by Jerome Louvel, a pioneer in REST frameworks.
- Apache Wink, Apache Software Foundation Incubator project, the server module implements JAX-RS.
[edit] Jersey
According to the Java EE 6 Tutorial, Volume 1: Jersey is Sun's production quality reference implementation for JSR 311: JAX-RS: The Java API for RESTful Web Services. Jersey implements support for the annotations defined in JSR-311, making it easy for developers to build RESTful web services with Java and the Java JVM. Jersey also adds additional features not specified by the JSR.[3]
[edit] Notes
- ^ Hadley, p. 1.
- ^ Mark Little, A Comparison of JAX-RS Implementations
- ^ Building RESTful Web Services with JAX-RS and Jersey
[edit] References
- Hadley, Marc and Paul Sandoz, eds. (September 17, 2009). JAX-RS: Java API for RESTful WebServices (version 1.1), Sun Microsystems, Inc.
[edit] External links
- JAX-RS specification page
- Jersey - open source JAX-RS Reference Implementation
- JSR 311 project
- RESTful Java with JAX-RS by Bill Burke on Google Books
- - Build a RESTful Web Service using the Restlet framework
[edit] See also
|
|||||||||||||||||||||||||
|
|||||