Status: New
Owner: ----
New issue 809 by [email protected]: Guice Assisted Inject with multiple
implementations of interface
http://code.google.com/p/google-guice/issues/detail?id=809
I have an interface A with multiple implementations say B, C and D. I am
using guice assisted inject to create these classes. Classes B and C use
the same assister parameters(say b, c) in constructor while D has one
different parameter(say d). The way I implementing this is have a factory
AFactory with 2 methods: create(int b, int c) and createD(int d) In my
module, I have created a PrivateModule to bind the concrete class to
factory.
The code looks like this:
public static PrivateModule getAFactoryModule(final String
factoryBindingKey,final Class<? extends A> targetClassToCreate) {
return new PrivateModule() {
@Override
public void configure() {
install(new FactoryModuleBuilder().implement(
A.class, targetClassToCreate).build(
AFactory.class));
bind(AFactory.class).annotatedWith(Names.named(factoryBindingKey)).to(
Key.get(AFactory.class));
expose(Key.get(AFactory.class, Names.named(factoryBindingKey)));
}
};
}
I call PrivateModule like this:
install(getAFactoryModule("B", B.class));
install(getAFactoryModule("C", C.class));
install(getAFactoryModule("D", D.class));
But, this gives an error saying:
com.guice.test.B has @AssistedInject constructors but none of them match
the parameters in method com.guice.test.AFactory.createD(). Unable to
create assisted inject
com.guice.test.C has @AssistedInject constructors but none of them match
the parameters in method com.guice.test.AFactory.createD(). Unable to
create assisted inject
com.guice.test.D has @AssistedInject constructors but none of them match
the parameters in method com.guice.test.AFactory.create(). Unable to create
assisted inject
It seems Guice is trying to use different create methods than what is
expected. Any idea how this can be resolved? Any pointers would be
appreciated!
Thanks!
--
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.