腾一部分笔记到csdn
1. 概述
// 推荐
<dubbo:reference scope="local" />
// 不推荐使用,准备废弃
<dubbo:reference injvm="true" />
<dubbo:reference scope="remote" />
|
2. createProxy
invoker = refprotocol.refer(interfaceClass, url); //获取invoker
-> return new InjvmInvoker<T>(serviceType, url, url.getServiceKey(), exporterMap);
@Override
public Result doInvoke(Invocation invocation) throws Throwable {
// 获得 Exporter 对象
Exporter<?> exporter= InjvmProtocol.getExporter(exporterMap, getUrl());
if (exporter == null) {
throw new RpcException("Service ["+ key + "] not found.");
}
// 设置服务提供者地址为本地
RpcContext.getContext().setRemoteAddress(NetUtils.LOCALHOST, 0);
// 调用
return exporter.getInvoker().invoke(invocation);
}
//Invoker这个invoker就是暴露时创建的 Invoker里面包类似springmvc的Wapper
|