On Jun 7, 4:30 am, "Dhanji R. Prasanna" <[email protected]> wrote:
> Actually once you grok that everything in Guice is key-based and not class
> based, a world of clarity opens up =)
Given that Key is based on TypeLiteral (emphasis on "literal"), I
believe what you are saying is that there is no way to do what what we
are talking about other than:
bind(B.class).in(Scopes.SINGLETON);
bind(A.class).to(B.class).in(Scopes.SINGLETON);
bind(Singleton.class).to(B.class).in(Scopes.SINGLETON);
This seems painfully verbose, with or without a world of clarity.
> In that regard I believe we have one of the best balanced APIs between
> flexibility and correctness.
I am definitely in favor of correctness, and keeping Guice tied to
literal types is certainly a good decision. Nonetheless, I believe
the ability to bind a specific range of types without explicit bind()
calls for each direct supertype would not in the least sacrifice
correctness. More importantly, without support from Guice itself it
is, as far as I can tell, to implement such a feature in a client
Module without the counter-intuitive side effect that the one type
which *cannot* be injected is the actual implementation class.
> I certainly understand, however that this may
> not be your first reaction upon uncovering this Guice property.
Would you not agree this could be solved more elegantly, without
sacrificing anything?
-Tim
--
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.