一、动态代理适配器类—ProxyFactory$Adaptive

  1. package org.apache.dubbo.rpc;
  2. import org.apache.dubbo.common.extension.ExtensionLoader;
  3. public class ProxyFactory$Adaptive implements org.apache.dubbo.rpc.ProxyFactory {
  4. public org.apache.dubbo.rpc.Invoker getInvoker(java.lang.Object arg0, java.lang.Class arg1, org.apache.dubbo.common.URL arg2) throws org.apache.dubbo.rpc.RpcException {
  5. if (arg2 == null) throw new IllegalArgumentException("url == null");
  6. org.apache.dubbo.common.URL url = arg2;
  7. String extName = url.getParameter("proxy", "javassist");
  8. if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.rpc.ProxyFactory) name from url (" + url.toString() + ") use keys([proxy])");
  9. org.apache.dubbo.rpc.ProxyFactory extension = (org.apache.dubbo.rpc.ProxyFactory)ExtensionLoader.getExtensionLoader(org.apache.dubbo.rpc.ProxyFactory.class).getExtension(extName);
  10. return extension.getInvoker(arg0, arg1, arg2);
  11. }
  12. public java.lang.Object getProxy(org.apache.dubbo.rpc.Invoker arg0, boolean arg1) throws org.apache.dubbo.rpc.RpcException {
  13. if (arg0 == null) throw new IllegalArgumentException("org.apache.dubbo.rpc.Invoker argument == null");
  14. if (arg0.getUrl() == null) throw new IllegalArgumentException("org.apache.dubbo.rpc.Invoker argument getUrl() == null");
  15. org.apache.dubbo.common.URL url = arg0.getUrl();
  16. String extName = url.getParameter("proxy", "javassist");
  17. if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.rpc.ProxyFactory) name from url (" + url.toString() + ") use keys([proxy])");
  18. org.apache.dubbo.rpc.ProxyFactory extension = (org.apache.dubbo.rpc.ProxyFactory)ExtensionLoader.getExtensionLoader(org.apache.dubbo.rpc.ProxyFactory.class).getExtension(extName);
  19. return extension.getProxy(arg0, arg1);
  20. }
  21. public java.lang.Object getProxy(org.apache.dubbo.rpc.Invoker arg0) throws org.apache.dubbo.rpc.RpcException {
  22. if (arg0 == null) throw new IllegalArgumentException("org.apache.dubbo.rpc.Invoker argument == null");
  23. if (arg0.getUrl() == null) throw new IllegalArgumentException("org.apache.dubbo.rpc.Invoker argument getUrl() == null");
  24. org.apache.dubbo.common.URL url = arg0.getUrl();
  25. String extName = url.;
  26. if(extName == null) throw ngetParameter("proxy", "javassist")ew IllegalStateException("Failed to get extension (org.apache.dubbo.rpc.ProxyFactory) name from url (" + url.toString() + ") use keys([proxy])");
  27. org.apache.dubbo.rpc.ProxyFactory extension = (org.apache.dubbo.rpc.ProxyFactory)ExtensionLoader.getExtensionLoader(org.apache.dubbo.rpc.ProxyFactory.class).getExtension(extName);
  28. return extension.getProxy(arg0);
  29. }
  30. }

二、容错策略适配器类—Cluster$Adaptive

  1. package org.apache.dubbo.rpc.cluster;
  2. import org.apache.dubbo.common.extension.ExtensionLoader;
  3. public class Cluster$Adaptive implements org.apache.dubbo.rpc.cluster.Cluster {
  4. public org.apache.dubbo.rpc.Invoker join(org.apache.dubbo.rpc.cluster.Directory arg0) throws org.apache.dubbo.rpc.RpcException {
  5. if (arg0 == null) throw new IllegalArgumentException("org.apache.dubbo.rpc.cluster.Directory argument == null");
  6. if (arg0.getUrl() == null) throw new IllegalArgumentException("org.apache.dubbo.rpc.cluster.Directory argument getUrl() == null");
  7. org.apache.dubbo.common.URL url = arg0.getUrl();
  8. String extName = url.getParameter("cluster", "failover");
  9. if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.rpc.cluster.Cluster) name from url (" + url.toString() + ") use keys([cluster])");
  10. org.apache.dubbo.rpc.cluster.Cluster extension = (org.apache.dubbo.rpc.cluster.Cluster)ExtensionLoader.getExtensionLoader(org.apache.dubbo.rpc.cluster.Cluster.class).getExtension(extName);
  11. return extension.join(arg0);
  12. }
  13. }

