将 Invoker
接口转换成业务接口。
org.apache.dubbo.rpc.ProxyFactory
<dubbo:protocol proxy="xxx" />
<!-- 缺省值配置,当<dubbo:protocol>没有配置proxy属性时,使用此配置 -->
<dubbo:provider proxy="xxx" />
org.apache.dubbo.rpc.proxy.JdkProxyFactory
org.apache.dubbo.rpc.proxy.JavassistProxyFactory
Maven 项目结构:
src
|-main
|-java
|-com
|-xxx
|-XxxProxyFactory.java (实现ProxyFactory接口)
|-resources
|-META-INF
|-dubbo
|-org.apache.dubbo.rpc.ProxyFactory (纯文本文件,内容为:xxx=com.xxx.XxxProxyFactory)
XxxProxyFactory.java:
package com.xxx;
import org.apache.dubbo.rpc.ProxyFactory;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcException;
public class XxxProxyFactory implements ProxyFactory {
public <T> T getProxy(Invoker<T> invoker) throws RpcException {
// ...
}
public <T> Invoker<T> getInvoker(T proxy, Class<T> type, URL url) throws RpcException {
// ...
}
}
META-INF/dubbo/org.apache.dubbo.rpc.ProxyFactory:
xxx=com.xxx.XxxProxyFactory