Comment #1 on issue 809 by sberlin: Guice Assisted Inject with multiple
implementations of interface
http://code.google.com/p/google-guice/issues/detail?id=809
When implementing the factory, assistedinject has to be able to match
*every* method it sees. You're installing the factory 4 times, and in each
it's saying it doesn't know how to implement one of the methods in the
factory.
Do you actually need B & C to be using the exact same method? The easiest
way to do this is to do something like:
interface Factory {
@Named("A") Foo createA();
@Named("B") Foo createB(int a, int b);
@Named("C") Foo createC(int a, int b);
@Named("D") Foo createD(int a);
}
and then install it using:
install(new FactoryModuleBuilder()
.implement(Keys.get(Foo.class, Names.named("A")), A.class)
.implement(Keys.get(Foo.class, Names.named("B")), B.class)
.implement(Keys.get(Foo.class, Names.named("C")), C.class)
.implement(Keys.get(Foo.class, Names.named("D")), D.class)
.build(AFactory.class));
.. and not mess with PrivateModules at all. Doing it this way will
associate each 'create' method with a different implementation.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice-dev.
For more options, visit https://groups.google.com/d/optout.