Use AbstractAotProcessor.AOT_PROCESSING instead of duplicate constant
Closes gh-42461
This commit is contained in:
parent
5806915155
commit
b7979cf443
@ -36,6 +36,7 @@ import org.springframework.boot.docker.compose.lifecycle.DockerComposeProperties
|
|||||||
import org.springframework.boot.docker.compose.lifecycle.DockerComposeProperties.Stop;
|
import org.springframework.boot.docker.compose.lifecycle.DockerComposeProperties.Stop;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.context.aot.AbstractAotProcessor;
|
||||||
import org.springframework.context.event.SimpleApplicationEventMulticaster;
|
import org.springframework.context.event.SimpleApplicationEventMulticaster;
|
||||||
import org.springframework.core.log.LogMessage;
|
import org.springframework.core.log.LogMessage;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
@ -95,7 +96,7 @@ class DockerComposeLifecycleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
if (Boolean.getBoolean("spring.aot.processing") || AotDetector.useGeneratedArtifacts()) {
|
if (Boolean.getBoolean(AbstractAotProcessor.AOT_PROCESSING) || AotDetector.useGeneratedArtifacts()) {
|
||||||
logger.trace("Docker Compose support disabled with AOT and native images");
|
logger.trace("Docker Compose support disabled with AOT and native images");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ import org.springframework.boot.test.system.CapturedOutput;
|
|||||||
import org.springframework.boot.test.system.OutputCaptureExtension;
|
import org.springframework.boot.test.system.OutputCaptureExtension;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.context.aot.AbstractAotProcessor;
|
||||||
import org.springframework.context.support.GenericApplicationContext;
|
import org.springframework.context.support.GenericApplicationContext;
|
||||||
import org.springframework.util.FileCopyUtils;
|
import org.springframework.util.FileCopyUtils;
|
||||||
|
|
||||||
@ -126,7 +127,7 @@ class DockerComposeLifecycleManagerTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void startWhenAotProcessingDoesNotStart() {
|
void startWhenAotProcessingDoesNotStart() {
|
||||||
withSystemProperty("spring.aot.processing", "true", () -> {
|
withSystemProperty(AbstractAotProcessor.AOT_PROCESSING, "true", () -> {
|
||||||
EventCapturingListener listener = new EventCapturingListener();
|
EventCapturingListener listener = new EventCapturingListener();
|
||||||
this.eventListeners.add(listener);
|
this.eventListeners.add(listener);
|
||||||
setUpRunningServices();
|
setUpRunningServices();
|
||||||
|
@ -40,6 +40,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
|
|||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
|
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.context.aot.AbstractAotProcessor;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.core.log.LogMessage;
|
import org.springframework.core.log.LogMessage;
|
||||||
@ -103,7 +104,7 @@ class TestcontainersLifecycleBeanPostProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAotProcessingInProgress() {
|
private boolean isAotProcessingInProgress() {
|
||||||
return Boolean.getBoolean("spring.aot.processing");
|
return Boolean.getBoolean(AbstractAotProcessor.AOT_PROCESSING);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeStartables(Startable startableBean, String startableBeanName) {
|
private void initializeStartables(Startable startableBean, String startableBeanName) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -24,6 +24,7 @@ import java.util.List;
|
|||||||
import org.testcontainers.containers.Container;
|
import org.testcontainers.containers.Container;
|
||||||
|
|
||||||
import org.springframework.boot.origin.Origin;
|
import org.springframework.boot.origin.Origin;
|
||||||
|
import org.springframework.context.aot.AbstractAotProcessor;
|
||||||
import org.springframework.core.annotation.MergedAnnotation;
|
import org.springframework.core.annotation.MergedAnnotation;
|
||||||
import org.springframework.core.annotation.MergedAnnotations;
|
import org.springframework.core.annotation.MergedAnnotations;
|
||||||
import org.springframework.test.context.ContextConfigurationAttributes;
|
import org.springframework.test.context.ContextConfigurationAttributes;
|
||||||
@ -96,7 +97,7 @@ class ServiceConnectionContextCustomizerFactory implements ContextCustomizerFact
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAotProcessingInProgress() {
|
private boolean isAotProcessingInProgress() {
|
||||||
return Boolean.getBoolean("spring.aot.processing");
|
return Boolean.getBoolean(AbstractAotProcessor.AOT_PROCESSING);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import org.springframework.beans.factory.support.AbstractBeanFactory;
|
|||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.aot.AbstractAotProcessor;
|
||||||
import org.springframework.core.env.MapPropertySource;
|
import org.springframework.core.env.MapPropertySource;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -149,7 +150,7 @@ class TestcontainersLifecycleApplicationContextInitializerTests {
|
|||||||
GenericContainer<?> container = mock(GenericContainer.class);
|
GenericContainer<?> container = mock(GenericContainer.class);
|
||||||
AnnotationConfigApplicationContext applicationContext = createApplicationContext(container);
|
AnnotationConfigApplicationContext applicationContext = createApplicationContext(container);
|
||||||
then(container).shouldHaveNoInteractions();
|
then(container).shouldHaveNoInteractions();
|
||||||
withSystemProperty("spring.aot.processing", "true",
|
withSystemProperty(AbstractAotProcessor.AOT_PROCESSING, "true",
|
||||||
() -> applicationContext.refreshForAotProcessing(new RuntimeHints()));
|
() -> applicationContext.refreshForAotProcessing(new RuntimeHints()));
|
||||||
then(container).shouldHaveNoInteractions();
|
then(container).shouldHaveNoInteractions();
|
||||||
applicationContext.close();
|
applicationContext.close();
|
||||||
|
@ -60,6 +60,7 @@ import org.springframework.aot.hint.TypeReference;
|
|||||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution;
|
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution;
|
||||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationCode;
|
import org.springframework.beans.factory.aot.BeanFactoryInitializationCode;
|
||||||
import org.springframework.boot.logging.LoggingInitializationContext;
|
import org.springframework.boot.logging.LoggingInitializationContext;
|
||||||
|
import org.springframework.context.aot.AbstractAotProcessor;
|
||||||
import org.springframework.core.CollectionFactory;
|
import org.springframework.core.CollectionFactory;
|
||||||
import org.springframework.core.NativeDetector;
|
import org.springframework.core.NativeDetector;
|
||||||
import org.springframework.core.io.ByteArrayResource;
|
import org.springframework.core.io.ByteArrayResource;
|
||||||
@ -140,7 +141,7 @@ class SpringBootJoranConfigurator extends JoranConfigurator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAotProcessingInProgress() {
|
private boolean isAotProcessingInProgress() {
|
||||||
return Boolean.getBoolean("spring.aot.processing");
|
return Boolean.getBoolean(AbstractAotProcessor.AOT_PROCESSING);
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class LogbackConfigurationAotContribution implements BeanFactoryInitializationAotContribution {
|
static final class LogbackConfigurationAotContribution implements BeanFactoryInitializationAotContribution {
|
||||||
|
@ -59,6 +59,7 @@ import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
|||||||
import org.springframework.aot.test.generate.TestGenerationContext;
|
import org.springframework.aot.test.generate.TestGenerationContext;
|
||||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution;
|
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution;
|
||||||
import org.springframework.boot.logging.logback.SpringBootJoranConfigurator.LogbackConfigurationAotContribution;
|
import org.springframework.boot.logging.logback.SpringBootJoranConfigurator.LogbackConfigurationAotContribution;
|
||||||
|
import org.springframework.context.aot.AbstractAotProcessor;
|
||||||
import org.springframework.core.io.InputStreamSource;
|
import org.springframework.core.io.InputStreamSource;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -287,7 +288,7 @@ class LogbackConfigurationAotContributionTests {
|
|||||||
contextCustomizer.accept(context);
|
contextCustomizer.accept(context);
|
||||||
SpringBootJoranConfigurator configurator = new SpringBootJoranConfigurator(null);
|
SpringBootJoranConfigurator configurator = new SpringBootJoranConfigurator(null);
|
||||||
configurator.setContext(context);
|
configurator.setContext(context);
|
||||||
withSystemProperty("spring.aot.processing", "true", () -> configurator.processModel(model));
|
withSystemProperty(AbstractAotProcessor.AOT_PROCESSING, "true", () -> configurator.processModel(model));
|
||||||
LogbackConfigurationAotContribution contribution = (LogbackConfigurationAotContribution) context
|
LogbackConfigurationAotContribution contribution = (LogbackConfigurationAotContribution) context
|
||||||
.getObject(BeanFactoryInitializationAotContribution.class.getName());
|
.getObject(BeanFactoryInitializationAotContribution.class.getName());
|
||||||
contribution.applyTo(generationContext, null);
|
contribution.applyTo(generationContext, null);
|
||||||
|
@ -32,6 +32,7 @@ import org.springframework.boot.context.properties.source.ConfigurationPropertyS
|
|||||||
import org.springframework.boot.logging.LoggingInitializationContext;
|
import org.springframework.boot.logging.LoggingInitializationContext;
|
||||||
import org.springframework.boot.testsupport.system.CapturedOutput;
|
import org.springframework.boot.testsupport.system.CapturedOutput;
|
||||||
import org.springframework.boot.testsupport.system.OutputCaptureExtension;
|
import org.springframework.boot.testsupport.system.OutputCaptureExtension;
|
||||||
|
import org.springframework.context.aot.AbstractAotProcessor;
|
||||||
import org.springframework.mock.env.MockEnvironment;
|
import org.springframework.mock.env.MockEnvironment;
|
||||||
import org.springframework.test.context.support.TestPropertySourceUtils;
|
import org.springframework.test.context.support.TestPropertySourceUtils;
|
||||||
|
|
||||||
@ -221,7 +222,7 @@ class SpringBootJoranConfiguratorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void addsAotContributionToContextDuringAotProcessing() throws Exception {
|
void addsAotContributionToContextDuringAotProcessing() throws Exception {
|
||||||
withSystemProperty("spring.aot.processing", "true", () -> {
|
withSystemProperty(AbstractAotProcessor.AOT_PROCESSING, "true", () -> {
|
||||||
initialize("property.xml");
|
initialize("property.xml");
|
||||||
Object contribution = this.context.getObject(BeanFactoryInitializationAotContribution.class.getName());
|
Object contribution = this.context.getObject(BeanFactoryInitializationAotContribution.class.getName());
|
||||||
assertThat(contribution).isNotNull();
|
assertThat(contribution).isNotNull();
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<subpackage name="logging">
|
<subpackage name="logging">
|
||||||
<allow pkg="org.springframework.boot.context.properties.bind" />
|
<allow pkg="org.springframework.boot.context.properties.bind" />
|
||||||
|
<allow pkg="org.springframework.context.aot" />
|
||||||
<disallow pkg="org.springframework.context" />
|
<disallow pkg="org.springframework.context" />
|
||||||
<disallow pkg="org.springframework.boot.context" />
|
<disallow pkg="org.springframework.boot.context" />
|
||||||
</subpackage>
|
</subpackage>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user