diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java
index d8b4f3a41a87..5a65001bdff4 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java
@@ -51,6 +51,7 @@
* @author Juergen Hoeller
* @author Rob Harrop
* @author Mark Fisher
+ * @author Sebastien Deleuze
* @see GenericBeanDefinition
* @see RootBeanDefinition
* @see ChildBeanDefinition
@@ -139,6 +140,18 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
*/
public static final String PREFERRED_CONSTRUCTORS_ATTRIBUTE = "preferredConstructors";
+ /**
+ * The name of an attribute that can be
+ * {@link org.springframework.core.AttributeAccessor#setAttribute set} on a
+ * {@link org.springframework.beans.factory.config.BeanDefinition} so that
+ * bean definitions can indicate the sort order for the targeted bean.
+ * This is analogous to the {@code @Order} annotation.
+ * @since 6.1.2
+ * @see org.springframework.core.annotation.Order
+ * @see org.springframework.core.Ordered
+ */
+ public static final String ORDER_ATTRIBUTE = "order";
+
/**
* Constant that indicates the container should attempt to infer the
* {@link #setDestroyMethodName destroy method name} for a bean as opposed to
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
index 20d406a54727..65ef5680a482 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
@@ -70,6 +70,7 @@
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.config.NamedBeanHolder;
import org.springframework.core.OrderComparator;
+import org.springframework.core.Ordered;
import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.MergedAnnotation;
import org.springframework.core.annotation.MergedAnnotations;
@@ -110,6 +111,7 @@
* @author Chris Beams
* @author Phillip Webb
* @author Stephane Nicoll
+ * @author Sebastien Deleuze
* @since 16 April 2001
* @see #registerBeanDefinition
* @see #addBeanPostProcessor
@@ -2230,7 +2232,9 @@ public Object get() throws BeansException {
* that is aware of the bean metadata of the instances to sort.
*
Lookup for the method factory of an instance to sort, if any, and let the
* comparator retrieve the {@link org.springframework.core.annotation.Order}
- * value defined on it. This essentially allows for the following construct:
+ * value defined on it.
+ *
As of 6.1.2, this class takes the {@link AbstractBeanDefinition#ORDER_ATTRIBUTE}
+ * attribute into account.
*/
private class FactoryAwareOrderSourceProvider implements OrderComparator.OrderSourceProvider {
@@ -2249,7 +2253,17 @@ public Object getOrderSource(Object obj) {
}
try {
RootBeanDefinition beanDefinition = (RootBeanDefinition) getMergedBeanDefinition(beanName);
- List