使用例子
<dubbo:service interface="com.alibaba.dubbo.demo.DemoService" ref="demoServiceImpl" protocol="injvm" scope="local" />
本地如何引用
参见《dubbo源码阅读-服务订阅(八)之本地订阅(injvm)》
InjvmInvoker
doInvoke
@Override public Result doInvoke(Invocation invocation) throws Throwable { //可以发现是从exporterMap获取对应的Exporter然后再获取内部Invoker执行调用 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); }