mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Remove spring.xml.ignore flag usages
This commit is a follow-up of spring-projects/spring-framework#29277. See gh-32653
This commit is contained in:
parent
8013c5f182
commit
5b17cacb1f
@ -34,7 +34,6 @@ import org.springframework.beans.factory.support.BeanNameGenerator;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
|
||||
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
|
||||
import org.springframework.core.SpringProperties;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
@ -61,9 +60,6 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
class BeanDefinitionLoader {
|
||||
|
||||
// Static final field to facilitate code removal by Graal
|
||||
private static final boolean XML_ENABLED = !SpringProperties.getFlag("spring.xml.ignore");
|
||||
|
||||
private static final Pattern GROOVY_CLOSURE_PATTERN = Pattern.compile(".*\\$_.*closure.*");
|
||||
|
||||
private final Object[] sources;
|
||||
@ -89,7 +85,7 @@ class BeanDefinitionLoader {
|
||||
Assert.notEmpty(sources, "Sources must not be empty");
|
||||
this.sources = sources;
|
||||
this.annotatedReader = new AnnotatedBeanDefinitionReader(registry);
|
||||
this.xmlReader = (XML_ENABLED ? new XmlBeanDefinitionReader(registry) : null);
|
||||
this.xmlReader = new XmlBeanDefinitionReader(registry);
|
||||
this.groovyReader = (isGroovyPresent() ? new GroovyBeanDefinitionReader(registry) : null);
|
||||
this.scanner = new ClassPathBeanDefinitionScanner(registry);
|
||||
this.scanner.addExcludeFilter(new ClassExcludeFilter(sources));
|
||||
|
@ -52,7 +52,6 @@ import org.springframework.boot.logging.LoggingSystem;
|
||||
import org.springframework.boot.logging.LoggingSystemFactory;
|
||||
import org.springframework.boot.logging.LoggingSystemProperties;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.SpringProperties;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
@ -74,9 +73,6 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem {
|
||||
|
||||
private static final String BRIDGE_HANDLER = "org.slf4j.bridge.SLF4JBridgeHandler";
|
||||
|
||||
// Static final field to facilitate code removal by Graal
|
||||
private static final boolean XML_ENABLED = !SpringProperties.getFlag("spring.xml.ignore");
|
||||
|
||||
private static final String CONFIGURATION_FILE_PROPERTY = "logback.configurationFile";
|
||||
|
||||
private static final LogLevels<Level> LEVELS = new LogLevels<>();
|
||||
@ -237,7 +233,7 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem {
|
||||
|
||||
private void configureByResourceUrl(LoggingInitializationContext initializationContext, LoggerContext loggerContext,
|
||||
URL url) throws JoranException {
|
||||
if (XML_ENABLED && url.toString().endsWith("xml")) {
|
||||
if (url.toString().endsWith("xml")) {
|
||||
JoranConfigurator configurator = new SpringBootJoranConfigurator(initializationContext);
|
||||
configurator.setContext(loggerContext);
|
||||
configurator.doConfigure(url);
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.boot.testsupport.classpath.ForkedClassPath;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
@ForkedClassPath
|
||||
class IgnoringXmlBeanDefinitionLoaderTests {
|
||||
|
||||
@BeforeAll
|
||||
static void ignoreXml() {
|
||||
System.setProperty("spring.xml.ignore", "true");
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void enableXml() {
|
||||
System.clearProperty("spring.xml.ignore");
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenXmlSupportIsDisabledXmlSourcesAreRejected() {
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
||||
.isThrownBy(() -> new BeanDefinitionLoader(new StaticApplicationContext(),
|
||||
"classpath:org/springframework/boot/sample-beans.xml").load())
|
||||
.withMessage("Cannot load XML bean definitions when XML support is disabled");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user