What is the correct way of modifying a guice module for deployers. I
have written a CacheProvider API that needs to be injected, but as
soon as I inject the default implementation, no other can be injected
(I only really want one deployer provided CacheProvider).
Adding yet another Guice module to the list of modules to be loaded by
the injector feels like overkill, so at the moment I have
/* Is there a better way to do this, its ugly */
Class<? extends CacheProvider> c = DefaultCacheProvider.class;
try {
c = (Class<? extends CacheProvider >)
Class.forName(properties.getProperty("cacheprovider"));
} catch ( Exception ex ) {
}
bind(CacheProvider.class).to(c).in(Scopes.SINGLETON);
So that a deployer can give the classname of the CacheProvider
implementation in the properties file and have it load without having
to add another module. It works just fine but ......
What's the right way to do this in Guice ?
Ian