From the course: Java EE: RESTful Service with JAX-RS 2.0

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Implement HATEOAS

Implement HATEOAS

From the course: Java EE: RESTful Service with JAX-RS 2.0

Start my 1-month free trial

Implement HATEOAS

- [Instructor] To use HATEOAS, we need to make changes to the server and to the client applications. In the server application, what we need to do is to add a delete method that responds to the request to delete a resource on a specific URI. Also we need to HATEOAS-enable the get all books method. Let's open up the book resources class. Let's go to the get all books method. In this class, all we need to do is to add the same logic that we added to the get book by ISBN. I'm just going to copy that logic, like so. We need to enter that logic in here. We need to iterate over each of the books and add this logic to each book. We'll just create a simple iteration like so, for books, we're going to add hypermedia capability. I've just copied this logic in to this method. I'm deleting the get clause because the object returned from the array is not wrapped in an optional, so in this case, they're not needed. Obviously, in the real application, what you'll do is you'll extract out this logic…

Contents