Example usage for com.google.gwt.user.server.rpc RPCServletUtils writeResponseForUnexpectedFailure

List of usage examples for com.google.gwt.user.server.rpc RPCServletUtils writeResponseForUnexpectedFailure

Introduction

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

Prototype

public static void writeResponseForUnexpectedFailure(ServletContext servletContext,
        HttpServletResponse response, Throwable failure) 

Source Link

Document

Called when the servlet itself has a problem, rather than the invoked third-party method.

Usage

From source file:com.dotspots.rpcplus.flexiblerpc.FlexibleRemoteServiceServlet.java

License:Apache License

/**
 * Override this method to control what should happen when an exception escapes the {@link #processCall(String)}
 * method. The default implementation will log the failure and send a generic failure response to the client.
 * <p>/*  w  w w.j  a va2  s .co  m*/
 * An "expected failure" is an exception thrown by a service method that is declared in the signature of the service
 * method. These exceptions are serialized back to the client, and are not passed to this method. This method is
 * called only for exceptions or errors that are not part of the service method's signature, or that result from
 * SecurityExceptions, SerializationExceptions, or other failures within the RPC framework.
 * <p>
 * Note that if the desired behavior is to both send the GENERIC_FAILURE_MSG response AND to rethrow the exception,
 * then this method should first send the GENERIC_FAILURE_MSG response itself (using getThreadLocalResponse), and
 * then rethrow the exception. Rethrowing the exception will cause it to escape into the servlet container.
 * 
 * @param e
 *            the exception which was thrown
 */
protected void doUnexpectedFailure(Throwable e) {
    ServletContext servletContext = getServletContext();
    RPCServletUtils.writeResponseForUnexpectedFailure(servletContext, getThreadLocalResponse(), e);
}

From source file:de.itsvs.cwtrpc.controller.RemoteServiceControllerServlet.java

License:Apache License

protected void processUnexpectedFailure(HttpServletRequest request, HttpServletResponse response,
        Throwable exception) throws ServletException, IOException {
    log.error("Unexpected error while processing service request", exception);

    if (CwtRpcUtils.getRpcSessionInvalidationPolicy(request).isInvalidateOnUnexpectedException()) {
        invalidateSession(request);// w ww. jav a2 s.  c om
    }
    if (!response.isCommitted()) {
        response.reset();
        addNoCacheResponseHeaders(request, response);
        RPCServletUtils.writeResponseForUnexpectedFailure(getServletContext(), response, exception);
        /*
         * Flush all remaining output to the client (client can continue
         * immediately). Also response will be marked as being committed
         * (status may be required later by a filter).
         */
        response.flushBuffer();
    }
}

From source file:de.itsvs.cwtrpc.controller.UnexpectedErrorFilter.java

License:Apache License

protected void processUnexpectedFailure(HttpServletRequest request, HttpServletResponse response, Throwable e) {
    log.error("Unexpected error while processing service request", e);

    if (!response.isCommitted()) {
        response.reset();//w  w  w . ja v a2s. c o m
        /*
         * Since unexpected failure does a non cachable status code, we do
         * not need to initialize caching.
         */
        RPCServletUtils.writeResponseForUnexpectedFailure(getServletContext(), response, e);
    }
}

From source file:de.itsvs.cwtrpc.security.AbstractRpcFailureHandler.java

License:Apache License

protected void writeUnexpectedException(HttpServletRequest request, HttpServletResponse response,
        Throwable exception) throws IOException {
    if (CwtRpcUtils.getRpcSessionInvalidationPolicy(request).isInvalidateOnUnexpectedException()) {
        invalidateSession(request);//from w w  w  .j a v  a2s  .c o m
    }

    response.reset();
    addNoCacheResponseHeaders(request, response);
    RPCServletUtils.writeResponseForUnexpectedFailure(getServletContext(), response, exception);
    response.flushBuffer();
}

From source file:de.itsvs.cwtrpc.security.AbstractRpcSuccessHandler.java

License:Apache License

protected void sendResponse(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    final RPCRequest rpcRequest;
    final String responsePayload;

    rpcRequest = AbstractRpcAuthenticationProcessingFilter.getRpcRequest(request);
    if (rpcRequest == null) {
        throw new CwtRpcException("RPC request has not been stored in request ("
                + AbstractRpcAuthenticationProcessingFilter.class.getName() + " must be used)");
    }/* w w  w  .j a  v  a 2  s . c  o  m*/

    try {
        addNoCacheResponseHeaders(request, response);
        responsePayload = RPC.encodeResponseForSuccess(rpcRequest.getMethod(),
                getResponse(request, rpcRequest, authentication), rpcRequest.getSerializationPolicy(),
                rpcRequest.getFlags());
        RPCServletUtils.writeResponse(getServletContext(), response, responsePayload, false);
    } catch (SerializationException e) {
        log.error("Serialization error while processing service request", e);
        if (!response.isCommitted()) {
            RPCServletUtils.writeResponseForUnexpectedFailure(getServletContext(), response, e);
        }
    }
}