三、线程调度适配器—Dispatcher$Adaptive

  1. package org.apache.dubbo.remoting;
  2. import org.apache.dubbo.common.extension.ExtensionLoader;
  3. public class Dispatcher$Adaptive implements org.apache.dubbo.remoting.Dispatcher {
  4. public org.apache.dubbo.remoting.ChannelHandler dispatch(org.apache.dubbo.remoting.ChannelHandler arg0, org.apache.dubbo.common.URL arg1) {
  5. if (arg1 == null) throw new IllegalArgumentException("url == null");
  6. org.apache.dubbo.common.URL url = arg1;
  7. String extName = url.getParameter("dispatcher", url.getParameter("dispather", url.getParameter("channel.handler", "all")));
  8. if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.remoting.Dispatcher) name from url (" + url.toString() + ") use keys([dispatcher, dispather, channel.handler])");
  9. org.apache.dubbo.remoting.Dispatcher extension = (org.apache.dubbo.remoting.Dispatcher)ExtensionLoader.getExtensionLoader(org.apache.dubbo.remoting.Dispatcher.class).getExtension(extName);
  10. return extension.dispatch(arg0, arg1);
  11. }
  12. }

四、注册类适配器—RegistryFactory$Adaptive

  1. package org.apache.dubbo.registry;
  2. import org.apache.dubbo.common.extension.ExtensionLoader;
  3. public class RegistryFactory$Adaptive implements org.apache.dubbo.registry.RegistryFactory {
  4. public org.apache.dubbo.registry.Registry getRegistry(org.apache.dubbo.common.URL arg0) {
  5. if (arg0 == null) throw new IllegalArgumentException("url == null");
  6. org.apache.dubbo.common.URL url = arg0;
  7. String extName = ( url.getProtocol() == null ? "dubbo" : url.getProtocol() );
  8. if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.registry.RegistryFactory) name from url (" + url.toString() + ") use keys([protocol])");
  9. org.apache.dubbo.registry.RegistryFactory extension = (org.apache.dubbo.registry.RegistryFactory)ExtensionLoader.getExtensionLoader(org.apache.dubbo.registry.RegistryFactory.class).getExtension(extName);
  10. return extension.getRegistry(arg0);
  11. }
  12. }

五、传输适配器—Transporter$Adaptive

  1. package org.apache.dubbo.remoting;
  2. import org.apache.dubbo.common.extension.ExtensionLoader;
  3. public class Transporter$Adaptive implements org.apache.dubbo.remoting.Transporter {
  4. public org.apache.dubbo.remoting.Client connect(org.apache.dubbo.common.URL arg0, org.apache.dubbo.remoting.ChannelHandler arg1) throws org.apache.dubbo.remoting.RemotingException {
  5. if (arg0 == null) throw new IllegalArgumentException("url == null");
  6. org.apache.dubbo.common.URL url = arg0;
  7. String extName = url.getParameter("client", url.getParameter("transporter", "netty"));
  8. if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.remoting.Transporter) name from url (" + url.toString() + ") use keys([client, transporter])");
  9. org.apache.dubbo.remoting.Transporter extension = (org.apache.dubbo.remoting.Transporter)ExtensionLoader.getExtensionLoader(org.apache.dubbo.remoting.Transporter.class).getExtension(extName);
  10. return extension.connect(arg0, arg1);
  11. }
  12. public org.apache.dubbo.remoting.Server bind(org.apache.dubbo.common.URL arg0, org.apache.dubbo.remoting.ChannelHandler arg1) throws org.apache.dubbo.remoting.RemotingException {
  13. if (arg0 == null) throw new IllegalArgumentException("url == null");
  14. org.apache.dubbo.common.URL url = arg0;
  15. String extName = url.getParameter("server", url.getParameter("transporter", "netty"));
  16. if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.remoting.Transporter) name from url (" + url.toString() + ") use keys([server, transporter])");
  17. org.apache.dubbo.remoting.Transporter extension = (org.apache.dubbo.remoting.Transporter)ExtensionLoader.getExtensionLoader(org.apache.dubbo.remoting.Transporter.class).getExtension(extName);
  18. return extension.bind(arg0, arg1);
  19. }
  20. }

