Jakarta RESTful Web Services
{{Short description|Jakarta EE specification}}
{{Infobox software
| name = Jakarta RESTful Web Services (JAX-RS)
| screenshot =
| caption =
| author = Sun Microsystems
| developer = Eclipse Foundation
| latest release version = 3.1.9
| latest release date = {{Start date and age|2024|10|17}}
| latest preview version =
| latest preview date =
| operating system = Cross-platform
| platform = Java
| programming language = Java
| genre = Application framework
| license = EPL 2.0 or GPL v2 w/Classpath exception
| website = {{Official URL}}
}}
Jakarta RESTful Web Services, (JAX-RS; formerly Java API for RESTful Web Services) is a Jakarta EE API specification that provides support in creating web services according to the Representational State Transfer (REST) architectural pattern.Hadley, p. 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 {{mono|web.xml}} deployment descriptor is required.
Specification
JAX-RS provides some annotations to aid in mapping a resource class (a POJO) as a web resource. The annotations use the Java package jakarta.ws.rs
(previously was javax.ws.rs
but was renamed on May 19, 2019{{cite web|url=https://github.com/eclipse-ee4j/jaxrs-api/commit/e06f5fe15462550887967483b0114fd23f2c972f#diff-ff5bd7d61ca9a56ff62b1cda910659282ebcb2b2830a80fe34f78e4e19bd2c0d|title=Rename package commit on Github |website=GitHub}}). They include:
@Path
specifies the relative path for a resource class or method.@GET
,@POST
,@PUT
,@PATCH
(since JAX-RS 2.1),@DELETE
,@HEAD
and@OPTIONS
(since JAX-RS 1.1) specify the HTTP request type of a resource.@Produces
specifies the response Internet media types (used for content negotiation).@Consumes
specifies the accepted request Internet 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 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
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.{{cite web |url=http://jcp.org/en/jsr/detail?id=339 |title=JSR 339: JAX-RS 2.0: The Java API for RESTful Web Services |website=Java Community Process}}
On 2017-08-22 JAX-RS 2.1{{cite web |url=http://jcp.org/en/jsr/detail?id=370 |title=JSR 370: Java API for RESTful Web Services (JAX-RS 2.1) Specification |website=Java Community Process}} specification final release was published.
Main new supported features include
reactive clients,
and JSON-B.{{cite web |url=http://jcp.org/en/jsr/detail?id=367 |title=JSR 367: Java API for JSON Binding (JSON-B) |website=Java Community Process}}
Implementations
Implementations of JAX-RS include:{{cite web |first=Mark |last=Little |url=http://www.infoq.com/news/2008/10/jaxrs-comparison |title=A Comparison of JAX-RS Implementations |date=October 1, 2008}}
- Apache CXF, an open source Web service framework
- Jersey, the reference implementation from Sun (now Oracle)
- [http://www.jboss.org/resteasy RESTeasy], JBoss's implementation
- Restlet
- WebSphere Application Server from IBM:
- Version 7.0: via the [http://www-01.ibm.com/software/webservers/appserv/was/featurepacks/cea/index.html "Feature Pack for Communications Enabled Applications"]
- Version 8.0 onwards: natively
- WebLogic Application Server from Oracle, see [http://docs.oracle.com/cd/E24329_01/web.1211/e24963/standards.htm#g1090347 notes]
- Apache Tuscany (http://tuscany.apache.org/documentation-2x/sca-java-bindingrest.html), discontinued
- Cuubez framework (https://web.archive.org/web/20190707005602/http://cuubez.com/)
- [https://github.com/codenvy/everrest/wiki Everrest], Codenvy's Implementation
- [http://jello-framework.com Jello-Framework], Java Application Framework optimized for Google App Engine, including a powerful RESTful engine and comprehensive Data Authorization model.
- Apache TomEE, an addition to Apache Tomcat
References
{{Reflist}}
- Hadley, Marc and Paul Sandoz, eds. (September 17, 2009). [http://jcp.org/en/jsr/detail?id=311 JAX-RS: Java API for RESTful WebServices] (version 1.1), Java Community Process
External links
- {{Official website}}
= Tutorials =
- https://javabrains.io/courses/javaee_jaxrs/ {{Webarchive|url=https://web.archive.org/web/20190525125521/https://javabrains.io/courses/javaee_jaxrs/ |date=2019-05-25 }}
- 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/
{{Jakarta EE}}
{{Jakarta RESTful Web Services}}