ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(InjvmProtocol.NAME); // load
}
return INSTANCE;
}
@Override
public Exporter export(Invoker invoker) throws RpcException {
return new InjvmExporter(invoker, invoker.getUrl().getServiceKey(), exporterMap);
}
@Override
public Invoker refer(Class serviceType, URL url) throws RpcException {
return new InjvmInvoker(serviceType, url, url.getServiceKey(), exporterMap);
}
}
除了export和refer方法,InjvmProtocol提供了isInjvmRefer()方法,
isInjvmRefer会读取配置文件,判断是否开启本地调用。
public boolean isInjvmRefer(URL url) {
String scope = url.getParameter(Constants.SCOPE_KEY);
// Since injvm protocol is configured explicitly, we don’t need to set any extra flag, use normal refer process.
if (Constants.SCOPE_LOCAL.equals(scope) || (url.getParameter(Constants.LOCAL_PROTOCOL, false))) {