六、协议适配器类源码—Protocol$Adaptive

  1. package org.apache.dubbo.rpc;
  2. import org.apache.dubbo.common.extension.ExtensionLoader;
  3. public class Protocol$Adaptive implements org.apache.dubbo.rpc.Protocol {
  4. public void destroy() {
  5. throw new UnsupportedOperationException("The method public abstract void org.apache.dubbo.rpc.Protocol.destroy() of interface org.apache.dubbo.rpc.Protocol is not adaptive method!");
  6. }
  7. public int getDefaultPort() {
  8. throw new UnsupportedOperationException("The method public abstract int org.apache.dubbo.rpc.Protocol.getDefaultPort() of interface org.apache.dubbo.rpc.Protocol is not adaptive method!");
  9. }
  10. public org.apache.dubbo.rpc.Exporter export(org.apache.dubbo.rpc.Invoker arg0) throws org.apache.dubbo.rpc.RpcException {
  11. if (arg0 == null) throw new IllegalArgumentException("org.apache.dubbo.rpc.Invoker argument == null");
  12. if (arg0.getUrl() == null) throw new IllegalArgumentException("org.apache.dubbo.rpc.Invoker argument getUrl() == null");
  13. org.apache.dubbo.common.URL url = arg0.getUrl();
  14. String extName = ( url.getProtocol() == null ? "dubbo" : url.getProtocol() );
  15. if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.rpc.Protocol) name from url (" + url.toString() + ") use keys([protocol])");
  16. //通过业务配置extName获取对应的实现类
  17. org.apache.dubbo.rpc.Protocol extension = (org.apache.dubbo.rpc.Protocol)ExtensionLoader.getExtensionLoader(org.apache.dubbo.rpc.Protocol.class).getExtension(extName);
  18. return extension.export(arg0);
  19. }
  20. public org.apache.dubbo.rpc.Invoker refer(java.lang.Class arg0, org.apache.dubbo.common.URL arg1) throws org.apache.dubbo.rpc.RpcException {
  21. if (arg1 == null) throw new IllegalArgumentException("url == null");
  22. org.apache.dubbo.common.URL url = arg1;
  23. String extName = ( url.getProtocol() == null ? "dubbo" : url.getProtocol() );
  24. if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.rpc.Protocol) name from url (" + url.toString() + ") use keys([protocol])");
  25. org.apache.dubbo.rpc.Protocol extension = (org.apache.dubbo.rpc.Protocol)ExtensionLoader.getExtensionLoader(org.apache.dubbo.rpc.Protocol.class).getExtension(extName);
  26. return extension.refer(arg0, arg1);
  27. }
  28. }

七、通信适配器类源码—Transporter$Adaptive

  1. package org.apache.dubbo.remoting;
  2. import org.apache.dubbo.common.extension.ExtensionLoader;
  3. public class Transporter$Adaptive implements org.apache.dubbo.remoting.Transporter {
  4. public org.apache.dubbo.remoting.Client connect(org.apache.dubbo.common.URL arg0, org.apache.dubbo.remoting.ChannelHandler arg1) throws org.apache.dubbo.remoting.RemotingException {
  5. if (arg0 == null) throw new IllegalArgumentException("url == null");
  6. org.apache.dubbo.common.URL url = arg0;
  7. String extName = url.getParameter("client", url.getParameter("transporter", "netty"));
  8. if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.remoting.Transporter) name from url (" + url.toString() + ") use keys([client, transporter])");
  9. org.apache.dubbo.remoting.Transporter extension = (org.apache.dubbo.remoting.Transporter)ExtensionLoader.getExtensionLoader(org.apache.dubbo.remoting.Transporter.class).getExtension(extName);
  10. return extension.connect(arg0, arg1);
  11. }
  12. public org.apache.dubbo.remoting.Server bind(org.apache.dubbo.common.URL arg0, org.apache.dubbo.remoting.ChannelHandler arg1) throws org.apache.dubbo.remoting.RemotingException {
  13. if (arg0 == null) throw new IllegalArgumentException("url == null");
  14. org.apache.dubbo.common.URL url = arg0;
  15. String extName = url.getParameter("server", url.getParameter("transporter", "netty"));
  16. if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.remoting.Transporter) name from url (" + url.toString() + ") use keys([server, transporter])");
  17. org.apache.dubbo.remoting.Transporter extension = (org.apache.dubbo.remoting.Transporter)ExtensionLoader.getExtensionLoader(org.apache.dubbo.remoting.Transporter.class).getExtension(extName);
  18. return extension.bind(arg0, arg1);
  19. }
  20. }