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.

Implement a client

Implement a client

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

Start my 1-month free trial

Implement a client

- [Narrator] We will start with a book service and implement a method that retrieves a catalog of books from the rest server. Now you will remember, the URI for a list of books is rest-serverapibooks, and the ATT method is get. But before we continue, let's have a look at what this class already has in it. Here you will see that we have an initialize method, annotated PostConstruct. This method will be provoked when the book service bin is constructed by the container. The purpose of this method is to construct a client, and to ensure that it is constructed before any calls are made to its methods. Also, you will see that I have hard-coded the rest server's URI and the location of the book resource. This is just for convenience when writing the server's methods. You can also see a PreDestroy annotation on the method that closes the client connection. This is called when the client instance is destroyed, and will cleanly close the client API. The other methods that you see here are…

Contents