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


Java RPC.encodeResponseForFailure方法代码示例

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


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

示例1: processCall

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
/**
 * This is taken from GWT 2.4 sources.  The changed code was to, rather than 
 * call the actual XxxxServer method that would have handled the request, 
 * simply encode an AccessDeniedException as the failure response for the request.
 * 
 * Revisions to newer GWT versions should verify that this code is still
 * suitable for those newer GWT versions.
 */
@Override
public String processCall(String payload) throws SerializationException {
    try {
        RPCRequest rpcRequest = RPC.decodeRequest(payload);
        onAfterRequestDeserialized(rpcRequest);
        // ******* CHANGED GWT 2.4 CODE STARTS
        LogFactory.getLog(GWTAccessDeniedHandlerImpl.class).warn("GWT Method: " 
                    + rpcRequest.getMethod().getName() + " Exception: " + e.getMessage());
        return RPC
                .encodeResponseForFailure(
                        rpcRequest.getMethod(),
                        new org.opendatakit.common.security.client.exception.AccessDeniedException(
                                e));
        // ******** CHANGED GWT 2.4 CODE ENDS
    } catch (IncompatibleRemoteServiceException ex) {
        LogFactory.getLog(GWTAccessDeniedHandlerImpl.class).warn("An IncompatibleRemoteServiceException was thrown while processing this call.",
                ex);
        return RPC.encodeResponseForFailure(null, ex);
    }
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:29,代码来源:GWTAccessDeniedHandlerImpl.java

示例2: processCall

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
@Override
public String processCall(String payload) throws SerializationException {
  try {
    RPCRequest req = RPC.decodeRequest(payload, null, this);

    RemoteService service = getServiceInstance(req.getMethod().getDeclaringClass());

    return RPC.invokeAndEncodeResponse(service, req.getMethod(),
      req.getParameters(), req.getSerializationPolicy());
    
  } catch (IncompatibleRemoteServiceException ex) {
    log("IncompatibleRemoteServiceException in the processCall(String) method.",
        ex);
    return RPC.encodeResponseForFailure(null, ex);
  }
}
 
开发者ID:DavidWhitlock,项目名称:PortlandStateJava,代码行数:17,代码来源:GuiceRemoteServiceServlet.java

示例3: doUnexpectedFailure

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
@Override
protected void doUnexpectedFailure(Throwable e) {
    RPCRequest req = (RPCRequest) ServerContext.getRequestOwner().getAttribute("rpcRequest");
    if (req == null) {
        super.doUnexpectedFailure(e);
        return;
    }
    try {
        RPC.encodeResponseForFailure(req.getMethod(), e, req.getSerializationPolicy());
    } catch (Exception ex) {
        ex.printStackTrace();
        super.doUnexpectedFailure(ex);
    }
}
 
开发者ID:lsst,项目名称:firefly,代码行数:15,代码来源:BaseRemoteService.java

示例4: 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

示例5: 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

示例6: processCall

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
public String processCall(String payload) throws SerializationException {
  try {

    RPCRequest rpcRequest = RPC.decodeRequest(payload, this.remoteServiceClass);

    return RPC.invokeAndEncodeResponse(this.remoteService, rpcRequest.getMethod(),
        rpcRequest.getParameters());
  } catch (IncompatibleRemoteServiceException ex) {
    LOGGER.warn("An IncompatibleRemoteServiceException was thrown while processing this call.",
        ex);
    return RPC.encodeResponseForFailure(null, ex);
  }
}
 
开发者ID:skidder,项目名称:mythpodcaster,代码行数:14,代码来源:GWTController.java

示例7: processCall

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
@Override
public String processCall(String payload) {
  // // ロギング
  // RPCRequest rpcRequest = RPC.decodeRequest(payload, getClass(), this);
  // if (!LOGGING_EXCLUDED_METHODS.contains(rpcRequest.getMethod().getName())) {
  // logger.info(getRemoteAddress() + " " + rpcRequest.getMethod());
  // }

  // processCall()から送出される例外を捕捉してログに出力する
  try {
    return super.processCall(payload);
  } catch (Throwable e) {
    String message = "processCall()中にエラーが発生しました: "
        + MoreObjects.toStringHelper(this).add("remoteAddress", getRemoteAddress())
            .add("rpcRequest", RPC.decodeRequest(payload, null, this)).add("payload", payload)
            .toString();
    logger.log(Level.WARNING, message, e);

    try {
      return RPC.encodeResponseForFailure(null,
          new ServiceException(Throwables.getStackTraceAsString(e)));
    } catch (SerializationException e1) {
      logger.log(Level.WARNING, "エラー情報の返信に失敗しました", e1);
    }
  }

  // フォールバック
  return "";
}
 
开发者ID:nodchip,项目名称:QMAClone,代码行数:30,代码来源:ServiceServletStub.java

示例8: encodeResponseForFailure

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
/**
 * Wrapper around RPC utility invocation
 * @param rpcRequest RPCRequest
 * @param cause Exception to handle
 * @param targetMethod Method which threw the exception
 * @param targetParameters Method arguments  
 * @return RPC payload
 * @throws SerializationException Exception caused by RPC serialization
 */
protected String encodeResponseForFailure(RPCRequest rpcRequest, Throwable cause, Method targetMethod, Object[] targetParameters) throws SerializationException{
	SerializationPolicy serializationPolicy = getSerializationPolicyProvider().getSerializationPolicyForFailure(rpcRequest, service, targetMethod, targetParameters, cause);
	return RPC.encodeResponseForFailure(rpcRequest.getMethod(), cause, serializationPolicy, serializationFlags);
}
 
开发者ID:ggeorgovassilis,项目名称:gwt-sl,代码行数:14,代码来源:GWTRPCServiceExporter.java

示例9: handleIncompatibleRemoteServiceException

import com.google.gwt.user.server.rpc.RPC; //导入方法依赖的package包/类
/**
 * Invoked by {@link #processCall(String)} when RPC throws an
 * {@link IncompatibleRemoteServiceException}. This implementation
 * propagates the exception back to the client via RPC.
 * 
 * @param cause
 *            Exception thrown
 * @return RPC encoded failure response
 * @throws SerializationException If problems during serialization of cause to RPC
 */
protected String handleIncompatibleRemoteServiceException(IncompatibleRemoteServiceException cause)
		throws SerializationException {
	logger.warn(cause.getMessage());
	return RPC.encodeResponseForFailure(null, cause);
}
 
开发者ID:ggeorgovassilis,项目名称:gwt-sl,代码行数:16,代码来源:GWTRPCServiceExporter.java


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