added svcapi ui and camunda code
[it/otf.git] / otf-camunda / src / main / java / org / oran / otf / camunda / configuration / OTFDataSourceConfiguration.java
diff --git a/otf-camunda/src/main/java/org/oran/otf/camunda/configuration/OTFDataSourceConfiguration.java b/otf-camunda/src/main/java/org/oran/otf/camunda/configuration/OTFDataSourceConfiguration.java
new file mode 100644 (file)
index 0000000..87936f5
--- /dev/null
@@ -0,0 +1,63 @@
+/*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
+#                                                                              #\r
+#   Licensed under the Apache License, Version 2.0 (the "License");            #\r
+#   you may not use this file except in compliance with the License.           #\r
+#   You may obtain a copy of the License at                                    #\r
+#                                                                              #\r
+#       http://www.apache.org/licenses/LICENSE-2.0                             #\r
+#                                                                              #\r
+#   Unless required by applicable law or agreed to in writing, software        #\r
+#   distributed under the License is distributed on an "AS IS" BASIS,          #\r
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
+#   See the License for the specific language governing permissions and        #\r
+#   limitations under the License.                                             #\r
+##############################################################################*/\r
+\r
+\r
+package org.oran.otf.camunda.configuration;\r
+\r
+import javax.sql.DataSource;\r
+\r
+import com.zaxxer.hikari.HikariDataSource;\r
+import org.springframework.beans.factory.annotation.Value;\r
+import org.springframework.boot.jdbc.DataSourceBuilder;\r
+import org.springframework.context.annotation.Bean;\r
+import org.springframework.context.annotation.Configuration;\r
+import org.springframework.context.annotation.Primary;\r
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;\r
+import org.springframework.transaction.PlatformTransactionManager;\r
+\r
+@Configuration\r
+public class OTFDataSourceConfiguration {\r
+  @Value("${otf.camunda.mysql.url}")\r
+  private String url;\r
+\r
+  @Value("${otf.camunda.mysql.username}")\r
+  private String username;\r
+\r
+  @Value("${otf.camunda.mysql.password}")\r
+  private String password;\r
+\r
+  @Bean\r
+  @Primary\r
+  public DataSource dataSource() {\r
+    DataSource dataSource = DataSourceBuilder.create()\r
+            .url(url)\r
+            .username(username)\r
+            .password(password)\r
+            .driverClassName("com.mysql.cj.jdbc.Driver")\r
+            .build();\r
+    if (dataSource instanceof HikariDataSource){\r
+//      ((HikariDataSource) dataSource).setLeakDetectionThreshold(10000);\r
+\r
+      ((HikariDataSource) dataSource).setMaximumPoolSize(75);\r
+      ((HikariDataSource) dataSource).setMinimumIdle(15);\r
+    }\r
+    return dataSource;\r
+  }\r
+\r
+  @Bean\r
+  public PlatformTransactionManager transactionManager() {\r
+    return new DataSourceTransactionManager(dataSource());\r
+  }\r
+}\r