You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/03/26 08:34:25 UTC

[GitHub] zonghaishang commented on a change in pull request #1511: ���������������������������Reference���������

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