/**
* Loads connection properties from $HOME/.cayenne/connection.properties.
*/
protected static ConnectionProperties loadDefaultProperties() {
DataSourceInfo dsi = new DataSourceInfo();
String adapter = System.getProperty(ADAPTER_KEY_MAVEN);
String usr = System.getProperty(USER_NAME_KEY_MAVEN);
String pass = System.getProperty(PASSWORD_KEY_MAVEN);
String url = System.getProperty(URL_KEY_MAVEN);
String driver = System.getProperty(DRIVER_KEY_MAVEN);
File f = new File(cayenneUserDir(), PROPERTIES_FILE);
try {
if (f.exists()) {
ConnectionProperties cp = new ConnectionProperties(
new ExtendedProperties(f.getAbsolutePath()));
if (((adapter != null && !adapter.startsWith("$"))
|| (usr != null && !usr.startsWith("$"))
|| (pass != null && !pass.startsWith("$"))
|| (url != null && !url.startsWith("$")) || (driver != null && !driver
.startsWith("$")))
&& (System.getProperty("cayenneTestConnection") != null && !System
.getProperty("cayenneTestConnection")
.equals("null"))) {
DataSourceInfo dsiOld = null;
if (connectionInfos.get(System.getProperty("cayenneTestConnection")) != null) {
dsiOld = connectionInfos.get(System
.getProperty("cayenneTestConnection"));
connectionInfos.remove(System
.getProperty("cayenneTestConnection"));
}
if (adapter != null && !adapter.startsWith("$")) {
dsi.setAdapterClassName(adapter);
}
else if (dsiOld != null) {
dsi.setAdapterClassName(dsiOld.getAdapterClassName());
}
if (usr != null && !usr.startsWith("$")) {
dsi.setUserName(usr);
}
else if (dsiOld != null) {
dsi.setUserName(dsiOld.getUserName());
}
if (pass != null && !pass.startsWith("$")) {
dsi.setPassword(pass);
}
else if (dsiOld != null) {
dsi.setPassword(dsiOld.getPassword());
}
if (url != null && !url.startsWith("$")) {
dsi.setDataSourceUrl(url);
}
else if (dsiOld != null) {
dsi.setDataSourceUrl(dsiOld.getDataSourceUrl());
}
if (driver != null && !driver.startsWith("$")) {
dsi.setJdbcDriver(driver);
}
else if (dsiOld != null) {
dsi.setJdbcDriver(dsiOld.getJdbcDriver());
}
connectionInfos.put(System.getProperty("cayenneTestConnection"), dsi);
}
else {
return cp;