Comment #4 on issue 548 by mcculls: Same Module Mutiple Implementation Problem
http://code.google.com/p/google-guice/issues/detail?id=548

The example is wrong - the module defines two bindings each with a qualifier (@Good and @Bad) but no default binding, it then asks the injector for the default binding:

   injector.getInstance(Player.class)

which fails because no such binding exists. Note that the qualifier on the local variable cannot be seen by Guice because the example is calling it via the getInstance method, and in Java methods cannot see where their return value will end up being stored. The correct call to get the @Good binding would be:

   injector.getInstance(Key.get(Player.class, Good.class))

HTH

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" 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-dev?hl=en.

Reply via email to