Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,8 +33,8 @@ import org.springframework.web.method.HandlerMethod;
|
||||
* or common handler behavior like locale or theme changes. Its main purpose
|
||||
* is to allow for factoring out repetitive handler code.
|
||||
*
|
||||
* <p>In an async processing scenario, the handler may be executed in a separate
|
||||
* thread while the main thread exits without rendering or invoking the
|
||||
* <p>In an asynchronous processing scenario, the handler may be executed in a
|
||||
* separate thread while the main thread exits without rendering or invoking the
|
||||
* {@code postHandle} and {@code afterCompletion} callbacks. When concurrent
|
||||
* handler execution completes, the request is dispatched back in order to
|
||||
* proceed with rendering the model and all methods of this contract are invoked
|
||||
@@ -77,16 +77,13 @@ public interface HandlerInterceptor {
|
||||
/**
|
||||
* Intercept the execution of a handler. Called after HandlerMapping determined
|
||||
* an appropriate handler object, but before HandlerAdapter invokes the handler.
|
||||
*
|
||||
* <p>DispatcherServlet processes a handler in an execution chain, consisting
|
||||
* of any number of interceptors, with the handler itself at the end.
|
||||
* With this method, each interceptor can decide to abort the execution chain,
|
||||
* typically sending a HTTP error or writing a custom response.
|
||||
*
|
||||
* <p><strong>Note:</strong> special considerations apply for asynchronous
|
||||
* request processing. For more details see
|
||||
* {@link org.springframework.web.servlet.AsyncHandlerInterceptor}.
|
||||
*
|
||||
* @param request current HTTP request
|
||||
* @param response current HTTP response
|
||||
* @param handler chosen handler to execute, for type and/or instance evaluation
|
||||
@@ -102,19 +99,16 @@ public interface HandlerInterceptor {
|
||||
* Intercept the execution of a handler. Called after HandlerAdapter actually
|
||||
* invoked the handler, but before the DispatcherServlet renders the view.
|
||||
* Can expose additional model objects to the view via the given ModelAndView.
|
||||
*
|
||||
* <p>DispatcherServlet processes a handler in an execution chain, consisting
|
||||
* of any number of interceptors, with the handler itself at the end.
|
||||
* With this method, each interceptor can post-process an execution,
|
||||
* getting applied in inverse order of the execution chain.
|
||||
*
|
||||
* <p><strong>Note:</strong> special considerations apply for asynchronous
|
||||
* request processing. For more details see
|
||||
* {@link org.springframework.web.servlet.AsyncHandlerInterceptor}.
|
||||
*
|
||||
* @param request current HTTP request
|
||||
* @param response current HTTP response
|
||||
* @param handler handler (or {@link HandlerMethod}) that started async
|
||||
* @param handler handler (or {@link HandlerMethod}) that started asynchronous
|
||||
* execution, for type and/or instance examination
|
||||
* @param modelAndView the {@code ModelAndView} that the handler returned
|
||||
* (can also be {@code null})
|
||||
@@ -127,21 +121,17 @@ public interface HandlerInterceptor {
|
||||
* Callback after completion of request processing, that is, after rendering
|
||||
* the view. Will be called on any outcome of handler execution, thus allows
|
||||
* for proper resource cleanup.
|
||||
*
|
||||
* <p>Note: Will only be called if this interceptor's {@code preHandle}
|
||||
* method has successfully completed and returned {@code true}!
|
||||
*
|
||||
* <p>As with the {@code postHandle} method, the method will be invoked on each
|
||||
* interceptor in the chain in reverse order, so the first interceptor will be
|
||||
* the last to be invoked.
|
||||
*
|
||||
* <p><strong>Note:</strong> special considerations apply for asynchronous
|
||||
* request processing. For more details see
|
||||
* {@link org.springframework.web.servlet.AsyncHandlerInterceptor}.
|
||||
*
|
||||
* @param request current HTTP request
|
||||
* @param response current HTTP response
|
||||
* @param handler handler (or {@link HandlerMethod}) that started async
|
||||
* @param handler handler (or {@link HandlerMethod}) that started asynchronous
|
||||
* execution, for type and/or instance examination
|
||||
* @param ex exception thrown on handler execution, if any
|
||||
* @throws Exception in case of errors
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ public abstract class AbstractHandlerMethodExceptionResolver extends AbstractHan
|
||||
|
||||
/**
|
||||
* Checks if the handler is a {@link HandlerMethod} and then delegates to the
|
||||
* base class implementation of {@link #shouldApplyTo(HttpServletRequest, Object)}
|
||||
* base class implementation of {@code #shouldApplyTo(HttpServletRequest, Object)}
|
||||
* passing the bean of the {@code HandlerMethod}. Otherwise returns {@code false}.
|
||||
*/
|
||||
@Override
|
||||
@@ -54,8 +54,7 @@ public abstract class AbstractHandlerMethodExceptionResolver extends AbstractHan
|
||||
|
||||
@Override
|
||||
protected final ModelAndView doResolveException(
|
||||
HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler, Exception ex) {
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
||||
|
||||
return doResolveHandlerMethodException(request, response, (HandlerMethod) handler, ex);
|
||||
}
|
||||
@@ -75,7 +74,6 @@ public abstract class AbstractHandlerMethodExceptionResolver extends AbstractHan
|
||||
* @return a corresponding ModelAndView to forward to, or {@code null} for default processing
|
||||
*/
|
||||
protected abstract ModelAndView doResolveHandlerMethodException(
|
||||
HttpServletRequest request, HttpServletResponse response,
|
||||
HandlerMethod handlerMethod, Exception ex);
|
||||
HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod, Exception ex);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -95,7 +95,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
||||
|
||||
public ExceptionHandlerExceptionResolver() {
|
||||
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
|
||||
stringHttpMessageConverter.setWriteAcceptCharset(false); // See SPR-7316
|
||||
stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316
|
||||
|
||||
this.messageConverters = new ArrayList<HttpMessageConverter<?>>();
|
||||
this.messageConverters.add(new ByteArrayHttpMessageConverter());
|
||||
@@ -264,11 +264,15 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
||||
ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(adviceBean.getBeanType());
|
||||
if (resolver.hasExceptionMappings()) {
|
||||
this.exceptionHandlerAdviceCache.put(adviceBean, resolver);
|
||||
logger.info("Detected @ExceptionHandler methods in " + adviceBean);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Detected @ExceptionHandler methods in " + adviceBean);
|
||||
}
|
||||
}
|
||||
if (ResponseBodyAdvice.class.isAssignableFrom(adviceBean.getBeanType())) {
|
||||
this.responseBodyAdvice.add(adviceBean);
|
||||
logger.info("Detected ResponseBodyAdvice implementation in " + adviceBean);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Detected ResponseBodyAdvice implementation in " + adviceBean);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user