Merge "add junit coverage"
[so.git] / adapters / mso-sdnc-adapter / src / main / java / org / onap / so / adapters / sdnc / SDNCAdapterApplication.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  *
7  * Copyright (C) 2019 IBM
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.adapters.sdnc;
24
25 import java.util.concurrent.Executor;
26 import org.onap.logging.filter.base.Constants;
27 import org.onap.logging.filter.spring.MDCTaskDecorator;
28 import org.onap.so.utils.Components;
29 import org.springframework.beans.factory.annotation.Value;
30 import org.springframework.boot.SpringApplication;
31 import org.springframework.boot.autoconfigure.SpringBootApplication;
32 import org.springframework.context.annotation.Bean;
33 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
34
35 @SpringBootApplication(scanBasePackages = {"org.onap"})
36 public class SDNCAdapterApplication {
37
38
39     @Value("${mso.async.core-pool-size}")
40     private int corePoolSize;
41
42     @Value("${mso.async.max-pool-size}")
43     private int maxPoolSize;
44
45     @Value("${mso.async.queue-capacity}")
46     private int queueCapacity;
47
48     private static final String LOGS_DIR = "logs_dir";
49
50     private static void setLogsDir() {
51         if (System.getProperty(LOGS_DIR) == null) {
52             System.getProperties().setProperty(LOGS_DIR, "./logs/sdnc/");
53         }
54     }
55
56     public static void main(String[] args) {
57         System.setProperty(Constants.Property.PARTNER_NAME, Components.SDNC_ADAPTER.toString());
58         SpringApplication.run(SDNCAdapterApplication.class, args);
59         System.getProperties().setProperty("server.name", "Springboot");
60         setLogsDir();
61     }
62
63     @Bean
64     public Executor asyncExecutor() {
65         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
66         executor.setTaskDecorator(new MDCTaskDecorator());
67         executor.setCorePoolSize(corePoolSize);
68         executor.setMaxPoolSize(maxPoolSize);
69         executor.setQueueCapacity(queueCapacity);
70         executor.setThreadNamePrefix("SDNCAdapter-");
71         executor.initialize();
72         return executor;
73     }
74
75 }