|
24 | 24 | import javax.servlet.http.HttpServletRequest;
|
25 | 25 |
|
26 | 26 | import org.springframework.beans.BeansException;
|
| 27 | +import org.springframework.beans.factory.BeanFactoryUtils; |
| 28 | +import org.springframework.core.OrderComparator; |
27 | 29 | import org.springframework.core.Ordered;
|
28 | 30 | import org.springframework.web.context.request.WebRequestInterceptor;
|
29 | 31 | import org.springframework.web.context.support.WebApplicationObjectSupport;
|
30 | 32 | import org.springframework.web.servlet.HandlerExecutionChain;
|
31 | 33 | import org.springframework.web.servlet.HandlerInterceptor;
|
32 | 34 | import org.springframework.web.servlet.HandlerMapping;
|
| 35 | +import org.springframework.web.servlet.ViewResolver; |
33 | 36 |
|
34 | 37 | /**
|
35 | 38 | * Abstract base class for {@link org.springframework.web.servlet.HandlerMapping}
|
@@ -142,19 +145,20 @@ protected void extendInterceptors(List interceptors) {
|
142 | 145 | */
|
143 | 146 | protected void initInterceptors() {
|
144 | 147 | if (this.detectInterceptors) {
|
145 |
| - Map<String, HandlerInterceptor> handlerInterceptors = getApplicationContext().getBeansOfType(HandlerInterceptor.class); |
146 |
| - if (handlerInterceptors != null && !handlerInterceptors.isEmpty()) { |
| 148 | + Map<String, HandlerInterceptor> handlerInterceptors = BeanFactoryUtils.beansOfTypeIncludingAncestors(getApplicationContext(), HandlerInterceptor.class, true, false); |
| 149 | + if (!handlerInterceptors.isEmpty()) { |
147 | 150 | this.interceptors.addAll(handlerInterceptors.values());
|
148 | 151 | }
|
149 |
| - Map<String, WebRequestInterceptor> webInterceptors = getApplicationContext().getBeansOfType(WebRequestInterceptor.class); |
150 |
| - if (webInterceptors != null && !webInterceptors.isEmpty()) { |
| 152 | + Map<String, WebRequestInterceptor> webInterceptors = BeanFactoryUtils.beansOfTypeIncludingAncestors(getApplicationContext(), WebRequestInterceptor.class, true, false); |
| 153 | + if (!webInterceptors.isEmpty()) { |
151 | 154 | for (WebRequestInterceptor interceptor : webInterceptors.values()) {
|
152 | 155 | this.interceptors.add(new WebRequestHandlerInterceptorAdapter(interceptor));
|
153 | 156 | }
|
154 | 157 | }
|
155 | 158 | }
|
156 | 159 |
|
157 | 160 | if (!this.interceptors.isEmpty()) {
|
| 161 | + OrderComparator.sort(this.interceptors); |
158 | 162 | this.adaptedInterceptors = new HandlerInterceptor[this.interceptors.size()];
|
159 | 163 | for (int i = 0; i < this.interceptors.size(); i++) {
|
160 | 164 | Object interceptor = this.interceptors.get(i);
|
|
0 commit comments