users@jersey.java.net

Re: [Jersey] ResourceContext questions

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 08 Dec 2009 11:19:08 +0100

On Dec 7, 2009, at 9:04 PM, FSauer_at_dsthealthsolutions.com wrote:

>
> 1) is there a way to make ResourceContext always create a new
> instance (as opposed to look up an existing one in a map). I am
> trying to create a collection of these things and the caching trips
> me up

Do you want to utilize a life-cycle of "per-instance" ?


> 2) Does ResourceContext also make use of @Component and @Resource
> annotations?

Yes. ResourceContext will defer to what ever IoC frameworks are
registered.

Does Spring support a per-instance life-cycle? If so it may just work,
but i have not tested it and may require some minor tweaks to the
Spring integration.

However, you cannot create instances of the same resource class for
different life-cycles.


> I need to inject a spring managed service bean into the created
> resources. Is there a SpringAwareResourceContext?
>
> Can I create my own ResourceContext implementation? Using @Provider
> perhaps?
>

You could override the one provided by defining your own injectable
provide. But i am not sure it is necessary.

Paul.