2 * Copyright 2016-2017, Nokia Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia;
19 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
20 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager;
21 import org.slf4j.Logger;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.boot.SpringApplication;
24 import org.springframework.boot.autoconfigure.SpringBootApplication;
25 import org.springframework.boot.context.event.ApplicationReadyEvent;
26 import org.springframework.context.ApplicationListener;
27 import org.springframework.context.annotation.Profile;
28 import org.springframework.context.event.ContextClosedEvent;
29 import org.springframework.stereotype.Component;
31 import static org.slf4j.LoggerFactory.getLogger;
34 * Represents the spring boot application
36 @SpringBootApplication
37 public class NokiaSvnfmApplication {
38 private static Logger logger = getLogger(NokiaSvnfmApplication.class);
41 * Entry point for the Spring boot application
43 * @param args arguments for the application (not used)
45 public static void main(String[] args) {
46 SpringApplication.run(NokiaSvnfmApplication.class, args);
50 * Responsible for starting the self registration process after the servlet has been started
51 * and is ready to answer REST request
52 * - has been disabled in the test because the application that provides the ONAP simulator
53 * has already not yet been started (can not answer REST requests)
57 public static class SelfRegistrationTrigger implements ApplicationListener<ApplicationReadyEvent> {
59 private SelfRegistrationManager selfRegistrationManager;
62 public void onApplicationEvent(ApplicationReadyEvent contextRefreshedEvent) {
63 logger.info("Self registration started");
65 selfRegistrationManager.register();
66 logger.info("Self registration finished");
67 } catch (RuntimeException e) {
68 logger.error("Self registration failed", e);
75 * Responsible for starting the un-registration process after the service has been ramped down
76 * - has been disabled in test because the same application that provides the ONAP simulator
77 * has already been ramped down (can not answer REST requests)
81 public static class SelfDeRegistrationTrigger implements ApplicationListener<ContextClosedEvent> {
83 private SelfRegistrationManager selfRegistrationManager;
85 private JobManager jobManager;
88 public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
89 logger.info("Self de-registration started");
91 jobManager.prepareForShutdown();
92 selfRegistrationManager.deRegister();
93 } catch (RuntimeException e) {
94 logger.error("Self de-registration failed", e);
97 logger.info("Self de-registration finished");