I should have included my code in my previous post
My module:
@Override
protected void configure() {
MapBinder<String, DelegateFactory> mapBinder =
MapBinder.newMapBinder(binder(), String.class,
DelegateFactory.class);
// Implementation that is responsible for fetching the three tiered
// client type.
mapBinder.addBinding("CLIENT_TYPE") // Constructor key attribute
.toProvider(FactoryProvider.newFactory(
DelegateFactory.class,
Delegate.class));
// Implementation that is responsible for fetching the credit product
// type.
mapBinder.addBinding("CP_TYPE")
.toProvider(FactoryProvider.newFactory(
DelegateFactory.class,
Delegate.class));
// Implementation that is responsible for fetching the report type.
mapBinder.addBinding("REPORT_TYPE")
.toProvider(FactoryProvider.newFactory(
DelegateFactory.class,
Delegate.class));
}
Constructor
@Inject
public Delegate(@Assisted String key) {
this.key = key;
}
@Inject
public void setFactory(Map<String, DelegateFactory> factory) {
this.factory = factory;
this.delegate = factory.get("CLIENT_TYPE").create("CLIENT_TYPE");
}
Invocation
Injector injector = Guice.createInjector(new DelegateModule());
injector.injectMembers(this);