Jakarta RESTful Web Services
| Company type | API standard |
|---|---|
| Industry | Software, Web services |
| Predecessor | Java API for RESTful Web Services |
| Founder | Sun Microsystems |
Area served | Worldwide |
| Products | RESTful web services API |
| Owner | Eclipse Foundation |
Jakarta RESTful Web Services (JAX-RS; previously known as Java API for RESTful Web Services) is a Jakarta EE API standard designed to facilitate the development of web services that adhere to the Representational State Transfer (REST) architectural style. Originally created by Sun Microsystems and currently overseen by the Eclipse Foundation, JAX-RS leverages annotations introduced in Java SE 5 to streamline both the creation and deployment of web service endpoints and clients.
Starting with version 1.1, JAX-RS has been integrated into Java EE 6 as a standard component, allowing compliant platforms to launch with no configuration needed. For environments that do not support Java EE 6, a small amount of setup is necessary.
Specification
The JAX-RS specification offers a set of annotations within the jakarta.ws.rs package (which replaced javax.ws.rs in 2019) that bind Plain Old Java Object (POJO) resource classes to web resources. Notable annotations include:
@Path: assigns a relative URI path to a resource class or method.- HTTP method annotations:
@GET,@POST,@PUT,@PATCH(introduced in 2.1),@DELETE,@HEAD, and@OPTIONS(available since 1.1). @Produces: indicates the media types that the resource can return.@Consumes: defines the media types accepted by the resource.
Parameter annotations are used to extract specific parts of incoming requests:
@PathParam,@QueryParam,@MatrixParam,@HeaderParam,@CookieParam, and@FormParamlink method parameters to corresponding request components.@DefaultValue: provides fallback values when parameters are absent.@Context: injects contextual information such as HTTP request objects.
These capabilities enhance the efficiency of building RESTful services within enterprise Java platforms.
JAX-RS 2.0
In January 2011, the Java Community Process established the JSR 339 expert group tasked with creating JAX-RS 2.0, emphasizing a unified client API and support for Hypermedia following the HATEOAS constraint of REST. The specification was officially released in May 2013.
The JAX-RS 2.1 update was completed on August 22, 2017, adding functionalities such as server-sent events, reactive client support, and integration with JSON-B.
Implementations
Prominent implementations of JAX-RS encompass:
- Apache CXF, an open source Web service framework
- Jersey, serving as the reference implementation originally from Sun (now under Oracle)
- RESTeasy, developed by JBoss
- Restlet
- WebSphere Application Server by IBM:
- Available via "Feature Pack for Communications Enabled Applications" in version 7.0
- Included natively from version 8.0 onward
- WebLogic Application Server by Oracle
- Apache Tuscany (no longer maintained)
- Cuubez framework
- Everrest, Codenvy's implementation
- Jello-Framework, tailored for Google App Engine with features including a RESTful engine and data authorization
- Apache TomEE, an extension built on top of Apache Tomcat
External links
Tutorials
- https://javabrains.io/courses/javaee_jaxrs/
- http://docs.oracle.com/javaee/6/tutorial/doc/giepu.html
- http://www.vogella.com/tutorials/REST/article.html
- http://www.mkyong.com/tutorials/jax-rs-tutorials/
- http://www.coderpanda.com/jax-rs-tutorial/
- https://www.javavogue.com/2015/03/java-jerseyjax-rs-tutorials/
- http://howtodoinjava.com/restful-web-service/
- https://jakarta.ee/learn/starter-guides/how-to-build-a-restful-web-service/
- https://jakarta.ee/learn/starter-guides/how-to-secure-a-restful-web-service/
- https://jakarta.ee/learn/docs/jakartaee-tutorial/current/websvcs/rest/rest.html
- https://jakarta.ee/learn/specification-guides/restful-web-services-explained/