diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java index 5f884f6fb5..1b3e6a9015 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java @@ -44,6 +44,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase; +import org.springframework.core.SpringProperties; import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.env.Environment; import org.springframework.core.io.Resource; @@ -68,6 +69,7 @@ import org.springframework.util.StringUtils; * @author Juergen Hoeller * @author Phillip Webb * @author Sam Brannen + * @author Sebastien Deleuze * @since 3.0 * @see ConfigurationClassParser */ @@ -77,6 +79,14 @@ class ConfigurationClassBeanDefinitionReader { private static final ScopeMetadataResolver scopeMetadataResolver = new AnnotationScopeMetadataResolver(); + /** + * Boolean flag controlled by a {@code spring.xml.ignore} system property that instructs Spring to + * ignore XML, i.e. to not initialize the XML-related infrastructure. + *

The default is "false". + */ + private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore"); + + private final BeanDefinitionRegistry registry; private final SourceExtractor sourceExtractor; @@ -349,6 +359,9 @@ class ConfigurationClassBeanDefinitionReader { // When clearly asking for Groovy, that's what they'll get... readerClass = GroovyBeanDefinitionReader.class; } + else if (shouldIgnoreXml) { + throw new UnsupportedOperationException("XML support disabled"); + } else { // Primarily ".xml" files but for any other extension as well readerClass = XmlBeanDefinitionReader.class;