users@jersey.java.net

Re: [Jersey] Simplifying Jersey life-cycle and IoC integration

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 26 Nov 2008 12:04:05 +0100

On Nov 25, 2008, at 5:47 PM, Paul Sandoz wrote:
>> All you'd need to do is add
>> getInjectableClass and use it in UriInfo. The implementation would be
>> very fast. How about we give it a try? If it doesn't work we can
>> always
>> take it out again...
>>
>
> Do you mind if we have a go at after the 1.0.1 release that will
> occur on Monday?
>
> I agree we probably can do something to support it in this case in
> an IoCComponentProviderFactory is registered. If there are well-
> defined and consistent rules for proxying that occur for an IoC
> framework can we support a method on IoCComponentProviderFactory
> instead?
>

I found another use-case from an efficiency perspective:

     @Path("subresource")
     public ProxiedSubResource getSubResource(@Context ResourceContext
rc) {
         return rc.getResource(ProxiedSubResource.class);
     }

in the above method if the returned object is a proxied instance, then
things will mostly work as expected because JAX-RS/Jersey supports
inherited methods and the @Consumes/_at_Produces are inherited
annotations. So everything works fine. But it is a little inefficient
because the meta-data about a resource is duplicated for the resource
class and the proxy resource class. So we could remove the duplication.

What is nice about this is spring works correctly, namely:

   final String names[] = springContext.getBeanNamesForType(c);

works for the class and proxy class.

Gili, does Guice do the same?

Paul.