From the course: Java EE: RESTful Service with JAX-RS 2.0
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
HATEOAS and JAX-RS
From the course: Java EE: RESTful Service with JAX-RS 2.0
HATEOAS and JAX-RS
- [Instructor] Okay, so how do we implement HATEOAS and JAX-RS? Well, there are two ways. The first way is to do exactly what I've explained before, which is to add those links to the resource, itself. But there is an alternative way to communicate those links to the client. And that is to add them to the HTTP header of the response. This is actually the easiest way to HATEOAS enable your API. So, let's look at how to do this. So, in both cases, the code that adds the links to the resource is located in the entity resource class, in the method that actually responds to the request. So, JAX-RS provides a nice build to API that constructs links to resources called link. So, from the link class, call the from URI method and pass it a reference to the base URI. This is obtained by injecting the current request context URI info and from this we call the get base URI builder method. From here, we call the path method and pass it the current class. This reads the path URI for the current…
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
-
-
-
-
-
-
(Locked)
The HTTP response4m 24s
-
(Locked)
Build a response3m 24s
-
(Locked)
How to handle errors3m 19s
-
(Locked)
Implement an exception manager2m 46s
-
(Locked)
Work with HATEOAS4m 21s
-
(Locked)
HATEOAS and JAX-RS2m 59s
-
(Locked)
Add HATEOAS to the resource10m 33s
-
(Locked)
Challenge: Add exception handlers19s
-
(Locked)
Solution: Add exception handlers1m 2s
-
(Locked)
-
-
-