users@jersey.java.net

Re: [Jersey] ResourceContext questions

From: <FSauer_at_dsthealthsolutions.com>
Date: Tue, 8 Dec 2009 08:55:20 -0600

I filed an enhancement request:
https://jersey.dev.java.net/issues/show_bug.cgi?id=441

Thanks Paul, as always, don't know how you do it :-)







Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Sent by: Paul.Sandoz_at_Sun.COM
12/08/2009 08:46 AM
Please respond to
users_at_jersey.dev.java.net


To
users_at_jersey.dev.java.net
cc

Subject
Re: [Jersey] ResourceContext questions






On Dec 8, 2009, at 3:41 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" ?

Yes, that would do it! Do we have that already and I missed it?



Jersey does not currently have support for that.



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.

Yes, that's what "prototype" does...


OK. Then it should work if the instances are instantiated *and* managed by
Spring.



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

That's acceptable (and understandable)



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.


Agreed, if I have a per-instance scope and spring injection works, then I
don't need to do this


Correct.

Paul.


-----------------------------------------
Please consider the environment before printing this email and any
attachments.

This e-mail and any attachments are intended only for the
individual or company to which it is addressed and may contain
information which is privileged, confidential and prohibited from
disclosure or unauthorized use under applicable law. If you are
not the intended recipient of this e-mail, you are hereby notified
that any use, dissemination, or copying of this e-mail or the
information contained in this e-mail is strictly prohibited by the
sender. If you have received this transmission in error, please
return the material received to the sender and delete all copies
from your system.