how to use optional injection with JSR330

13 views
Skip to first unread message

Mingfai

unread,
Oct 18, 2010, 6:24:22 AM10/18/10
to google...@googlegroups.com
hi,

What's the equivalent of the "optional" value of @com.google.inject.Inject in Guice 3.0 when using JSR330 annotation? obviously, @javax.inject.Inject doesn't have an optional value.

regards,
mingfai

Philippe Beaudoin

unread,
Oct 18, 2010, 10:56:58 AM10/18/10
to google...@googlegroups.com
I've been looking at the Guice source for a replacement and found
nothing. From what I've seen, if you're using JSR330 you don't have
access to optional injection. :(

Philippe

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

Sam Berlin

unread,
Oct 18, 2010, 11:27:28 AM10/18/10
to google...@googlegroups.com
Yup, that's correct.  The JSR 330 spec is a little more strict about when things can be injected.  See http://code.google.com/p/google-guice/wiki/JSR330 for some more details.

sam

On Mon, Oct 18, 2010 at 10:56 AM, Philippe Beaudoin <philippe...@gmail.com> wrote:
I've been looking at the Guice source for a replacement and found
nothing. From what I've seen, if you're using JSR330 you don't have
access to optional injection. :(

 Philippe

Mingfai

unread,
Oct 18, 2010, 12:06:38 PM10/18/10
to google...@googlegroups.com
I suppose the JSR just hasn't define any way to use optional, but not suggesting optional/nullable inject is bad.  I've created an issue as follows:
http://code.google.com/p/google-guice/issues/detail?id=558

mingfai
Reply all
Reply to author
Forward
0 new messages