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

  1. <dubbo:protocol proxy="xxx" />
  2. <!-- Default configuration, used when the <dubbo:protocol> does not configure the proxy attribute -->
  3. <dubbo:provider proxy="xxx" />

Known Extensions

  • org.apache.dubbo.rpc.proxy.JdkProxyFactory
  • org.apache.dubbo.rpc.proxy.JavassistProxyFactory

Extension Example

Maven project structure:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxProxyFactory.java (implements ProxyFactory interface)
  7. |-resources
  8. |-META-INF
  9. |-dubbo
  10. |-org.apache.dubbo.rpc.ProxyFactory (plain text file, content: xxx=com.xxx.XxxProxyFactory)

XxxProxyFactory.java:

  1. package com.xxx;
  2. import org.apache.dubbo.rpc.ProxyFactory;
  3. import org.apache.dubbo.rpc.Invoker;
  4. import org.apache.dubbo.rpc.RpcException;
  5. public class XxxProxyFactory implements ProxyFactory {
  6. public <T> T getProxy(Invoker<T> invoker) throws RpcException {
  7. // ...
  8. }
  9. public <T> Invoker<T> getInvoker(T proxy, Class<T> type, URL url) throws RpcException {
  10. // ...
  11. }
  12. }

META-INF/dubbo/org.apache.dubbo.rpc.ProxyFactory:

  1. xxx=com.xxx.XxxProxyFactory

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)