Description
Presently there is no equivalent to @Order
when using functional bean registration to allow ordering of beans outside of the bean implementation (where @Order
, Ordered, PriorityOrdered etc can be used):
// no attribute for order, no access to BeanDefinition, and BeanDefinition doesn't have an order attribute
bean<SomeBean>(name = "abc", ...)
@Bean
@Order(33) // bean ordering set separately from bean implementation
fun someBean() = SomeBean()
@Order
works at sort time (provider.orderedStream()
or injecting a List<> of beans) by introspecting the factory method looking for @Order
via an implementation of OrderComparator.OrderSourceProvider
that uses beanDefinition.getResolvedFactoryMethod()
(org.springframework.beans.factory.support.DefaultListableBeanFactory.FactoryAwareOrderSourceProvider).
It would be useful to have order
as an optional first-class property on BeanDefinition
which would allow the functional bean registration API to (optionally) provide an order and furthermore allow @Order
processing to be collapsed to the same mechanism, while also providing future capabilities for any bean registration capability to support bean ordering.
Without this capability there is no mechanism for functional bean registration to provide bean ordering external to the bean implementation, as is possible with @Order
.