2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
20 package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows;
23 import static org.slf4j.LoggerFactory.getLogger;
24 import javax.sql.DataSource;
25 import org.slf4j.Logger;
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.boot.context.properties.ConfigurationProperties;
28 import org.springframework.context.annotation.Bean;
29 import org.springframework.context.annotation.Configuration;
30 import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
31 import org.springframework.jmx.export.MBeanExporter;
32 import org.springframework.transaction.annotation.EnableTransactionManagement;
33 import com.zaxxer.hikari.HikariConfig;
34 import com.zaxxer.hikari.HikariDataSource;
37 * @author Waqas Ikram (waqas.ikram@est.tech)
41 @EnableTransactionManagement
42 @EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager")
43 public class CamundaDatabaseConfiguration {
45 private static final String CAMUNDA_DATA_SOURCE_BEAN_NAME = "camundaBpmDataSource";
47 private static final Logger logger = getLogger(CamundaDatabaseConfiguration.class);
49 @Autowired(required = false)
50 private MBeanExporter mBeanExporter;
53 @ConfigurationProperties(prefix = "spring.datasource.hikari.camunda")
54 public HikariConfig camundaDbConfig() {
55 logger.debug("Creating Camunda HikariConfig bean ... ");
56 return new HikariConfig();
59 @Bean(name = CAMUNDA_DATA_SOURCE_BEAN_NAME)
60 public DataSource camundaDataSource() {
61 if (mBeanExporter != null) {
62 mBeanExporter.addExcludedBean(CAMUNDA_DATA_SOURCE_BEAN_NAME);
64 logger.debug("Creating Camunda HikariDataSource bean ... ");
65 final HikariConfig hikariConfig = this.camundaDbConfig();
66 return new HikariDataSource(hikariConfig);