W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
遠(yuǎn)程通訊的服務(wù)器及客戶端傳輸實(shí)現(xiàn)。
<!-- 服務(wù)器和客戶端使用相同的傳輸實(shí)現(xiàn) -->
<dubbo:protocol transporter="xxx" />
<!-- 服務(wù)器和客戶端使用不同的傳輸實(shí)現(xiàn) -->
<dubbo:protocol server="xxx" client="xxx" />
<!-- 缺省值設(shè)置,當(dāng)<dubbo:protocol>沒(méi)有配置transporter/server/client屬性時(shí),使用此配置 -->
<dubbo:provider transporter="xxx" server="xxx" client="xxx" />
Maven 項(xiàng)目結(jié)構(gòu):
src
|-main
|-java
|-com
|-xxx
|-XxxTransporter.java (實(shí)現(xiàn)Transporter接口)
|-XxxServer.java (實(shí)現(xiàn)Server接口)
|-XxxClient.java (實(shí)現(xiàn)Client接口)
|-resources
|-META-INF
|-dubbo
|-org.apache.dubbo.remoting.Transporter (純文本文件,內(nèi)容為:xxx=com.xxx.XxxTransporter)
XxxTransporter.java:
package com.xxx;
import org.apache.dubbo.remoting.Transporter;
public class XxxTransporter implements Transporter {
public Server bind(URL url, ChannelHandler handler) throws RemotingException {
return new XxxServer(url, handler);
}
public Client connect(URL url, ChannelHandler handler) throws RemotingException {
return new XxxClient(url, handler);
}
}
XxxServer.java:
package com.xxx;
import org.apache.dubbo.remoting.transport.transporter.AbstractServer;
public class XxxServer extends AbstractServer {
public XxxServer(URL url, ChannelHandler handler) throws RemotingException{
super(url, handler);
}
protected void doOpen() throws Throwable {
// ...
}
protected void doClose() throws Throwable {
// ...
}
public Collection<Channel> getChannels() {
// ...
}
public Channel getChannel(InetSocketAddress remoteAddress) {
// ...
}
}
XxxClient.java:
package com.xxx;
import org.apache.dubbo.remoting.transport.transporter.AbstractClient;
public class XxxClient extends AbstractClient {
public XxxServer(URL url, ChannelHandler handler) throws RemotingException{
super(url, handler);
}
protected void doOpen() throws Throwable {
// ...
}
protected void doClose() throws Throwable {
// ...
}
protected void doConnect() throws Throwable {
// ...
}
public Channel getChannel() {
// ...
}
}
META-INF/dubbo/org.apache.dubbo.remoting.Transporter:
xxx=com.xxx.XxxTransporter
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: