This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new 8456a11  Merge pull request #4014, Zipkin compatible.
8456a11 is described below

commit 8456a11a492b33270435dba8d01417cb35025289
Author: cvictory <[email protected]>
AuthorDate: Fri May 17 15:43:13 2019 +0800

    Merge pull request #4014, Zipkin compatible.
    
    fixes #3728.
---
 .../exchange/ResponseCallback.java}                |  7 +-
 .../java/com/alibaba/dubbo/rpc/Invocation.java     |  2 +-
 .../java/com/alibaba/dubbo/rpc/RpcContext.java     | 29 +++++++
 .../dubbo/FutureAdapter.java}                      | 13 +++-
 .../com/alibaba/dubbo/rpc/support/RpcUtils.java    | 88 ++++++++++++++++++++++
 .../main/java/org/apache/dubbo/rpc/RpcContext.java |  4 +
 6 files changed, 137 insertions(+), 6 deletions(-)

diff --git 
a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java 
b/dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/exchange/ResponseCallback.java
similarity index 83%
copy from dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
copy to 
dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/exchange/ResponseCallback.java
index a5db891..893b262 100644
--- a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
+++ 
b/dubbo-compatible/src/main/java/com/alibaba/dubbo/remoting/exchange/ResponseCallback.java
@@ -15,8 +15,11 @@
  * limitations under the License.
  */
 
-package com.alibaba.dubbo.rpc;
+package com.alibaba.dubbo.remoting.exchange;
 
+/**
+ * 2019-04-18
+ */
 @Deprecated
