dubbo生成的代理类

穿精又带淫゛_ 提交于 2020-05-06 18:04:08
public interface DemoService {

String sayHello(String name);

}

代理类生成入口 org.apache.dubbo.common.bytecode.Wrapper#getWrapper

原类 


实现类 

@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());
}

} 

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!