|
|
|
@ -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"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with 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 |
|
|
|
* or common handler behavior like locale or theme changes. Its main purpose |
|
|
|
* is to allow for factoring out repetitive handler code. |
|
|
|
* is to allow for factoring out repetitive handler code. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>In an async processing scenario, the handler may be executed in a separate |
|
|
|
* <p>In an asynchronous processing scenario, the handler may be executed in a |
|
|
|
* thread while the main thread exits without rendering or invoking the |
|
|
|
* separate thread while the main thread exits without rendering or invoking the |
|
|
|
* {@code postHandle} and {@code afterCompletion} callbacks. When concurrent |
|
|
|
* {@code postHandle} and {@code afterCompletion} callbacks. When concurrent |
|
|
|
* handler execution completes, the request is dispatched back in order to |
|
|
|
* handler execution completes, the request is dispatched back in order to |
|
|
|
* proceed with rendering the model and all methods of this contract are invoked |
|
|
|
* proceed with rendering the model and all methods of this contract are invoked |
|
|
|
@ -48,7 +48,7 @@ import org.springframework.web.method.HandlerMethod; |
|
|
|
* in the application context, referenced by the mapping bean definition |
|
|
|
* in the application context, referenced by the mapping bean definition |
|
|
|
* via its "interceptors" property (in XML: a <list> of <ref>). |
|
|
|
* via its "interceptors" property (in XML: a <list> of <ref>). |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>HandlerInterceptor is basically similar to a Servlet 2.3 Filter, but in |
|
|
|
* <p>HandlerInterceptor is basically similar to a Servlet Filter, but in |
|
|
|
* contrast to the latter it just allows custom pre-processing with the option |
|
|
|
* contrast to the latter it just allows custom pre-processing with the option |
|
|
|
* of prohibiting the execution of the handler itself, and custom post-processing. |
|
|
|
* of prohibiting the execution of the handler itself, and custom post-processing. |
|
|
|
* Filters are more powerful, for example they allow for exchanging the request |
|
|
|
* Filters are more powerful, for example they allow for exchanging the request |
|
|
|
@ -81,6 +81,9 @@ public interface HandlerInterceptor { |
|
|
|
* of any number of interceptors, with the handler itself at the end. |
|
|
|
* of any number of interceptors, with the handler itself at the end. |
|
|
|
* With this method, each interceptor can decide to abort the execution chain, |
|
|
|
* With this method, each interceptor can decide to abort the execution chain, |
|
|
|
* typically sending a HTTP error or writing a custom response. |
|
|
|
* 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 request current HTTP request |
|
|
|
* @param response current HTTP response |
|
|
|
* @param response current HTTP response |
|
|
|
* @param handler chosen handler to execute, for type and/or instance evaluation |
|
|
|
* @param handler chosen handler to execute, for type and/or instance evaluation |
|
|
|
@ -100,16 +103,18 @@ public interface HandlerInterceptor { |
|
|
|
* of any number of interceptors, with the handler itself at the end. |
|
|
|
* of any number of interceptors, with the handler itself at the end. |
|
|
|
* With this method, each interceptor can post-process an execution, |
|
|
|
* With this method, each interceptor can post-process an execution, |
|
|
|
* getting applied in inverse order of the execution chain. |
|
|
|
* 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 request current HTTP request |
|
|
|
* @param response current HTTP response |
|
|
|
* @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 |
|
|
|
* execution, for type and/or instance examination |
|
|
|
* @param modelAndView the {@code ModelAndView} that the handler returned |
|
|
|
* @param modelAndView the {@code ModelAndView} that the handler returned |
|
|
|
* (can also be {@code null}) |
|
|
|
* (can also be {@code null}) |
|
|
|
* @throws Exception in case of errors |
|
|
|
* @throws Exception in case of errors |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void postHandle( |
|
|
|
void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) |
|
|
|
HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) |
|
|
|
|
|
|
|
throws Exception; |
|
|
|
throws Exception; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -121,15 +126,17 @@ public interface HandlerInterceptor { |
|
|
|
* <p>As with the {@code postHandle} method, the method will be invoked on each |
|
|
|
* <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 |
|
|
|
* interceptor in the chain in reverse order, so the first interceptor will be |
|
|
|
* the last to be invoked. |
|
|
|
* 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 request current HTTP request |
|
|
|
* @param response current HTTP response |
|
|
|
* @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 |
|
|
|
* execution, for type and/or instance examination |
|
|
|
* @param ex exception thrown on handler execution, if any |
|
|
|
* @param ex exception thrown on handler execution, if any |
|
|
|
* @throws Exception in case of errors |
|
|
|
* @throws Exception in case of errors |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void afterCompletion( |
|
|
|
void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) |
|
|
|
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) |
|
|
|
|
|
|
|
throws Exception; |
|
|
|
throws Exception; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|