You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2019/07/04 06:51:07 UTC

[dubbo] branch 3.x-dev updated: Improve/consumer model (#4464)

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

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


The following commit(s) were added to refs/heads/3.x-dev by this push:
     new c2b272a  Improve/consumer model (#4464)
c2b272a is described below

commit c2b272ad4cd11e54572bda331f6a6fbb97b00ef5
Author: qinliujie <li...@alibaba-inc.com>
AuthorDate: Thu Jul 4 14:51:00 2019 +0800

    Improve/consumer model (#4464)
    
    * improve:get ConsumerMethodModel by method name and args type
    
    * improve:build router chain with router argument
---
 .../java/org/apache/dubbo/rpc/cluster/RouterChain.java    |  2 +-
 .../java/org/apache/dubbo/rpc/model/ConsumerModel.java    | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
index a690d73..44daff4 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
@@ -48,7 +48,7 @@ public class RouterChain<T> {
 
     private RouterChain(URL url) {
         List<RouterFactory> extensionFactories = ExtensionLoader.getExtensionLoader(RouterFactory.class)
-                .getActivateExtension(url, (String[]) null);
+                .getActivateExtension(url, "router");
 
         List<Router> routers = extensionFactories.stream()
                 .map(factory -> factory.getRouter(url))
diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/model/ConsumerModel.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/model/ConsumerModel.java
index e66e7b2..1a91ae1 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/model/ConsumerModel.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/model/ConsumerModel.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.rpc.model;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.IdentityHashMap;
 import java.util.List;
 import java.util.Map;
@@ -76,6 +77,20 @@ public class ConsumerModel {
     }
 
     /**
+     * @param method   metodName
+     * @param argsType method arguments type
+     * @return
+     */
+    public ConsumerMethodModel getMethodModel(String method, String[] argsType) {
+        Optional<ConsumerMethodModel> consumerMethodModel = methodModels.entrySet().stream()
+                .filter(entry -> entry.getKey().getName().equals(method))
+                .map(Map.Entry::getValue).filter(methodModel ->  Arrays.equals(argsType, methodModel.getParameterTypes()))
+                .findFirst();
+        return consumerMethodModel.orElse(null);
+    }
+
+
+    /**
      * @return
      */
     public Class<?> getServiceInterfaceClass() {