users@jersey.java.net

[Jersey] Singleton class in Jersey

From: Dietz, Randall <randall_at_dietz.id.au>
Date: Sat, 31 Jan 2015 07:11:18 +1000

Hi all,

Can someone please point me to some up-to-date documentation that has an
example of how to add a singleton class to a Jersey (v2.15) REST API?

I have successfully built a REST application in Jersey, now all I want to
do is inject a Singleton class (that controls access to my central
configuration) in my service classes that is shared across all requests.
Really, really simple use case... but I've wasted hours trying to get it
working.

The problem I've encountered is that there are a number of "solutions" on
the InterWeb, but they're either out of date, confusing or just plain wrong.

Would appreciate some guidance or examples of how it should be done in the
latest Jersey.

Thanks -- Randall