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;
29 import io.dropwizard.Application;
30 import io.dropwizard.setup.Environment;
32 public class ExtsysApp extends Application<ExtsysAppConfiguration> {
34 private static final Logger LOGGER = LoggerFactory.getLogger(ExtsysApp.class);
36 public static void main(String[] args) throws Exception {
37 new ExtsysApp().run(args);
41 public String getName() {
46 public void run(ExtsysAppConfiguration configuration, Environment environment) {
47 LOGGER.info("Start to initialize esr.");
48 MsbConfig.setMsbServerAddr(configuration.getMsbServerAddr());
49 MsbConfig.setMsbDiscoveryIp(configuration.getMsbDiscoveryIp());
50 MsbConfig.setMsbDiscoveryPort(configuration.getMsbDiscoveryPort());
51 environment.jersey().register(new EmsManager());
52 environment.jersey().register(new ThirdpartySdncManager());
53 environment.jersey().register(new VimManager());
54 environment.jersey().register(new VnfmManager());
55 environment.jersey().register(new ServiceTest());
56 if (configuration.getRegistByHand().equals("true")) {
57 String MSB_IP = configuration.getMsbDiscoveryIp();
58 Integer MSB_Port = Integer.valueOf(configuration.getMsbDiscoveryPort());
59 MSBServiceClient msbClient = new MSBServiceClient(MSB_IP, MSB_Port);
60 MsbHelper helper = new MsbHelper(msbClient);
63 LOGGER.info("Register esr-server to msb by java-sdk finished");
64 } catch (Exception e) {
65 LOGGER.error("Register esr-server to msb by java-sdk failed", e);
68 LOGGER.info("Initialize extsys finished.");