Example ex09_2: Link Headers

There are two educational goals I want to get across with this
example. The first is the use of Link
headers within a RESTful application. The second is that if your services
provide the appropriate links, you only need one published URL to navigate
through your system. When you look at the client code for this example,
you’ll see that only one URL is hardcoded to start the whole process of
the example.

To illustrate these techniques, a few more additional JAX-RS
services were built beyond the simple customer database example that has
been repeated so many times throughout this book. Chapter 2 discussed the design of an
e-commerce application. This chapter starts the process of implementing
this application by introducing an order-entry RESTful service.

The Server Code

To make it easier to publish Link headers, the Link class from ex09_1 is expanded to add a toString() and valueOf() method: