by Default the life-cycle of root resource classes are per-request, namely that a new instance of a root resource Class is created every time the request URI path matches the root resource. This makes for a very natural programming model where constructors and fields can is utilized (as in the previous section Showing the constructor of the SparklinesResource
class) without concern for multiple concurrent requests to the same resource.
In the unlikely to be a cause of performance issues. Class Construction and garbage collection of JVMs have vastly improved over the years and many objects would be created and Discarded to serve and process the HTTP request and return the HTTP response.
Instances of Singleton root resource classes can be declared by an instance of application.
Jersey supports-further life-cycles using Jersey specific annotations. If a root resource class is annotated with @Singleton then only one instance is created Per-web application. If a root resource class is annotated with @PerSession then one instance is created per Web session and stored as A session attribute.
Jersey (1.19.1)-life-cycle of Root Resource Classes