001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.springframework.web.context.request; 017 018/** 019 * Extends {@code WebRequestInterceptor} with a callback method invoked during 020 * asynchronous request handling. 021 * 022 * <p>When a handler starts asynchronous request handling, the DispatcherServlet 023 * exits without invoking {@code postHandle} and {@code afterCompletion}, as it 024 * normally does, since the results of request handling (e.g. ModelAndView) are 025 * not available in the current thread and handling is not yet complete. 026 * In such scenarios, the {@link #afterConcurrentHandlingStarted(WebRequest)} 027 * method is invoked instead allowing implementations to perform tasks such as 028 * cleaning up thread bound attributes. 029 * 030 * <p>When asynchronous handling completes, the request is dispatched to the 031 * container for further processing. At this stage the DispatcherServlet invokes 032 * {@code preHandle}, {@code postHandle} and {@code afterCompletion} as usual. 033 * 034 * @author Rossen Stoyanchev 035 * @since 3.2 036 * 037 * @see org.springframework.web.context.request.async.WebAsyncManager 038 */ 039public interface AsyncWebRequestInterceptor extends WebRequestInterceptor{ 040 041 /** 042 * Called instead of {@code postHandle} and {@code afterCompletion}, when the 043 * the handler started handling the request concurrently. 044 * 045 * @param request the current request 046 */ 047 void afterConcurrentHandlingStarted(WebRequest request); 048 049}