users@jersey.java.net

Re: [Jersey] Re: Jersey 1.2 and Guice

From: Alexandru Popescu ☀ <the.mindstorm.mailinglist_at_gmail.com>
Date: Mon, 30 Aug 2010 12:16:09 +0300

>> 4. A new question that arose while looking at the jersey-guice in 1.3
>> and the sample code is: who is actually injecting the values.
>>
>> The PerRequestResource is defined as:
>>
>> [code]
>> @Path("bound/perrequest")
>> @RequestScoped
>> public class PerRequestResource {
>>
>>   @Context UriInfo ui;
>>
>>   @QueryParam("x") String x;
>>
>>   private final SingletonComponent sc;
>>
>>   @Inject
>>   public PerRequestResource(SingletonComponent sc) {
>>       this.sc = sc;
>>   }
>>
>> }
>> [/code]
>>
>> While it is clear that Guice will manage the lifecycle of this
>> resource (per request) and will inject the SingletonComponent through
>> the constructor, it is not clear who will provide @Context UriInfo and
>> @QueryParam("x") String
>>
>
> Guice will inject everything related to @Inject. Jersey will inject
> everything related to the JAX-RS annotations. Basically after Guice
> instantiates and injects Jersey will have a go injecting.
>
>
>> I know this mail got really long, so I apologize in advance for the
>> effort to go through it while still hoping to get some help from the
>> more experienced people on the list.
>>
>
> Np, hth,
> Paul.


To see if I got this right: the only limitation of the current
integration is that you cannot use both @Inject and @*Param on
constructors, methods or fields. Is this correct? If so, I'll give it
a try to see if it really is a limitation or you can easily work
around it.

I'll make sure I'll study all the links you've provided.

thanks so much,

:- alex