summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-core
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-core')
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java35
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java2
2 files changed, 37 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java
index eb4e66cb..95f149ae 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java
@@ -178,7 +178,13 @@ public class AppConfig extends WebMvcConfigurerAdapter implements Configurable,
@Bean
public DataSource dataSource() throws Exception {
+
systemProperties();
+
+ Boolean testConnectionOnCheckout = getConnectionOnCheckout();
+ String preferredTestQuery = getPreferredTestQuery();
+
+
ComboPooledDataSource dataSource = new ComboPooledDataSource();
try {
dataSource.setDriverClass(SystemProperties.getProperty(SystemProperties.DB_DRIVER));
@@ -199,6 +205,9 @@ public class AppConfig extends WebMvcConfigurerAdapter implements Configurable,
.setMaxPoolSize(Integer.parseInt(SystemProperties.getProperty(SystemProperties.DB_MAX_POOL_SIZE)));
dataSource.setIdleConnectionTestPeriod(
Integer.parseInt(SystemProperties.getProperty(SystemProperties.IDLE_CONNECTION_TEST_PERIOD)));
+ dataSource.setTestConnectionOnCheckout(testConnectionOnCheckout);
+ dataSource.setPreferredTestQuery(preferredTestQuery);
+
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,
"Error initializing database, verify database settings in properties file: "
@@ -216,6 +225,32 @@ public class AppConfig extends WebMvcConfigurerAdapter implements Configurable,
return dataSource;
}
+ private String getPreferredTestQuery() {
+ String preferredTestQueryStr = null;
+ try {
+ preferredTestQueryStr = SystemProperties.getProperty(SystemProperties.PREFERRED_TEST_QUERY);
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger,
+ SystemProperties.PREFERRED_TEST_QUERY + " value not found "
+ + UserUtils.getStackTrace(e));
+ }
+ String preferredTestQuery = ((preferredTestQueryStr == null) ? "SELECT 1" : preferredTestQueryStr);
+ return preferredTestQuery;
+ }
+
+ private Boolean getConnectionOnCheckout() {
+ String testConnectionOnCheckoutStr = null;
+ try {
+ testConnectionOnCheckoutStr = SystemProperties.getProperty(SystemProperties.TEST_CONNECTION_ON_CHECKOUT);
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger,
+ SystemProperties.TEST_CONNECTION_ON_CHECKOUT + " value not found "
+ + UserUtils.getStackTrace(e));
+ }
+ Boolean testConnectionOnCheckout = Boolean.valueOf(testConnectionOnCheckoutStr == null ? "true":testConnectionOnCheckoutStr);
+ return testConnectionOnCheckout;
+ }
+
/*
* TODO: Check whether it is appropriate to extend the list of tile
* definitions at every invocation.
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java
index 6a705aed..033bb26b 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java
@@ -253,6 +253,8 @@ public class SystemProperties {
public static final String DB_MIN_POOL_SIZE = "db.min_pool_size";
public static final String DB_MAX_POOL_SIZE = "db.max_pool_size";
public static final String IDLE_CONNECTION_TEST_PERIOD = "hb.idle_connection_test_period";
+ public static final String TEST_CONNECTION_ON_CHECKOUT = "db.test_connection_on_checkout";
+ public static final String PREFERRED_TEST_QUERY = "db.preferred_test_query";
public static final String MYLOGINS_FEED_CRON = "mylogins_feed_cron";
public static final String SESSIONTIMEOUT_FEED_CRON = "sessiontimeout_feed_cron";