1 /*******************************************************************************
2 * Copyright 2017 ZTE, Inc. and others.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing permissions and limitations under
13 ******************************************************************************/
14 package org.onap.msb.sdk.example.server;
16 import java.net.InetAddress;
17 import java.util.HashSet;
20 import org.jvnet.hk2.annotations.Service;
21 import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
22 import org.onap.msb.sdk.discovery.entity.Node;
23 import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
25 public class MsbHelper {
27 private MSBServiceClient msbClient;
29 public MsbHelper(MSBServiceClient msbClient) {
31 this.msbClient = msbClient;
36 public void registerMsb() throws Exception {
39 MicroServiceInfo msinfo = new MicroServiceInfo();
41 msinfo.setServiceName("animals");
42 msinfo.setVersion("v1");
43 msinfo.setUrl("/api/rpc/v1");
44 msinfo.setProtocol("REST");
45 msinfo.setVisualRange("0|1");
47 Set<Node> nodes = new HashSet<>();
48 Node node1 = new Node();
49 node1.setIp(InetAddress.getLocalHost().getHostAddress());
50 node1.setPort("9090");
52 msinfo.setNodes(nodes);
53 msbClient.registerMicroServiceInfo(msinfo, false);