akonsu
akonsu

Reputation: 29576

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?

Upvotes: 2

Views: 517

Answers (1)

Paul Samsotha
Paul Samsotha

Reputation: 209082

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

Upvotes: 1

Related Questions