Open
Description
Hello,
in Boot we have the use-case to get the order of a bean. We have the bean instance, and also the bean name.
We tried:
return new AnnotationAwareOrderComparator() {
@Override
public int getOrder(Object obj) {
return super.getOrder(obj);
}
}.getOrder(bean);
but this only looks at the bean itself, not the factory method.
Combined with this:
Order orderAnnotation = beanFactory.findAnnotationOnBean(beanName, Order.class);
if (orderAnnotation != null) {
return orderAnnotation.value();
}
it also supports @Order
on the bean method, but it's missing @Priority
(is that supported on bean methods?) and, looking at org.springframework.beans.factory.support.DefaultListableBeanFactory.FactoryAwareOrderSourceProvider
there's also a ORDER
attribute on the bean definition.
There's also org.springframework.core.annotation.OrderUtils
but this only looks at annotations, not at implements Ordered
.
Would it be possible to provide a way to reliably get the order of the bean?