added svcapi ui and camunda code
[it/otf.git] / otf-camunda / src / main / java / org / oran / otf / Application.java
diff --git a/otf-camunda/src/main/java/org/oran/otf/Application.java b/otf-camunda/src/main/java/org/oran/otf/Application.java
new file mode 100644 (file)
index 0000000..7dfa547
--- /dev/null
@@ -0,0 +1,100 @@
+/*  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;\r
+\r
+import java.util.List;\r
+import java.util.concurrent.Executor;\r
+import org.camunda.bpm.application.PostDeploy;\r
+import org.camunda.bpm.application.PreUndeploy;\r
+import org.camunda.bpm.application.ProcessApplicationInfo;\r
+import org.camunda.bpm.engine.ProcessEngine;\r
+import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.beans.factory.annotation.Value;\r
+import org.springframework.boot.SpringApplication;\r
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;\r
+import org.springframework.boot.autoconfigure.SpringBootApplication;\r
+import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;\r
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;\r
+import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;\r
+import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;\r
+import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;\r
+import org.springframework.context.annotation.Bean;\r
+import org.springframework.context.annotation.ComponentScan;\r
+import org.springframework.context.annotation.Primary;\r
+import org.springframework.scheduling.annotation.EnableAsync;\r
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;\r
+\r
+@SpringBootApplication\r
+@EnableAsync\r
+@ComponentScan(basePackages = "org.oran.otf")\r
+@EnableProcessApplication\r
+@EnableAutoConfiguration(\r
+    exclude = {\r
+        ErrorMvcAutoConfiguration.class,\r
+        DataSourceAutoConfiguration.class,\r
+        HibernateJpaAutoConfiguration.class,\r
+        MongoDataAutoConfiguration.class,\r
+        MongoAutoConfiguration.class\r
+    })\r
+public class Application {\r
+  public static void main(String[] args) {\r
+    SpringApplication.run(Application.class, args);\r
+\r
+  }\r
+\r
+  private static final Logger logger = LoggerFactory.getLogger(Application.class);\r
+\r
+  @Value("${otf.camunda.executor.async.core-pool-size}")\r
+  private int corePoolSize;\r
+\r
+  @Value("${otf.camunda.executor.async.max-pool-size}")\r
+  private int maxPoolSize;\r
+\r
+  @Value("${otf.camunda.executor.async.queue-capacity}")\r
+  private int queueCapacity;\r
+\r
+  private static final String LOGS_DIR = "logs_dir";\r
+\r
+\r
+  private static void setLogsDir() {\r
+    if (System.getProperty(LOGS_DIR) == null) {\r
+      System.getProperties().setProperty(LOGS_DIR, "./logs/camunda/");\r
+    }\r
+  }\r
+\r
+  @PostDeploy\r
+  public void postDeploy(ProcessEngine processEngineInstance) {}\r
+\r
+  @PreUndeploy\r
+  public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo,\r
+      List<ProcessEngine> processEngines) {}\r
+\r
+  @Bean\r
+  @Primary\r
+  public Executor asyncExecutor() {\r
+    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();\r
+    //executor.setTaskDecorator(new MDCTaskDecorator());\r
+    executor.setCorePoolSize(corePoolSize);\r
+    executor.setMaxPoolSize(maxPoolSize);\r
+    executor.setQueueCapacity(queueCapacity);\r
+    executor.setThreadNamePrefix("Camunda-");\r
+    executor.initialize();\r
+    return executor;\r
+  }\r
+}\r