use of com.google.gwt.user.server.rpc.impl.StandardSerializationPolicy in project pentaho-platform by pentaho.
the class AbstractGwtRpcProxyServlet method processCall.
@Override
public String processCall(String payload) throws SerializationException {
Map<Class<?>, Boolean> whitelist = new HashMap<Class<?>, Boolean>();
whitelist.put(GwtRpcProxyException.class, Boolean.TRUE);
Map<Class<?>, String> obfuscatedTypeIds = new HashMap<Class<?>, String>();
StandardSerializationPolicy policy = new StandardSerializationPolicy(whitelist, whitelist, obfuscatedTypeIds);
String servletContextPath = getServletContextPath();
Object target = null;
try {
target = resolveDispatchTarget(servletContextPath);
} catch (GwtRpcProxyException ex) {
logger.error(Messages.getInstance().getErrorString("AbstractGwtRpcProxyServlet.ERROR_0001_FAILED_TO_RESOLVE_DISPATCH_TARGET", servletContextPath), // $NON-NLS-1$
ex);
return RPC.encodeResponseForFailure(null, ex, policy);
}
final ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
final ClassLoader altLoader = target.getClass().getClassLoader();
try {
// class specified in the request
if (altLoader != origLoader) {
Thread.currentThread().setContextClassLoader(altLoader);
}
RPCRequest rpcRequest = RPC.decodeRequest(payload, null, this);
onAfterRequestDeserialized(rpcRequest);
// don't require the server side to implement the service interface
Method method = rpcRequest.getMethod();
try {
Method m = target.getClass().getMethod(method.getName(), method.getParameterTypes());
if (m != null) {
method = m;
}
} catch (Exception e) {
e.printStackTrace();
}
return RPC.invokeAndEncodeResponse(target, method, rpcRequest.getParameters(), rpcRequest.getSerializationPolicy());
} catch (IncompatibleRemoteServiceException ex) {
logger.error(Messages.getInstance().getErrorString("AbstractGwtRpcProxyServlet.ERROR_0003_RPC_INVOCATION_FAILED", target.getClass().getName()), // $NON-NLS-1$
ex);
return RPC.encodeResponseForFailure(null, ex);
} finally {
// reset the context classloader if necessary
if ((altLoader != origLoader) && origLoader != null) {
Thread.currentThread().setContextClassLoader(origLoader);
}
}
}
Aggregations