Skip to content

Commit 2cc4486

Browse files
committed
Rename ApplicationContextAotGenerator entry point
Closes gh-28927
1 parent 2475523 commit 2cc4486

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

spring-context/src/main/java/org/springframework/context/aot/ApplicationContextAotGenerator.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@
3636
public class ApplicationContextAotGenerator {
3737

3838
/**
39-
* Refresh the specified {@link GenericApplicationContext} and generate the
40-
* necessary code to restore the state of its {@link BeanFactory}, using the
41-
* specified {@link GenerationContext}.
42-
* @param applicationContext the application context to handle
39+
* Process the specified {@link GenericApplicationContext} instance
40+
* ahead-of-time using the specified {@link GenerationContext}.
41+
* <p>Return the {@link ClassName} of the {@link ApplicationContextInitializer}
42+
* to use to restore an optimized state of the application context.
43+
* @param applicationContext the non-refreshed application context to handle
4344
* @param generationContext the generation context to use
4445
* @return the class name of the {@link ApplicationContextInitializer} entry point
4546
*/
46-
public ClassName generateApplicationContext(GenericApplicationContext applicationContext,
47+
public ClassName processAheadOfTime(GenericApplicationContext applicationContext,
4748
GenerationContext generationContext) {
4849
applicationContext.refreshForAotProcessing();
4950
DefaultListableBeanFactory beanFactory = applicationContext.getDefaultListableBeanFactory();

spring-context/src/test/java/org/springframework/context/aot/ApplicationContextAotGeneratorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private void testCompiledResult(GenericApplicationContext applicationContext,
186186
BiConsumer<ApplicationContextInitializer<GenericApplicationContext>, Compiled> result) {
187187
ApplicationContextAotGenerator generator = new ApplicationContextAotGenerator();
188188
TestGenerationContext generationContext = new TestGenerationContext();
189-
generator.generateApplicationContext(applicationContext, generationContext);
189+
generator.processAheadOfTime(applicationContext, generationContext);
190190
generationContext.writeGeneratedContent();
191191
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile(compiled ->
192192
result.accept(compiled.getInstance(ApplicationContextInitializer.class), compiled));

spring-context/src/test/java/org/springframework/context/aot/RuntimeHintsBeanFactoryInitializationAotProcessorTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void setup() {
6363
void shouldProcessRegistrarOnConfiguration() {
6464
GenericApplicationContext applicationContext = createApplicationContext(
6565
ConfigurationWithHints.class);
66-
this.generator.generateApplicationContext(applicationContext,
66+
this.generator.processAheadOfTime(applicationContext,
6767
this.generationContext);
6868
assertThatSampleRegistrarContributed();
6969
}
@@ -72,7 +72,7 @@ void shouldProcessRegistrarOnConfiguration() {
7272
void shouldProcessRegistrarOnBeanMethod() {
7373
GenericApplicationContext applicationContext = createApplicationContext(
7474
ConfigurationWithBeanDeclaringHints.class);
75-
this.generator.generateApplicationContext(applicationContext,
75+
this.generator.processAheadOfTime(applicationContext,
7676
this.generationContext);
7777
assertThatSampleRegistrarContributed();
7878
}
@@ -82,7 +82,7 @@ void shouldProcessRegistrarInSpringFactory() {
8282
GenericApplicationContext applicationContext = createApplicationContext();
8383
applicationContext.setClassLoader(
8484
new TestSpringFactoriesClassLoader("test-runtime-hints-aot.factories"));
85-
this.generator.generateApplicationContext(applicationContext,
85+
this.generator.processAheadOfTime(applicationContext,
8686
this.generationContext);
8787
assertThatSampleRegistrarContributed();
8888
}
@@ -97,7 +97,7 @@ void shouldProcessDuplicatedRegistrarsOnlyOnce() {
9797
applicationContext.setClassLoader(
9898
new TestSpringFactoriesClassLoader("test-duplicated-runtime-hints-aot.factories"));
9999
IncrementalRuntimeHintsRegistrar.counter.set(0);
100-
this.generator.generateApplicationContext(applicationContext,
100+
this.generator.processAheadOfTime(applicationContext,
101101
this.generationContext);
102102
RuntimeHints runtimeHints = this.generationContext.getRuntimeHints();
103103
assertThat(runtimeHints.resources().resourceBundles().map(ResourceBundleHint::getBaseName))
@@ -109,7 +109,7 @@ void shouldProcessDuplicatedRegistrarsOnlyOnce() {
109109
void shouldRejectRuntimeHintsRegistrarWithoutDefaultConstructor() {
110110
GenericApplicationContext applicationContext = createApplicationContext(
111111
ConfigurationWithIllegalRegistrar.class);
112-
assertThatThrownBy(() -> this.generator.generateApplicationContext(
112+
assertThatThrownBy(() -> this.generator.processAheadOfTime(
113113
applicationContext, this.generationContext))
114114
.isInstanceOf(BeanInstantiationException.class);
115115
}

spring-context/src/test/java/org/springframework/context/generator/ApplicationContextAotGeneratorRuntimeHintsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
109109
private void compile(GenericApplicationContext applicationContext, BiConsumer<RuntimeHints, RuntimeHintsInvocations> initializationResult) {
110110
ApplicationContextAotGenerator generator = new ApplicationContextAotGenerator();
111111
TestGenerationContext generationContext = new TestGenerationContext();
112-
generator.generateApplicationContext(applicationContext, generationContext);
112+
generator.processAheadOfTime(applicationContext, generationContext);
113113
generationContext.writeGeneratedContent();
114114
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile(compiled -> {
115115
ApplicationContextInitializer instance = compiled.getInstance(ApplicationContextInitializer.class);

0 commit comments

Comments
 (0)