Allow chained BeanRegistry registration
Add a `register(BeanRegistry registry)` method to `BeanRegistry` to allow registration chaining. See gh-34557
This commit is contained in:
committed by
Sébastien Deleuze
parent
a0e2d3a221
commit
789791e186
@@ -409,7 +409,7 @@ class ConfigurationClassBeanDefinitionReader {
|
||||
"Cannot support bean registrars since " + this.registry.getClass().getName() +
|
||||
" does not implement BeanDefinitionRegistry");
|
||||
registrars.forEach(registrar -> registrar.register(new BeanRegistryAdapter(this.registry,
|
||||
(ListableBeanFactory) this.registry, registrar.getClass()), this.environment));
|
||||
(ListableBeanFactory) this.registry, this.environment, registrar.getClass()), this.environment));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -936,10 +936,10 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||
private CodeBlock generateRegisterCode() {
|
||||
Builder code = CodeBlock.builder();
|
||||
for (BeanRegistrar beanRegistrar : this.beanRegistrars) {
|
||||
code.addStatement("new $T().register(new $T(($T)$L, $L, $T.class, $L), $L)", beanRegistrar.getClass(),
|
||||
code.addStatement("new $T().register(new $T(($T)$L, $L, $L, $T.class, $L), $L)", beanRegistrar.getClass(),
|
||||
BeanRegistryAdapter.class, BeanDefinitionRegistry.class, BeanFactoryInitializationCode.BEAN_FACTORY_VARIABLE,
|
||||
BeanFactoryInitializationCode.BEAN_FACTORY_VARIABLE, beanRegistrar.getClass(), CUSTOMIZER_MAP_VARIABLE,
|
||||
ENVIRONMENT_VARIABLE);
|
||||
BeanFactoryInitializationCode.BEAN_FACTORY_VARIABLE, ENVIRONMENT_VARIABLE, beanRegistrar.getClass(),
|
||||
CUSTOMIZER_MAP_VARIABLE, ENVIRONMENT_VARIABLE);
|
||||
}
|
||||
return code.build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user