users@jersey.java.net

Re: [Jersey] Re: Jersey 1.2 and Guice

From: Alexandru Popescu ☀ <the.mindstorm.mailinglist_at_gmail.com>
Date: Wed, 1 Sep 2010 15:10:11 +0300

On Wed, Sep 1, 2010 at 2:15 PM, Paul Sandoz <Paul.Sandoz_at_oracle.com> wrote:
>
> On Sep 1, 2010, at 12:36 PM, Alexandru Popescu ☀ wrote:
>
>> On Wed, Sep 1, 2010 at 12:12 PM, Paul Sandoz <Paul.Sandoz_at_oracle.com>
>> wrote:
>>>
>>> On Aug 31, 2010, at 11:17 PM, Alexandru Popescu ☀ wrote:
>>>
>>>> ... and finally it works. So final status: the jersey-guice-1.3 is now
>>>> completely backported.
>>>>
>>>
>>> Phew :-) glad it works now.
>>>
>>> BTW one thing i forgot to mention is that when Jersey constructs and
>>> Guice
>>> injects you can use the @InjectParam (on 1.4 builds, renamed from @Inject
>>> in
>>> 1.2/1.3) to obtain Guice bound references for constructor params. This
>>> also
>>> applies to any method that Jersey is responsible for invoking on a
>>> resource.
>>>
>>> Paul.
>>>
>>
>> I thought I'm done :-).
>
> I think you are in terms of 1.3->1.2 transition.
>
>
>> I'll need to look into this as I'm not very
>> sure what you mean..
>>
>
> Using com.sun.jersey.spi.inject.Inject annotation one can defer to the
> plugged in IoC framework (if one is present) to obtain a reference.
>
> Given the obvious conflict with Guice and 330 i deprecated that in
> 1.4-SNAPSHOT and renamed it to @com.sun.jersey.api.core.InjectParam.
>
> So one could do:
>
>  public class Foo {
>    @Inject GuiceBaz baz;
>
>    public Foo(@InjectParam GuiceBar, @QueryParam("x") String x) { ... }
>
>    @GET
>    public String get(@InjectParam GuiceBoz boz) { ... }
>  }
>
> Hth,
> Paul.

Besides the renaming, is there some new functionality that enables
this @InjectParam behavior? If so, then I'll have to think about it
(my initial thought is that the workarounds I've suggested in my blog
post are good enough if backporting this functionality would require
too much work :-)