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
From the course: Java EE: RESTful Service with JAX-RS 2.0
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Define the REST contract3m 42s
-
Inheritance or XML configuration3m 25s
-
Define the API root3m 14s
-
Create the resource entity5m 37s
-
Create the resource methods6m 16s
-
Path parameters2m 35s
-
Add path paramaters3m 21s
-
@Consumes and @Produces2m 7s
-
Add the media types4m 56s
-
Challenge: Add resource methods31s
-
Solution: Add resource methods1m 56s
-
-
-
-
-