akonsu akonsu - 5 months ago 49
Java Question

jersey 2: how singleton resources are used?

I read Jersey documentation and did not find an answer to a simple question: when I create a singleton resource, how is it used to serve requests?

When serving requests by a singleton resource, does Jersey queue requests and access the singleton instance for each request synchronously, or does Jersey access the same singleton instance concurrently?


It's access concurrently, so you should make sure that if you want to use a singleton, that the resource class is thread-safe, and any request scope services injected (by field or constructor) are proxied