Skip to content

Commit 69207c6

Browse files
committed
Introduce BeanFactoryInitializationCode#getClassName
See gh-35803
1 parent f61832e commit 69207c6

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
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
2425
* perform bean factory initialization.
2526
*
2627
* @author Phillip Webb
2728
* @author Stephane Nicoll
29+
* @author Sebastien Deleuze
2830
* @since 6.0
2931
* @see BeanFactoryInitializationAotContribution
3032
*/
@@ -41,6 +43,13 @@ public interface BeanFactoryInitializationCode {
4143
*/
4244
GeneratedMethods getMethods();
4345

46+
/**
47+
* Return the name of the class used by the initializing code.
48+
* @return the generated class name
49+
* @since 7.0.2
50+
*/
51+
ClassName getClassName();
52+
4453
/**
4554
* Add an initializer method call. An initializer can use a flexible signature,
4655
* 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)