SPR-8094
This commit is contained in:
parent
3690002dce
commit
0c736776da
|
|
@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
|
||||||
import org.springframework.util.AntPathMatcher;
|
import org.springframework.util.AntPathMatcher;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
@ -165,13 +164,9 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
|
||||||
@Override
|
@Override
|
||||||
protected void initInterceptors() {
|
protected void initInterceptors() {
|
||||||
super.initInterceptors();
|
super.initInterceptors();
|
||||||
Map<String, MappedInterceptor> mappedInterceptors = BeanFactoryUtils.beansOfTypeIncludingAncestors(
|
if (mappedInterceptors == null) {
|
||||||
getApplicationContext(), MappedInterceptor.class, true, false);
|
this.mappedInterceptors = MappedInterceptors.createFromDeclaredBeans(getApplicationContext());
|
||||||
if (!mappedInterceptors.isEmpty()) {
|
|
||||||
this.mappedInterceptors = new MappedInterceptors(mappedInterceptors.values().toArray(
|
|
||||||
new MappedInterceptor[mappedInterceptors.size()]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -203,20 +198,6 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
|
||||||
handler = buildPathExposingHandler(rawHandler, lookupPath, lookupPath, null);
|
handler = buildPathExposingHandler(rawHandler, lookupPath, lookupPath, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (handler != null && this.mappedInterceptors != null) {
|
|
||||||
HandlerInterceptor[] mappedInterceptors =
|
|
||||||
this.mappedInterceptors.getInterceptors(lookupPath, this.pathMatcher);
|
|
||||||
if (mappedInterceptors.length != 0) {
|
|
||||||
HandlerExecutionChain chain;
|
|
||||||
if (handler instanceof HandlerExecutionChain) {
|
|
||||||
chain = (HandlerExecutionChain) handler;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
chain = new HandlerExecutionChain(handler);
|
|
||||||
}
|
|
||||||
chain.addInterceptors(mappedInterceptors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (handler != null && logger.isDebugEnabled()) {
|
if (handler != null && logger.isDebugEnabled()) {
|
||||||
logger.debug("Mapping [" + lookupPath + "] to " + handler);
|
logger.debug("Mapping [" + lookupPath + "] to " + handler);
|
||||||
}
|
}
|
||||||
|
|
@ -306,6 +287,19 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
|
||||||
protected void validateHandler(Object handler, HttpServletRequest request) throws Exception {
|
protected void validateHandler(Object handler, HttpServletRequest request) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected HandlerExecutionChain getHandlerExecutionChain(Object handler, HttpServletRequest request) {
|
||||||
|
HandlerExecutionChain chain = super.getHandlerExecutionChain(handler, request);
|
||||||
|
if (this.mappedInterceptors != null) {
|
||||||
|
String lookupPath = urlPathHelper.getLookupPathForRequest(request);
|
||||||
|
HandlerInterceptor[] handlerInterceptors = mappedInterceptors.getInterceptors(lookupPath, pathMatcher);
|
||||||
|
if (handlerInterceptors.length > 0) {
|
||||||
|
chain.addInterceptors(handlerInterceptors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return chain;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a handler object for the given raw handler, exposing the actual
|
* Build a handler object for the given raw handler, exposing the actual
|
||||||
* handler, the {@link #PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE}, as well as
|
* handler, the {@link #PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE}, as well as
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue