users@jersey.java.net

Re: [Jersey] Using Guice with JAX-RS

From: Gili <cowwoc_at_bbs.darktech.org>
Date: Tue, 7 Oct 2008 06:56:09 -0700 (PDT)

Paul Sandoz wrote:
>
> You should not have to check for the PerRequest annotation. It should
> be sufficient to use the "scope" that Jersey is requesting. It seems
> to me there are some cases that may be reliably consistent to check:
>

Checking the "scope" that Jersey is requesting is not enough, because I want
to be able to differentiate between the default scope versus someone
explicitly asking for PerRequest. I could implement a ResourceProvider to do
this but I found this approach easier.

I want to prevent users from using both Jersey and Guice scopes on the same
field. This means that a default scope (which just happens to be PerRequest)
with a Guice scope is okay, but @PerRequest with a Guice scope is not.


Paul Sandoz wrote:
>
> It is frustrating that one cannot tell Guice which constructor to use
> with a list of constructor parameters, where null values mean Guice
> should determine the parameters.
>

Guice expects you to mark up one of your constructors with @Inject at
compile-time. This is your way of telling it which constructor to use. I
think what is missing is not so much telling Guice which constructor to use
but being able to merge the Jersey and Guice injection configuration. For
example, Jersey knows how to inject X but Guice knows how to inject Y. It
would be nice to be able to import Jersey's configuration into Guice once at
startup and just use Guice from that point onward.

Gili
-- 
View this message in context: http://n2.nabble.com/Using-Guice-with-JAX-RS-tp1127230p1303632.html
Sent from the Jersey mailing list archive at Nabble.com.