I worked on a Spring/RESTEasy (JBoss's implementation of JAX-RS) integration
that allowed Spring to inject the @Context parameters.  The same could be
done with Guice, especially with James Strachan's updates to the Guice
code-base.

Are you interested in getting a Guice/RESTEasy integration going?  I'm a
committer to the RESTEasy project, and JBoss has been extremely open to
integrating with multiple IoC engines.  I can get the process started, If
someone is willing to help out from the Guice-side of the world.

I'd also help with a Jersey/CXF/Restlets implementation, as long as someone
from the core team can help with the implementation specific details.

-Solomon Duskis

On Sun, Oct 26, 2008 at 1:09 PM, Gili Tzabari <[EMAIL PROTECTED]>wrote:

>
>
>    The problem is that JAX-RS knows how to inject some classes, Guice
> the others, and there is no way for me to use constructor injection
> where some objects come from Guice and others from JAX-RS. At least, I
> don't know how this could be done.
>
>    As for the package-private constructor approach, I'd want to use one
> constructor for production (without UriInfo) and another one for testing
> (with UriInfo) and Guice injecting both of them (which you can't do).
>
>    Would it be possible to have a single Guice-injected constructor
> that includes objects such as UriInfo which Guice doesn't know how to
> inject, then telling Guice to simply bind them to null at production
> time and a mock object at testing time? Somehow I suspect Guice doesn't
> let you inject null...
>
> Gili
>
> Robbie Vanbrabant wrote:
> > In general you should dependency inject it, using constructor
> > injection or method injection.
> > Field injection is only a good idea in code that you don't need to
> > test. I would image that JAX-RS does more than just field injection?
> > If that doesn't work, you could add a constructor and make it package
> > private. Or create a builder using a library that makes it easy
> > (shameless self-promotion: http://tinyurl.com/builderbuilder).
> >
> > Robbie
> >
> > On Sun, Oct 26, 2008 at 9:52 PM, Gili <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> >
> >     Hi,
> >
> >     I've got code that runs on top of JAX-RS and Guice. All my classes
> use
> >     construction injection. One such class has the following field:
> >
> >     @Context UriInfo uri;
> >
> >     that is injected after-the-fact by JAX-RS.
> >
> >     When I try unit testing this code I run into a problem because I'm
> not
> >     sure how to inject a mock object in place of "uri". Guice isn't
> >     injecting it in the first place. I was thinking of adding UriInfo to
> >     the constructor and making it optional but Guice doesn't support that
> >     sort of thing. Alternatively I could add a setUri() method to be used
> >     exclusively by the test framework but this seems a bit ugly.
> >
> >     I'm new to unit testing. I would appreciate some advice.
> >
> >     Thank you,
> >     Gili
> >
> >
> >
> > >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to