Introduction to Java EE and JAX-RS
JAX-RS is the Java API for RESTful web services, normally shortened to just JAX-RS, and it is Java’s implementation of the REST architectural pattern and provides a simple way to create RESTful APIs. It also provides support for Hypermedia, by following the HATEOAS model.
JAX-RS API History
JAX-RS 1.1 was standardized in Java EE 6 and became an official part of the specification. It was updated in Java EE 7 to release version 2.0, and development continues with a new release planned for Java EE 8. JAX-RS is annotation driven. This is important because it makes it very easy to represent, in code, the elements that form the parts of the REST pattern.
Annotation Driven Design
This means that a class that represents the root of a resource, would be annotated @Path and methods that ‘respond’ to HTTP requests, are annotated appropriately, with annotations that echo the HTTP verb, such as, the @POST annotation for POST requests and the @GET annotation for GET requests.
Reflect RESTful conventions
Likewise, query parameters and path variables are easily accessed with the logically named annotations @QueryParam and @PathParam, and content types are defined using the @Consumes and @Produces annotations.
There’s much more to JAX-RS than just the annotations you see here, but these key concepts to get started.
You can learn to develop client and server application in new JAX-RS 2.0 course while developing a fully functioning bookshop application.
Topics include in the course are:
- Discover the extent of JAX-RS’s features
- Use the annotation methodology
- Use the inheritance methodology
- Define a REST contract and API root
- Create the REST resource entity
- Create the REST resource methods
- Understand consumers and producers
- Work with different media types
- Define and work with path parameters
- Build a REST response and handle exceptions
- Implement Bean Validation and manage failures
- Create a RESTful client that consumes the web service
- Use JSON-P API with the REST client
- Implement hypermedia (HATEOAS)
Why not preview the JAX-RS 2.0 course with a 10-day trial.