com.alibaba.dubbo.config.ServiceConfig#export
經過消費者export()方法能夠找到以上方法,消費者須要根據配置的接口生成代理對象。 ###生成Invoker java
以上經過工廠生成服務者的Invoker,Wrapper.getWrapper裏面經過接口生成新Wrapper及接口的實現。 生成的具體代碼 public class AClass$sw1 extends Wrapper { public static String[] pns; public static Map pts; public static String[] mns; public static String[] dmns; public static Class[] mts0; public static Class[] mts1; public AClass$sw1() { } public String[] getPropertyNames(){ return pns; } public boolean hasProperty(String n){ return pts.containsKey(n); } public Class getPropertyType(String n){ return (Class)pts.get(n); } public String[] getMethodNames(){ return mns; } public String[] getDeclaredMethodNames(){ return dmns; } public void setPropertyValue(Object o, String n, Object v){ AClass w; try{ w = ((AClass)o); }catch(Throwable e){ throw new IllegalArgumentException(e); } if( n.equals("field1") ){ w.field1=((Boolean) v).booleanValue(); return; } if( n.equals("field2") ){ w.field2=((Boolean) v).booleanValue(); return; } throw new NoSuchPropertyException("Not found property $2 filed or setter method in class AClass."); } public Object getPropertyValue(Object o, String n){ AClass w; try{ w = ((AClass)o); }catch(Throwable e){ throw new IllegalArgumentException(e); } if( n.equals("field1") ){ return ($w)w.field1; } if( n.equals("field2") ){ return ($w)w.field2; } // getField11 if( n.equals("field11") ){ return ($w)w.getField11(); } // isField21|hasField21|canField21 if( n.equals("field21") ){ return ($w)w.isField21(); } throw new NoSuchPropertyException("Not found property $2 filed or setter method in class AClass."); } public Object invokeMethod(Object o, String n, Class[] p, Object[] v) throws InvocationTargetException { AClass w; try{ w = ((AClass)o); }catch(Throwable e){ throw new IllegalArgumentException(e); } try{ if( "method1".equals( n ) && p.length == && p[0].getName().equals("Boolean") && p[1].getName().equals("Integer") ) { return ($w)w.method1(((Boolean)v[0]).booleanValue(), ((Number)v[1]).intValue()); } } catch(Throwable e) { throw new java.lang.reflect.InvocationTargetException(e); } throw new NoSuchMethodException("Not found method n in class AClass."); } }
服務者生成了對應的Invoker,經過DubboProtocol暴露Exporter。app