Introduce BeanFactoryInitializationCode#getClassName

See gh-35803
This commit is contained in:
Sébastien Deleuze
2025-12-05 17:04:51 +01:00
parent f61832ecb8
commit 69207c6c16
3 changed files with 13 additions and 3 deletions
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.aot;
import org.springframework.aot.generate.GeneratedMethods;
import org.springframework.aot.generate.MethodReference;
import org.springframework.javapoet.ClassName;
/**
* Interface that can be used to configure the code that will be generated to
@@ -25,6 +26,7 @@ import org.springframework.aot.generate.MethodReference;
*
* @author Phillip Webb
* @author Stephane Nicoll
* @author Sebastien Deleuze
* @since 6.0
* @see BeanFactoryInitializationAotContribution
*/
@@ -41,6 +43,13 @@ public interface BeanFactoryInitializationCode {
*/
GeneratedMethods getMethods();
/**
* Return the name of the class used by the initializing code.
* @return the generated class name
* @since 7.0.2
*/
ClassName getClassName();
/**
* Add an initializer method call. An initializer can use a flexible signature,
* using any of the following:
@@ -57,7 +57,7 @@ public class ApplicationContextAotGenerator {
new ApplicationContextInitializationCodeGenerator(applicationContext, generationContext);
DefaultListableBeanFactory beanFactory = applicationContext.getDefaultListableBeanFactory();
new BeanFactoryInitializationAotContributions(beanFactory).applyTo(generationContext, codeGenerator);
return codeGenerator.getGeneratedClass().getName();
return codeGenerator.getClassName();
});
}
@@ -127,8 +127,9 @@ class ApplicationContextInitializationCodeGenerator implements BeanFactoryInitia
return ArgumentCodeGenerator.from(new InitializerMethodArgumentCodeGenerator());
}
GeneratedClass getGeneratedClass() {
return this.generatedClass;
@Override
public ClassName getClassName() {
return this.generatedClass.getName();
}
@Override