From 2038b43d1fe3f286d8cf9e6051f1720bcb081be2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 25 Feb 2009 13:41:57 +0000 Subject: [PATCH] clarified applicability of @Order git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@693 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../BeanFactoryAspectInstanceFactory.java | 10 ++++----- .../core/annotation/Order.java | 22 +++++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectInstanceFactory.java b/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectInstanceFactory.java index 3b9cfd7279a..a640e364584 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectInstanceFactory.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectInstanceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +23,8 @@ import org.springframework.core.annotation.Order; import org.springframework.util.ClassUtils; /** - * AspectInstanceFactory backed by a Spring - * {@link org.springframework.beans.factory.BeanFactory}. + * {@link org.springframework.aop.aspectj.AspectInstanceFactory} implementation + * backed by a Spring {@link org.springframework.beans.factory.BeanFactory}. * *

Note that this may instantiate multiple times if using a prototype, * which probably won't give the semantics you expect. @@ -100,12 +100,12 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst * @see org.springframework.core.annotation.Order */ public int getOrder() { - Class type = this.beanFactory.getType(this.name); + Class type = this.beanFactory.getType(this.name); if (type != null) { if (Ordered.class.isAssignableFrom(type) && this.beanFactory.isSingleton(this.name)) { return ((Ordered) this.beanFactory.getBean(this.name)).getOrder(); } - Order order = (Order) type.getAnnotation(Order.class); + Order order = type.getAnnotation(Order.class); if (order != null) { return order.value(); } diff --git a/org.springframework.core/src/main/java/org/springframework/core/annotation/Order.java b/org.springframework.core/src/main/java/org/springframework/core/annotation/Order.java index 917e7b8eebb..06f77067b44 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/annotation/Order.java +++ b/org.springframework.core/src/main/java/org/springframework/core/annotation/Order.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,14 +24,18 @@ import java.lang.annotation.Target; import org.springframework.core.Ordered; /** - * Annotation to define ordering. + * Annotation that defines ordering. The value is optional, and represents order value + * as defined in the {@link Ordered} interface. Lower values have higher priority. + * The default value is Ordered.LOWEST_PRECEDENCE, indicating + * lowest priority (losing to any other specified order value). + * + *

NOTE: Annotation-based ordering is supported for specific kinds of + * components only, e.g. for annotation-based AspectJ aspects. Spring container + * strategies, on the other hand, are typically based on the {@link Ordered} + * interface in order to allow for configurable ordering of each instance. * - *

Value is optional, and represents order value as defined - * in the Ordered interface. Lower values have higher priority. - * Default value is Integer.MAX_VALUE, indicating lowest - * priority (losing to any other specified order value). - * * @author Rod Johnson + * @author Juergen Hoeller * @since 2.0 * @see org.springframework.core.Ordered * @see AnnotationAwareOrderComparator @@ -40,6 +44,10 @@ import org.springframework.core.Ordered; @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) public @interface Order { + /** + * The order value. Default is {@link Ordered#LOWEST_PRECEDENCE}. + * @see Ordered#getOrder() + */ int value() default Ordered.LOWEST_PRECEDENCE; }