Summary

The REST style API is improved in Version 2.0 for Java EE 7. In this chapter, we covered the essentials of Representational State Transfer, the architectural style of the application.

We saw how to write REST style endpoints for collections of entities and how that progresses to single entities. REST is about the design of URI patterns and templates. We learnt how to configure the servlet mapping for JAX-RS applications.

We built a sample JAX resource endpoint with the HTTP request protocols GET, PUT, POST, and DELETE. We applied the corresponding annotations: @GET, @PUT, @POST, and @DELETE. We mapped URL fragments to JAX-RS server side resources and subresources with the @Path annotation. We configure dynamic behavior through path variable and we are able to extract values from the URI template; and now we can also extract data using the various annotations, such as @QueryParam, and @FormParam.

JAX-RS sub-resources can be configured by location or directly in the same resource. We saw that architecting resources into sub-resources is preferred as best practice, because it separates concerns and leads to better modularity in the code base for the long term; therefore reducing the technical debt and high maintenance.

We explored the new Client API in JAX-RS 2.0 and witnessed how it can help unit test to RESTful endpoints. We understood how to write asynchronous input and output application to leverage another JAX-RS 2.0 feature.

JAX-RS resources have the option to generate custom response using the ResponseBuilder and Response classes. We revealed that JAX-RS Provider instances are the key to extending the runtime and the door to writing custom functionality through server or client side filter, or the entity interceptors.

The next chapter Java Message Service investigates Java EE 7's latest support for sending and receiving data through a messaging system.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.173.242