You are previewing RESTful Java with JAX-RS.

RESTful Java with JAX-RS

Cover of RESTful Java with JAX-RS by Bill Burke Published by O'Reilly Media, Inc.

Chapter 17. Examples for Chapter 4

Chapter 4 discussed three things. First, it mentions how the annotation works and how to define and bind Java methods to new HTTP methods. Next, the chapter talks about the intricacies of the @Path annotation. It explains how you can use complex regular expressions to define your application’s published URIs. Finally, the chapter goes over the concept of subresource locators.

This chapter walks you through three different example programs that you can build and run to illustrate the concepts in Chapter 4. The first example uses @HttpMethod to define a new HTTP method called PATCH. The second example expands on the customer service database example from Chapter 16 by adding some funky regular expression mappings with @Path. The third example implements the subresource locator example shown in Full Dynamic Dispatching in Chapter 4.

Example ex04_1: HTTP Method Extension

This example shows you how your JAX-RS services can consume HTTP methods other than the common standard ones defined in HTTP 1.1. Specifically, the example implements the PATCH method. The PATCH method was originally mentioned in an earlier draft version of the HTTP 1.1 specification:[27]

The PATCH method is similar to PUT except that the entity contains a list of differences between the original version of the resource identified by the Request-URI and the desired content of the resource after the PATCH action has been applied.

The idea of PATCH is that instead ...

The best content for your career. Discover unlimited learning on demand for around $1/day.