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.context.annotation.Primary;
31 import org.springframework.context.annotation.Profile;
32 import org.springframework.jmx.export.MBeanExporter;
33 import org.springframework.transaction.annotation.EnableTransactionManagement;
34 import com.zaxxer.hikari.HikariConfig;
35 import com.zaxxer.hikari.HikariDataSource;
38 * @author Waqas Ikram (waqas.ikram@est.tech)
42 @EnableTransactionManagement
44 public class CamundaDatabaseConfiguration {
46 private static final Logger logger = getLogger(CamundaDatabaseConfiguration.class);
48 @Autowired(required = false)
49 private MBeanExporter mBeanExporter;
52 @ConfigurationProperties(prefix = "spring.datasource.hikari.camunda")
53 public HikariConfig camundaDbConfig() {
54 logger.debug("Creating HikariConfig bean ... ");
55 return new HikariConfig();
59 @Bean(name = "dataSource")
60 public DataSource dataSource() {
61 if (mBeanExporter != null) {
62 mBeanExporter.addExcludedBean("dataSource");
64 logger.debug("Creating HikariDataSource bean ... ");
65 final HikariConfig hikariConfig = this.camundaDbConfig();
66 return new HikariDataSource(hikariConfig);