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: Fri, 07 Mar 2008 22:29:29 +0100

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>
> To: users_at_jersey.dev.java.net; 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.
> The World 's Favourite Email.