// no known constants to use in this case
String result = null;
// get the RPC Request from the request data
//RPCRequest rpcRequest= RPC.decodeRequest(payload);
RPCRequest rpcRequest = RPC.decodeRequest(payload,null,this);
onAfterRequestDeserialized(rpcRequest);
// get the parameter types for the method look-up
Class<?>[] paramTypes = rpcRequest.getMethod().getParameterTypes();
paramTypes = rpcRequest.getMethod().getParameterTypes();
// we need to get the action method from Struts
Method method = findInterfaceMethod(
actionInvocation.getAction().getClass(),
rpcRequest.getMethod().getName(),
paramTypes, true);
// if the method is null, this may be a hack attempt
// or we have some other big problem
if (method == null) {
// present the params
StringBuffer params = new StringBuffer();
for (int i=0; i < paramTypes.length; i++) {
params.append(paramTypes[i]);
if (i < paramTypes.length-1) {
params.append(", ");
}
}
// throw a security exception, could be attempted hack
throw new GWTServletException(
"Failed to locate method "+ rpcRequest.getMethod().getName()
+ "("+ params +") on interface "
+ actionInvocation.getAction().getClass().getName()
+ " requested through interface "
+ rpcRequest.getClass().getName());
}
Object callResult = null;
try {
callResult = method.invoke(actionInvocation.getAction(),
rpcRequest.getParameters());
// package up response for GWT
result = RPC.encodeResponseForSuccess(method, callResult);
} catch (Exception e) {
// check for checked exceptions
if (e.getCause() != null) {
Throwable cause = e.getCause();
boolean found = false;
for (Class<?> checkedException : rpcRequest.getMethod().getExceptionTypes()){
if (cause.getClass().equals(checkedException)) {
found = true;
break;
}
}
if (!found) {
throw new GWTServletException("Unchecked exception: " + e.getCause().getClass().getName());
}
result = RPC.encodeResponseForFailure(null, e.getCause(), rpcRequest.getSerializationPolicy());
} else {
throw new GWTServletException("Unable to serialize the exception.");
}
}