Hi there,
I am binding my property files with a provider. Now I have round about
3 different property files like: standard.properties,
config.properties etc.
Is there a more elegant way to have only one provider for all property
files instead writing for each property file one provider?
Code:
bind(Properties.class).annotatedWith(Names.named("config")).toProvider(ConfigPropertiesProvider.class).in(Scopes.SINGLETON);
static class ConfigPropertiesProvider implements Provider<Properties>
{
private Logger log =
Logger.getLogger(ConfigPropertiesProvider.class);
public Properties get() {
return loadProperties();
}
private Properties loadProperties() {
Properties prop =
PropertiesUtil.loadProperties("config.properties");
if(prop == null){
log.error("config.properties not found");
}
return prop;
}
}
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.