Skip to content

Commit 96e00d6

Browse files
committed
clarified applicability of @order
1 parent 5367ec0 commit 96e00d6

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

org.springframework.aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectInstanceFactory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,8 +23,8 @@
2323
import org.springframework.util.ClassUtils;
2424

2525
/**
26-
* AspectInstanceFactory backed by a Spring
27-
* {@link org.springframework.beans.factory.BeanFactory}.
26+
* {@link org.springframework.aop.aspectj.AspectInstanceFactory} implementation
27+
* backed by a Spring {@link org.springframework.beans.factory.BeanFactory}.
2828
*
2929
* <p>Note that this may instantiate multiple times if using a prototype,
3030
* which probably won't give the semantics you expect.
@@ -100,12 +100,12 @@ public AspectMetadata getAspectMetadata() {
100100
* @see org.springframework.core.annotation.Order
101101
*/
102102
public int getOrder() {
103-
Class type = this.beanFactory.getType(this.name);
103+
Class<?> type = this.beanFactory.getType(this.name);
104104
if (type != null) {
105105
if (Ordered.class.isAssignableFrom(type) && this.beanFactory.isSingleton(this.name)) {
106106
return ((Ordered) this.beanFactory.getBean(this.name)).getOrder();
107107
}
108-
Order order = (Order) type.getAnnotation(Order.class);
108+
Order order = type.getAnnotation(Order.class);
109109
if (order != null) {
110110
return order.value();
111111
}

org.springframework.core/src/main/java/org/springframework/core/annotation/Order.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2006 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,14 +24,18 @@
2424
import org.springframework.core.Ordered;
2525

2626
/**
27-
* Annotation to define ordering.
27+
* Annotation that defines ordering. The value is optional, and represents order value
28+
* as defined in the {@link Ordered} interface. Lower values have higher priority.
29+
* The default value is <code>Ordered.LOWEST_PRECEDENCE</code>, indicating
30+
* lowest priority (losing to any other specified order value).
31+
*
32+
* <p><b>NOTE:</b> Annotation-based ordering is supported for specific kinds of
33+
* components only, e.g. for annotation-based AspectJ aspects. Spring container
34+
* strategies, on the other hand, are typically based on the {@link Ordered}
35+
* interface in order to allow for configurable ordering of each <i>instance</i>.
2836
*
29-
* <p>Value is optional, and represents order value as defined
30-
* in the Ordered interface. Lower values have higher priority.
31-
* Default value is <code>Integer.MAX_VALUE</code>, indicating lowest
32-
* priority (losing to any other specified order value).
33-
*
3437
* @author Rod Johnson
38+
* @author Juergen Hoeller
3539
* @since 2.0
3640
* @see org.springframework.core.Ordered
3741
* @see AnnotationAwareOrderComparator
@@ -40,6 +44,10 @@
4044
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
4145
public @interface Order {
4246

47+
/**
48+
* The order value. Default is {@link Ordered#LOWEST_PRECEDENCE}.
49+
* @see Ordered#getOrder()
50+
*/
4351
int value() default Ordered.LOWEST_PRECEDENCE;
4452

4553
}

0 commit comments

Comments
 (0)