Ejemplo n.º 1
0
  @Override
  public String processCall(String content) throws SerializationException {
    try {
      // decode the request
      RPCRequest rpcRequest = RPC.decodeRequest(content, this.serviceClass);

      // if this is any service other than UserService we check session security here
      if (!(service instanceof UserService)) {
        validateSession(rpcRequest.getParameters());
      }
      // delegate work to the spring injected service
      return RPC.invokeAndEncodeResponse(
          service, rpcRequest.getMethod(), rpcRequest.getParameters());
    } catch (IncompatibleRemoteServiceException ex) {
      getServletContext()
          .log("An IncompatibleRemoteServiceException was thrown while processing this call.", ex);
      return RPC.encodeResponseForFailure(null, ex);
    } catch (SessionTimedOutException ste) {
      return RPC.encodeResponseForFailure(null, ste);
    }
  }
Ejemplo n.º 2
0
  public String processCall(String payload) throws SerializationException {
    // First, check for possible XSRF situation
    checkPermutationStrongName();

    try {
      Object handler = getBean(getThreadLocalRequest());
      RPCRequest rpcRequest = RPC.decodeRequest(payload, handler.getClass(), this);
      onAfterRequestDeserialized(rpcRequest);
      return RPC.invokeAndEncodeResponse(
          handler,
          rpcRequest.getMethod(),
          rpcRequest.getParameters(),
          rpcRequest.getSerializationPolicy(),
          rpcRequest.getFlags());
    } catch (IncompatibleRemoteServiceException ex) {
      log("An IncompatibleRemoteServiceException was thrown while processing this call.", ex);
      return RPC.encodeResponseForFailure(null, ex);
    } catch (RpcTokenException tokenException) {
      log("An RpcTokenException was thrown while processing this call.", tokenException);
      return RPC.encodeResponseForFailure(null, tokenException);
    }
  }
Ejemplo n.º 3
0
  public static String invokeAndEncodeResponse(
      Object target,
      Method serviceMethod,
      Object[] args,
      SerializationPolicy serializationPolicy,
      int flags)
      throws SerializationException {
    if (serviceMethod == null) {
      throw new NullPointerException("serviceMethod");
    }

    if (serializationPolicy == null) {
      throw new NullPointerException("serializationPolicy");
    }

    String responsePayload;
    try {
      Object result = serviceMethod.invoke(target, args);

      responsePayload =
          RPC.encodeResponseForSuccess(serviceMethod, result, serializationPolicy, flags);
    } catch (IllegalAccessException e) {
      SecurityException securityException =
          new SecurityException(formatIllegalAccessErrorMessage(target, serviceMethod));
      securityException.initCause(e);
      throw securityException;
    } catch (IllegalArgumentException e) {
      SecurityException securityException =
          new SecurityException(formatIllegalArgumentErrorMessage(target, serviceMethod, args));
      securityException.initCause(e);
      throw securityException;
    } catch (InvocationTargetException e) {
      // Try to encode the caught exception
      //
      Throwable cause = e.getCause();

      LOG.error(
          "Unexpected exception occured while invoking service method - "
              + (serviceMethod != null ? serviceMethod.getName() : "null"),
          cause);

      responsePayload =
          RPC.encodeResponseForFailure(serviceMethod, cause, serializationPolicy, flags);
    }

    return responsePayload;
  }
  @Override
  public String processCall(String payload) throws SerializationException {
    try {
      String serviceName = extractServiceName(getThreadLocalRequest().getServletPath());
      Object service = applicationContext.getBean(serviceName);

      RPCRequest rpcRequest = RPC.decodeRequest(payload, service.getClass(), this);
      onAfterRequestDeserialized(rpcRequest);

      return RPC.invokeAndEncodeResponse(
          service,
          rpcRequest.getMethod(),
          rpcRequest.getParameters(),
          rpcRequest.getSerializationPolicy(),
          rpcRequest.getFlags());
    } catch (IncompatibleRemoteServiceException ex) {
      log("An IncompatibleRemoteServiceException was thrown while processing this call.", ex);
      return RPC.encodeResponseForFailure(null, ex);
    }
  }