users@jersey.java.net

Re: Injectable fields not set on target object for proxied resource (using cglib)

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 20 Mar 2008 18:03:06 +0100

Duncan Eley wrote:
> Hi Paul,
>
> I've gone ahead and logged an enhancement issue.
>
> I personally prefer the getInjectableInstance(Object resource) approach
> as it deferrs injection to Jersey and is more resistant to change.
>

Fixed in the trunk.

Paul.

> Many thanks,
>
> Duncan Eley
>
>
> ----- Original Message ----
> From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
> To: users_at_jersey.dev.java.net
> Sent: Friday, 7 March, 2008 9:29:29 PM
> Subject: Re: Injectable fields not set on target object for proxied
> resource (using cglib)
>
>
> On Mar 7, 2008, at 6:41 PM, Duncan Eley wrote:
>
>> Hi Paul,
>>
>> I've not looked in any great detail at the new component provider but
>> I can't see how the AOP trick can be applied using it. The
>> getInstance() method in the SPI by Marc gave access to a
>> ResourceProviderContext. This allowed me to inject dependencies on the
>> proxy's target object and then return the proxied object itself from
>> getInstance(). The target object cannot be the object returned from
>> getInstance().
>>
>> Using the component provider, how can we do the DI on the target
>> object? Or there there some other solution to this that I'm not aware of?
>>
>
> Ah! you are right, can you please log an issue so that i don't forget
> about this?
>
> We may need another method on ComponentProvider e.g. Object
> getInjectableInstance(Object resource) that Jersey can call and perform
> injection on the returned instance. Or we have to provide a context as
> before.
>
> Thanks,
> Paul.
>
>> Many thanks,
>>
>> Duncan Eley
>>
>>
>> ----- Original Message ----
>> From: Paul Sandoz <Paul.Sandoz_at_Sun.COM <mailto:Paul.Sandoz_at_Sun.COM>>
>> To: users_at_jersey.dev.java.net <mailto:users_at_jersey.dev.java.net>;
>> dunk_e_at_yahoo.co.uk <mailto:dunk_e_at_yahoo.co.uk>
>> Sent: Friday, 7 March, 2008 4:55:04 PM
>> Subject: Re: Injectable fields not set on target object for proxied
>> resource (using cglib)
>>
>> Duncan Eley wrote:
>> > The above example uses the SPI described here:
>> > http://weblogs.java.net/blog/mhadley/archive/2007/09/integrating_jer.html.
>> > This demonstrates how to get at the cglib proxied object using
>> > Spring. However, I'm aware that the Jersey SPI has changed quite a
>> > bit since I did this.
>>
>> Yes, you should be able to do the same AOP trick with the component
>> provider [1].
>>
>>
>> > It would be really nice, if at some point, Jersey had an optional
>> > library for users wanting to integrate with Spring.
>> >
>>
>> Very much agree. I would like to consider something like that for 0.7
>> (see my blog on the 0.6 release), my concern is Marc, Jakub and I are a
>> little maxed out so i was wondering if anyone would like to volunteer to
>> contribute Spring & Guice stuff to the Jersey distribution ?
>>
>> Paul.
>>
>> [1] http://blogs.sun.com/sandoz/entry/integrating_jersey_and_spring_take
>>
>> --
>> | ? + ? = To question
>> ----------------\
>> Paul Sandoz
>> x38109
>> +33-4-76188109
>>
>>
>> ------------------------------------------------------------------------
>> Sent from Yahoo! Mail
>> <http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=52419/*http://uk.docs.yahoo.com/nowyoucan.html>.
>> The World 's Favourite Email.
>
>
>
> ------------------------------------------------------------------------
> Sent from Yahoo! Mail
> <http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=52419/*http://uk.docs.yahoo.com/nowyoucan.html>.
>
> The World 's Favourite Email.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109