users@jersey.java.net

Re: [Jersey] Resource life cycle and injections

From: Jaka Jančar <jaka_at_kubje.org>
Date: Mon, 9 Mar 2009 02:26:06 +0100

JAX-RS does not define @Inject. There's a good intro to Guice on
YouTube.

Resources are created per-request unless annotated using @Singleton.

You can access those instances using the getSingletons() method from
javax.ws.rs.core.Application.

Jaka

> Erdinc Yilmazel wrote:
>>
>> Hello,
>>
>> Where can I find detailed information about life cycle of resource
>> instances and how to use the @Inject annotation in resource
>> classes? I
>> know that if I use @Singleton annotation jersey creates just one
>> instance for the resource, however I don't know how I can access this
>> instance that jersey created for me.
>>
>> I want to use a dependency injection framework such as guice to
>> manage
>> the resource instances and injections that are made in these objects.
>> Can you show me a starting point in implementing such behavior?
>>
>> Thank you,
>> Erdinc