@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); } }
onAfterRequestDeserialized(rpcRequest); return RPC.invokeAndEncodeResponse(delegate, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); } catch (IncompatibleRemoteServiceException ex) {
/** * Handles the {@link CometPublicationService}. * * @param connection * {@link ServerGwtRpcConnection} to notify client that * published. * @param flow * {@link PublishFlow}. */ public void publish(ServerGwtRpcConnection<Long> connection, PublishFlow flow) { // Obtain the published event RPCRequest request = connection.getRpcRequest(); CometEvent event = (CometEvent) request.getParameters()[0]; // Publish the event flow.publish(event); }
@Override public void service(ServerGwtRpcConnection<CometResponse> connection) { // Obtain the Comet Request RPCRequest rpcRequest = connection.getRpcRequest(); CometRequest cometRequest = (CometRequest) rpcRequest.getParameters()[0]; // Retrieve or wait on events for Comet Request this.source.receiveOrWaitOnEvents(cometRequest.getInterests(), connection, this.async, cometRequest.getLastSequenceNumber()); }
return RPC.invokeAndEncodeResponse(this.remoteService, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy()); } catch (IncompatibleRemoteServiceException e) { return RPC.encodeResponseForFailure(null, e);
@Override public Object doTask( TaskContext<GwtServiceTask, Dependencies, Indexed> context) throws Throwable { // Obtain the request ServerGwtRpcConnection<?> connection = (ServerGwtRpcConnection<?>) context .getObject(Dependencies.SERVER_GWT_RPC_CONNECTION); // Obtain the GWT request RPCRequest rpc = connection.getRpcRequest(); // Obtain the flow index String methodName = rpc.getMethod().getName(); Integer flowIndex = this.methodToFlow.get(methodName); if (flowIndex == null) { // Indicate unknown GWT service method connection.onFailure(new IncompatibleRemoteServiceException( "Unknown service method '" + methodName + "(...)'")); return null; // No further processing } // Obtain the parameter value Object[] parameters = rpc.getParameters(); Object parameter = (parameters.length == 0 ? null : parameters[0]); // Invoke flow to service request context.doFlow(flowIndex.intValue(), parameter); // Processing by flows return null; }
@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); } }
@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); } }
@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); } }
@Override protected void onAfterRequestDeserialized(RPCRequest request) { final Principal principal = getThreadLocalRequest().getUserPrincipal(); if (principal == null || StringUtils.isNullOrEmpty(principal.getName())) { throw new DCSecurityException("No user principal - log in to use the system"); } if (!(principal instanceof Authentication)) { throw new IllegalStateException("Principal is not an instance of Authentication: " + principal); } final Authentication authentication = (Authentication) principal; final UserBean user = new UserBean(); user.updateUser(authentication, getTenantResolver()); final Method method = request.getMethod(); final RolesAllowed rolesAllowedAnnotation = ReflectionUtils.getAnnotation(method, RolesAllowed.class); if (rolesAllowedAnnotation != null) { String[] rolesAllowed = rolesAllowedAnnotation.value(); checkRoles(user, rolesAllowed, method); } final Class<?>[] parameterTypes = method.getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { final Class<?> cls = parameterTypes[i]; if (cls == TenantIdentifier.class) { TenantIdentifier tenantIdentifier = (TenantIdentifier) request.getParameters()[i]; checkTenant(user, tenantIdentifier); break; } } }
Object[] parameters = rpcRequest.getParameters(); CometEvent event = (CometEvent) parameters[0];
onAfterRequestDeserialized(rpcRequest); return RPC.invokeAndEncodeResponse(this, 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) {
onAfterRequestDeserialized(rpcRequest); return RPC.invokeAndEncodeResponse(delegate, rpcRequest.getMethod(), rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags()); } catch (IncompatibleRemoteServiceException ex) {
onAfterRequestDeserialized(rpcRequest); Method targetMethod = getMethodToInvoke(rpcRequest.getMethod()); Object[] targetParameters = rpcRequest.getParameters();
onAfterRequestDeserialized(rpcRequest); Method targetMethod = getMethodToInvoke(rpcRequest.getMethod()); Object[] targetParameters = rpcRequest.getParameters();