当启动provider服务配置时,
serviceConfig.export();
会在ServiceConfig中调用Protocol.export
启动连接:
Invoker<?> invoker = PROXY_FACTORY.getInvoker(ref, (Class) interfaceClass,
registryURL.addParameterAndEncoded(EXPORT_KEY, url.toFullString()));
DelegateProviderMetaDataInvoker wrapperInvoker = new DelegateProviderMetaDataInvoker(invoker, this);
Exporter<?> exporter = PROTOCOL.export(wrapperInvoker);
exporters.add(exporter);
我看别人写的源码分析,此时的Protocol
为RegistryProtocol
。
然后我就想知道RegistryProtocol
何时加载的,默认的Protocol
不应该是DubboProtocol
么?
@SPI("dubbo")
public interface Protocol {
@Adaptive
<T> Exporter<T> export(Invoker<T> invoker) throws RpcException;
}
dubbo=org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol
一开始url里的protocol是registry,在
org.apache.dubbo.registry.integration.RegistryProtocol#export
里移除并设置为dubbo