Depending on how you're doing your webapp, you have a couple classic
options:
- use a Singleton Session Bean with @Startup - get the data from your db
and cache it. Depending on how you're building your Jersey endpoints (are
you using EJB's?), you'll either be able to inject the EJB or use JNDI to
access the configuration (EE6 gives EJB's portable JNDI names!)
- use a JMX bean to actually cache the data. You can "initialize" it at
app startup with a singleton startup bean or an app listener. It inherently
gives you caching, security, ability to refresh (using JMX client and
creating an operation on the JMX bean). Register it with the platform mbean
server and you'll be able to get it from anywhere with the ObjectName.
- use a static member variable on your Jersey class, initialized in a
static block (I really don't recommend this, but it's an option I sometimes
use in prototyping)
Just some ideas....I like the JMX/Singleton solution - I use this when
building EE applications because, depending on how you build you JMX bean,
you can easily allow for remote modifications of the transient configuration
values (cached in the JMX bean)...really giving you a lot of power when
scaling out or building a distributed system.
Regards,
S
On Wed, Mar 9, 2011 at 12:50 PM, <forums_at_java.net> wrote:
> Anyone?
>
> May be I should ask if there is "global" place in Jersey where I can store
> something that's accessible by all RESTful services answering to incoming
> requests?
>
>
> --
>
> [Message sent by forum member 'arthury']
>
> View Post: http://forums.java.net/node/779342
>
>
>