Dave Syer opened SPR-16959 and commented
There is a gap in the the functional bean registration features in BeanDefinitionBuilder and GenericApplicationContext. Once you register a Supplier 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 the BeanDefinitionRegistry interface, for example to support a Predicate<ConditionContext> as well as the Supplier. If the interface doesn't change, I suppose returning null from the Supplier might be an option, but that seems a bit ugly, and might be too late, since the BeanDefinition has already been registered at that point.
Issue Links:
Dave Syer opened SPR-16959 and commented
There is a gap in the the functional bean registration features in
BeanDefinitionBuilderandGenericApplicationContext. Once you register aSupplieryou 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 theBeanDefinitionRegistryinterface, for example to support aPredicate<ConditionContext>as well as theSupplier. If the interface doesn't change, I suppose returningnullfrom theSuppliermight be an option, but that seems a bit ugly, and might be too late, since theBeanDefinitionhas already been registered at that point.Issue Links: