组网扩展

扩展说明

对等网络节点组网器。

扩展接口

com.alibaba.dubbo.remoting.p2p.Networker

扩展配置

  1. <dubbo:protocol networker="xxx" />
  2. <!-- 缺省值设置,当<dubbo:protocol>没有配置networker属性时,使用此配置 -->
  3. <dubbo:provider networker="xxx" />

已知扩展

  • com.alibaba.dubbo.remoting.p2p.support.MulticastNetworker
  • com.alibaba.dubbo.remoting.p2p.support.FileNetworker

    扩展示例

Maven 项目结构:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxNetworker.java (实现Networker接口)
  7. |-resources
  8. |-META-INF
  9. |-dubbo
  10. |-com.alibaba.dubbo.remoting.p2p.Networker (纯文本文件,内容为:xxx=com.xxx.XxxNetworker)

XxxNetworker.java:

  1. package com.xxx;
  2. import com.alibaba.dubbo.remoting.p2p.Networker;
  3. public class XxxNetworker implements Networker {
  4. public Group lookup(URL url) {
  5. // ...
  6. }
  7. }

META-INF/dubbo/com.alibaba.dubbo.remoting.p2p.Networker:

  1. xxx=com.xxx.XxxNetworker

原文: http://dubbo.apache.org/#!/docs/dev/impls/networker.md?lang=zh-cn