创建代理对象
com.alibaba.dubbo.config.ServiceConfig#export
通过消费者export()方法可以找到以上方法,消费者需要根据配置的接口生成代理对象。 ###生成Invoker

1以上通过工厂生成服务者的Invoker,Wrapper.getWrapper里面通过接口生成新Wrapper及接口的实现。 2生成的具体代码 3public class AClass$sw1 extends Wrapper { 4 5 public static String[] pns; 6 public static Map pts; 7 public static String[] mns; 8 public static String[] dmns; 9 public static Class[] mts0; 10 public static Class[] mts1; 11 12 13 public AClass$sw1() { 14 } 15 16 public String[] getPropertyNames(){ return pns; } 17 18 public boolean hasProperty(String n){ return pts.containsKey(n); } 19 20 public Class getPropertyType(String n){ return (Class)pts.get(n); } 21 22 public String[] getMethodNames(){ return mns; } 23 24 public String[] getDeclaredMethodNames(){ return dmns; } 25 26 public void setPropertyValue(Object o, String n, Object v){ 27 AClass w; 28 try{ 29 w = ((AClass)o); 30 }catch(Throwable e){ 31 throw new IllegalArgumentException(e); 32 } 33 if( n.equals("field1") ){ 34 w.field1=((Boolean) v).booleanValue(); 35 return; 36 } 37 if( n.equals("field2") ){ 38 w.field2=((Boolean) v).booleanValue(); 39 return; 40 } 41 throw new NoSuchPropertyException("Not found property $2 filed or setter method in class AClass."); 42 } 43 44 public Object getPropertyValue(Object o, String n){ 45 AClass w; 46 try{ 47 w = ((AClass)o); 48 }catch(Throwable e){ 49 throw new IllegalArgumentException(e); 50 } 51 if( n.equals("field1") ){ 52 return ($w)w.field1; 53 } 54 if( n.equals("field2") ){ 55 return ($w)w.field2; 56 } 57 // getField11 58 if( n.equals("field11") ){ 59 return ($w)w.getField11(); 60 } 61 // isField21|hasField21|canField21 62 if( n.equals("field21") ){ 63 return ($w)w.isField21(); 64 } 65 throw new NoSuchPropertyException("Not found property $2 filed or setter method in class AClass."); 66 } 67 68 public Object invokeMethod(Object o, String n, Class[] p, Object[] v) throws InvocationTargetException { 69 AClass w; 70 try{ 71 w = ((AClass)o); 72 }catch(Throwable e){ 73 throw new IllegalArgumentException(e); 74 } 75 try{ 76 if( "method1".equals( n ) && p.length == && p[0].getName().equals("Boolean") && p[1].getName().equals("Integer") ) { 77 return ($w)w.method1(((Boolean)v[0]).booleanValue(), ((Number)v[1]).intValue()); 78 } 79 } catch(Throwable e) { 80 throw new java.lang.reflect.InvocationTargetException(e); 81 } 82 throw new NoSuchMethodException("Not found method n in class AClass."); 83 } 84}
服务者生成了对应的Invoker,通过DubboProtocol暴露Exporter。