Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / onap / so / bpmn / common / MSOCommonApplication.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (c) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.so.bpmn.common;
24
25 import java.util.List;
26 import java.util.concurrent.Executor;
27 import org.camunda.bpm.application.PostDeploy;
28 import org.camunda.bpm.application.PreUndeploy;
29 import org.camunda.bpm.application.ProcessApplicationInfo;
30 import org.camunda.bpm.engine.ProcessEngine;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33 import org.springframework.beans.factory.annotation.Value;
34 import org.springframework.boot.SpringApplication;
35 import org.springframework.boot.autoconfigure.SpringBootApplication;
36 import org.springframework.context.annotation.Bean;
37 import org.springframework.context.annotation.ComponentScan;
38 import org.springframework.context.annotation.ComponentScan.Filter;
39 import org.springframework.context.annotation.FilterType;
40 import org.springframework.scheduling.annotation.EnableAsync;
41 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
42
43 /**
44  * @since Version 1.0
45  *
46  */
47
48 @SpringBootApplication
49 @EnableAsync
50 @ComponentScan(basePackages = {"org.onap"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class,
51         excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
52 public class MSOCommonApplication {
53
54     private static final Logger logger = LoggerFactory.getLogger(MSOCommonApplication.class);
55
56     @Value("${mso.async.core-pool-size}")
57     private int corePoolSize;
58
59     @Value("${mso.async.max-pool-size}")
60     private int maxPoolSize;
61
62     @Value("${mso.async.queue-capacity}")
63     private int queueCapacity;
64
65     private static final String LOGS_DIR = "logs_dir";
66
67
68     private static void setLogsDir() {
69         if (System.getProperty(LOGS_DIR) == null) {
70             System.getProperties().setProperty(LOGS_DIR, "./logs/bpmn/");
71         }
72     }
73
74     public static void main(String... args) {
75         SpringApplication.run(MSOCommonApplication.class, args);
76         System.getProperties().setProperty("mso.config.path", ".");
77         setLogsDir();
78     }
79
80     @PostDeploy
81     public void postDeploy(ProcessEngine processEngineInstance) {}
82
83     @PreUndeploy
84     public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo,
85             List<ProcessEngine> processEngines) {}
86
87     @Bean
88     public Executor asyncExecutor() {
89         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
90
91         executor.setCorePoolSize(corePoolSize);
92         executor.setMaxPoolSize(maxPoolSize);
93         executor.setQueueCapacity(queueCapacity);
94         executor.setThreadNamePrefix("Camunda-");
95         executor.initialize();
96         return executor;
97     }
98 }