2 * Copyright 2016-2017 ZTE 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.
16 package org.onap.aai.esr;
19 import org.onap.aai.esr.common.MsbConfig;
20 import org.onap.aai.esr.externalservice.msb.MsbHelper;
21 import org.onap.aai.esr.resource.EmsManager;
22 import org.onap.aai.esr.resource.ServiceTest;
23 import org.onap.aai.esr.resource.ThirdpartySdncManager;
24 import org.onap.aai.esr.resource.VimManager;
25 import org.onap.aai.esr.resource.VnfmManager;
26 import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 import io.dropwizard.Application;
31 import io.dropwizard.setup.Environment;
33 public class ExtsysApp extends Application<ExtsysAppConfiguration> {
35 private static final Logger LOGGER = LoggerFactory.getLogger(ExtsysApp.class);
37 public static void main(String[] args) throws Exception {
38 new ExtsysApp().run(args);
42 public String getName() {
47 public void run(ExtsysAppConfiguration configuration, Environment environment) {
48 LOGGER.info("Start to initialize esr.");
49 MsbConfig.setMsbServerAddr(configuration.getMsbServerAddr());
50 MsbConfig.setMsbDiscoveryIp(configuration.getMsbDiscoveryIp());
51 MsbConfig.setMsbDiscoveryPort(configuration.getMsbDiscoveryPort());
52 environment.jersey().register(new EmsManager());
53 environment.jersey().register(new ThirdpartySdncManager());
54 environment.jersey().register(new VimManager());
55 environment.jersey().register(new VnfmManager());
56 environment.jersey().register(new ServiceTest());
57 if (configuration.getRegistByHand().equals("true")){
58 String MSB_IP=configuration.getMsbDiscoveryIp();
59 Integer MSB_Port= Integer.valueOf(configuration.getMsbDiscoveryPort());
60 MSBServiceClient msbClient = new MSBServiceClient(MSB_IP, MSB_Port);
61 MsbHelper helper = new MsbHelper(msbClient);
64 LOGGER.info("Register esr-server to msb by java-sdk finished");
65 } catch (Exception e) {
66 LOGGER.error("Register esr-server to msb by java-sdk failed", e);
69 LOGGER.info("Initialize extsys finished.");