List of usage examples for com.google.gwt.user.server.rpc.impl StandardSerializationPolicy StandardSerializationPolicy
public StandardSerializationPolicy(Map<Class<?>, Boolean> serializationWhitelist,
Map<Class<?>, Boolean> deserializationWhitelist, Map<Class<?>, String> obfuscatedTypeIds)
From source file:org.pentaho.platform.web.servlet.AbstractGwtRpcProxyServlet.java
License:Open Source License
@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);// www. j ava 2s . co m 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 { // temporarily swap out the context classloader to an alternate classloader if // the targetBean has been loaded by one other than the context classloader. // This is necessary, so the RPC class can do a Class.forName and find the service // 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); } } }