Created
July 30, 2013 04:36
-
-
Save ruseel/6110273 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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