Package com.google.gwt.user.server.rpc

Examples of com.google.gwt.user.server.rpc.RPCRequest


      // 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() ), ex ); //$NON-NLS-1$
      return RPC.encodeResponseForFailure( null, ex );
View Full Code Here


   * that encodes either the method return or an exception thrown by it.
   */
  @Override
  public String processCall(String payload) throws SerializationException {
    try {
      RPCRequest rpcRequest = RPC.decodeRequest(payload, this.getClass());
      return RPC.invokeAndEncodeResponse(this, rpcRequest.getMethod(),
          rpcRequest.getParameters());
    } catch (IncompatibleRemoteServiceException ex) {
      return RPC.encodeResponseForFailure(null, ex);
    }
  }
View Full Code Here

      HttpServletResponse httpResponse) {
    String payload = readPayloadAsUtf8(httpRequest);

    try {
      try {
        RPCRequest rpcRequest = RPC.decodeRequest(payload);

        Object targetInstance = getInstanceToHandleRequest(httpRequest,
            rpcRequest);

        Method targetMethod = maybeMapRequestedMethod(targetInstance,
            rpcRequest.getMethod());

        Object[] targetParameters = maybeMapParameters(rpcRequest.getParameters());

        try {
          Object result = targetMethod.invoke(targetInstance, targetParameters);

          result = maybeMapResult(rpcRequest.getMethod(), result);

          /*
           * Encode the object that will be given to the client code's
           * AsyncCallback::onSuccess(Object) method.
           */
          String encodedResult = RPC.encodeResponseForSuccess(
              rpcRequest.getMethod(), result);

          sendResponseForSuccess(httpResponse, encodedResult);
        } catch (IllegalArgumentException e) {
          SecurityException securityException = new SecurityException(
              "Blocked attempt to invoke method " + targetMethod);
          securityException.initCause(e);
          throw securityException;
        } catch (IllegalAccessException e) {
          SecurityException securityException = new SecurityException(
              "Blocked attempt to access inaccessible method "
                  + targetMethod
                  + (targetInstance != null ? " on target " + targetInstance
                      : ""));
          securityException.initCause(e);
          throw securityException;
        } catch (InvocationTargetException e) {
          Throwable cause = e.getCause();

          Throwable mappedThrowable = maybeMapThrowable(cause,
              rpcRequest.getMethod());

          /*
           * Encode the exception that will be passed back to the client's
           * client code's AsyncCallback::onFailure(Throwable) method.
           */
          String failurePayload = RPC.encodeResponseForFailure(
              rpcRequest.getMethod(), mappedThrowable);

          sendResponseForFailure(httpResponse, failurePayload);
        }
      } catch (IncompatibleRemoteServiceException e) {
        sendResponseForFailure(httpResponse, RPC.encodeResponseForFailure(null,
View Full Code Here

    {
      if (log.isDebugEnabled())
      {
        log.debug("currentHandler = [" + getCurrentHandler().getClass() + "], payload = [" + payload);
      }
      final RPCRequest rpcRequest = RPC.decodeRequest(payload, getCurrentHandler().getClass(), this);
      if (log.isDebugEnabled())
      {
        log.debug("rpcRequest = [" + rpcRequest + "] rpcRequest.getSerializationPolicy() = ["
            + rpcRequest.getSerializationPolicy() + "]");
      }
      onAfterRequestDeserialized(rpcRequest);
      final String response = RPC.invokeAndEncodeResponse(getCurrentHandler(), rpcRequest.getMethod(),
          rpcRequest.getParameters(), rpcRequest.getSerializationPolicy());
      if (log.isDebugEnabled())
      {
        log.debug("response = [" + response + "]");
      }
      return response;
View Full Code Here

    assert clientOracle != null : "clientOracle";
    assert payload != null : "payload";
    assert stream != null : "stream";

    try {
      RPCRequest rpcRequest = RPC.decodeRequest(payload, this.getClass(),
          clientOracle);
      onAfterRequestDeserialized(rpcRequest);
      RPC.invokeAndStreamResponse(this, rpcRequest.getMethod(),
          rpcRequest.getParameters(), clientOracle, stream);
    } catch (RemoteException ex) {
      throw new SerializationException("An exception was sent from the client",
          ex.getCause());
    } catch (IncompatibleRemoteServiceException ex) {
      log(
View Full Code Here

          Object o = CommandSerializationUtil.getAccessor(parameterTypes[i]).readNext(
              streamReader);
          parameterValues[i] = o;
        }

        return new RPCRequest(method, parameterValues, null, 0);

      } catch (NoSuchMethodException e) {
        throw new IncompatibleRemoteServiceException(
            formatMethodNotFoundErrorMessage(serviceIntf, serviceMethodName,
                parameterTypes));
View Full Code Here

      if (delegate == null) {
        throw new AssertionError("RPC实例为null");
      }
      String payload = RPCServletUtils.readContent(request,
          "text/x-gwt-rpc", null);
      RPCRequest rpcRequest = RPC.decodeRequest(payload,
          delegate.getClass(), this);
      Method rpcRequestMethod = rpcRequest.getMethod();
      try {
        String responsePayload = RPC4Monitor.invokeAndEncodeResponse(delegate,
            rpcRequestMethod, rpcRequest.getParameters(),
            rpcRequest.getSerializationPolicy(),
            rpcRequest.getFlags());
        RPCServletUtils.writeResponse(null, (HttpServletResponse) resp,
            responsePayload, false);
      } catch (SerializationException e) {
        log.error(e);
        throw new RuntimeException("RPC序列化异常", e);
View Full Code Here

                for (int i = 0; i < parameterValues.length; i++) {
                    parameterValues[i] = streamReader.deserializeValue(parameterTypes[i]);
                }

                return new RPCRequest(method, parameterValues,
                    serializationPolicy);
            } catch (NoSuchMethodException e) {
                throw new IncompatibleRemoteServiceException(formatMethodNotFoundErrorMessage(
                        type, serviceMethodName, parameterTypes));
            }
View Full Code Here

    }

    @Override
    public String processCall(String payload) throws SerializationException {
        try {
            RPCRequest rpcRequest = StreamServiceUtils.decodeRequest(payload,
                    this.getClass(), this);
            //onAfterRequestDeserialized(rpcRequest);

            StreamServiceIterator iterator = null;

            try {
                iterator = (StreamServiceIterator) rpcRequest.getMethod()
                                                             .invoke(this,
                        rpcRequest.getParameters());

                try {
                    this.sendResults(rpcRequest.getMethod(), iterator,
                        rpcRequest.getSerializationPolicy());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                } finally {
                    if (iterator != null) {
                        iterator.close();
View Full Code Here

        log.error( e.getMessage(), e );
        throw e;
      }
    }
    else {
      RPCRequest rpcRequest = RPC.decodeRequest( payload, this.getClass(), this );
      return RPC.encodeResponseForFailure( rpcRequest.getMethod(), new GWTInvalidSessionException() );
    }
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.user.server.rpc.RPCRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.