package cn.hhj.proxy.remote; import cn.hhj.request.RpcRequest; import cn.hhj.rpcsend.RpcNetTransport; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; public class RemoteInvocationHandler implements InvocationHandler { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // 进行请求数据的包装 RpcRequest request=new RpcRequest(); request.setClassName(method.getDeclaringClass().getName()); request.setMethodName(method.getName()); request.setParameters(args); request.setVersion("V1.0"); System.err.println("【client】:远程通信,需要调用的接口是:"+request.getClassName()+"."+request.getMethodName()+"()"); RpcNetTransport rnt=new RpcNetTransport(); return rnt.send(request); } }