dubbo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] zonghaishang commented on a change in pull request #1511: 增加特性:动态获取Reference服务类
Date Mon, 26 Mar 2018 08:34:25 GMT
zonghaishang commented on a change in pull request #1511: 增加特性:动态获取Reference服务类
URL: https://github.com/apache/incubator-dubbo/pull/1511#discussion_r177013896
 
 

 ##########
 File path: dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/AnnotationBean.java
 ##########
 @@ -288,6 +296,73 @@ private Object refer(Reference reference, Class<?> referenceClass)
{ //method.ge
         return referenceConfig.get();
     }
 
+    /**
+     * refer 方法的公开版,将注解参数Reference换为 ReferenceConf 类
+     * @param reference
+     * @param referenceClass
+     * @return
+     */
+    public Object referNew(RefConf reference, Class<?> referenceClass) { //method.getParameterTypes()[0]
+        String interfaceName;
+
+        if (! "".equals( reference.interfaceName)) {
+            interfaceName =  reference.interfaceName;
+        } else if (! void.class.equals( reference.interfaceClass)) {
+            interfaceName =  reference.interfaceClass.getName();
+        } else if (referenceClass.isInterface()) {
+            interfaceName = referenceClass.getName();
+        } else {
+            throw new IllegalStateException("The @Reference undefined interfaceClass or interfaceName,
and the property type " + referenceClass.getName() + " is not a interface.");
+        }
+        String key =  reference.group + "/" + interfaceName + ":" +  reference.version;
 
 Review comment:
   Please see com.alibaba.dubbo.common.URL#getServiceKey , you should check property value
if exists.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message