当前位置: 首页>>代码示例>>Java>>正文


Java RPC.encodeResponseForSuccess方法代码示例

本文整理汇总了Java中com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess方法的典型用法代码示例。如果您正苦于以下问题:Java RPC.encodeResponseForSuccess方法的具体用法?Java RPC.encodeResponseForSuccess怎么用?Java RPC.encodeResponseForSuccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.user.server.rpc.RPC的用法示例。


在下文中一共展示了RPC.encodeResponseForSuccess方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processCall

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
private void processCall(final HttpServletResponse response,
                         final byte[] bytes, final Map<String, String> parameters) throws Exception {
    Object presentationService = applicationContext.getBean(serviceName
            .get());
    if (!(presentationService instanceof IFileUploadPresentationService)) {
        throw new IllegalArgumentException(
                "Requested Spring Bean is not a File Upload Presentation Service: ("
                        + presentationService + ")");
    }
    String encodedResult = null;

    if (parameters.get(MAX_FILE_SIZE_PARAM_NAME) != null) {
        long maxFileSize = Long.parseLong(parameters
                .get(MAX_FILE_SIZE_PARAM_NAME));
        if (bytes.length > maxFileSize) {
            encodedResult = RPC.encodeResponseForFailure(
                    ((IFileUploadPresentationService) presentationService)
                            .getClass().getDeclaredMethod("uploadFile",
                            bytes.getClass(), Map.class),
                    new GWTMaxFileSizeExceedException());
        }
    }

    try {
        String result = ((IFileUploadPresentationService) presentationService)
                .uploadFile(bytes, parameters);
        encodedResult = RPC.encodeResponseForSuccess(
                ((IFileUploadPresentationService) presentationService)
                        .getClass().getDeclaredMethod("uploadFile",
                        bytes.getClass(), Map.class), result);
    } catch (PresentationException e) {
        GWTPresentationException pex = new GWTPresentationException(e);
        encodedResult = RPC.encodeResponseForFailure(
                ((IFileUploadPresentationService) presentationService)
                        .getClass().getDeclaredMethod("uploadFile",
                        bytes.getClass(), Map.class), pex);
    }
    response.getOutputStream().write(encodedResult.getBytes());
    response.getOutputStream().flush();
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:41,代码来源:FileUploadController.java

示例2: processCall

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
@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);
	}
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:31,代码来源:GwtRpcController.java

示例3: toClient

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
/**
 * serialize PresenceRoom to send to client.
 * @param p_room
 * @return null if any error occur.
 */
public static String toClient(PresenceRoom p_room)
{
  String response = null;
  try
  {
    response = RPC.encodeResponseForSuccess( s_getRoom, p_room,
        FmgSerializationPolicy.getPolicy() );
  } catch( SerializationException e )
  {
    log.error( e );
  }
  return response;
}
 
开发者ID:kroc702,项目名称:fullmetalgalaxy,代码行数:19,代码来源:Serializer.java

示例4: gwtSerialize

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
/**
 * Server-side deserialize does not match server-side serialize, so we can't test a round trip.
 */
public static <T> void gwtSerialize(T object) throws SerializationException {
  RPC.encodeResponseForSuccess(arbitraryVoidReturningMethod(), object);
}
 
开发者ID:google,项目名称:FreeBuilder,代码行数:7,代码来源:ProcessorTest.java

示例5: invokeMethodOnService

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
/**
 * Handles method invocation on a service and is invoked by
 * {@link #processCall(String)}.
 * 
 * @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 Any exception caused in serialization
 */
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);
	String encodedResult = RPC.encodeResponseForSuccess(rpcRequest.getMethod(), result, serializationPolicy, serializationFlags);
	return encodedResult;
}
 
开发者ID:ggeorgovassilis,项目名称:gwt-sl,代码行数:23,代码来源:GWTRPCServiceExporter.java


注:本文中的com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。