2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 package org.onap.so.adapters.sdnc;
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;
35 @SpringBootApplication(scanBasePackages = {"org.onap"})
36 public class SDNCAdapterApplication {
39 @Value("${mso.async.core-pool-size}")
40 private int corePoolSize;
42 @Value("${mso.async.max-pool-size}")
43 private int maxPoolSize;
45 @Value("${mso.async.queue-capacity}")
46 private int queueCapacity;
48 private static final String LOGS_DIR = "logs_dir";
50 private static void setLogsDir() {
51 if (System.getProperty(LOGS_DIR) == null) {
52 System.getProperties().setProperty(LOGS_DIR, "./logs/sdnc/");
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");
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();