diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java index ca56adfe1c..d5f71a9fa0 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java @@ -108,22 +108,23 @@ abstract class ConfigurationClassUtils { } } - Map orderAttributes = metadata.getAnnotationAttributes(Order.class.getName()); - if (orderAttributes != null) { - beanDef.setAttribute(ORDER_ATTRIBUTE, orderAttributes.get(AnnotationUtils.VALUE)); - } - if (isFullConfigurationCandidate(metadata)) { beanDef.setAttribute(CONFIGURATION_CLASS_ATTRIBUTE, CONFIGURATION_CLASS_FULL); - return true; } else if (isLiteConfigurationCandidate(metadata)) { beanDef.setAttribute(CONFIGURATION_CLASS_ATTRIBUTE, CONFIGURATION_CLASS_LITE); - return true; } else { return false; } + + // It's a full or lite configuration candidate... Let's determine the order value, if any. + Map orderAttributes = metadata.getAnnotationAttributes(Order.class.getName()); + if (orderAttributes != null) { + beanDef.setAttribute(ORDER_ATTRIBUTE, orderAttributes.get(AnnotationUtils.VALUE)); + } + + return true; } /** @@ -203,6 +204,7 @@ abstract class ConfigurationClassUtils { * @param beanDef the bean definition to check * @return the {@link @Order} annotation value on the configuration class, * or {@link Ordered#LOWEST_PRECEDENCE} if none declared + * @since 4.2 */ public static int getOrder(BeanDefinition beanDef) { Integer order = (Integer) beanDef.getAttribute(ORDER_ATTRIBUTE);