From the course: Java EE 8: Web Services

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Dissecting your REST service

Dissecting your REST service - Java EE Tutorial

From the course: Java EE 8: Web Services

Start my 1-month free trial

Dissecting your REST service

- [Instructor] Let's get a deeper understanding of some of the more important pieces of our RESTful web service implementation so far. We begin with the code. Our entire MyResource class defines a RESTful resource, or more specifically, a root resource. It's a root resource based on the presence of the @Path annotation on line 18. For each call to the URL configured in this @Path annotation, the Jersey runtime is going to create a new instance of this class. For the most part, you're not going to suffer any performance hit. Famous last words, I know. If you need to have only one instance of the root resource class for any reason, just add the @Singleton annotation. That's @Singleton annotation. That's from the javax.inject package. Add @Singleton to the class, and there will only be one instance of the MyResource class available throughout the entirety of the application. There could be a scenario where you want to…

Contents