used managed list to detect bean definitions
This commit is contained in:
parent
7309b11849
commit
94eeb99333
|
|
@ -16,14 +16,13 @@
|
|||
|
||||
package org.springframework.web.servlet.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
|
|
@ -74,7 +73,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
|||
Element interceptors = DomUtils.getChildElementByTagName(element, "interceptors");
|
||||
if (interceptors != null) {
|
||||
List<Element> beans = DomUtils.getChildElementsByTagName(interceptors, "bean");
|
||||
List<BeanDefinition> interceptorBeans = new ArrayList<BeanDefinition>(beans.size());
|
||||
List<BeanDefinition> interceptorBeans = new ManagedList<BeanDefinition>(beans.size());
|
||||
for (Element bean : beans) {
|
||||
interceptorBeans.add(parserContext.getDelegate().parseBeanDefinitionElement(bean).getBeanDefinition());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ import javax.validation.Valid;
|
|||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.core.convert.ConversionFailedException;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.style.StylerUtils;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat.ISO;
|
||||
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
|
||||
|
|
@ -74,6 +74,8 @@ public class MvcNamespaceTests {
|
|||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(container);
|
||||
reader.loadBeanDefinitions(new ClassPathResource("mvc-config.xml", getClass()));
|
||||
assertEquals(4, container.getBeanDefinitionCount());
|
||||
container.refresh();
|
||||
|
||||
DefaultAnnotationHandlerMapping mapping = container.getBean(DefaultAnnotationHandlerMapping.class);
|
||||
assertNotNull(mapping);
|
||||
assertEquals(0, mapping.getOrder());
|
||||
|
|
@ -99,6 +101,8 @@ public class MvcNamespaceTests {
|
|||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(container);
|
||||
reader.loadBeanDefinitions(new ClassPathResource("mvc-config-custom-conversion-service.xml", getClass()));
|
||||
assertEquals(4, container.getBeanDefinitionCount());
|
||||
container.refresh();
|
||||
|
||||
DefaultAnnotationHandlerMapping mapping = container.getBean(DefaultAnnotationHandlerMapping.class);
|
||||
assertNotNull(mapping);
|
||||
assertEquals(0, mapping.getOrder());
|
||||
|
|
@ -120,6 +124,8 @@ public class MvcNamespaceTests {
|
|||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(container);
|
||||
reader.loadBeanDefinitions(new ClassPathResource("mvc-config-custom-validator.xml", getClass()));
|
||||
assertEquals(4, container.getBeanDefinitionCount());
|
||||
container.refresh();
|
||||
|
||||
DefaultAnnotationHandlerMapping mapping = container.getBean(DefaultAnnotationHandlerMapping.class);
|
||||
assertNotNull(mapping);
|
||||
assertEquals(0, mapping.getOrder());
|
||||
|
|
@ -140,11 +146,12 @@ public class MvcNamespaceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testInterceptors() throws Exception {
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(container);
|
||||
reader.loadBeanDefinitions(new ClassPathResource("mvc-config-interceptors.xml", getClass()));
|
||||
assertEquals(4, container.getBeanDefinitionCount());
|
||||
container.refresh();
|
||||
|
||||
DefaultAnnotationHandlerMapping mapping = container.getBean(DefaultAnnotationHandlerMapping.class);
|
||||
assertNotNull(mapping);
|
||||
mapping.setRootHandler(new TestController());
|
||||
|
|
@ -153,9 +160,9 @@ public class MvcNamespaceTests {
|
|||
request.addParameter("theme", "green");
|
||||
|
||||
HandlerExecutionChain chain = mapping.getHandler(request);
|
||||
assertEquals(2, chain.getInterceptors().length);
|
||||
assertTrue(chain.getInterceptors()[0] instanceof LocaleChangeInterceptor);
|
||||
assertTrue(chain.getInterceptors()[1] instanceof ThemeChangeInterceptor);
|
||||
assertEquals(3, chain.getInterceptors().length);
|
||||
assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor);
|
||||
assertTrue(chain.getInterceptors()[2] instanceof ThemeChangeInterceptor);
|
||||
}
|
||||
|
||||
@Controller
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<mvc:annotation-driven>
|
||||
<mvc:interceptors>
|
||||
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
|
||||
<bean class="org.springframework.web.servlet.i18n.ThemeChangeInterceptor" />
|
||||
<bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor" />
|
||||
</mvc:interceptors>
|
||||
</mvc:annotation-driven>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue