Open GoogleCodeExporter opened 9 years ago
I think Fred made an extension that does something like what you're looking for
(LegsProvider?), cc'ing him.
Original comment by sberlin
on 26 Sep 2011 at 7:22
It looks like I can do something like this...
public class ConfigModule extends AbstractModule {
@Override
protected void configure() {
bind(PicasaConfig.class).toProvider(new ConfigProvider<PicasaConfig>(PicasaConfig.class));
bind(FlickrConfig.class).toProvider(new ConfigProvider<FlickrConfig>(FlickrConfig.class));
}
}
public class ConfigProvider<T> implements Provider<T> {
private final Class<T> type;
private volatile ClassLoader loader;
private volatile Environment environment;
public SettingsProvider(Class<T> type) {
this.type = type;
}
@Inject
void init(@Named("mv.config.cl") ClassLoader loader, @Named("my.env") String environment) {
this.loader = loader;
this.environment = environment;
}
@Override
public T get() {
return DoSomeMagic.newInstance(loader, environment, type);
}
}
Original comment by rka...@gmail.com
on 26 Sep 2011 at 9:04
Original issue reported on code.google.com by
rka...@gmail.com
on 26 Sep 2011 at 7:09