Example usage for com.google.gwt.user.server.rpc CacheableRPC encodeResponseForSuccess

List of usage examples for com.google.gwt.user.server.rpc CacheableRPC encodeResponseForSuccess

Introduction

In this page you can find the example usage for com.google.gwt.user.server.rpc CacheableRPC encodeResponseForSuccess.

Prototype

public static String encodeResponseForSuccess(Method serviceMethod, Object object,
            SerializationPolicy serializationPolicy, int flags) throws SerializationException 

Source Link

Usage

From source file:sk.seges.acris.rpc.GWTRPCServiceExporter.java

License:Apache License

/**
 * Handles method invocation on a service and is invoked by
 * {@link #processCall(String)}./*from  w w  w  .ja va  2s . c o  m*/
 * 
 * @param service
 *            Service to invoke method on
 * @param targetMethod
 *            Method to invoke.
 * @param targetParameters
 *            Parameters to pass to method. Can be null for no arguments.
 * @param rpcRequest
 *            RPCRequest instance for this request
 * @return Return RPC encoded result.
 * @throws Exception
 */
protected String invokeMethodOnService(Object service, Method targetMethod, Object[] targetParameters,
        RPCRequest rpcRequest) throws Exception {
    Object result = targetMethod.invoke(service, targetParameters);
    SerializationPolicy serializationPolicy = getSerializationPolicyProvider()
            .getSerializationPolicyForSuccess(rpcRequest, service, targetMethod, targetParameters, result);

    Object ehCacheStatus = ServletUtils.getRequest().getAttribute(EHCACHE_ENABLED);

    if (disableResponseCaching || ehCacheStatus == null || ehCacheStatus.equals(false)) {
        return RPC.encodeResponseForSuccess(rpcRequest.getMethod(), result, serializationPolicy,
                serializationFlags);
    }
    return CacheableRPC.encodeResponseForSuccess(rpcRequest.getMethod(), result, serializationPolicy,
            serializationFlags);
}