dubbo生成的代理类

编程

原类 


实现类 

@Service 

public class DemoServiceImpl implements DemoService {

private static final Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class);

@Override

public String sayHello(String name) {

logger.info("Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());

return "Hello " + name + ", response from provider: " + RpcContext.getContext().getLocalAddress();

}

}

代理类 

package org.apache.dubbo.common.bytecode;

import java.lang.reflect.InvocationTargetException;

import java.util.Map;

import org.apache.dubbo.common.bytecode.ClassGenerator;

import org.apache.dubbo.common.bytecode.NoSuchMethodException;

import org.apache.dubbo.common.bytecode.NoSuchPropertyException;

import org.apache.dubbo.common.bytecode.Wrapper;

import org.apache.dubbo.demo.provider.DemoServiceImpl;

public class Wrapper1 extends Wrapper implements ClassGenerator.DC {

public static String[] pns;

public static Map pts;

public static String[] mns;

public static String[] dmns;

public static Class[] mts0;

public String[] getPropertyNames() {

return pns;

}

public boolean hasProperty(String string) {

return pts.containsKey(string);

}

public Class getPropertyType(String string) {

return (Class)pts.get(string);

}

public String[] getMethodNames() {

return mns;

}

public String[] getDeclaredMethodNames() {

return dmns;

}

public void setPropertyValue(Object object, String string, Object object2) {

try {

DemoServiceImpl demoServiceImpl = (DemoServiceImpl)object;

}

catch (Throwable throwable) {

throw new IllegalArgumentException(throwable);

}

throw new NoSuchPropertyException(new StringBuffer().append("Not found property "").append(string).append("" field or setter method in class org.apache.dubbo.demo.provider.DemoServiceImpl.").toString());

}

public Object getPropertyValue(Object object, String string) {

try {

DemoServiceImpl demoServiceImpl = (DemoServiceImpl)object;

}

catch (Throwable throwable) {

throw new IllegalArgumentException(throwable);

}

throw new NoSuchPropertyException(new StringBuffer().append("Not found property "").append(string).append("" field or setter method in class org.apache.dubbo.demo.provider.DemoServiceImpl.").toString());

}

public Object invokeMethod(Object object, String string, Class[] arrclass, Object[] arrobject) throws InvocationTargetException {

DemoServiceImpl demoServiceImpl;

try {

demoServiceImpl = (DemoServiceImpl)object;

}

catch (Throwable throwable) {

throw new IllegalArgumentException(throwable);

}

try {

if ("sayHello".equals(string) && arrclass.length == 1) {

return demoServiceImpl.sayHello((String)arrobject[0]);

}

}

catch (Throwable throwable) {

throw new InvocationTargetException(throwable);

}

throw new NoSuchMethodException(new StringBuffer().append("Not found method "").append(string).append("" in class org.apache.dubbo.demo.provider.DemoServiceImpl.").toString());

}

}

 

以上是 dubbo生成的代理类 的全部内容, 来源链接: utcz.com/z/516176.html

回到顶部