-public class RpcContext extends org.apache.dubbo.rpc.RpcContext {
+public interface ResponseCallback extends 
org.apache.dubbo.remoting.exchange.ResponseCallback {
 }
diff --git 
a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/Invocation.java 
b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/Invocation.java
index b96d14d..9d960c2 100644
--- a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/Invocation.java
+++ b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/Invocation.java
@@ -29,7 +29,7 @@ public interface Invocation extends 
org.apache.dubbo.rpc.Invocation {
         return null;
     }
 
-    class CompatibleInvocation implements Invocation {
+    class CompatibleInvocation implements Invocation, 
org.apache.dubbo.rpc.Invocation {
 
         private org.apache.dubbo.rpc.Invocation delegate;
 
diff --git 
a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java 
b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
index a5db891..bf6160c 100644
--- a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
+++ b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
@@ -19,4 +19,33 @@ package com.alibaba.dubbo.rpc;
 
 @Deprecated
 public class RpcContext extends org.apache.dubbo.rpc.RpcContext {
+
+
+    public static RpcContext getContext() {
+        return newInstance(org.apache.dubbo.rpc.RpcContext.getContext());
+    }
+
+    private static RpcContext newInstance(org.apache.dubbo.rpc.RpcContext 
rpcContext) {
+        RpcContext copy = new RpcContext();
+        copy.getAttachments().putAll(rpcContext.getAttachments());
+        copy.get().putAll(rpcContext.get());
+        copy.setFuture(rpcContext.getFuture());
+        copy.setUrls(rpcContext.getUrls());
+        copy.setUrl(rpcContext.getUrl());
+        copy.setMethodName(rpcContext.getMethodName());
+        copy.setParameterTypes(rpcContext.getParameterTypes());
+        copy.setArguments(rpcContext.getArguments());
+        copy.setLocalAddress(rpcContext.getLocalAddress());
+        copy.setRemoteAddress(rpcContext.getRemoteAddress());
+        copy.setRemoteApplicationName(rpcContext.getRemoteApplicationName());
+        copy.setInvokers(rpcContext.getInvokers());
+        copy.setInvoker(rpcContext.getInvoker());
+        copy.setInvocation(rpcContext.getInvocation());
+
+        copy.setRequest(rpcContext.getRequest());
+        copy.setResponse(rpcContext.getResponse());
+        copy.setAsyncContext(rpcContext.getAsyncContext());
+
+        return copy;
+    }
 }
diff --git 
a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java 
b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureAdapter.java
similarity index 72%
copy from dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
copy to 
dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureAdapter.java
index a5db891..07a6987 100644
--- a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
+++ 
b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureAdapter.java
@@ -15,8 +15,15 @@
  * limitations under the License.
  */
 
-package com.alibaba.dubbo.rpc;
+package com.alibaba.dubbo.rpc.protocol.dubbo;
 
-@Deprecated
-public class RpcContext extends org.apache.dubbo.rpc.RpcContext {
+import org.apache.dubbo.remoting.exchange.ResponseFuture;
+
+/**
+ * 2019-04-18
+ */
+public class FutureAdapter<V> extends 
org.apache.dubbo.rpc.protocol.dubbo.FutureAdapter<V> {
+    public FutureAdapter(ResponseFuture future) {
+        super(future);
+    }
 }
diff --git 
a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/support/RpcUtils.java 
b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/support/RpcUtils.java
new file mode 100644
index 0000000..7f1ab98
--- /dev/null
+++ b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/support/RpcUtils.java
@@ -0,0 +1,88 @@
+/*
+ * 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 com.alibaba.dubbo.rpc.support;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.rpc.Invocation;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+/**
+ * 2019-04-18
+ */
+public class RpcUtils extends org.apache.dubbo.rpc.support.RpcUtils {
+
+
+    public static Class<?> getReturnType(Invocation invocation) {
+        return org.apache.dubbo.rpc.support.RpcUtils.getReturnType(invocation);
+    }
+
+    // TODO why not get return type when initialize Invocation?
+    public static Type[] getReturnTypes(Invocation invocation) {
+        return 
org.apache.dubbo.rpc.support.RpcUtils.getReturnTypes(invocation);
+    }
+
+    public static Long getInvocationId(Invocation inv) {
+        return org.apache.dubbo.rpc.support.RpcUtils.getInvocationId(inv);
+    }
+
+    /**
+     * Idempotent operation: invocation id will be added in async operation by 
default
+     *
+     * @param url
+     * @param inv
+     */
+    public static void attachInvocationIdIfAsync(URL url, Invocation inv) {
+        
org.apache.dubbo.rpc.support.RpcUtils.attachInvocationIdIfAsync(url.getOriginalURL(),
 inv);
+    }
+
+
+    public static String getMethodName(Invocation invocation) {
+        return org.apache.dubbo.rpc.support.RpcUtils.getMethodName(invocation);
+    }
+
+    public static Object[] getArguments(Invocation invocation) {
+        return org.apache.dubbo.rpc.support.RpcUtils.getArguments(invocation);
+    }
+
+    public static Class<?>[] getParameterTypes(Invocation invocation) {
+        return 
org.apache.dubbo.rpc.support.RpcUtils.getParameterTypes(invocation);
+    }
+
+    public static boolean isAsync(URL url, Invocation inv) {
+        return 
org.apache.dubbo.rpc.support.RpcUtils.isAsync(url.getOriginalURL(), inv);
+    }
+
+    public static boolean isReturnTypeFuture(Invocation inv) {
+        return org.apache.dubbo.rpc.support.RpcUtils.isReturnTypeFuture(inv);
+    }
+
+    public static boolean hasFutureReturnType(Method method) {
+        return 
org.apache.dubbo.rpc.support.RpcUtils.hasFutureReturnType(method);
+    }
+
+    public static boolean isOneway(URL url, Invocation inv) {
+        return 
org.apache.dubbo.rpc.support.RpcUtils.isOneway(url.getOriginalURL(), inv);
+    }
+
+    public static Map<String, String> getNecessaryAttachments(Invocation inv) {
+        return 
org.apache.dubbo.rpc.support.RpcUtils.getNecessaryAttachments(inv);
+    }
+}
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java
index a468baa..fc658db 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java
@@ -758,6 +758,10 @@ public class RpcContext {
         return currentContext.asyncContext;
     }
 
+    protected void setAsyncContext(AsyncContext asyncContext) {
+        this.asyncContext = asyncContext;
+    }
+
     public boolean isAsyncStarted() {
         if (this.asyncContext == null) {
             return false;

Reply via email to