added spring boot example using msb java sdk 37/9937/2
authorvirajput <vijendra_rajput@infosys.com>
Fri, 1 Sep 2017 16:13:34 +0000 (21:43 +0530)
committerVijendra Rajput <vijendra_rajput@infosys.com>
Fri, 1 Sep 2017 16:21:18 +0000 (16:21 +0000)
Issue-Id: MSB-23
Change-Id: I789dc5f101a3e511f9f4ccc6f023c57489ea28f6
Signed-off-by: virajput <vijendra_rajput@infosys.com>
example-spring-boot/pom.xml
example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/ContextRefreshedListener.java
example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/EmployeeServiceClient.java
example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/ExampleClient.java
example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/SpringBootApp.java
example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/common/MsbHelper.java
example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/controller/EmployeeController.java
example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/model/Employee.java

index be3ada7..07a02c2 100644 (file)
@@ -2,11 +2,11 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
-    
+
        <parent>
-      <groupId>org.onap.oparent</groupId>
-      <artifactId>oparent</artifactId>
-      <version>1.0.0-SNAPSHOT</version>
+               <groupId>org.onap.oparent</groupId>
+               <artifactId>oparent</artifactId>
+               <version>1.0.0-SNAPSHOT</version>
     </parent>
 
        <groupId>org.onap.msb.sdk</groupId>
                        </dependency>   
                </dependencies>
        </dependencyManagement> 
-       
+
        <dependencies>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter</artifactId>
                </dependency>
-
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-test</artifactId>
                        <scope>test</scope>
                </dependency>
-               
                <dependency>
-                   <groupId>org.springframework.boot</groupId>
-                   <artifactId>spring-boot-starter-web</artifactId>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter-web</artifactId>
                </dependency>
-        
-        <dependency>
-          <groupId>org.onap.msb.sdk</groupId>
+               <dependency>
+                       <groupId>org.onap.msb.sdk</groupId>
                        <artifactId>msb-java-sdk</artifactId>
                        <version>1.0.0-SNAPSHOT</version>
-        </dependency>    
-
+               </dependency>    
        </dependencies>
 
        <build>
index 9f3e532..2c4cc45 100644 (file)
@@ -1,9 +1,11 @@
 /*******************************************************************************
  * Copyright 2017 Infosys Limited and others.
- *------------------------------------------------------------------------------
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software distributed under the License
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  * or implied. See the License for the specific language governing permissions and limitations under
@@ -28,11 +30,11 @@ public class ContextRefreshedListener implements ApplicationListener<ContextRefr
 
         MSBServiceClient msbClient = new MSBServiceClient(MSB_IP, MSB_Port);
         MsbHelper helper = new MsbHelper(msbClient);
-        
+
         try {
-                       helper.registerMsb();
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
+               helper.registerMsb();
+        } catch (Exception e) {
+               e.printStackTrace();
+        }
     }
 }
\ No newline at end of file
index 8017f04..1718517 100644 (file)
@@ -1,9 +1,11 @@
 /*******************************************************************************
  * Copyright 2017 Infosys Limited and others.
- *------------------------------------------------------------------------------
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software distributed under the License
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  * or implied. See the License for the specific language governing permissions and limitations under
@@ -19,6 +21,6 @@ import retrofit2.http.GET;
 
 @ServiceHttpEndPoint(serviceName = "employee", serviceVersion = "v1")
 public interface EmployeeServiceClient {
-         @GET("employee")
-         Call<Employee> queryEmployee();
+       @GET("employee")
+       Call<Employee> queryEmployee();
 }
index ff0dee8..bce0d96 100644 (file)
@@ -1,9 +1,11 @@
 /*******************************************************************************
  * Copyright 2017 Infosys Limited and others.
- *------------------------------------------------------------------------------
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software distributed under the License
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  * or implied. See the License for the specific language governing permissions and limitations under
@@ -17,7 +19,6 @@ import org.onap.msb.sdk.example.springboot.model.Employee;
 import org.onap.msb.sdk.httpclient.RestServiceCreater;
 import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
 
-
 public class ExampleClient {
 
   /**
@@ -26,7 +27,7 @@ public class ExampleClient {
    */
   public static void main(String[] args) throws IOException {
     //For real use case, MSB IP and Port should come from configuration file instead of hard code here
-    String MSB_IP="192.168.0.110";
+    String MSB_IP="127.0.0.1";
     int MSB_Port=10081;
 
     MSBServiceClient msbClient = new MSBServiceClient(MSB_IP, MSB_Port);
index 4a37b58..8ba925d 100644 (file)
@@ -1,9 +1,11 @@
 /*******************************************************************************
  * Copyright 2017 Infosys Limited and others.
- *------------------------------------------------------------------------------
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software distributed under the License
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  * or implied. See the License for the specific language governing permissions and limitations under
@@ -16,9 +18,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 
 @SpringBootApplication
 public class SpringBootApp {
-
        public static void main(String[] args) {
                SpringApplication.run(SpringBootApp.class, args);
        }
-}
-
+}
\ No newline at end of file
index 9c1642c..ba28cba 100644 (file)
@@ -1,9 +1,11 @@
 /*******************************************************************************
  * Copyright 2017 Infosys Limited and others.
- *------------------------------------------------------------------------------
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software distributed under the License
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  * or implied. See the License for the specific language governing permissions and limitations under
@@ -38,7 +40,7 @@ public class MsbHelper {
     msinfo.setUrl("/api/v1");
     msinfo.setProtocol("REST");
     msinfo.setVisualRange("0|1");
-    
+
     Set<Node> nodes = new HashSet<>();
     Node node1 = new Node();
     node1.setIp(InetAddress.getLocalHost().getHostAddress());
index 9223006..bed8bfa 100644 (file)
@@ -1,9 +1,11 @@
 /*******************************************************************************
  * Copyright 2017 Infosys Limited and others.
- *------------------------------------------------------------------------------
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software distributed under the License
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  * or implied. See the License for the specific language governing permissions and limitations under
@@ -13,9 +15,8 @@ package org.onap.msb.sdk.example.springboot.controller;
 
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import org.onap.msb.sdk.example.springboot.model.Employee;;
+import org.onap.msb.sdk.example.springboot.model.Employee;
+
 @RestController
 public class EmployeeController {
     @RequestMapping("/employee")
index 43e6d88..f0076c2 100644 (file)
@@ -1,9 +1,11 @@
 /*******************************************************************************
  * Copyright 2017 Infosys Limited and others.
- *------------------------------------------------------------------------------
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software distributed under the License
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  * or implied. See the License for the specific language governing permissions and limitations under
 package org.onap.msb.sdk.example.springboot.model;
 
 import java.io.Serializable;
-
 import com.fasterxml.jackson.annotation.JsonProperty;
 
 public class Employee implements Serializable {
-        
-       private static final long serialVersionUID = 1L;
+
+  private static final long serialVersionUID = 1L;
 
     @JsonProperty
     private Integer id;
-    
+
     @JsonProperty
     private String firstName;
-    
+
     @JsonProperty
     private String lastName;
 
     @JsonProperty
     private String email;
-     
+
     public Employee() {}
 
     public Employee(Integer id, String firstName, String lastName, String email) {
@@ -40,7 +41,7 @@ public class Employee implements Serializable {
         this.lastName = lastName;
         this.email = email;
     }
-    
+
     public Integer getId() {
         return id;
     }