Allow MergedBeanDefinitionPostProcessor to handle bean creation

This commit registers the MergedBeanDefinitionPostProcessor instances
on the BeanFactory processed for AOT purposes. This allows beans that
are created at build-time to be post-processed for low-level needs such
as initialization and autowiring.

Closes gh-28777
This commit is contained in:
Stephane Nicoll
2022-07-20 11:55:00 +02:00
parent 9573fc96ec
commit ebe3b37298
3 changed files with 58 additions and 1 deletions

View File

@@ -364,7 +364,7 @@ final class PostProcessorRegistrationDelegate {
* Register the given BeanPostProcessor beans.
*/
private static void registerBeanPostProcessors(
ConfigurableListableBeanFactory beanFactory, List<BeanPostProcessor> postProcessors) {
ConfigurableListableBeanFactory beanFactory, List<? extends BeanPostProcessor> postProcessors) {
if (beanFactory instanceof AbstractBeanFactory) {
// Bulk addition is more efficient against our CopyOnWriteArrayList there
@@ -439,6 +439,7 @@ final class PostProcessorRegistrationDelegate {
Class<?> beanType = resolveBeanType(bd);
postProcessRootBeanDefinition(postProcessors, beanName, beanType, bd);
}
registerBeanPostProcessors(this.beanFactory, postProcessors);
}
private void postProcessRootBeanDefinition(List<MergedBeanDefinitionPostProcessor> postProcessors,