summaryrefslogtreecommitdiffstats
path: root/so-etsi-nfvo
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2020-09-17 16:09:06 +0100
committerWaqas Ikram <waqas.ikram@est.tech>2020-09-21 13:09:27 +0000
commit9a8013406748df6d23386ea514b2407c3ffc56a5 (patch)
treea5a787c45617311511be9e062e0013fea2c62a73 /so-etsi-nfvo
parent436da2796d3487a23c7778d9f1558a086a35fb21 (diff)
Fix for flyway picking up wrong datasource
Change-Id: Ia607dc9723dc9c837f754bfb2e3cf321e8c26326 Issue-ID: SO-3248 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'so-etsi-nfvo')
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java18
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/config/NfvoDatabaseConfiguration.java8
2 files changed, 17 insertions, 9 deletions
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java
index 946bd38cbe..c803808df1 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/CamundaDatabaseConfiguration.java
@@ -27,8 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-import org.springframework.context.annotation.Profile;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jmx.export.MBeanExporter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.zaxxer.hikari.HikariConfig;
@@ -40,9 +39,11 @@ import com.zaxxer.hikari.HikariDataSource;
*/
@Configuration
@EnableTransactionManagement
-@Profile({"!test"})
+@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager")
public class CamundaDatabaseConfiguration {
+ private static final String CAMUNDA_DATA_SOURCE_BEAN_NAME = "camundaBpmDataSource";
+
private static final Logger logger = getLogger(CamundaDatabaseConfiguration.class);
@Autowired(required = false)
@@ -51,17 +52,16 @@ public class CamundaDatabaseConfiguration {
@Bean
@ConfigurationProperties(prefix = "spring.datasource.hikari.camunda")
public HikariConfig camundaDbConfig() {
- logger.debug("Creating HikariConfig bean ... ");
+ logger.debug("Creating Camunda HikariConfig bean ... ");
return new HikariConfig();
}
- @Primary
- @Bean(name = "dataSource")
- public DataSource dataSource() {
+ @Bean(name = CAMUNDA_DATA_SOURCE_BEAN_NAME)
+ public DataSource camundaDataSource() {
if (mBeanExporter != null) {
- mBeanExporter.addExcludedBean("dataSource");
+ mBeanExporter.addExcludedBean(CAMUNDA_DATA_SOURCE_BEAN_NAME);
}
- logger.debug("Creating HikariDataSource bean ... ");
+ logger.debug("Creating Camunda HikariDataSource bean ... ");
final HikariConfig hikariConfig = this.camundaDbConfig();
return new HikariDataSource(hikariConfig);
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/config/NfvoDatabaseConfiguration.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/config/NfvoDatabaseConfiguration.java
index 8f146e5378..1b4e40985a 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/config/NfvoDatabaseConfiguration.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/config/NfvoDatabaseConfiguration.java
@@ -19,11 +19,14 @@
*/
package org.onap.so.etsi.nfvo.ns.lcm.database.config;
+import static org.slf4j.LoggerFactory.getLogger;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
+import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.flyway.FlywayDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
@@ -47,6 +50,7 @@ import com.zaxxer.hikari.HikariDataSource;
@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory",
basePackages = {"org.onap.so.etsi.nfvo.ns.lcm.database.repository"})
public class NfvoDatabaseConfiguration {
+ private static final Logger logger = getLogger(NfvoDatabaseConfiguration.class);
private static final String PERSISTENCE_UNIT = "nfvo";
private static final String NFVO_DATA_SOURCE_QUALIFIER = "nfvoDataSource";
@@ -57,14 +61,18 @@ public class NfvoDatabaseConfiguration {
@Bean
@ConfigurationProperties(prefix = "spring.datasource.hikari.nfvo")
public HikariConfig nfvoDbConfig() {
+ logger.debug("Creating NFVO HikariConfig bean ... ");
return new HikariConfig();
}
+ @Primary
+ @FlywayDataSource
@Bean(name = NFVO_DATA_SOURCE_QUALIFIER)
public DataSource dataSource() {
if (mBeanExporter != null) {
mBeanExporter.addExcludedBean(NFVO_DATA_SOURCE_QUALIFIER);
}
+ logger.debug("Creating NFVO HikariDataSource bean ... ");
final HikariConfig hikariConfig = this.nfvoDbConfig();
return new HikariDataSource(hikariConfig);
}