diff options
author | virajput <vijendra_rajput@infosys.com> | 2017-09-01 21:43:34 +0530 |
---|---|---|
committer | Vijendra Rajput <vijendra_rajput@infosys.com> | 2017-09-01 16:21:18 +0000 |
commit | 4673d50960034dddd0620dbde0f86d8f61e12b4e (patch) | |
tree | e7b0a3a193ad1bfeba6a95d5c44008a3e5ac266d /example-spring-boot/src/main | |
parent | ae4b66d2e236855929313c6b2b4cbfe448ee4184 (diff) |
added spring boot example using msb java sdk
Issue-Id: MSB-23
Change-Id: I789dc5f101a3e511f9f4ccc6f023c57489ea28f6
Signed-off-by: virajput <vijendra_rajput@infosys.com>
Diffstat (limited to 'example-spring-boot/src/main')
7 files changed, 39 insertions, 30 deletions
diff --git a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/ContextRefreshedListener.java b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/ContextRefreshedListener.java index 9f3e532..2c4cc45 100644 --- a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/ContextRefreshedListener.java +++ b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/ContextRefreshedListener.java @@ -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 diff --git a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/EmployeeServiceClient.java b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/EmployeeServiceClient.java index 8017f04..1718517 100644 --- a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/EmployeeServiceClient.java +++ b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/EmployeeServiceClient.java @@ -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(); } diff --git a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/ExampleClient.java b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/ExampleClient.java index ff0dee8..bce0d96 100644 --- a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/ExampleClient.java +++ b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/ExampleClient.java @@ -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); diff --git a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/SpringBootApp.java b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/SpringBootApp.java index 4a37b58..8ba925d 100644 --- a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/SpringBootApp.java +++ b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/SpringBootApp.java @@ -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 diff --git a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/common/MsbHelper.java b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/common/MsbHelper.java index 9c1642c..ba28cba 100644 --- a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/common/MsbHelper.java +++ b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/common/MsbHelper.java @@ -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()); diff --git a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/controller/EmployeeController.java b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/controller/EmployeeController.java index 9223006..bed8bfa 100644 --- a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/controller/EmployeeController.java +++ b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/controller/EmployeeController.java @@ -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") diff --git a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/model/Employee.java b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/model/Employee.java index 43e6d88..f0076c2 100644 --- a/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/model/Employee.java +++ b/example-spring-boot/src/main/java/org/onap/msb/sdk/example/springboot/model/Employee.java @@ -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 @@ -12,25 +14,24 @@ 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; } |