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

Unlock the full course today

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

Solution: Add resource methods

Solution: Add resource methods

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

Start my 1-month free trial

Solution: Add resource methods

- [Instructor] Okay so how did you get along with that challenge? Well here's my solution. In the book resource class, you can see that I've created a method called update book. This method has the annotation PUT which is a TTP method we need for an update. And I've also defined a consumes and produces annotation as well. Both of them will have the media type Jason. I've also annotated the method with path and I've passed it the regular expression for the ISBN. Now in the method itself, what I've done is to pass in the ISBN as a path parameter into the string ISBN variable as well as the book entity. And the code in the method. What this does is to call the save-book method on the book repository. Past to the save-book method the book entity that's being passed into the update book method. And then the save-book is passed back to the calling client. Let's have a look at the author resource. In the author resource, we have two methods. The first method gets a list of all of the authors…

Contents