aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-10-25 09:04:40 -0400
committerDan Timoney <dtimoney@att.com>2017-10-25 09:04:40 -0400
commit19c5fcb7461d0e35896829daef13bfb9290bc4af (patch)
treed072653cd455e5cc528e1a62a1ea1e2654c2e5fa
parent6f62f6514dd546a1a922b3a89abbd48920d0a2b2 (diff)
Use dblib.properties for dblib service
If dblib service cannot be resolved via OSGi, the fallback logic that creates a new instance of DBResourceManager should pass the contents of /opt/sdnc/data/properties/dblib.properties as properties to the DBResourceManager constructor instead of just passing System.getProperties(). Change-Id: Ia6ac8a4bb229026cabdf07463ca25619f923e3f3 Issue-ID: CCSDK-126 Signed-off-by: Dan Timoney <dtimoney@att.com>
-rw-r--r--sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResource.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResource.java b/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResource.java
index 45e5ad2b..b2b77b57 100644
--- a/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResource.java
+++ b/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResource.java
@@ -21,6 +21,8 @@
package org.onap.ccsdk.sli.adaptors.resource.sql;
+import java.io.File;
+import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -29,6 +31,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
import javax.sql.rowset.CachedRowSet;
@@ -349,8 +352,31 @@ public class SqlResource implements SvcLogicResource, SvcLogicJavaPlugin {
// Must not be running in an OSGI container. See if you can load it
// as a
// a POJO then.
+
+ // If $SDNC_CONFIG_DIR/dblib.properties exists, that should
+ // be the properties passed to DBResourceManager constructor.
+ // If not, as default just use system properties.
+ Properties dblibProps = System.getProperties();
+ String cfgDir = System.getenv("SDNC_CONFIG_DIR");
+
+ if ((cfgDir == null) || (cfgDir.length() == 0)) {
+ cfgDir = "/opt/sdnc/data/properties";
+ }
+
+ File dblibPropFile = new File(cfgDir + "/dblib.properties");
+ if (dblibPropFile.exists()) {
+ try {
+ dblibProps = new Properties();
+ dblibProps.load(new FileInputStream(dblibPropFile));
+ } catch (Exception e) {
+ LOG.warn("Could not load properties file " + dblibPropFile.getAbsolutePath(), e);
+
+ dblibProps = System.getProperties();
+ }
+ }
+
try {
- dblibSvc = new DBResourceManager(System.getProperties());
+ dblibSvc = new DBResourceManager(dblibProps);
} catch (Exception e) {
LOG.error("Caught exception trying to create dblib service", e);
}