Support for conditional registration of functional bean definitions [SPR-16959] #21497
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Dave Syer opened SPR-16959 and commented
There is a gap in the the functional bean registration features in
BeanDefinitionBuilder
andGenericApplicationContext
. Once you register aSupplier
you have committed to provide an instance of the class you register, whereas in a lot of use cases you don't know whether or not you want to provide it until the bean factory is available (e.g. conditional on another instance of the same class being available). I guess the change needs to be in theBeanDefinitionRegistry
interface, for example to support aPredicate<``ConditionContext``>
as well as theSupplier
. If the interface doesn't change, I suppose returningnull
from theSupplier
might be an option, but that seems a bit ugly, and might be too late, since theBeanDefinition
has already been registered at that point.Issue Links:
The text was updated successfully, but these errors were encountered: