I like this approach, 'cause it's concise.
But it adds lots of new complexity to AssistedInject, and I'm not 100% convinced
that this complexity pays for itself. With FactoryBinder, assistedinject's
Binder sort of competes with Guice's own binder.
From issue 131, we've been here before.
http://code.google.com/p/google-guice/issues/detail?id=131
what if instead of all of this stuff, we did a clean-slate API and called it,
say, 'FactoryModuleBuilder':
install(new FactoryModuleBuilder()
.withImplementation(Subcompact.class, Mini.class)
.withImplementation(Suv.class, Forester.class)
.build(CarFactory.class));
I'm not sure if this is the exact right API, but I think it'll work better than
introducing a new kind of binder.
With the builder we've got a place to tweak the API later if necessary. For
example, that approach will probably work nicely when we add '.toConstructor'
binding targets.
http://code.google.com/p/google-guice/issues/detail?id=231http://codereview.appspot.com/25084/diff/3002/3003
File
extensions/assistedinject/src/com/google/inject/assistedinject/BindingCollector.java
(right):
http://codereview.appspot.com/25084/diff/3002/3003#newcode31
Line 31: class BindingCollector {
I like this interface, it's helpful since the map would be less obvious
http://codereview.appspot.com/25084/diff/3002/3003#newcode33
Line 33: private final Map<Key, TypeLiteral> bindings = Maps.newHashMap();
don't use raw types for key and typeliteral - should be
Map<Key<?>, TypeLiteral<?>>
similarly in addBinding()
http://codereview.appspot.com/25084/diff/3002/3003#newcode39
Line 39: throw new ConfigurationException(Collections.singleton(new Message("
Binding illegal")));
include the name of the offending key?
http://codereview.appspot.com/25084/diff/3002/3007
File
extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider.java
(right):
http://codereview.appspot.com/25084/diff/3002/3007#newcode77
Line 77: * provider (this example assumes that the above factory returns a
{@code RealPayment} and not a
I don't really like for the factory interface to depend on the implementation
class . . . .
http://codereview.appspot.com/25084/diff/3002/3009
File
extensions/assistedinject/test/com/google/inject/assistedinject/FactoryProvider2Test.java
(right):
http://codereview.appspot.com/25084/diff/3002/3009#newcode42
Line 42: public void testNoBindingAssitedInject() {
Assited -> Assisted
http://codereview.appspot.com/25084/diff/3002/3009#newcode252
Line 252: FactoryProvider.newFactory(ColoredCarFactory.class, Porsche.class));
nice fix!
Issue 25084: Extending AssistedInject with multi type factory support
(Closed)
Created 17 years, 1 month ago by Aragos
Modified 16 years, 8 months ago
Reviewers: jessewilson
Base URL: http://google-guice.googlecode.com/svn/trunk/
Comments: 6