Browse Source

Introduce BeanFactoryInitializationCode#getClassName

See gh-35803
pull/35975/head
Sébastien Deleuze 2 weeks ago
parent
commit
69207c6c16
  1. 9
      spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationCode.java
  2. 2
      spring-context/src/main/java/org/springframework/context/aot/ApplicationContextAotGenerator.java
  3. 5
      spring-context/src/main/java/org/springframework/context/aot/ApplicationContextInitializationCodeGenerator.java

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

@ -18,6 +18,7 @@ package org.springframework.beans.factory.aot; @@ -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; @@ -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 { @@ -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:

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

@ -57,7 +57,7 @@ public class ApplicationContextAotGenerator { @@ -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();
});
}

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

@ -127,8 +127,9 @@ class ApplicationContextInitializationCodeGenerator implements BeanFactoryInitia @@ -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

Loading…
Cancel
Save