summaryrefslogtreecommitdiffstats
path: root/example/src/main/java/org/onap
diff options
context:
space:
mode:
authorHuabingZhao <zhao.huabing@zte.com.cn>2017-08-18 16:18:01 +0800
committerHuabingZhao <zhao.huabing@zte.com.cn>2017-08-18 08:53:28 +0000
commit9252e604db14785fe5382e33cedffbdd2759091d (patch)
tree27e0199aae05823ee6fd714cba6796f4f76362f8 /example/src/main/java/org/onap
parent33c5e66c67d9eb72f1bf1cef974a538005b8a7ff (diff)
Modify Example code
Issue-Id: MSB-23 Change-Id: I03a05b27987015725234d31ccbef2b979be40f92 Signed-off-by: HuabingZhao <zhao.huabing@zte.com.cn>
Diffstat (limited to 'example/src/main/java/org/onap')
-rw-r--r--example/src/main/java/org/onap/msb/sdk/example/client/AnimalServiceClient.java (renamed from example/src/main/java/org/onap/msb/sdk/httpclient/client/AnimalServiceClient.java)9
-rw-r--r--example/src/main/java/org/onap/msb/sdk/example/client/ExampleClient.java (renamed from example/src/main/java/org/onap/msb/sdk/httpclient/client/ExampleClient.java)12
-rw-r--r--example/src/main/java/org/onap/msb/sdk/example/common/Animal.java (renamed from example/src/main/java/org/onap/msb/sdk/httpclient/common/Animal.java)2
-rw-r--r--example/src/main/java/org/onap/msb/sdk/example/server/Config.java (renamed from example/src/main/java/org/onap/msb/sdk/httpclient/server/Config.java)2
-rw-r--r--example/src/main/java/org/onap/msb/sdk/example/server/ExampleApp.java (renamed from example/src/main/java/org/onap/msb/sdk/httpclient/server/ExampleApp.java)11
-rw-r--r--example/src/main/java/org/onap/msb/sdk/example/server/MsbHelper.java (renamed from example/src/main/java/org/onap/msb/sdk/httpclient/server/MsbHelper.java)8
-rw-r--r--example/src/main/java/org/onap/msb/sdk/example/server/resources/AnimalResource.java (renamed from example/src/main/java/org/onap/msb/sdk/httpclient/server/resources/AnimalResource.java)10
7 files changed, 27 insertions, 27 deletions
diff --git a/example/src/main/java/org/onap/msb/sdk/httpclient/client/AnimalServiceClient.java b/example/src/main/java/org/onap/msb/sdk/example/client/AnimalServiceClient.java
index 22101ad..8600241 100644
--- a/example/src/main/java/org/onap/msb/sdk/httpclient/client/AnimalServiceClient.java
+++ b/example/src/main/java/org/onap/msb/sdk/example/client/AnimalServiceClient.java
@@ -11,10 +11,10 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
-package org.onap.msb.sdk.httpclient.client;
+package org.onap.msb.sdk.example.client;
+import org.onap.msb.sdk.example.common.Animal;
import org.onap.msb.sdk.httpclient.annotaion.ServiceHttpEndPoint;
-import org.onap.msb.sdk.httpclient.common.Animal;
import retrofit2.Call;
import retrofit2.http.GET;
@@ -25,10 +25,9 @@ import retrofit2.http.Path;
*
*/
-@ServiceHttpEndPoint(serviceName = "animals", serviceVersion = "v1", nameSpace = "javaAF")
+@ServiceHttpEndPoint(serviceName = "animals", serviceVersion = "v1")
public interface AnimalServiceClient {
@GET("animals/{name}")
- Call<Animal> queryAnimal(@Path("name") String name);
-
+ Call<Animal> queryAnimal1(@Path("name") String name);
}
diff --git a/example/src/main/java/org/onap/msb/sdk/httpclient/client/ExampleClient.java b/example/src/main/java/org/onap/msb/sdk/example/client/ExampleClient.java
index 570078b..59263f1 100644
--- a/example/src/main/java/org/onap/msb/sdk/httpclient/client/ExampleClient.java
+++ b/example/src/main/java/org/onap/msb/sdk/example/client/ExampleClient.java
@@ -14,12 +14,12 @@
/**
*
*/
-package org.onap.msb.sdk.httpclient.client;
+package org.onap.msb.sdk.example.client;
import java.io.IOException;
+import org.onap.msb.sdk.example.common.Animal;
import org.onap.msb.sdk.httpclient.RetrofitServiceCreater;
-import org.onap.msb.sdk.httpclient.common.Animal;
import org.onap.msb.sdk.httpclient.conf.HttpClientConf;
import org.onap.msb.sdk.httpclient.msb.MSBServiceWrapperClient;
@@ -31,16 +31,18 @@ public class ExampleClient {
* @throws IOException
*/
public static void main(String[] args) throws IOException {
-
+ String MSB_IP="127.0.0.1";
+ int MSB_Port=10081;
+
HttpClientConf globalHttpClientConf = new HttpClientConf();
- MSBServiceWrapperClient msbClient = new MSBServiceWrapperClient("127.0.0.1", 10081);
+ MSBServiceWrapperClient msbClient = new MSBServiceWrapperClient(MSB_IP, MSB_Port);
RetrofitServiceCreater retrofitServiceCreater =
new RetrofitServiceCreater(globalHttpClientConf, msbClient);
AnimalServiceClient implProxy =
retrofitServiceCreater.createRetrofitService(AnimalServiceClient.class);
- Animal animal = implProxy.queryAnimal("example").execute().body();
+ Animal animal = implProxy.queryAnimal1("panda").execute().body();
System.out.println("animal:" + animal);
}
diff --git a/example/src/main/java/org/onap/msb/sdk/httpclient/common/Animal.java b/example/src/main/java/org/onap/msb/sdk/example/common/Animal.java
index 092a2f7..03572ce 100644
--- a/example/src/main/java/org/onap/msb/sdk/httpclient/common/Animal.java
+++ b/example/src/main/java/org/onap/msb/sdk/example/common/Animal.java
@@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
-package org.onap.msb.sdk.httpclient.common;
+package org.onap.msb.sdk.example.common;
import java.io.Serializable;
diff --git a/example/src/main/java/org/onap/msb/sdk/httpclient/server/Config.java b/example/src/main/java/org/onap/msb/sdk/example/server/Config.java
index 4dbb6eb..446e2c1 100644
--- a/example/src/main/java/org/onap/msb/sdk/httpclient/server/Config.java
+++ b/example/src/main/java/org/onap/msb/sdk/example/server/Config.java
@@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
-package org.onap.msb.sdk.httpclient.server;
+package org.onap.msb.sdk.example.server;
import io.dropwizard.Configuration;
diff --git a/example/src/main/java/org/onap/msb/sdk/httpclient/server/ExampleApp.java b/example/src/main/java/org/onap/msb/sdk/example/server/ExampleApp.java
index 03c052a..b93875f 100644
--- a/example/src/main/java/org/onap/msb/sdk/httpclient/server/ExampleApp.java
+++ b/example/src/main/java/org/onap/msb/sdk/example/server/ExampleApp.java
@@ -11,10 +11,10 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
-package org.onap.msb.sdk.httpclient.server;
+package org.onap.msb.sdk.example.server;
+import org.onap.msb.sdk.example.server.resources.AnimalResource;
import org.onap.msb.sdk.httpclient.msb.MSBServiceWrapperClient;
-import org.onap.msb.sdk.httpclient.server.resources.AnimalResource;
import io.dropwizard.Application;
import io.dropwizard.setup.Environment;
@@ -38,10 +38,13 @@ public class ExampleApp extends Application<Config> {
@Override
public void run(Config configuration, Environment environment) throws Exception {
-
+
+ String MSB_IP="127.0.0.1";
+ int MSB_Port=10081;
+
environment.jersey().register(new AnimalResource());
- MSBServiceWrapperClient msbClient = new MSBServiceWrapperClient("127.0.0.1", 10081);
+ MSBServiceWrapperClient msbClient = new MSBServiceWrapperClient(MSB_IP, MSB_Port);
MsbHelper helper = new MsbHelper(msbClient);
helper.registerMsb();
diff --git a/example/src/main/java/org/onap/msb/sdk/httpclient/server/MsbHelper.java b/example/src/main/java/org/onap/msb/sdk/example/server/MsbHelper.java
index ffaba08..7b0c79d 100644
--- a/example/src/main/java/org/onap/msb/sdk/httpclient/server/MsbHelper.java
+++ b/example/src/main/java/org/onap/msb/sdk/example/server/MsbHelper.java
@@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
-package org.onap.msb.sdk.httpclient.server;
+package org.onap.msb.sdk.example.server;
import java.net.InetAddress;
import java.util.HashSet;
@@ -50,7 +50,7 @@ public class MsbHelper {
msinfo.setUrl("/api/rpc/v1");
msinfo.setProtocol("REST");
msinfo.setVisualRange("0|1");
-
+
Set<Node> nodes = new HashSet<>();
Node node1 = new Node();
node1.setIp(InetAddress.getLocalHost().getHostAddress());
@@ -58,9 +58,5 @@ public class MsbHelper {
nodes.add(node1);
msinfo.setNodes(nodes);
msbClient.registerMicroServiceInfo(msinfo, false);
-
}
-
-
-
}
diff --git a/example/src/main/java/org/onap/msb/sdk/httpclient/server/resources/AnimalResource.java b/example/src/main/java/org/onap/msb/sdk/example/server/resources/AnimalResource.java
index 7a51c0f..ce7115f 100644
--- a/example/src/main/java/org/onap/msb/sdk/httpclient/server/resources/AnimalResource.java
+++ b/example/src/main/java/org/onap/msb/sdk/example/server/resources/AnimalResource.java
@@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
-package org.onap.msb.sdk.httpclient.server.resources;
+package org.onap.msb.sdk.example.server.resources;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -20,7 +20,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.onap.msb.sdk.httpclient.common.Animal;
+import org.onap.msb.sdk.example.common.Animal;
@Path("/animals")
@@ -30,9 +30,9 @@ public class AnimalResource {
@GET
@Path("/{name}")
@Produces(MediaType.APPLICATION_JSON)
- public Response query(@PathParam("name") String name) {
- return Response.ok(new Animal("animal", name, (int) System.currentTimeMillis() % 10)).build();
+ public Response queryJson(@PathParam("name") String name) {
+ return Response.ok(new Animal("animal", name, Math.abs((int) System.currentTimeMillis() % 10)))
+ .build();
}
-
}