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