Skip to content

Commit a04a4c6

Browse files
committed
Introduce BeanFactoryInitializationCode#getClassName
See spring-projectsgh-35803
1 parent 6143c7c commit a04a4c6

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationCode.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.springframework.aot.generate.GeneratedMethods;
2020
import org.springframework.aot.generate.MethodReference;
21+
import org.springframework.javapoet.ClassName;
2122

2223
/**
2324
* Interface that can be used to configure the code that will be generated to
@@ -41,6 +42,13 @@ public interface BeanFactoryInitializationCode {
4142
*/
4243
GeneratedMethods getMethods();
4344

45+
/**
46+
* Return the name of the class used by the initializing code.
47+
* @return the generated class name.
48+
* @since 7.0.2
49+
*/
50+
ClassName getClassName();
51+
4452
/**
4553
* Add an initializer method call. An initializer can use a flexible signature,
4654
* using any of the following:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public ClassName processAheadOfTime(GenericApplicationContext applicationContext
5757
new ApplicationContextInitializationCodeGenerator(applicationContext, generationContext);
5858
DefaultListableBeanFactory beanFactory = applicationContext.getDefaultListableBeanFactory();
5959
new BeanFactoryInitializationAotContributions(beanFactory).applyTo(generationContext, codeGenerator);
60-
return codeGenerator.getGeneratedClass().getName();
60+
return codeGenerator.getClassName();
6161
});
6262
}
6363

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ static ArgumentCodeGenerator createInitializerMethodArgumentCodeGenerator() {
127127
return ArgumentCodeGenerator.from(new InitializerMethodArgumentCodeGenerator());
128128
}
129129

130-
GeneratedClass getGeneratedClass() {
131-
return this.generatedClass;
130+
@Override
131+
public ClassName getClassName() {
132+
return this.generatedClass.getName();
132133
}
133134

134135
@Override

0 commit comments

Comments
 (0)