设为首页 加入收藏

TOP

dubbo中Listener的实现(二)
2017-10-13 09:55:07 】 浏览:10083
Tags:dubbo Listener 实现
ExporterListener了,因为直接继承接口会强制要求实现两个方法的,而实际编码中dubbo的作者应该也发现这两个方法是完全不同的业务时使用,所有我们可以只继承ExporterListenerAdapter,如此自己的业务代码中就不需要出现一个空方法了。

 

实际扩展dubbo时,我们这这样写:

@Activate
public class ExportListenerTest extends ExporterListenerAdapter{

    public void exported(Exporter<?> exporter) throws RpcException {
        Class<?> exportClz = exporter.getInvoker().getInterface();
        System.out.println(exportClz.getName());
    }


}

然后用插件机制,在resource/META-INF/dubbo下新建一个文件:

文件名:com.alibaba.dubbo.rpc.ExporterListener

内容:

exportListenerTest=com.test.dubbo.service.listener.ExportListenerTest

如此我们在发布一个方法时都会调用到ExportListenerTest的exported方法。
 
首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇dubbo中Listener的实现 下一篇java冒泡排序的思想及代码实现

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目