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.
Define the API root
From the course: Java EE: RESTful Service with JAX-RS 2.0
Define the API root
- [Instructor] Let's start by creating the class that defines the root URI of your rest application. We create a class in the root of the application structure and call it rest config. This is our root of the application and here we're going to create our class rest config. Now remember we must sub class the application class like so. By extending the application class and annotate the class application path and pass it the base URI which is going to be API. And by passing it the string API we're passing it the base URI from which all rest resources are going to respond. Now all calls to API are directed to this location. This class does look a bit empty. That's fine for our application and for most simple applications. But as you advance you can add more specialized configurations into this class. So, for example, all resources are processed by default. By over writing the gate classes method you can specify which class to register by returning a set of those classes and within the…
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
-
-
-
-
-