Comment #6 on issue 519 by sberlin: toProvider() should continue to use Guice's Provider, not JSR-330's
http://code.google.com/p/google-guice/issues/detail?id=519
I didn't know users weren't supposed to implement j.i.Provider... that does change my thoughts a bit. Still, I'm not certain I agree that making c.g.i.Provider extend j.i.Provider makes things more confusing for users. I think it actually makes it easier.
If Guice had gone the Locater & Provider route, I'd agree. But as-is, Guice uses Provider, @Provides, toProvider(..), etc.. which means that Guice considers concept locating & providing to be the same thing.
Right now, the difference between c.g.i.Provider & j.i.Provider only matter when you decide what to import. If we make it any more complex than that, we're adding confusion into the mix, not reducing it. Guice 3.0 already will force the jsr-330 jar into the classpath, so there will always be a choice of Providers.. and if someone accidentally picks the wrong one, it will be hard to understand what's going wrong.
There's also a lot of times where you have pre-existing code that acts as a Provider and I want to bind it with toProvider. If c.g.i.Provider doesn't extend j.i.Provider, then you're forced to make it implement c.g.i.Provider (whereas I could have made it extend j.i.Provider). Couple that with other code that is written to be DI-agnostic and thus wants j.i.Providers injected... in order to test, you need to use a wrapper class that converts from c.g.i.Provider to j.i.Provider, adding complexity.
Ultimately, I think that making c.g.i.Provider extend j.i.Provider ends up making life simpler for the user. They don't have to worry about wrong imports and don't have to worry about converting from one to the other.
I understand the confusion with the toProvider(Key|TypeLiteral|Class) methods having the generic types linking to j.i.Provider, but I feel like I'm missing some other confusion. IMO, the wins for the user definitely outweigh the javadoc confusion (which can be cleaned up in documentation).
-- 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.
