561273bf4d0f40bdcf5018cc203c213f6a24df80
[ccsdk/apps.git] / ms / neng / src / main / java / org / onap / ccsdk / apps / ms / neng / core / Application.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : CCSDK.apps
4  * ================================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2018 IBM.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.ccsdk.apps.ms.neng.core;
23
24 import java.util.Arrays;
25
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28 import org.springframework.boot.CommandLineRunner;
29 import org.springframework.boot.SpringApplication;
30 import org.springframework.boot.autoconfigure.SpringBootApplication;
31 import org.springframework.boot.builder.SpringApplicationBuilder;
32 import org.springframework.boot.web.support.SpringBootServletInitializer;
33 import org.springframework.context.ApplicationContext;
34 import org.springframework.context.annotation.Bean;
35 import org.springframework.context.annotation.ComponentScan;
36 import org.springframework.scheduling.annotation.EnableAsync;
37
38 /**
39  * Entry point for the micro-service -- it starts up the application. 
40  */
41 @SpringBootApplication
42 @ComponentScan(basePackages = "org.onap.ccsdk")
43 @EnableAsync
44 public class Application extends SpringBootServletInitializer {
45
46     private Logger log = LoggerFactory.getLogger(Application.class);
47
48     /**
49      * Configures the application.
50      */
51     @Override
52     protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
53         return application.sources(Application.class);
54     }
55
56     /**
57      * Entry point for the application. 
58      */
59     public static void main(String[] args) {
60         SpringApplication.run(Application.class, args);
61     }
62
63     /**
64      * Prints diagnostic information after application startup.
65      */
66     @Bean
67     public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
68         return args -> {
69             log.info("################################");
70             log.info("Inspecting the beans provided by Spring Boot:");
71             String[] beanNames = ctx.getBeanDefinitionNames();
72             Arrays.sort(beanNames);
73             for (String beanName : beanNames) {
74                 log.info(beanName);
75             }
76             log.info("################################");
77         };
78     }
79
80 }