Leverage spring.ignore.xml flag to avoid XmlBeanDefinitionReader
Closes gh-25338
This commit is contained in:
parent
06b364fefe
commit
02b539c5f5
|
@ -44,6 +44,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||||
import org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase;
|
import org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase;
|
||||||
|
import org.springframework.core.SpringProperties;
|
||||||
import org.springframework.core.annotation.AnnotationAttributes;
|
import org.springframework.core.annotation.AnnotationAttributes;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
@ -68,6 +69,7 @@ import org.springframework.util.StringUtils;
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
|
* @author Sebastien Deleuze
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
* @see ConfigurationClassParser
|
* @see ConfigurationClassParser
|
||||||
*/
|
*/
|
||||||
|
@ -77,6 +79,14 @@ class ConfigurationClassBeanDefinitionReader {
|
||||||
|
|
||||||
private static final ScopeMetadataResolver scopeMetadataResolver = new AnnotationScopeMetadataResolver();
|
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.
|
||||||
|
* <p>The default is "false".
|
||||||
|
*/
|
||||||
|
private static final boolean shouldIgnoreXml = SpringProperties.getFlag("spring.xml.ignore");
|
||||||
|
|
||||||
|
|
||||||
private final BeanDefinitionRegistry registry;
|
private final BeanDefinitionRegistry registry;
|
||||||
|
|
||||||
private final SourceExtractor sourceExtractor;
|
private final SourceExtractor sourceExtractor;
|
||||||
|
@ -349,6 +359,9 @@ class ConfigurationClassBeanDefinitionReader {
|
||||||
// When clearly asking for Groovy, that's what they'll get...
|
// When clearly asking for Groovy, that's what they'll get...
|
||||||
readerClass = GroovyBeanDefinitionReader.class;
|
readerClass = GroovyBeanDefinitionReader.class;
|
||||||
}
|
}
|
||||||
|
else if (shouldIgnoreXml) {
|
||||||
|
throw new UnsupportedOperationException("XML support disabled");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// Primarily ".xml" files but for any other extension as well
|
// Primarily ".xml" files but for any other extension as well
|
||||||
readerClass = XmlBeanDefinitionReader.class;
|
readerClass = XmlBeanDefinitionReader.class;
|
||||||
|
|
Loading…
Reference in New Issue