You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2017/12/27 02:10:59 UTC
[incubator-servicecomb-java-chassis] 05/05: JAV-583 add demo for
different consumer method name
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git
commit b15551c6d5d411745127be9e90f81c5a21c203ef
Author: wujimin <wu...@huawei.com>
AuthorDate: Tue Dec 26 10:43:12 2017 +0800
JAV-583 add demo for different consumer method name
---
.../demo/pojo/client/CodeFirstPojoClient.java | 18 ++++++++++++++-
.../demo/pojo/client/CodeFirstPojoClientIntf.java | 27 ++++++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/demo/demo-pojo/pojo-client/src/main/java/io/servicecomb/demo/pojo/client/CodeFirstPojoClient.java b/demo/demo-pojo/pojo-client/src/main/java/io/servicecomb/demo/pojo/client/CodeFirstPojoClient.java
index 1f89fe9..578c722 100644
--- a/demo/demo-pojo/pojo-client/src/main/java/io/servicecomb/demo/pojo/client/CodeFirstPojoClient.java
+++ b/demo/demo-pojo/pojo-client/src/main/java/io/servicecomb/demo/pojo/client/CodeFirstPojoClient.java
@@ -22,6 +22,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
@@ -35,7 +37,7 @@ import io.servicecomb.provider.pojo.RpcReference;
public class CodeFirstPojoClient {
@RpcReference(microserviceName = "pojo", schemaId = "io.servicecomb.demo.CodeFirstPojoIntf")
- public CodeFirstPojoIntf codeFirstAnnotation;
+ public CodeFirstPojoClientIntf codeFirstAnnotation;
@RpcReference(microserviceName = "pojo")
public CodeFirstPojoIntf codeFirstAnnotationEmptySchemaId;
@@ -68,6 +70,20 @@ public class CodeFirstPojoClient {
// testCodeFirstRawJsonString(template, cseUrlPrefix);
testCodeFirstSayHello(codeFirst);
testCodeFirstReduce(codeFirst);
+ testCodeFirstCompletableFuture(codeFirst);
+ }
+
+ private void testCodeFirstCompletableFuture(CodeFirstPojoIntf codeFirst) {
+ if (!CodeFirstPojoClientIntf.class.isInstance(codeFirst)) {
+ return;
+ }
+
+ CompletableFuture<String> future = ((CodeFirstPojoClientIntf) codeFirst).sayHiAsync("someone");
+ try {
+ TestMgr.check("someone sayhi", future.get());
+ } catch (InterruptedException | ExecutionException e) {
+ throw new IllegalStateException(e);
+ }
}
private void testCodeFirstUserMap(CodeFirstPojoIntf codeFirst) {
diff --git a/demo/demo-pojo/pojo-client/src/main/java/io/servicecomb/demo/pojo/client/CodeFirstPojoClientIntf.java b/demo/demo-pojo/pojo-client/src/main/java/io/servicecomb/demo/pojo/client/CodeFirstPojoClientIntf.java
new file mode 100644
index 0000000..6603deb
--- /dev/null
+++ b/demo/demo-pojo/pojo-client/src/main/java/io/servicecomb/demo/pojo/client/CodeFirstPojoClientIntf.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 the License.
+ */
+package io.servicecomb.demo.pojo.client;
+
+import java.util.concurrent.CompletableFuture;
+
+import io.servicecomb.demo.CodeFirstPojoIntf;
+import io.swagger.annotations.ApiOperation;
+
+public interface CodeFirstPojoClientIntf extends CodeFirstPojoIntf {
+ @ApiOperation(nickname = "sayHi", value = "")
+ CompletableFuture<String> sayHiAsync(String name);
+}
--
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.