blob: a96ed43de093e2152543a55660aac63a95c733df [file] [log] [blame]
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>6.9 注册中心扩展 · GitBook</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2">
<link rel="stylesheet" href="../gitbook/style.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="监控中心扩展.html" />
<link rel="prev" href="合并结果扩展.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="../">
<a href="../">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="../contribution.html">
<a href="../contribution.html">
1 contribution
</a>
</li>
<li class="chapter " data-level="1.3" data-path="../版本管理.html">
<a href="../版本管理.html">
2 版本管理
</a>
</li>
<li class="chapter " data-level="1.4" data-path="../源码构建.html">
<a href="../源码构建.html">
3 源码构建
</a>
</li>
<li class="chapter " data-level="1.5" data-path="../框架设计.html">
<a href="../框架设计.html">
4 框架设计
</a>
</li>
<li class="chapter " data-level="1.6" data-path="../扩展点加载.html">
<a href="../扩展点加载.html">
5 扩展点加载
</a>
</li>
<li class="chapter " data-level="1.7" data-path="introduction.html">
<a href="introduction.html">
6 SPI参考手册
</a>
<ul class="articles">
<li class="chapter " data-level="1.7.1" data-path="协议扩展.html">
<a href="协议扩展.html">
6.1 协议扩展
</a>
</li>
<li class="chapter " data-level="1.7.2" data-path="调用拦截扩展.html">
<a href="调用拦截扩展.html">
6.2 调用拦截扩展
</a>
</li>
<li class="chapter " data-level="1.7.3" data-path="引用监听扩展.html">
<a href="引用监听扩展.html">
6.3 引用监听扩展
</a>
</li>
<li class="chapter " data-level="1.7.4" data-path="暴露监听扩展.html">
<a href="暴露监听扩展.html">
6.4 暴露监听扩展
</a>
</li>
<li class="chapter " data-level="1.7.5" data-path="集群扩展.html">
<a href="集群扩展.html">
6.5 集群扩展
</a>
</li>
<li class="chapter " data-level="1.7.6" data-path="路由扩展.html">
<a href="路由扩展.html">
6.6 路由扩展
</a>
</li>
<li class="chapter " data-level="1.7.7" data-path="负载均衡扩展.html">
<a href="负载均衡扩展.html">
6.7 负载均衡扩展
</a>
</li>
<li class="chapter " data-level="1.7.8" data-path="合并结果扩展.html">
<a href="合并结果扩展.html">
6.8 合并结果扩展
</a>
</li>
<li class="chapter active" data-level="1.7.9" data-path="注册中心扩展.html">
<a href="注册中心扩展.html">
6.9 注册中心扩展
</a>
</li>
<li class="chapter " data-level="1.7.10" data-path="监控中心扩展.html">
<a href="监控中心扩展.html">
6.10 监控中心扩展
</a>
</li>
<li class="chapter " data-level="1.7.11" data-path="扩展点加载扩展.html">
<a href="扩展点加载扩展.html">
6.11 扩展点加载扩展
</a>
</li>
<li class="chapter " data-level="1.7.12" data-path="动态代理扩展.html">
<a href="动态代理扩展.html">
6.12 动态代理扩展
</a>
</li>
<li class="chapter " data-level="1.7.13" data-path="编译器扩展.html">
<a href="编译器扩展.html">
6.13 编译器扩展
</a>
</li>
<li class="chapter " data-level="1.7.14" data-path="消息派发扩展.html">
<a href="消息派发扩展.html">
6.14 消息派发扩展
</a>
</li>
<li class="chapter " data-level="1.7.15" data-path="线程池扩展.html">
<a href="线程池扩展.html">
6.15 线程池扩展
</a>
</li>
<li class="chapter " data-level="1.7.16" data-path="序列化扩展.html">
<a href="序列化扩展.html">
6.16 序列化扩展
</a>
</li>
<li class="chapter " data-level="1.7.17" data-path="网络传输扩展.html">
<a href="网络传输扩展.html">
6.17 网络传输扩展
</a>
</li>
<li class="chapter " data-level="1.7.18" data-path="信息交换扩展.html">
<a href="信息交换扩展.html">
6.18 信息交换扩展
</a>
</li>
<li class="chapter " data-level="1.7.19" data-path="组网扩展.html">
<a href="组网扩展.html">
6.19 组网扩展
</a>
</li>
<li class="chapter " data-level="1.7.20" data-path="Telnet命令扩展.html">
<a href="Telnet命令扩展.html">
6.20 Telnet命令扩展
</a>
</li>
<li class="chapter " data-level="1.7.21" data-path="状态检查扩展.html">
<a href="状态检查扩展.html">
6.21 状态检查扩展
</a>
</li>
<li class="chapter " data-level="1.7.22" data-path="容器扩展.html">
<a href="容器扩展.html">
6.22 容器扩展
</a>
</li>
<li class="chapter " data-level="1.7.23" data-path="页面扩展.html">
<a href="页面扩展.html">
6.23 页面扩展
</a>
</li>
<li class="chapter " data-level="1.7.24" data-path="缓存扩展.html">
<a href="缓存扩展.html">
6.24 缓存扩展
</a>
</li>
<li class="chapter " data-level="1.7.25" data-path="验证扩展.html">
<a href="验证扩展.html">
6.25 验证扩展
</a>
</li>
<li class="chapter " data-level="1.7.26" data-path="日志适配扩展.html">
<a href="日志适配扩展.html">
6.26 日志适配扩展
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.8" data-path="../技术兼容性测试.html">
<a href="../技术兼容性测试.html">
7 技术兼容性测试
</a>
</li>
<li class="chapter " data-level="1.9" data-path="../公共契约.html">
<a href="../公共契约.html">
8 公共契约
</a>
</li>
<li class="chapter " data-level="1.10" data-path="../坏味道.html">
<a href="../坏味道.html">
9 坏味道
</a>
</li>
<li class="chapter " data-level="1.11" data-path="../编码约定.html">
<a href="../编码约定.html">
10 编码约定
</a>
</li>
<li class="chapter " data-level="1.12" data-path="../检查列表.html">
<a href="../检查列表.html">
11 检查列表
</a>
</li>
<li class="chapter " data-level="1.13" data-path="../设计原则.html">
<a href="../设计原则.html">
12 设计原则
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href=".." >6.9 注册中心扩展</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h5 id="1-&#x6269;&#x5C55;&#x8BF4;&#x660E;">1. &#x6269;&#x5C55;&#x8BF4;&#x660E;</h5>
<p>&#x8D1F;&#x8D23;&#x670D;&#x52A1;&#x7684;&#x6CE8;&#x518C;&#x4E0E;&#x53D1;&#x73B0;&#x3002;</p>
<h5 id="2-&#x6269;&#x5C55;&#x63A5;&#x53E3;">2. &#x6269;&#x5C55;&#x63A5;&#x53E3;</h5>
<ul>
<li><code>com.alibaba.dubbo.registry.RegistryFactory</code></li>
<li><code>com.alibaba.dubbo.registry.Registry</code></li>
</ul>
<h5 id="3-&#x6269;&#x5C55;&#x914D;&#x7F6E;">3. &#x6269;&#x5C55;&#x914D;&#x7F6E;</h5>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dubbo:registry</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;xxx1&quot;</span> <span class="hljs-attr">address</span>=<span class="hljs-string">&quot;xxx://ip:port&quot;</span> /&gt;</span> <span class="hljs-comment">&lt;!-- &#x5B9A;&#x4E49;&#x6CE8;&#x518C;&#x4E2D;&#x5FC3; --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">dubbo:service</span> <span class="hljs-attr">registry</span>=<span class="hljs-string">&quot;xxx1&quot;</span> /&gt;</span> <span class="hljs-comment">&lt;!-- &#x5F15;&#x7528;&#x6CE8;&#x518C;&#x4E2D;&#x5FC3;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x914D;&#x7F6E;registry&#x5C5E;&#x6027;&#xFF0C;&#x5C06;&#x5728;ApplicationContext&#x4E2D;&#x81EA;&#x52A8;&#x626B;&#x63CF;registry&#x914D;&#x7F6E; --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">dubbo:provider</span> <span class="hljs-attr">registry</span>=<span class="hljs-string">&quot;xxx1&quot;</span> /&gt;</span> <span class="hljs-comment">&lt;!-- &#x5F15;&#x7528;&#x6CE8;&#x518C;&#x4E2D;&#x5FC3;&#x7F3A;&#x7701;&#x503C;&#xFF0C;&#x5F53;&lt;dubbo:service&gt;&#x6CA1;&#x6709;&#x914D;&#x7F6E;registry&#x5C5E;&#x6027;&#x65F6;&#xFF0C;&#x4F7F;&#x7528;&#x6B64;&#x914D;&#x7F6E; --&gt;</span>
</code></pre>
<h5 id="4-&#x6269;&#x5C55;&#x5951;&#x7EA6;">4. &#x6269;&#x5C55;&#x5951;&#x7EA6;</h5>
<p>RegistryFactory.java</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">RegistryFactory</span> </span>{
<span class="hljs-comment">/**
* &#x8FDE;&#x63A5;&#x6CE8;&#x518C;&#x4E2D;&#x5FC3;.
*
* &#x8FDE;&#x63A5;&#x6CE8;&#x518C;&#x4E2D;&#x5FC3;&#x9700;&#x5904;&#x7406;&#x5951;&#x7EA6;&#xFF1A;&lt;br&gt;
* 1. &#x5F53;&#x8BBE;&#x7F6E;check=false&#x65F6;&#x8868;&#x793A;&#x4E0D;&#x68C0;&#x67E5;&#x8FDE;&#x63A5;&#xFF0C;&#x5426;&#x5219;&#x5728;&#x8FDE;&#x63A5;&#x4E0D;&#x4E0A;&#x65F6;&#x629B;&#x51FA;&#x5F02;&#x5E38;&#x3002;&lt;br&gt;
* 2. &#x652F;&#x6301;URL&#x4E0A;&#x7684;username:password&#x6743;&#x9650;&#x8BA4;&#x8BC1;&#x3002;&lt;br&gt;
* 3. &#x652F;&#x6301;backup=10.20.153.10&#x5907;&#x9009;&#x6CE8;&#x518C;&#x4E2D;&#x5FC3;&#x96C6;&#x7FA4;&#x5730;&#x5740;&#x3002;&lt;br&gt;
* 4. &#x652F;&#x6301;file=registry.cache&#x672C;&#x5730;&#x78C1;&#x76D8;&#x6587;&#x4EF6;&#x7F13;&#x5B58;&#x3002;&lt;br&gt;
* 5. &#x652F;&#x6301;timeout=1000&#x8BF7;&#x6C42;&#x8D85;&#x65F6;&#x8BBE;&#x7F6E;&#x3002;&lt;br&gt;
* 6. &#x652F;&#x6301;session=60000&#x4F1A;&#x8BDD;&#x8D85;&#x65F6;&#x6216;&#x8FC7;&#x671F;&#x8BBE;&#x7F6E;&#x3002;&lt;br&gt;
*
* <span class="hljs-doctag">@param</span> url &#x6CE8;&#x518C;&#x4E2D;&#x5FC3;&#x5730;&#x5740;&#xFF0C;&#x4E0D;&#x5141;&#x8BB8;&#x4E3A;&#x7A7A;
* <span class="hljs-doctag">@return</span> &#x6CE8;&#x518C;&#x4E2D;&#x5FC3;&#x5F15;&#x7528;&#xFF0C;&#x603B;&#x4E0D;&#x8FD4;&#x56DE;&#x7A7A;
*/</span>
<span class="hljs-function">Registry <span class="hljs-title">getRegistry</span><span class="hljs-params">(URL url)</span></span>;
}
</code></pre>
<p>RegistryService.java</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">RegistryService</span> </span>{ <span class="hljs-comment">// Registry extends RegistryService </span>
<span class="hljs-comment">/**
* &#x6CE8;&#x518C;&#x670D;&#x52A1;.
*
* &#x6CE8;&#x518C;&#x9700;&#x5904;&#x7406;&#x5951;&#x7EA6;&#xFF1A;&lt;br&gt;
* 1. &#x5F53;URL&#x8BBE;&#x7F6E;&#x4E86;check=false&#x65F6;&#xFF0C;&#x6CE8;&#x518C;&#x5931;&#x8D25;&#x540E;&#x4E0D;&#x62A5;&#x9519;&#xFF0C;&#x5728;&#x540E;&#x53F0;&#x5B9A;&#x65F6;&#x91CD;&#x8BD5;&#xFF0C;&#x5426;&#x5219;&#x629B;&#x51FA;&#x5F02;&#x5E38;&#x3002;&lt;br&gt;
* 2. &#x5F53;URL&#x8BBE;&#x7F6E;&#x4E86;dynamic=false&#x53C2;&#x6570;&#xFF0C;&#x5219;&#x9700;&#x6301;&#x4E45;&#x5B58;&#x50A8;&#xFF0C;&#x5426;&#x5219;&#xFF0C;&#x5F53;&#x6CE8;&#x518C;&#x8005;&#x51FA;&#x73B0;&#x65AD;&#x7535;&#x7B49;&#x60C5;&#x51B5;&#x5F02;&#x5E38;&#x9000;&#x51FA;&#x65F6;&#xFF0C;&#x9700;&#x81EA;&#x52A8;&#x5220;&#x9664;&#x3002;&lt;br&gt;
* 3. &#x5F53;URL&#x8BBE;&#x7F6E;&#x4E86;category=overrides&#x65F6;&#xFF0C;&#x8868;&#x793A;&#x5206;&#x7C7B;&#x5B58;&#x50A8;&#xFF0C;&#x7F3A;&#x7701;&#x7C7B;&#x522B;&#x4E3A;providers&#xFF0C;&#x53EF;&#x6309;&#x5206;&#x7C7B;&#x90E8;&#x5206;&#x901A;&#x77E5;&#x6570;&#x636E;&#x3002;&lt;br&gt;
* 4. &#x5F53;&#x6CE8;&#x518C;&#x4E2D;&#x5FC3;&#x91CD;&#x542F;&#xFF0C;&#x7F51;&#x7EDC;&#x6296;&#x52A8;&#xFF0C;&#x4E0D;&#x80FD;&#x4E22;&#x5931;&#x6570;&#x636E;&#xFF0C;&#x5305;&#x62EC;&#x65AD;&#x7EBF;&#x81EA;&#x52A8;&#x5220;&#x9664;&#x6570;&#x636E;&#x3002;&lt;br&gt;
* 5. &#x5141;&#x8BB8;URI&#x76F8;&#x540C;&#x4F46;&#x53C2;&#x6570;&#x4E0D;&#x540C;&#x7684;URL&#x5E76;&#x5B58;&#xFF0C;&#x4E0D;&#x80FD;&#x8986;&#x76D6;&#x3002;&lt;br&gt;
*
* <span class="hljs-doctag">@param</span> url &#x6CE8;&#x518C;&#x4FE1;&#x606F;&#xFF0C;&#x4E0D;&#x5141;&#x8BB8;&#x4E3A;&#x7A7A;&#xFF0C;&#x5982;&#xFF1A;dubbo://10.20.153.10/com.alibaba.foo.BarService?version=1.0.0&amp;application=kylin
*/</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">register</span><span class="hljs-params">(URL url)</span></span>;
<span class="hljs-comment">/**
* &#x53D6;&#x6D88;&#x6CE8;&#x518C;&#x670D;&#x52A1;.
*
* &#x53D6;&#x6D88;&#x6CE8;&#x518C;&#x9700;&#x5904;&#x7406;&#x5951;&#x7EA6;&#xFF1A;&lt;br&gt;
* 1. &#x5982;&#x679C;&#x662F;dynamic=false&#x7684;&#x6301;&#x4E45;&#x5B58;&#x50A8;&#x6570;&#x636E;&#xFF0C;&#x627E;&#x4E0D;&#x5230;&#x6CE8;&#x518C;&#x6570;&#x636E;&#xFF0C;&#x5219;&#x629B;IllegalStateException&#xFF0C;&#x5426;&#x5219;&#x5FFD;&#x7565;&#x3002;&lt;br&gt;
* 2. &#x6309;&#x5168;URL&#x5339;&#x914D;&#x53D6;&#x6D88;&#x6CE8;&#x518C;&#x3002;&lt;br&gt;
*
* <span class="hljs-doctag">@param</span> url &#x6CE8;&#x518C;&#x4FE1;&#x606F;&#xFF0C;&#x4E0D;&#x5141;&#x8BB8;&#x4E3A;&#x7A7A;&#xFF0C;&#x5982;&#xFF1A;dubbo://10.20.153.10/com.alibaba.foo.BarService?version=1.0.0&amp;application=kylin
*/</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">unregister</span><span class="hljs-params">(URL url)</span></span>;
<span class="hljs-comment">/**
* &#x8BA2;&#x9605;&#x670D;&#x52A1;.
*
* &#x8BA2;&#x9605;&#x9700;&#x5904;&#x7406;&#x5951;&#x7EA6;&#xFF1A;&lt;br&gt;
* 1. &#x5F53;URL&#x8BBE;&#x7F6E;&#x4E86;check=false&#x65F6;&#xFF0C;&#x8BA2;&#x9605;&#x5931;&#x8D25;&#x540E;&#x4E0D;&#x62A5;&#x9519;&#xFF0C;&#x5728;&#x540E;&#x53F0;&#x5B9A;&#x65F6;&#x91CD;&#x8BD5;&#x3002;&lt;br&gt;
* 2. &#x5F53;URL&#x8BBE;&#x7F6E;&#x4E86;category=overrides&#xFF0C;&#x53EA;&#x901A;&#x77E5;&#x6307;&#x5B9A;&#x5206;&#x7C7B;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x591A;&#x4E2A;&#x5206;&#x7C7B;&#x7528;&#x9017;&#x53F7;&#x5206;&#x9694;&#xFF0C;&#x5E76;&#x5141;&#x8BB8;&#x661F;&#x53F7;&#x901A;&#x914D;&#xFF0C;&#x8868;&#x793A;&#x8BA2;&#x9605;&#x6240;&#x6709;&#x5206;&#x7C7B;&#x6570;&#x636E;&#x3002;&lt;br&gt;
* 3. &#x5141;&#x8BB8;&#x4EE5;interface,group,version,classifier&#x4F5C;&#x4E3A;&#x6761;&#x4EF6;&#x67E5;&#x8BE2;&#xFF0C;&#x5982;&#xFF1A;interface=com.alibaba.foo.BarService&amp;version=1.0.0&lt;br&gt;
* 4. &#x5E76;&#x4E14;&#x67E5;&#x8BE2;&#x6761;&#x4EF6;&#x5141;&#x8BB8;&#x661F;&#x53F7;&#x901A;&#x914D;&#xFF0C;&#x8BA2;&#x9605;&#x6240;&#x6709;&#x63A5;&#x53E3;&#x7684;&#x6240;&#x6709;&#x5206;&#x7EC4;&#x7684;&#x6240;&#x6709;&#x7248;&#x672C;&#xFF0C;&#x6216;&#xFF1A;interface=*&amp;group=*&amp;version=*&amp;classifier=*&lt;br&gt;
* 5. &#x5F53;&#x6CE8;&#x518C;&#x4E2D;&#x5FC3;&#x91CD;&#x542F;&#xFF0C;&#x7F51;&#x7EDC;&#x6296;&#x52A8;&#xFF0C;&#x9700;&#x81EA;&#x52A8;&#x6062;&#x590D;&#x8BA2;&#x9605;&#x8BF7;&#x6C42;&#x3002;&lt;br&gt;
* 6. &#x5141;&#x8BB8;URI&#x76F8;&#x540C;&#x4F46;&#x53C2;&#x6570;&#x4E0D;&#x540C;&#x7684;URL&#x5E76;&#x5B58;&#xFF0C;&#x4E0D;&#x80FD;&#x8986;&#x76D6;&#x3002;&lt;br&gt;
* 7. &#x5FC5;&#x987B;&#x963B;&#x585E;&#x8BA2;&#x9605;&#x8FC7;&#x7A0B;&#xFF0C;&#x7B49;&#x7B2C;&#x4E00;&#x6B21;&#x901A;&#x77E5;&#x5B8C;&#x540E;&#x518D;&#x8FD4;&#x56DE;&#x3002;&lt;br&gt;
*
* <span class="hljs-doctag">@param</span> url &#x8BA2;&#x9605;&#x6761;&#x4EF6;&#xFF0C;&#x4E0D;&#x5141;&#x8BB8;&#x4E3A;&#x7A7A;&#xFF0C;&#x5982;&#xFF1A;consumer://10.20.153.10/com.alibaba.foo.BarService?version=1.0.0&amp;application=kylin
* <span class="hljs-doctag">@param</span> listener &#x53D8;&#x66F4;&#x4E8B;&#x4EF6;&#x76D1;&#x542C;&#x5668;&#xFF0C;&#x4E0D;&#x5141;&#x8BB8;&#x4E3A;&#x7A7A;
*/</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">subscribe</span><span class="hljs-params">(URL url, NotifyListener listener)</span></span>;
<span class="hljs-comment">/**
* &#x53D6;&#x6D88;&#x8BA2;&#x9605;&#x670D;&#x52A1;.
*
* &#x53D6;&#x6D88;&#x8BA2;&#x9605;&#x9700;&#x5904;&#x7406;&#x5951;&#x7EA6;&#xFF1A;&lt;br&gt;
* 1. &#x5982;&#x679C;&#x6CA1;&#x6709;&#x8BA2;&#x9605;&#xFF0C;&#x76F4;&#x63A5;&#x5FFD;&#x7565;&#x3002;&lt;br&gt;
* 2. &#x6309;&#x5168;URL&#x5339;&#x914D;&#x53D6;&#x6D88;&#x8BA2;&#x9605;&#x3002;&lt;br&gt;
*
* <span class="hljs-doctag">@param</span> url &#x8BA2;&#x9605;&#x6761;&#x4EF6;&#xFF0C;&#x4E0D;&#x5141;&#x8BB8;&#x4E3A;&#x7A7A;&#xFF0C;&#x5982;&#xFF1A;consumer://10.20.153.10/com.alibaba.foo.BarService?version=1.0.0&amp;application=kylin
* <span class="hljs-doctag">@param</span> listener &#x53D8;&#x66F4;&#x4E8B;&#x4EF6;&#x76D1;&#x542C;&#x5668;&#xFF0C;&#x4E0D;&#x5141;&#x8BB8;&#x4E3A;&#x7A7A;
*/</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">unsubscribe</span><span class="hljs-params">(URL url, NotifyListener listener)</span></span>;
<span class="hljs-comment">/**
* &#x67E5;&#x8BE2;&#x6CE8;&#x518C;&#x5217;&#x8868;&#xFF0C;&#x4E0E;&#x8BA2;&#x9605;&#x7684;&#x63A8;&#x6A21;&#x5F0F;&#x76F8;&#x5BF9;&#x5E94;&#xFF0C;&#x8FD9;&#x91CC;&#x4E3A;&#x62C9;&#x6A21;&#x5F0F;&#xFF0C;&#x53EA;&#x8FD4;&#x56DE;&#x4E00;&#x6B21;&#x7ED3;&#x679C;&#x3002;
*
* <span class="hljs-doctag">@see</span> com.alibaba.dubbo.registry.NotifyListener#notify(List)
* <span class="hljs-doctag">@param</span> url &#x67E5;&#x8BE2;&#x6761;&#x4EF6;&#xFF0C;&#x4E0D;&#x5141;&#x8BB8;&#x4E3A;&#x7A7A;&#xFF0C;&#x5982;&#xFF1A;consumer://10.20.153.10/com.alibaba.foo.BarService?version=1.0.0&amp;application=kylin
* <span class="hljs-doctag">@return</span> &#x5DF2;&#x6CE8;&#x518C;&#x4FE1;&#x606F;&#x5217;&#x8868;&#xFF0C;&#x53EF;&#x80FD;&#x4E3A;&#x7A7A;&#xFF0C;&#x542B;&#x4E49;&#x540C;{<span class="hljs-doctag">@link</span> com.alibaba.dubbo.registry.NotifyListener#notify(List&lt;URL&gt;)}&#x7684;&#x53C2;&#x6570;&#x3002;
*/</span>
<span class="hljs-function">List&lt;URL&gt; <span class="hljs-title">lookup</span><span class="hljs-params">(URL url)</span></span>;
}
</code></pre>
<p>NotifyListener.java</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">NotifyListener</span> </span>{
<span class="hljs-comment">/**
* &#x5F53;&#x6536;&#x5230;&#x670D;&#x52A1;&#x53D8;&#x66F4;&#x901A;&#x77E5;&#x65F6;&#x89E6;&#x53D1;&#x3002;
*
* &#x901A;&#x77E5;&#x9700;&#x5904;&#x7406;&#x5951;&#x7EA6;&#xFF1A;&lt;br&gt;
* 1. &#x603B;&#x662F;&#x4EE5;&#x670D;&#x52A1;&#x63A5;&#x53E3;&#x548C;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x4E3A;&#x7EF4;&#x5EA6;&#x5168;&#x91CF;&#x901A;&#x77E5;&#xFF0C;&#x5373;&#x4E0D;&#x4F1A;&#x901A;&#x77E5;&#x4E00;&#x4E2A;&#x670D;&#x52A1;&#x7684;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x90E8;&#x5206;&#x6570;&#x636E;&#xFF0C;&#x7528;&#x6237;&#x4E0D;&#x9700;&#x8981;&#x5BF9;&#x6BD4;&#x4E0A;&#x4E00;&#x6B21;&#x901A;&#x77E5;&#x7ED3;&#x679C;&#x3002;&lt;br&gt;
* 2. &#x8BA2;&#x9605;&#x65F6;&#x7684;&#x7B2C;&#x4E00;&#x6B21;&#x901A;&#x77E5;&#xFF0C;&#x5FC5;&#x987B;&#x662F;&#x4E00;&#x4E2A;&#x670D;&#x52A1;&#x7684;&#x6240;&#x6709;&#x7C7B;&#x578B;&#x6570;&#x636E;&#x7684;&#x5168;&#x91CF;&#x901A;&#x77E5;&#x3002;&lt;br&gt;
* 3. &#x4E2D;&#x9014;&#x53D8;&#x66F4;&#x65F6;&#xFF0C;&#x5141;&#x8BB8;&#x4E0D;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;&#x5206;&#x5F00;&#x901A;&#x77E5;&#xFF0C;&#x6BD4;&#x5982;&#xFF1A;providers, consumers, routes, overrides&#xFF0C;&#x5141;&#x8BB8;&#x53EA;&#x901A;&#x77E5;&#x5176;&#x4E2D;&#x4E00;&#x79CD;&#x7C7B;&#x578B;&#xFF0C;&#x4F46;&#x8BE5;&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;&#x5FC5;&#x987B;&#x662F;&#x5168;&#x91CF;&#x7684;&#xFF0C;&#x4E0D;&#x662F;&#x589E;&#x91CF;&#x7684;&#x3002;&lt;br&gt;
* 4. &#x5982;&#x679C;&#x4E00;&#x79CD;&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;&#x4E3A;&#x7A7A;&#xFF0C;&#x9700;&#x901A;&#x77E5;&#x4E00;&#x4E2A;empty&#x534F;&#x8BAE;&#x5E76;&#x5E26;category&#x53C2;&#x6570;&#x7684;&#x6807;&#x8BC6;&#x6027;URL&#x6570;&#x636E;&#x3002;&lt;br&gt;
* 5. &#x901A;&#x77E5;&#x8005;(&#x5373;&#x6CE8;&#x518C;&#x4E2D;&#x5FC3;&#x5B9E;&#x73B0;)&#x9700;&#x4FDD;&#x8BC1;&#x901A;&#x77E5;&#x7684;&#x987A;&#x5E8F;&#xFF0C;&#x6BD4;&#x5982;&#xFF1A;&#x5355;&#x7EBF;&#x7A0B;&#x63A8;&#x9001;&#xFF0C;&#x961F;&#x5217;&#x4E32;&#x884C;&#x5316;&#xFF0C;&#x5E26;&#x7248;&#x672C;&#x5BF9;&#x6BD4;&#x3002;&lt;br&gt;
*
* <span class="hljs-doctag">@param</span> urls &#x5DF2;&#x6CE8;&#x518C;&#x4FE1;&#x606F;&#x5217;&#x8868;&#xFF0C;&#x603B;&#x4E0D;&#x4E3A;&#x7A7A;&#xFF0C;&#x542B;&#x4E49;&#x540C;{<span class="hljs-doctag">@link</span> com.alibaba.dubbo.registry.RegistryService#lookup(URL)}&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x3002;
*/</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">notify</span><span class="hljs-params">(List&lt;URL&gt; urls)</span></span>;
}
</code></pre>
<h5 id="5-&#x5DF2;&#x77E5;&#x6269;&#x5C55;">5. &#x5DF2;&#x77E5;&#x6269;&#x5C55;</h5>
<p><code>com.alibaba.dubbo.registry.support.dubbo.DubboRegistryFactory</code></p>
<h5 id="6-&#x6269;&#x5C55;&#x793A;&#x4F8B;">6. &#x6269;&#x5C55;&#x793A;&#x4F8B;</h5>
<p>Maven&#x9879;&#x76EE;&#x7ED3;&#x6784;</p>
<pre><code>src
|-main
|-java
|-com
|-xxx
|-XxxRegistryFactoryjava (&#x5B9E;&#x73B0;RegistryFactory&#x63A5;&#x53E3;)
|-XxxRegistry.java (&#x5B9E;&#x73B0;Registry&#x63A5;&#x53E3;)
|-resources
|-META-INF
|-dubbo
|-com.alibaba.dubbo.registry.RegistryFactory (&#x7EAF;&#x6587;&#x672C;&#x6587;&#x4EF6;&#xFF0C;&#x5185;&#x5BB9;&#x4E3A;&#xFF1A;xxx=com.xxx.XxxRegistryFactory)
</code></pre><p>XxxRegistryFactory.java</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> com.xxx;
<span class="hljs-keyword">import</span> com.alibaba.dubbo.registry.RegistryFactory;
<span class="hljs-keyword">import</span> com.alibaba.dubbo.registry.Registry;
<span class="hljs-keyword">import</span> com.alibaba.dubbo.common.URL;
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">XxxRegistryFactory</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">RegistryFactory</span> </span>{
<span class="hljs-function"><span class="hljs-keyword">public</span> Registry <span class="hljs-title">getRegistry</span><span class="hljs-params">(URL url)</span> </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> XxxRegistry(url);
}
}
</code></pre>
<p>XxxRegistry.java</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> com.xxx;
<span class="hljs-keyword">import</span> com.alibaba.dubbo.registry.Registry;
<span class="hljs-keyword">import</span> com.alibaba.dubbo.registry.NotifyListener;
<span class="hljs-keyword">import</span> com.alibaba.dubbo.common.URL;
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">XxxRegistry</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Registry</span> </span>{
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">register</span><span class="hljs-params">(URL url)</span> </span>{
<span class="hljs-comment">// ...</span>
}
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">unregister</span><span class="hljs-params">(URL url)</span> </span>{
<span class="hljs-comment">// ...</span>
}
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">subscribe</span><span class="hljs-params">(URL url, NotifyListener listener)</span> </span>{
<span class="hljs-comment">// ...</span>
}
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">unsubscribe</span><span class="hljs-params">(URL url, NotifyListener listener)</span> </span>{
<span class="hljs-comment">// ...</span>
}
}
</code></pre>
<p>META-INF/dubbo/com.alibaba.dubbo.registry.RegistryFactory</p>
<pre><code>xxx=com.xxx.XxxRegistryFactory
</code></pre>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="合并结果扩展.html" class="navigation navigation-prev " aria-label="Previous page: 6.8 合并结果扩展">
<i class="fa fa-angle-left"></i>
</a>
<a href="监控中心扩展.html" class="navigation navigation-next " aria-label="Next page: 6.10 监控中心扩展">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"6.9 注册中心扩展","level":"1.7.9","depth":2,"next":{"title":"6.10 监控中心扩展","level":"1.7.10","depth":2,"path":"SPI参考手册/监控中心扩展.md","ref":"./SPI参考手册/监控中心扩展.md","articles":[]},"previous":{"title":"6.8 合并结果扩展","level":"1.7.8","depth":2,"path":"SPI参考手册/合并结果扩展.md","ref":"./SPI参考手册/合并结果扩展.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"SPI参考手册/注册中心扩展.md","mtime":"2017-08-02T06:13:38.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-08-02T07:36:57.834Z"},"basePath":"..","book":{"language":""}});
});
</script>
</div>
<script src="../gitbook/gitbook.js"></script>
<script src="../gitbook/theme.js"></script>
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>