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.apache.log4j.Logger;
20 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
21 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager;
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;
32 * Represents the spring boot application
34 @SpringBootApplication
35 public class NokiaSvnfmApplication {
36 private static Logger logger = Logger.getLogger(NokiaSvnfmApplication.class);
39 * Entry point for the Spring boot application
41 * @param args arguments for the application (not used)
43 public static void main(String[] args) {
44 SpringApplication.run(NokiaSvnfmApplication.class, args);
48 * Responsible for starting the self registration process after the servlet has been started
49 * and is ready to answer REST request
50 * - has been disabled in the test because the application that provides the ONAP simulator
51 * has already not yet been started (can not answer REST requests)
55 public static class SelfRegistrationTrigger implements ApplicationListener<ApplicationReadyEvent> {
57 private SelfRegistrationManager selfRegistrationManager;
60 public void onApplicationEvent(ApplicationReadyEvent contextRefreshedEvent) {
61 logger.info("Self registration started");
63 selfRegistrationManager.register();
64 logger.info("Self registration finished");
65 } catch (RuntimeException e) {
66 logger.error("Self registration failed", e);
73 * Responsible for starting the un-registration process after the service has been ramped down
74 * - has been disabled in test because the same application that provides the ONAP simulator
75 * has already been ramped down (can not answer REST requests)
79 public static class SelfDeRegistrationTrigger implements ApplicationListener<ContextClosedEvent> {
81 private SelfRegistrationManager selfRegistrationManager;
83 private JobManager jobManager;
86 public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
87 logger.info("Self de-registration started");
89 jobManager.prepareForShutdown();
90 selfRegistrationManager.deRegister();
91 } catch (RuntimeException e) {
92 logger.error("Self de-registration failed", e);
95 logger.info("Self de-registration finished");