/** * Log the given exception at warn level, provided that warn logging has been * activated through the {@link #setWarnLogCategory "warnLogCategory"} property. * <p>Calls {@link #buildLogMessage} in order to determine the concrete message to log. * @param ex the exception that got thrown during handler execution * @param request current HTTP request (useful for obtaining metadata) * @see #setWarnLogCategory * @see #buildLogMessage * @see org.apache.commons.logging.Log#warn(Object, Throwable) */ protected void logException(Exception ex, HttpServletRequest request) { if (this.warnLogger != null && this.warnLogger.isWarnEnabled()) { this.warnLogger.warn(buildLogMessage(ex, request)); } }
/** * Check whether this resolver is supposed to apply (i.e. if the supplied handler * matches any of the configured {@linkplain #setMappedHandlers handlers} or * {@linkplain #setMappedHandlerClasses handler classes}), and then delegate * to the {@link #doResolveException} template method. */ @Override @Nullable public ModelAndView resolveException( HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) { if (shouldApplyTo(request, handler)) { prepareResponse(ex, response); ModelAndView result = doResolveException(request, response, handler, ex); if (result != null) { // Print warn message when warn logger is not enabled... if (logger.isDebugEnabled() && (this.warnLogger == null || !this.warnLogger.isWarnEnabled())) { logger.debug("Resolved [" + ex + "]" + (result.isEmpty() ? "" : " to " + result)); } // warnLogger with full stack trace (requires explicit config) logException(ex, request); } return result; } else { return null; } }
/** * Prepare the response for the exceptional case. * <p>The default implementation prevents the response from being cached, * if the {@link #setPreventResponseCaching "preventResponseCaching"} property * has been set to "true". * @param ex the exception that got thrown during handler execution * @param response current HTTP response * @see #preventCaching */ protected void prepareResponse(Exception ex, HttpServletResponse response) { if (this.preventResponseCaching) { preventCaching(response); } }
/** * Checks if the handler is a {@link HandlerMethod} and then delegates to the * base class implementation of {@code #shouldApplyTo(HttpServletRequest, Object)} * passing the bean of the {@code HandlerMethod}. Otherwise returns {@code false}. */ @Override protected boolean shouldApplyTo(HttpServletRequest request, @Nullable Object handler) { if (handler == null) { return super.shouldApplyTo(request, null); } else if (handler instanceof HandlerMethod) { HandlerMethod handlerMethod = (HandlerMethod) handler; handler = handlerMethod.getBean(); return super.shouldApplyTo(request, handler); } else { return false; } }
/** * Checks if the handler is a {@link HandlerMethod} and then delegates to the * base class implementation of {@code #shouldApplyTo(HttpServletRequest, Object)} * passing the bean of the {@code HandlerMethod}. Otherwise returns {@code false}. */ @Override protected boolean shouldApplyTo(HttpServletRequest request, @Nullable Object handler) { if (handler == null) { return super.shouldApplyTo(request, null); } else if (handler instanceof HandlerMethod) { HandlerMethod handlerMethod = (HandlerMethod) handler; handler = handlerMethod.getBean(); return super.shouldApplyTo(request, handler); } else { return false; } }
/** * Check whether this resolver is supposed to apply (i.e. if the supplied handler * matches any of the configured {@linkplain #setMappedHandlers handlers} or * {@linkplain #setMappedHandlerClasses handler classes}), and then delegate * to the {@link #doResolveException} template method. */ @Override @Nullable public ModelAndView resolveException( HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) { if (shouldApplyTo(request, handler)) { prepareResponse(ex, response); ModelAndView result = doResolveException(request, response, handler, ex); if (result != null) { // Print warn message when warn logger is not enabled... if (logger.isDebugEnabled() && (this.warnLogger == null || !this.warnLogger.isWarnEnabled())) { logger.debug("Resolved [" + ex + "]" + (result.isEmpty() ? "" : " to " + result)); } // warnLogger with full stack trace (requires explicit config) logException(ex, request); } return result; } else { return null; } }
/** * Prepare the response for the exceptional case. * <p>The default implementation prevents the response from being cached, * if the {@link #setPreventResponseCaching "preventResponseCaching"} property * has been set to "true". * @param ex the exception that got thrown during handler execution * @param response current HTTP response * @see #preventCaching */ protected void prepareResponse(Exception ex, HttpServletResponse response) { if (this.preventResponseCaching) { preventCaching(response); } }
/** * Log the given exception at warn level, provided that warn logging has been * activated through the {@link #setWarnLogCategory "warnLogCategory"} property. * <p>Calls {@link #buildLogMessage} in order to determine the concrete message to log. * @param ex the exception that got thrown during handler execution * @param request current HTTP request (useful for obtaining metadata) * @see #setWarnLogCategory * @see #buildLogMessage * @see org.apache.commons.logging.Log#warn(Object, Throwable) */ protected void logException(Exception ex, HttpServletRequest request) { if (this.warnLogger != null && this.warnLogger.isWarnEnabled()) { this.warnLogger.warn(buildLogMessage(ex, request)); } }
/** * Checks if the handler is a {@link HandlerMethod} and then delegates to the * base class implementation of {@code #shouldApplyTo(HttpServletRequest, Object)} * passing the bean of the {@code HandlerMethod}. Otherwise returns {@code false}. */ @Override protected boolean shouldApplyTo(HttpServletRequest request, Object handler) { if (handler == null) { return super.shouldApplyTo(request, handler); } else if (handler instanceof HandlerMethod) { HandlerMethod handlerMethod = (HandlerMethod) handler; handler = handlerMethod.getBean(); return super.shouldApplyTo(request, handler); } else { return false; } }
/** * Check whether this resolver is supposed to apply (i.e. if the supplied handler * matches any of the configured {@linkplain #setMappedHandlers handlers} or * {@linkplain #setMappedHandlerClasses handler classes}), and then delegate * to the {@link #doResolveException} template method. */ @Override public ModelAndView resolveException( HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { if (shouldApplyTo(request, handler)) { prepareResponse(ex, response); ModelAndView result = doResolveException(request, response, handler, ex); if (result != null) { // Print warn message when warn logger is not enabled... if (logger.isDebugEnabled() && (this.warnLogger == null || !this.warnLogger.isWarnEnabled())) { logger.debug("Resolved [" + ex + "]" + (result.isEmpty() ? "" : " to " + result)); } // warnLogger with full stack trace (requires explicit config) logException(ex, request); } return result; } else { return null; } }
/** * Prepare the response for the exceptional case. * <p>The default implementation prevents the response from being cached, * if the {@link #setPreventResponseCaching "preventResponseCaching"} property * has been set to "true". * @param ex the exception that got thrown during handler execution * @param response current HTTP response * @see #preventCaching */ protected void prepareResponse(Exception ex, HttpServletResponse response) { if (this.preventResponseCaching) { preventCaching(response); } }
/** * Log the given exception at warn level, provided that warn logging has been * activated through the {@link #setWarnLogCategory "warnLogCategory"} property. * <p>Calls {@link #buildLogMessage} in order to determine the concrete message to log. * @param ex the exception that got thrown during handler execution * @param request current HTTP request (useful for obtaining metadata) * @see #setWarnLogCategory * @see #buildLogMessage * @see org.apache.commons.logging.Log#warn(Object, Throwable) */ protected void logException(Exception ex, HttpServletRequest request) { if (this.warnLogger != null && this.warnLogger.isWarnEnabled()) { this.warnLogger.warn(buildLogMessage(ex, request)); } }