Example usage for org.springframework.web.servlet HandlerExecutionChain triggerAfterCompletion

List of usage examples for org.springframework.web.servlet HandlerExecutionChain triggerAfterCompletion

Introduction

In this page you can find the example usage for org.springframework.web.servlet HandlerExecutionChain triggerAfterCompletion.

Prototype

void triggerAfterCompletion(HttpServletRequest request, HttpServletResponse response, @Nullable Exception ex)
        throws Exception 

Source Link

Document

Trigger afterCompletion callbacks on the mapped HandlerInterceptors.

Usage

From source file:com.mystudy.source.spring.mvc.DispatcherServlet.java

private void triggerAfterCompletion(HttpServletRequest request, HttpServletResponse response,
        HandlerExecutionChain mappedHandler, Exception ex) throws Exception {

    if (mappedHandler != null) {
        mappedHandler.triggerAfterCompletion(request, response, ex);
    }/*from w  w w  .  j  ava  2s  . c  o  m*/
    throw ex;
}

From source file:com.mystudy.source.spring.mvc.DispatcherServlet.java

private void triggerAfterCompletionWithError(HttpServletRequest request, HttpServletResponse response,
        HandlerExecutionChain mappedHandler, Error error) throws Exception, ServletException {

    ServletException ex = new NestedServletException("Handler processing failed", error);
    if (mappedHandler != null) {
        mappedHandler.triggerAfterCompletion(request, response, ex);
    }/*from  www.ja  v a  2 s  . com*/
    throw ex;
}

From source file:com.mystudy.source.spring.mvc.DispatcherServlet.java

/**
 * Handle the result of handler selection and handler invocation, which is
 * either a ModelAndView or an Exception to be resolved to a ModelAndView.
 */// w w  w.j  a v  a 2s .  c  o m
private void processDispatchResult(HttpServletRequest request, HttpServletResponse response,
        HandlerExecutionChain mappedHandler, ModelAndView mv, Exception exception) throws Exception {

    boolean errorView = false;

    if (exception != null) {
        if (exception instanceof ModelAndViewDefiningException) {
            logger.debug("ModelAndViewDefiningException encountered", exception);
            mv = ((ModelAndViewDefiningException) exception).getModelAndView();
        } else {
            Object handler = (mappedHandler != null ? mappedHandler.getHandler() : null);
            mv = processHandlerException(request, response, handler, exception);
            errorView = (mv != null);
        }
    }

    // Did the handler return a view to render?
    if (mv != null && !mv.wasCleared()) {
        render(mv, request, response);
        if (errorView) {
            WebUtils.clearErrorRequestAttributes(request);
        }
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("Null ModelAndView returned to DispatcherServlet with name '" + getServletName()
                    + "': assuming HandlerAdapter completed request handling");
        }
    }

    if (WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted()) {
        // Concurrent handling started during a forward
        return;
    }

    if (mappedHandler != null) {
        mappedHandler.triggerAfterCompletion(request, response, null);
    }
}

From source file:org.springframework.web.servlet.DispatcherServlet.java

/**
 * Handle the result of handler selection and handler invocation, which is
 * either a ModelAndView or an Exception to be resolved to a ModelAndView.
 *///from  w  ww .j  av a 2 s  .c  om
private void processDispatchResult(HttpServletRequest request, HttpServletResponse response,
        @Nullable HandlerExecutionChain mappedHandler, @Nullable ModelAndView mv, @Nullable Exception exception)
        throws Exception {

    boolean errorView = false;

    if (exception != null) {
        if (exception instanceof ModelAndViewDefiningException) {
            logger.debug("ModelAndViewDefiningException encountered", exception);
            mv = ((ModelAndViewDefiningException) exception).getModelAndView();
        } else {
            Object handler = (mappedHandler != null ? mappedHandler.getHandler() : null);
            mv = processHandlerException(request, response, handler, exception);
            errorView = (mv != null);
        }
    }

    // Did the handler return a view to render?
    if (mv != null && !mv.wasCleared()) {
        render(mv, request, response);
        if (errorView) {
            WebUtils.clearErrorRequestAttributes(request);
        }
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("Null ModelAndView returned to DispatcherServlet with name '" + getServletName()
                    + "': assuming HandlerAdapter completed request handling");
        }
    }

    if (WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted()) {
        // Concurrent handling started during a forward
        return;
    }

    if (mappedHandler != null) {
        mappedHandler.triggerAfterCompletion(request, response, null);
    }
}

From source file:org.springframework.web.servlet.DispatcherServlet.java

private void triggerAfterCompletion(HttpServletRequest request, HttpServletResponse response,
        @Nullable HandlerExecutionChain mappedHandler, Exception ex) throws Exception {

    if (mappedHandler != null) {
        mappedHandler.triggerAfterCompletion(request, response, ex);
    }//from w w  w .  j  a v  a  2s.c o  m
    throw ex;
}

From source file:org.springframework.web.servlet.LogDispatcherServlet.java

private void triggerAfterCompletionWithError(HttpServletRequest request, HttpServletResponse response,
        HandlerExecutionChain mappedHandler, Error error) throws Exception {

    ServletException ex = new NestedServletException("Handler processing failed", error);
    if (mappedHandler != null) {
        mappedHandler.triggerAfterCompletion(request, response, ex);
    }//from  w  ww .j a  v  a  2  s  .co m
    throw ex;
}