No, Guice supports any annotation named "Nullable". So you can create it
yourself. This means you can also reuse IntelliJ IDEA's @Nullable, for
example.
Robbie

On Mon, Oct 27, 2008 at 1:14 AM, Gili Tzabari <[EMAIL PROTECTED]>wrote:

>
>
>    That's odd. Why does Nullable only exist in test/com/google/inject?
> I was going to try Jesse's snapshot20081016 but it doesn't include this
> class. I suspect he only included files compiled from src/*
>
> Gili
>
> Robbie Vanbrabant wrote:
> > Guice trunk has support for @Nullable.
> > @Inject
> > public MyClass(Some param, @Nullable Other param) { ... }
> >
> > Robbie
> >
> > On Sun, Oct 26, 2008 at 10:39 PM, Gili Tzabari <[EMAIL PROTECTED]
> > <mailto:[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]>
> >     > <mailto:[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