You actually _can_ leave the unannotated version and still get what you
want, but you need to delve a bit more into Guice's API and use the
toConstructor binding.  The issue here is what's called the "Turkey Bacon"
problem and is described @ http://tinyurl.com/turkeybaconproblem .  The
fixed issue @ http://code.google.com/p/google-guice/issues/detail?id=231
describes
it in a little detail.  Coment 8 in that issue should give some idea how to
resolve this for yourself -- basically you bind OneOfEach as a singleton
itself, bind @A OneOfEach using toConstructor(..).in(Singleton.class), and
same with @B.  Doing it this way should avoid the need for the error
checking (which I'm not sure would be possible without some fun use of the
Guice SPI.)

sam


On Thu, Aug 18, 2011 at 2:45 PM, glenviewjeff <[email protected]>wrote:

> Sam, thanks so much for the great (and understandable explanation.)
>
> It was, in fact, the case that I did wish the unannotated versions to be
> singletons as well, but to be a different singleton than the two annotated
> ones.  I now understand how and why this doesn't work with Guice, and it's
> really not a big deal to just create a third annotation and never inject
> unannotated OneOfEachAnnotation classes.
>
> That having been said, I have a follow-up question if you don't mind:  Is
> there a mechanism to require annotations so I don't inadvertently do so?
>
> Thanks,
> Jeff
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-guice/-/wEXSWcM1hI4J.
>
> 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.
>

-- 
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