1 /*******************************************************************************
2 * Copyright 2017 Infosys Limited and others.
3 *------------------------------------------------------------------------------
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
6 * http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software distributed under the License
8 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
9 * or implied. See the License for the specific language governing permissions and limitations under
11 ******************************************************************************/
12 package org.onap.msb.sdk.example.springboot.common;
14 import java.net.InetAddress;
15 import java.util.HashSet;
18 import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
19 import org.onap.msb.sdk.discovery.entity.Node;
20 import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
22 public class MsbHelper {
24 private MSBServiceClient msbClient;
26 public MsbHelper(MSBServiceClient msbClient) {
28 this.msbClient = msbClient;
31 public void registerMsb() throws Exception {
34 MicroServiceInfo msinfo = new MicroServiceInfo();
36 msinfo.setServiceName("employee");
37 msinfo.setVersion("v1");
38 msinfo.setUrl("/api/v1");
39 msinfo.setProtocol("REST");
40 msinfo.setVisualRange("0|1");
42 Set<Node> nodes = new HashSet<>();
43 Node node1 = new Node();
44 node1.setIp(InetAddress.getLocalHost().getHostAddress());
45 node1.setPort("8080");
47 msinfo.setNodes(nodes);
48 msbClient.registerMicroServiceInfo(msinfo, false);