1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 package org.oran.otf.camunda.configuration;
\r
19 import javax.sql.DataSource;
\r
21 import com.zaxxer.hikari.HikariDataSource;
\r
22 import org.springframework.beans.factory.annotation.Value;
\r
23 import org.springframework.boot.jdbc.DataSourceBuilder;
\r
24 import org.springframework.context.annotation.Bean;
\r
25 import org.springframework.context.annotation.Configuration;
\r
26 import org.springframework.context.annotation.Primary;
\r
27 import org.springframework.jdbc.datasource.DataSourceTransactionManager;
\r
28 import org.springframework.transaction.PlatformTransactionManager;
\r
31 public class OTFDataSourceConfiguration {
\r
32 @Value("${otf.camunda.mysql.url}")
\r
35 @Value("${otf.camunda.mysql.username}")
\r
36 private String username;
\r
38 @Value("${otf.camunda.mysql.password}")
\r
39 private String password;
\r
43 public DataSource dataSource() {
\r
44 DataSource dataSource = DataSourceBuilder.create()
\r
48 .driverClassName("com.mysql.cj.jdbc.Driver")
\r
50 if (dataSource instanceof HikariDataSource){
\r
51 // ((HikariDataSource) dataSource).setLeakDetectionThreshold(10000);
\r
53 ((HikariDataSource) dataSource).setMaximumPoolSize(75);
\r
54 ((HikariDataSource) dataSource).setMinimumIdle(15);
\r
60 public PlatformTransactionManager transactionManager() {
\r
61 return new DataSourceTransactionManager(dataSource());
\r