Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ruseel/6110273 to your computer and use it in GitHub Desktop.
Save ruseel/6110273 to your computer and use it in GitHub Desktop.
public class PropertyConfiguredDataSourceFactoryBean implements FactoryBean<DataSource> {
private String productionProperty;
private String devProperty;
private String envName;
public DataSource getObject() throws Exception {
String propFileName = getPropertyFilenameByENV();
Properties p = PropertiesLoaderUtils.loadAllProperties(propFileName);
return BasicDataSourceFactory.createDataSource(p);
}
public String getPropertyFilenameByENV() {
String n = devProperty;
if ("production".equals(System.getenv(envName))) {
n = productionProperty;
}
return n;
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment