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;
\r
19 import java.util.List;
\r
20 import java.util.concurrent.Executor;
\r
21 import org.camunda.bpm.application.PostDeploy;
\r
22 import org.camunda.bpm.application.PreUndeploy;
\r
23 import org.camunda.bpm.application.ProcessApplicationInfo;
\r
24 import org.camunda.bpm.engine.ProcessEngine;
\r
25 import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
\r
26 import org.slf4j.Logger;
\r
27 import org.slf4j.LoggerFactory;
\r
28 import org.springframework.beans.factory.annotation.Value;
\r
29 import org.springframework.boot.SpringApplication;
\r
30 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
\r
31 import org.springframework.boot.autoconfigure.SpringBootApplication;
\r
32 import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
\r
33 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
\r
34 import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
\r
35 import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
\r
36 import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
\r
37 import org.springframework.context.annotation.Bean;
\r
38 import org.springframework.context.annotation.ComponentScan;
\r
39 import org.springframework.context.annotation.Primary;
\r
40 import org.springframework.scheduling.annotation.EnableAsync;
\r
41 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
\r
43 @SpringBootApplication
\r
45 @ComponentScan(basePackages = "org.oran.otf")
\r
46 @EnableProcessApplication
\r
47 @EnableAutoConfiguration(
\r
49 ErrorMvcAutoConfiguration.class,
\r
50 DataSourceAutoConfiguration.class,
\r
51 HibernateJpaAutoConfiguration.class,
\r
52 MongoDataAutoConfiguration.class,
\r
53 MongoAutoConfiguration.class
\r
55 public class Application {
\r
56 public static void main(String[] args) {
\r
57 SpringApplication.run(Application.class, args);
\r
61 private static final Logger logger = LoggerFactory.getLogger(Application.class);
\r
63 @Value("${otf.camunda.executor.async.core-pool-size}")
\r
64 private int corePoolSize;
\r
66 @Value("${otf.camunda.executor.async.max-pool-size}")
\r
67 private int maxPoolSize;
\r
69 @Value("${otf.camunda.executor.async.queue-capacity}")
\r
70 private int queueCapacity;
\r
72 private static final String LOGS_DIR = "logs_dir";
\r
75 private static void setLogsDir() {
\r
76 if (System.getProperty(LOGS_DIR) == null) {
\r
77 System.getProperties().setProperty(LOGS_DIR, "./logs/camunda/");
\r
82 public void postDeploy(ProcessEngine processEngineInstance) {}
\r
85 public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo,
\r
86 List<ProcessEngine> processEngines) {}
\r
90 public Executor asyncExecutor() {
\r
91 ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
\r
92 //executor.setTaskDecorator(new MDCTaskDecorator());
\r
93 executor.setCorePoolSize(corePoolSize);
\r
94 executor.setMaxPoolSize(maxPoolSize);
\r
95 executor.setQueueCapacity(queueCapacity);
\r
96 executor.setThreadNamePrefix("Camunda-");
\r
97 executor.initialize();
\r