users@jersey.java.net

Re: [Jersey] injecting _at_Context fields on sub resources...

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 21 Apr 2010 23:09:16 +0200

On Apr 21, 2010, at 12:46 PM, James Strachan wrote:

> On 21 April 2010 09:43, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
>> Hi James,
>>
>> Another problem is if the resource instance is not managed then we
>> do not
>> know the scope of that instance, it could be even a static instance
>> (bad
>> practice i know!),
>
> Yeah. Though if folks use container injection annotations on
> singletons that are given to the container to invoke which also have
> request specific stuff in there which their code depends on, their
> code's already broken whether Jersey injects or not :)
>
>
>> Thus probably the only reliable thing we can do under these
>> circumstances is
>> perform field injection (no setter method injection) of singleton
>> dependencies,
>> which would include all of the @Context you require plus what
>> Jersey additional defines (or what the user adds too). Jersey's
>> injection
>> support will not inject if a field value is non-null.
>
> Great!
>
>> Hence we could have init param to support this a re-injection of
>> fields
>> should not have any side effects if it has occurred already.
>
> Sounds great!
>
>> Can you log an
>> issue?
>
> Done...
> https://jersey.dev.java.net/issues/show_bug.cgi?id=513
>

Thanks!
Paul.