diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationAotProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationAotProcessor.java index c1037d51af..cfa48d8fc5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationAotProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanFactoryInitializationAotProcessor.java @@ -24,15 +24,19 @@ import org.springframework.lang.Nullable; * AOT processor that makes bean factory initialization contributions by * processing {@link ConfigurableListableBeanFactory} instances. * - *

{@link BeanFactoryInitializationAotProcessor} implementations may be + *

{@code BeanFactoryInitializationAotProcessor} implementations may be * registered in a {@value AotServices#FACTORIES_RESOURCE_LOCATION} resource or * as a bean. * - *

Note: Using this interface on a registered bean will cause the bean - * and all of its dependencies to be initialized during AOT processing. - * We generally recommend that this interface is only used with infrastructure - * beans such as {@link BeanFactoryPostProcessor} which have limited dependencies - * and are already initialized early in the bean factory lifecycle. + *

Using this interface on a registered bean will cause the bean and + * all of its dependencies to be initialized during AOT processing. We generally + * recommend that this interface is only used with infrastructure beans such as + * {@link BeanFactoryPostProcessor} which have limited dependencies and are + * already initialized early in the bean factory lifecycle. If such a bean is + * registered using a factory method, make sure to make it {@code static} so + * that its enclosing class does not have to be initialized. + * + *

A component that implements this interface is not contributed. * * @author Phillip Webb * @author Stephane Nicoll diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationAotProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationAotProcessor.java index 7873199a26..5e2c171696 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationAotProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationAotProcessor.java @@ -22,21 +22,24 @@ import org.springframework.lang.Nullable; /** * AOT processor that makes bean registration contributions by processing - * {@link RegisteredBean} instances. An AOT processor replaces its usual - * runtime behavior by an optimized arrangement, usually in generated - * code. For that reason, a component that implements this interface is - * not contributed by default. If a component that implements this - * interface still needs to be invoked at runtime, - * {@link #isBeanExcludedFromAotProcessing} can be overridden. + * {@link RegisteredBean} instances. * - *

{@link BeanRegistrationAotProcessor} implementations may be registered in + *

{@code BeanRegistrationAotProcessor} implementations may be registered in * a {@value AotServices#FACTORIES_RESOURCE_LOCATION} resource or as a bean. * - *

Note: Using this interface on a registered bean will cause the bean - * and all of its dependencies to be initialized during AOT processing. - * We generally recommend that interface is only used with infrastructure beans - * such as {@link BeanPostProcessor} which have limited dependencies and are - * already initialized early in the bean factory lifecycle. + *

Using this interface on a registered bean will cause the bean and + * all of its dependencies to be initialized during AOT processing. We generally + * recommend that this interface is only used with infrastructure beans such as + * {@link BeanPostProcessor} which have limited dependencies and are already + * initialized early in the bean factory lifecycle. If such a bean is registered + * using a factory method, make sure to make it {@code static} so that its + * enclosing class does not have to be initialized. + * + *

An AOT processor replaces its usual runtime behavior by an optimized + * arrangement, usually in generated code. For that reason, a component that + * implements this interface is not contributed by default. If a component that + * implements this interface still needs to be invoked at runtime, + * {@link #isBeanExcludedFromAotProcessing} can be overridden. * * @author Phillip Webb * @author Stephane Nicoll