|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2012 the original author or authors. |
|
|
|
|
* Copyright 2002-2013 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. |
|
|
|
|
@ -18,6 +18,8 @@ package org.springframework.web.servlet.config;
@@ -18,6 +18,8 @@ package org.springframework.web.servlet.config;
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
import org.w3c.dom.Element; |
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.config.BeanDefinition; |
|
|
|
|
import org.springframework.beans.factory.parsing.BeanComponentDefinition; |
|
|
|
|
import org.springframework.beans.factory.parsing.CompositeComponentDefinition; |
|
|
|
|
@ -27,11 +29,10 @@ import org.springframework.beans.factory.xml.BeanDefinitionParser;
@@ -27,11 +29,10 @@ import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
|
|
|
|
import org.springframework.beans.factory.xml.ParserContext; |
|
|
|
|
import org.springframework.util.xml.DomUtils; |
|
|
|
|
import org.springframework.web.servlet.handler.MappedInterceptor; |
|
|
|
|
import org.w3c.dom.Element; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses a {@code interceptors} element to register |
|
|
|
|
* a set of {@link MappedInterceptor} definitions. |
|
|
|
|
* {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses a |
|
|
|
|
* {@code interceptors} element to register a set of {@link MappedInterceptor} definitions. |
|
|
|
|
* |
|
|
|
|
* @author Keith Donald |
|
|
|
|
* @since 3.0 |
|
|
|
|
@ -42,7 +43,7 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
@@ -42,7 +43,7 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
|
|
|
|
|
CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element)); |
|
|
|
|
parserContext.pushContainingComponent(compDefinition); |
|
|
|
|
|
|
|
|
|
List<Element> interceptors = DomUtils.getChildElementsByTagName(element, new String[] { "bean", "ref", "interceptor" }); |
|
|
|
|
List<Element> interceptors = DomUtils.getChildElementsByTagName(element, "bean", "ref", "interceptor"); |
|
|
|
|
for (Element interceptor : interceptors) { |
|
|
|
|
RootBeanDefinition mappedInterceptorDef = new RootBeanDefinition(MappedInterceptor.class); |
|
|
|
|
mappedInterceptorDef.setSource(parserContext.extractSource(interceptor)); |
|
|
|
|
@ -54,7 +55,7 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
@@ -54,7 +55,7 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
|
|
|
|
|
if ("interceptor".equals(interceptor.getLocalName())) { |
|
|
|
|
includePatterns = getIncludePatterns(interceptor, "mapping"); |
|
|
|
|
excludePatterns = getIncludePatterns(interceptor, "exclude-mapping"); |
|
|
|
|
Element beanElem = DomUtils.getChildElementsByTagName(interceptor, new String[] { "bean", "ref"}).get(0); |
|
|
|
|
Element beanElem = DomUtils.getChildElementsByTagName(interceptor, "bean", "ref").get(0); |
|
|
|
|
interceptorBean = parserContext.getDelegate().parsePropertySubElement(beanElem, null); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
@ -75,8 +76,8 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
@@ -75,8 +76,8 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser {
|
|
|
|
|
private ManagedList<String> getIncludePatterns(Element interceptor, String elementName) { |
|
|
|
|
List<Element> paths = DomUtils.getChildElementsByTagName(interceptor, elementName); |
|
|
|
|
ManagedList<String> patterns = new ManagedList<String>(paths.size()); |
|
|
|
|
for (int i = 0; i < paths.size(); i++) { |
|
|
|
|
patterns.add(paths.get(i).getAttribute("path")); |
|
|
|
|
for (Element path : paths) { |
|
|
|
|
patterns.add(path.getAttribute("path")); |
|
|
|
|
} |
|
|
|
|
return patterns; |
|
|
|
|
} |
|
|
|
|
|