elephant.rpc.client.core.RPCAsyncInvocationHandler Maven / Gradle / Ivy
package elephant.rpc.client.core;
import java.lang.reflect.Method;
import java.util.List;
import elephant.rpc.client.RPCClient;
import elephant.rpc.server.message.RPCRequest;
import elephant.rpc.server.session.RPCSession;
/**
*
* @author skydu
*
*/
public class RPCAsyncInvocationHandler extends RPCInvocationHandler{
//
public RPCAsyncInvocationHandler(
RPCClient client,
List sessions) {
super(client,sessions);
}
//
@Override
protected Object invoke0(RPCRequest req,Method method) throws Throwable{
req.getMessage().isAsync=true;
if(!method.getReturnType().equals(void.class)){
throw new IllegalArgumentException(
"only void return type method can invoke async.but returnType is "+
method.getReturnType());
}
req.getSession().write(req.getMessage());
return null;
}
}