Rename ApplicationContextAotGenerator entry point
Closes gh-28927
This commit is contained in:
parent
2475523e19
commit
2cc4486e3d
|
@ -36,14 +36,15 @@ import org.springframework.javapoet.ClassName;
|
|||
public class ApplicationContextAotGenerator {
|
||||
|
||||
/**
|
||||
* Refresh the specified {@link GenericApplicationContext} and generate the
|
||||
* necessary code to restore the state of its {@link BeanFactory}, using the
|
||||
* specified {@link GenerationContext}.
|
||||
* @param applicationContext the application context to handle
|
||||
* Process the specified {@link GenericApplicationContext} instance
|
||||
* ahead-of-time using the specified {@link GenerationContext}.
|
||||
* <p>Return the {@link ClassName} of the {@link ApplicationContextInitializer}
|
||||
* to use to restore an optimized state of the application context.
|
||||
* @param applicationContext the non-refreshed application context to handle
|
||||
* @param generationContext the generation context to use
|
||||
* @return the class name of the {@link ApplicationContextInitializer} entry point
|
||||
*/
|
||||
public ClassName generateApplicationContext(GenericApplicationContext applicationContext,
|
||||
public ClassName processAheadOfTime(GenericApplicationContext applicationContext,
|
||||
GenerationContext generationContext) {
|
||||
applicationContext.refreshForAotProcessing();
|
||||
DefaultListableBeanFactory beanFactory = applicationContext.getDefaultListableBeanFactory();
|
||||
|
|
|
@ -186,7 +186,7 @@ class ApplicationContextAotGeneratorTests {
|
|||
BiConsumer<ApplicationContextInitializer<GenericApplicationContext>, Compiled> result) {
|
||||
ApplicationContextAotGenerator generator = new ApplicationContextAotGenerator();
|
||||
TestGenerationContext generationContext = new TestGenerationContext();
|
||||
generator.generateApplicationContext(applicationContext, generationContext);
|
||||
generator.processAheadOfTime(applicationContext, generationContext);
|
||||
generationContext.writeGeneratedContent();
|
||||
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile(compiled ->
|
||||
result.accept(compiled.getInstance(ApplicationContextInitializer.class), compiled));
|
||||
|
|
|
@ -63,7 +63,7 @@ class RuntimeHintsBeanFactoryInitializationAotProcessorTests {
|
|||
void shouldProcessRegistrarOnConfiguration() {
|
||||
GenericApplicationContext applicationContext = createApplicationContext(
|
||||
ConfigurationWithHints.class);
|
||||
this.generator.generateApplicationContext(applicationContext,
|
||||
this.generator.processAheadOfTime(applicationContext,
|
||||
this.generationContext);
|
||||
assertThatSampleRegistrarContributed();
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class RuntimeHintsBeanFactoryInitializationAotProcessorTests {
|
|||
void shouldProcessRegistrarOnBeanMethod() {
|
||||
GenericApplicationContext applicationContext = createApplicationContext(
|
||||
ConfigurationWithBeanDeclaringHints.class);
|
||||
this.generator.generateApplicationContext(applicationContext,
|
||||
this.generator.processAheadOfTime(applicationContext,
|
||||
this.generationContext);
|
||||
assertThatSampleRegistrarContributed();
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ class RuntimeHintsBeanFactoryInitializationAotProcessorTests {
|
|||
GenericApplicationContext applicationContext = createApplicationContext();
|
||||
applicationContext.setClassLoader(
|
||||
new TestSpringFactoriesClassLoader("test-runtime-hints-aot.factories"));
|
||||
this.generator.generateApplicationContext(applicationContext,
|
||||
this.generator.processAheadOfTime(applicationContext,
|
||||
this.generationContext);
|
||||
assertThatSampleRegistrarContributed();
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class RuntimeHintsBeanFactoryInitializationAotProcessorTests {
|
|||
applicationContext.setClassLoader(
|
||||
new TestSpringFactoriesClassLoader("test-duplicated-runtime-hints-aot.factories"));
|
||||
IncrementalRuntimeHintsRegistrar.counter.set(0);
|
||||
this.generator.generateApplicationContext(applicationContext,
|
||||
this.generator.processAheadOfTime(applicationContext,
|
||||
this.generationContext);
|
||||
RuntimeHints runtimeHints = this.generationContext.getRuntimeHints();
|
||||
assertThat(runtimeHints.resources().resourceBundles().map(ResourceBundleHint::getBaseName))
|
||||
|
@ -109,7 +109,7 @@ class RuntimeHintsBeanFactoryInitializationAotProcessorTests {
|
|||
void shouldRejectRuntimeHintsRegistrarWithoutDefaultConstructor() {
|
||||
GenericApplicationContext applicationContext = createApplicationContext(
|
||||
ConfigurationWithIllegalRegistrar.class);
|
||||
assertThatThrownBy(() -> this.generator.generateApplicationContext(
|
||||
assertThatThrownBy(() -> this.generator.processAheadOfTime(
|
||||
applicationContext, this.generationContext))
|
||||
.isInstanceOf(BeanInstantiationException.class);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ class ApplicationContextAotGeneratorRuntimeHintsTests {
|
|||
private void compile(GenericApplicationContext applicationContext, BiConsumer<RuntimeHints, RuntimeHintsInvocations> initializationResult) {
|
||||
ApplicationContextAotGenerator generator = new ApplicationContextAotGenerator();
|
||||
TestGenerationContext generationContext = new TestGenerationContext();
|
||||
generator.generateApplicationContext(applicationContext, generationContext);
|
||||
generator.processAheadOfTime(applicationContext, generationContext);
|
||||
generationContext.writeGeneratedContent();
|
||||
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile(compiled -> {
|
||||
ApplicationContextInitializer instance = compiled.getInstance(ApplicationContextInitializer.class);
|
||||
|
|
Loading…
Reference in New Issue