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.

Add HATEOAS to the resource

Add HATEOAS to the resource

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

Start my 1-month free trial

Add HATEOAS to the resource

- [Instructor] Okay, so let's start by creating the link resource class. This class represents a link to a URI endpoint, such as self or delete. And then create the class here in the domain. I'm gonna call this class LinkResource. This is a simple class and requires only three fields. The first field is going to be called rel, and this is the name of a logical relationship. The next field is going to be called type and this is going to be the HTTP method type, so we get to post or delete. And the final field is going to be a URI field. We're just going to call this URI. Okay. We're gonna now add a xmlRootElement annotation to the class and we're going to auto generate our getters and setters like so. I'm also going to add a constructor. I'm gonna auto generate the constructor. What I'm going to do is make this constructor accept a link object, and you'll see why in a moment. From the link object we're going to get the data we need in order to construct our hypermedia data. So link…

Contents