diff options
author | st782s <statta@research.att.com> | 2017-06-01 17:32:04 -0400 |
---|---|---|
committer | st782s <statta@research.att.com> | 2017-06-01 17:34:59 -0400 |
commit | 4ec00b6c5542b36161495fd6152c7f20d6482df3 (patch) | |
tree | b6424e3757d625dd401e91aefd1f737c50be5c35 /ecomp-sdk/epsdk-core | |
parent | 34f706fedc5536caf2a218dbcd809991a1b484dd (diff) |
[PORTAL-13] Also [PORTAL-6]
The fixes include adding additional connection parameters to the
datasource class and adding licensing text at the root level
Change-Id: Ib37739f1c3eb9253363bb1546679936007be6cbc
Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-core')
-rw-r--r-- | ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java | 35 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java | 2 |
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"; |