@Override public String processCall(String payload) throws SerializationException { try { perThreadRequest.set(getThreadLocalRequest()); Object handler = getBean(getThreadLocalRequest()); RPCRequest rpcRequest = RPC.decodeRequest(payload, handler.getClass(), this); onAfterRequestDeserialized(rpcRequest); if (LOG.isDebugEnabled()) { LOG.debug("Invoking " + handler.getClass().getName() + "." + rpcRequest.getMethod().getName()); } return RpcHelper .invokeAndEncodeResponse( handler, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy() ); } catch (IncompatibleRemoteServiceException ex) { log("An IncompatibleRemoteServiceException was thrown while processing this call.", ex); return RPC.encodeResponseForFailure(null, ex); } catch (SerializationException ex) { LOG.error("An SerializationException was thrown while processing this call.", ex); throw ex; } finally { perThreadRequest.set(null); } }
/** * Returns a string that encodes an exception. If <code>rpcRequest</code> * is <code>null</code> a default serialization policy and default request * flags will be used. Otherwise these information are taken from * <code>rpcRequest</code>. * <p> * This method should be used if the RPC request could not be decoded or * could not be executed because of an exception thrown, e.g. * {@link IncompatibleRemoteServiceException}, {@link RpcTokenException} * </p> * @param rpcRequest the RPCRequest that failed to execute, may be null * @param cause the {@link Throwable} that was thrown * @return a String that encodes the exception * @throws SerializationException if the result cannot be serialized */ public static String encodeResponseForFailedRequest(RPCRequest rpcRequest, Throwable cause) throws SerializationException { if (rpcRequest == null) { return RPC.encodeResponseForFailure(null, cause, getDefaultSerializationPolicy(), AbstractSerializationStream.DEFAULT_FLAGS); } else { return RPC.encodeResponseForFailure(null, cause, rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); } }
public SerializationPolicy getSerializationPolicyForSuccess( RPCRequest request, Object target, Method method, Object[] parameters, Object result) { return request.getSerializationPolicy(); }
public SerializationPolicy getSerializationPolicyForFailure( RPCRequest request, Object target, Method method, Object[] parameters, Throwable exception) { return request.getSerializationPolicy(); } }
public SerializationPolicy getSerializationPolicyForSuccess( RPCRequest request, Object target, Method method, Object[] parameters, Object result) { return request.getSerializationPolicy(); }
public SerializationPolicy getSerializationPolicyForFailure( RPCRequest request, Object target, Method method, Object[] parameters, Throwable exception) { return request.getSerializationPolicy(); }
onAfterRequestDeserialized(rpcRequest); return RPC.invokeAndEncodeResponse(delegate, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); } catch (IncompatibleRemoteServiceException ex) {
static String encodeResponse(RPCRequest rpcRequest, Object message) throws SerializationException { if (rpcRequest == null) { throw new NullPointerException("rpcRequest"); } if (rpcRequest.getSerializationPolicy() == null) { throw new NullPointerException("serializationPolicy"); } String responsePayload; responsePayload = RPC.encodeResponseForSuccess(rpcRequest.getMethod(), message, rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); return responsePayload; }
@Override protected void processPost(HttpServletRequest request, HttpServletResponse response) throws Throwable { try { String requestPayload = this.readContent(request); RPCRequest rpcRequest = RPC.decodeRequest(requestPayload, this.getClass(), this); String responsePayload = RPC.invokeAndEncodeResponse(this, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); boolean gzipEncode = RPCServletUtils.acceptsGzipEncoding(request) && RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload); RPCServletUtils.writeResponse(null, response, responsePayload, gzipEncode); } catch (Exception e) { this.logger.error("Request processing failed", e); throw Throwables.propagate(e); } } }
@Override protected void processPost(HttpServletRequest request, HttpServletResponse response) throws Throwable { try { String requestPayload = this.readContent(request); RPCRequest rpcRequest = RPC.decodeRequest(requestPayload, this.getClass(), this); String responsePayload = RPC.invokeAndEncodeResponse(this, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); boolean gzipEncode = RPCServletUtils.acceptsGzipEncoding(request) && RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload); RPCServletUtils.writeResponse(null, response, responsePayload, gzipEncode); } catch (Exception e) { this.logger.error("Request processing failed", e); throw Throwables.propagate(e); } } }
@RequestMapping(value = "/commandService", method = RequestMethod.POST) public void processPostRpc(HttpServletRequest request, HttpServletResponse response) throws Throwable { try { String requestPayload = RPCServletUtils.readContentAsGwtRpc(request); RPCRequest rpcRequest = RPC.decodeRequest(requestPayload, CommandService.class, this); String responsePayload = RPC.invokeAndEncodeResponse(commandService, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); boolean gzipEncode = RPCServletUtils.acceptsGzipEncoding(request) && RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload); RPCServletUtils.writeResponse(null, response, responsePayload, gzipEncode); } catch (Exception e) { this.logger.error("Request processing failed", e); throw Throwables.propagate(e); } }
/** * Returns a string that encodes an exception. If <code>rpcRequest</code> * is <code>null</code> a default serialization policy and default request * flags will be used. Otherwise these information are taken from * <code>rpcRequest</code>. * <p> * This method should be used if the RPC request could not be decoded or * could not be executed because of an exception thrown, e.g. * {@link IncompatibleRemoteServiceException}, {@link RpcTokenException} * </p> * @param rpcRequest the RPCRequest that failed to execute, may be null * @param cause the {@link Throwable} that was thrown * @return a String that encodes the exception * @throws SerializationException if the result cannot be serialized */ public static String encodeResponseForFailedRequest(RPCRequest rpcRequest, Throwable cause) throws SerializationException { if (rpcRequest == null) { return RPC.encodeResponseForFailure(null, cause, getDefaultSerializationPolicy(), AbstractSerializationStream.DEFAULT_FLAGS); } else { return RPC.encodeResponseForFailure(null, cause, rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); } }
/** * Returns a string that encodes an exception. If <code>rpcRequest</code> * is <code>null</code> a default serialization policy and default request * flags will be used. Otherwise these information are taken from * <code>rpcRequest</code>. * <p> * This method should be used if the RPC request could not be decoded or * could not be executed because of an exception thrown, e.g. * {@link IncompatibleRemoteServiceException}, {@link RpcTokenException} * </p> * @param rpcRequest the RPCRequest that failed to execute, may be null * @param cause the {@link Throwable} that was thrown * @return a String that encodes the exception * @throws SerializationException if the result cannot be serialized */ public static String encodeResponseForFailedRequest(RPCRequest rpcRequest, Throwable cause) throws SerializationException { if (rpcRequest == null) { return RPC.encodeResponseForFailure(null, cause, getDefaultSerializationPolicy(), AbstractSerializationStream.DEFAULT_FLAGS); } else { return RPC.encodeResponseForFailure(null, cause, rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); } }
@Override public String processCall(final String payload) throws SerializationException { try { Object presentationService = applicationContext.getBean(serviceName .get()); if (!(presentationService instanceof RemoteService)) { throw new IllegalArgumentException( "Requested Spring Bean is not a GWT RemoteService Presentation Service: " + payload + " (" + presentationService + ")"); } RPCRequest rpcRequest = RPC.decodeRequest(payload, presentationService.getClass(), this); if (presentationService instanceof AuthenticationServiceFacade && rpcRequest.getMethod().equals( AuthenticationServiceFacade.class .getMethod("getXSRFSessionToken"))) { return RPC.encodeResponseForSuccess(rpcRequest.getMethod(), SecurityHelper.createXSRFToken(getThreadLocalRequest())); } return RPC.invokeAndEncodeResponse(presentationService, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); } catch (Exception e) { GWTPresentationException pex = new GWTPresentationException( e.getMessage()); return RPC.encodeResponseForFailure(null, pex); } }
try { payload = RPC.encodeResponseForSuccess(rpc.getMethod(), result, rpc.getSerializationPolicy(), rpc.getFlags()); } catch (Exception ex) {
@Override public String processCall(String payload) throws SerializationException { try { RPCRequest req = RPC.decodeRequest(payload, null, this); RemoteService service = getServiceInstance(req.getMethod().getDeclaringClass()); return RPC.invokeAndEncodeResponse(service, req.getMethod(), req.getParameters(), req.getSerializationPolicy(), req.getFlags()); } catch (IncompatibleRemoteServiceException ex) { log("IncompatibleRemoteServiceException in the processCall(String) method.", ex); return RPC.encodeResponseForFailure(null, ex); } }
onAfterRequestDeserialized(rpcRequest); return RPC.invokeAndEncodeResponse(this, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); } catch (IncompatibleRemoteServiceException ex) {
if (rpc != null) { serializationPolicy = rpc.getSerializationPolicy(); flags = rpc.getFlags(); } else {
onAfterRequestDeserialized(rpcRequest); return RPC.invokeAndEncodeResponse(delegate, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); } catch (IncompatibleRemoteServiceException ex) {
onAfterRequestDeserialized(rpcRequest); return RPC.invokeAndEncodeResponse(delegate, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); } catch (IncompatibleRemoteServiceException ex) {