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 07:59:50 UTC

[GitHub] zhouzhipeng opened a new pull request #1511: ���������������������������Reference���������

zhouzhipeng opened a new pull request #1511: 增加特性:动态获取Reference服务类
URL: https://github.com/apache/incubator-dubbo/pull/1511
 
 
   ## 动态获取Reference服务
   
   支持dubbo reference服务动态获取, 方便同一接口有多个dubbo实现类的场景。(可以通过group区分, eg: 从配置动态获取group名称来动态调用指定的group实现的服务,见下方示例代码)
   
   ## 服务提供方代码示例
   ```java
   
       @Service(group = "abctest")
       public class TagSearchServiceImpl implements TagSearchService {
       ...
       }
   
   
       @Service(group = "abctest2")
       public class TagSearchServiceImpl2 implements TagSearchService {
       ...
       }
   ```
   
   
   ## 消费端代码示例
   ```java
       //注入服务
       @Autowired
       private DynamicReferenceService dynamicReferenceService;
   ```
   
   ```java
   
       // 业务代码,动态获取指定接口和group的实现类
       RefConf rc=new RefConf();
   
       rc.group="abctest"; //或者 abctest2, 建议动态获取
   
       TagSearchService tagSearchService = dynamicReferenceService.getDubboService(TagSearchService.class,rc);
   
   ```
   

----------------------------------------------------------------
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