Dynamic Proxy Extension
Dynamic Proxy Extension
Extension Description
Converts the Invoker
interface into a business interface.
Extension Interface
org.apache.dubbo.rpc.ProxyFactory
Extension Configuration
<dubbo:protocol proxy="xxx" />
<!-- Default configuration, used when the <dubbo:protocol> does not configure the proxy attribute -->
<dubbo:provider proxy="xxx" />
Known Extensions
org.apache.dubbo.rpc.proxy.JdkProxyFactory
org.apache.dubbo.rpc.proxy.JavassistProxyFactory
Extension Example
Maven project structure:
src
|-main
|-java
|-com
|-xxx
|-XxxProxyFactory.java (implements ProxyFactory interface)
|-resources
|-META-INF
|-dubbo
|-org.apache.dubbo.rpc.ProxyFactory (plain text file, content: 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
Feedback
Was this page helpful?
Yes No
Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)