com.googlecode.gwt.test.rpc.GwtRpcInvocationHandler Maven / Gradle / Ivy
package com.googlecode.gwt.test.rpc;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.StatusCodeException;
import com.googlecode.gwt.test.RemoteServiceExecutionHandler;
import com.googlecode.gwt.test.exceptions.GwtTestException;
import com.googlecode.gwt.test.exceptions.GwtTestRpcException;
import com.googlecode.gwt.test.internal.BrowserSimulatorImpl;
import com.googlecode.gwt.test.internal.GwtConfig;
import com.googlecode.gwt.test.internal.patchers.AbstractRemoteServiceServletPatcher;
import com.googlecode.gwt.test.utils.GwtReflectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
class GwtRpcInvocationHandler implements InvocationHandler {
private static final Logger logger = LoggerFactory.getLogger(GwtRpcInvocationHandler.class);
private final GwtRpcExceptionHandler exceptionHandler;
private final Map methodTable;
private final GwtRpcSerializerHandler serializerHander;
private final Object target;
public GwtRpcInvocationHandler(Class asyncClazz, Object target,
GwtRpcExceptionHandler exceptionHandler, GwtRpcSerializerHandler serializerHandler) {
this.target = target;
this.exceptionHandler = exceptionHandler;
this.serializerHander = serializerHandler;
this.methodTable = new HashMap();
for (Method m : asyncClazz.getMethods()) {
for (Method m2 : target.getClass().getMethods()) {
if (m.getName().equals(m2.getName())
&& m.getParameterTypes().length == m2.getParameterTypes().length + 1) {
methodTable.put(m, m2);
GwtReflectionUtils.makeAccessible(m2);
}
}
}
}
@SuppressWarnings("unchecked")
public Object invoke(Object proxy, Method method, Object[] args) {
Object[] subArgs = new Object[args.length - 1];
for (int i = 0; i < args.length - 1; i++) {
subArgs[i] = args[i];
}
final AsyncCallback