diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationCode.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationCode.java index c9048d6e174..de5a608362f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationCode.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationCode.java @@ -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: diff --git a/spring-context/src/main/java/org/springframework/context/aot/ApplicationContextAotGenerator.java b/spring-context/src/main/java/org/springframework/context/aot/ApplicationContextAotGenerator.java index 1d57be971b9..8ba857cff97 100644 --- a/spring-context/src/main/java/org/springframework/context/aot/ApplicationContextAotGenerator.java +++ b/spring-context/src/main/java/org/springframework/context/aot/ApplicationContextAotGenerator.java @@ -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(); }); } diff --git a/spring-context/src/main/java/org/springframework/context/aot/ApplicationContextInitializationCodeGenerator.java b/spring-context/src/main/java/org/springframework/context/aot/ApplicationContextInitializationCodeGenerator.java index 8c17f4a3210..7cbd5a4157c 100644 --- a/spring-context/src/main/java/org/springframework/context/aot/ApplicationContextInitializationCodeGenerator.java +++ b/spring-context/src/main/java/org/springframework/context/aot/ApplicationContextInitializationCodeGenerator.java @@ -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