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

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


        return Boolean.TRUE.equals(var);
    }

    static void writeResponse(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource, Object message) throws IOException{
        try {
            RPCRequest rpcRequest = (RPCRequest) resource.getRequest().getAttribute(AtmospherePollService.GWT_REQUEST);
            String response = encodeResponse(rpcRequest, message);
            writeResponse(resource.getRequest(), resource.getResponse(),
                    resource.getAtmosphereConfig().getServletContext(),
                    response);
View Full Code Here


   * @throws RuntimeException if the service method throws an unchecked
   *           exception (the exception will be the one thrown by the service)
   */
  public String processCall(String payload) throws SerializationException {
    try {
      RPCRequest rpcRequest = RPC.decodeRequest(payload, this.getClass(), this);
      onAfterRequestDeserialized(rpcRequest);
      return RPC.invokeAndEncodeResponse(this, 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);
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(serviceIntf,
View Full Code Here

    @Override
    public String processCall(String payload)
    throws SerializationException {
        try {

            RPCRequest rpcRequest = RPC.decodeRequest(payload, this
                    .getClass(), this);
            ServerSerializationStreamWriter_1_5_3 writer = getWriter(rpcRequest);

            return RPC1524.invokeAndEncodeResponse(this, rpcRequest
                    .getMethod(), rpcRequest.getParameters(), writer);

        } catch (IncompatibleRemoteServiceException ex) {
            log
            .error(
                    "An IncompatibleRemoteServiceException was thrown while processing this call.",
View Full Code Here

    // no known constants to use in this case
    String result = null;

    // get the RPC Request from the request data
    //RPCRequest rpcRequest= RPC.decodeRequest(payload);
    RPCRequest rpcRequest = RPC.decodeRequest(payload,null,this);
 
   
     onAfterRequestDeserialized(rpcRequest);
    
    // get the parameter types for the method look-up
    Class<?>[] paramTypes = rpcRequest.getMethod().getParameterTypes();       
    paramTypes = rpcRequest.getMethod().getParameterTypes();

    // we need to get the action method from Struts
    Method method = findInterfaceMethod(
        actionInvocation.getAction().getClass(),
        rpcRequest.getMethod().getName(),
        paramTypes, true);

    // if the method is null, this may be a hack attempt
    // or we have some other big problem
    if (method == null) {
      // present the params
      StringBuffer params = new StringBuffer();
      for (int i=0; i < paramTypes.length; i++) {
        params.append(paramTypes[i]);
        if (i < paramTypes.length-1) {
          params.append(", ");
        }
      }

      // throw a security exception, could be attempted hack
      throw new GWTServletException(
          "Failed to locate method "+ rpcRequest.getMethod().getName()
          + "("+ params +") on interface "
          + actionInvocation.getAction().getClass().getName()
          + " requested through interface "
          + rpcRequest.getClass().getName());
    }

 
    Object callResult = null;
    try {
      callResult = method.invoke(actionInvocation.getAction(),
          rpcRequest.getParameters());
      // package  up response for GWT
      result = RPC.encodeResponseForSuccess(method, callResult);
     
    } catch (Exception e) {
      // check for checked exceptions
      if (e.getCause() != null) {
        Throwable cause = e.getCause();
        boolean found = false;
        for (Class<?> checkedException : rpcRequest.getMethod().getExceptionTypes()){
          if (cause.getClass().equals(checkedException)) {
            found = true;
            break;
          }
        }
        if (!found) {
          throw new GWTServletException("Unchecked exception: " + e.getCause().getClass().getName());
        }
        result = RPC.encodeResponseForFailure(null, e.getCause(), rpcRequest.getSerializationPolicy());
      } else {
        throw new GWTServletException("Unable to serialize the exception.");
      }
    }
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

    boolean localeInitializedByServlet = false;
    try
    {
      localeInitializedByServlet = initUserLocaleResolver();
      Object service = getServiceForRequest(payload);
      RPCRequest rpcRequest = RPC.decodeRequest(payload, service.getClass(), this);
      onAfterRequestDeserialized(rpcRequest);

      //TODO: criar um ponto de injecao de comportamento aki.... para permitir que plugins sejam criados (ex: seguranca, logs, etc)
      CruxSynchronizerTokenHandler handler = CruxSynchronizerTokenHandlerFactory.getCruxSynchronizerTokenHandler(getThreadLocalRequest());

      boolean useToken = checkSynchonizerToken(rpcRequest, handler);
      try
      {
        return RPC.invokeAndEncodeResponse(service, rpcRequest.getMethod(),
            rpcRequest.getParameters(), rpcRequest.getSerializationPolicy());
      }
      finally
      {
        if (useToken)
        {
          String methodFullSignature = handler.getMethodDescription(rpcRequest.getMethod());
          handler.endMethod(methodFullSignature);
        }
      }
    }
    catch (IncompatibleRemoteServiceException ex)
View Full Code Here

  @Override
  public String processCall(String payload) throws SerializationException {
    try {
      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 RPC.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);
    }
View Full Code Here

    }

    @Override
    public String processCall(String payload) throws SerializationException {
        RemoteService remoteService = null;
        RPCRequest rpcRequest = null;
        try {
            remoteService = (RemoteService) applicationContext.getBean(remoteServiceName);
            setServiceData(remoteService, false);

            rpcRequest = RPC.decodeRequest(payload, remoteService.getClass(), this);
           
            if (logger.isDebugEnabled()) {
                logger.debug("Executing method " + rpcRequest.getMethod());
            }

            return RPC.invokeAndEncodeResponse(remoteService, rpcRequest
                    .getMethod(), rpcRequest.getParameters(), rpcRequest
                    .getSerializationPolicy());
        } catch (Exception e) {
            if (rpcRequest != null) {
                logger.error("An error occurred calling the GWT service method " + rpcRequest.getMethod() + ". Cause: " + e.getMessage(), e);
            } else {
                logger.error("An error occurred calling the GWT service " + (remoteService != null ? remoteService.getClass().getName() : remoteServiceName) + ". Cause: " + e.getMessage(), e);
            }
            return RPC.encodeResponseForFailure(null, e);
        } finally {
View Full Code Here

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

                return new RPCRequest(method, parameterValues,
                    serializationPolicy, 0);
            } catch (NoSuchMethodException e) {
                throw new IncompatibleRemoteServiceException(formatMethodNotFoundErrorMessage(
                        type, serviceMethodName, parameterTypes));
            }
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.