I am developing a RESTful Web Service and while reading the Jersey documentation I came across an annotation @Singleton
In my web service I am mostly returning data based on the unique keys provided as parameter. An analogy would be return all the information of a Student when the Student_Id is passed.
So my question is when @Singleton
would be suited in such kind of Web Services?
As per documentation for @RequestScoped
If the resource is used more than one time in the request processing, always the same instance will be used.
Then in that case we should not bother to use @Singleton
right?
Also what could be the use cases where we have to make a new instance for every request?
I did have a look at this post but my question was not answered.