users@jersey.java.net

Re: [Jersey] Enhanced Guice-Jersey integration

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 29 Jun 2009 11:06:49 +0200

On Jun 29, 2009, at 10:58 AM, Paul Sandoz wrote:
>>
>> I saw that and that's why I pointed out it wouldn't work on
>> constructor or method injection. I'd definitely be interested in
>> adding support for this to GuiceyFruit and eventually getting the
>> changes merged back into Guice itself. I wonder how much James has
>> already looked into this and if he has any ideas.
>>
>
> Dunno.
>
> We might be able to "plug-in" an additional binding to bind an
> annotation, such as QueryParam (it does not have to be meta-
> annotated, i was never sure why that was necessary expect for docs
> purposes), to a provider that supports a, possibly open, set of
> types defined by that provider. Then that would work consistently
> for all forms of injection (the TypeListenerBinding is insufficient).
>
> This would defer some of the responsibility of type checking to the
> provider, but that checking could still be performed at module
> initialization. And a helper class could be implemented to support a
> fixed set of types (rather than having to register something per
> type).
>
> One complication is annotations such as @QueryParam may come with
> other annotations like @DefaultValue and also @Encoded (which may
> also occur on the class). So there needs to be some contextual
> information when injecting, namely:
>
> 1) Class/Instance where injection will occur;
>
> 2) Type of instance to be injected; and
>
> 3) Set of Annotations associated with 2).
>

Also @QueryParam stuff cannot be injected onto singletons, because the
scope is wider than that of the value to be injected, and there may be
no query parameter information to obtain (injecting the Provider would
work).

So either Guice manages the scope checking or there needs to be
additional contextual information of the scope of 1) such that it can
be managed by the provider.

Paul.