2 * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
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.usecaseui.server;
18 import org.onap.msb.sdk.discovery.common.RouteException;
19 import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
20 import org.onap.msb.sdk.discovery.entity.Node;
21 import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
22 import org.onap.usecaseui.server.util.RestfulServices;
23 import org.springframework.boot.SpringApplication;
24 import org.springframework.boot.autoconfigure.SpringBootApplication;
25 import org.springframework.context.annotation.Bean;
26 import org.springframework.context.annotation.ComponentScan;
27 import org.springframework.web.client.RestTemplate;
29 import java.net.InetAddress;
30 import java.net.UnknownHostException;
31 import java.util.HashSet;
34 @SpringBootApplication
35 @ComponentScan(basePackages = "org.onap.usecaseui.server")
36 public class UsecaseuiServerApplication {
39 public RestTemplate getRestTemplate(){
40 return new RestTemplate();
43 public static void main(String[] args) {
44 SpringApplication.run(UsecaseuiServerApplication.class, args);
45 String msbUrl = RestfulServices.getMsbAddress();
46 if (msbUrl.contains(":")) {
47 String[] ipAndPort = msbUrl.split(":");
48 MSBServiceClient msbClient = new MSBServiceClient(ipAndPort[0], Integer.parseInt(ipAndPort[1]));
50 MicroServiceInfo msinfo = new MicroServiceInfo();
51 msinfo.setServiceName("usecase-ui-server");
52 msinfo.setVersion("v1");
53 msinfo.setUrl("/api/usecaseui/server/v1");
54 msinfo.setProtocol("REST");
55 msinfo.setVisualRange("0|1");
58 Set<Node> nodes = new HashSet<>();
59 Node node1 = new Node();
60 node1.setIp(InetAddress.getLocalHost().getHostAddress());
61 node1.setPort("8082");
63 msinfo.setNodes(nodes);
64 msbClient.registerMicroServiceInfo(msinfo, false);
65 } catch (UnknownHostException e) {
67 } catch (RouteException e) {