|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
* Copyright 2002-2015 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -27,8 +27,8 @@ import org.springframework.core.OrderComparator; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* {@link java.util.Comparator} implementation that checks Spring's |
|
|
|
* {@link java.util.Comparator} implementation that checks Spring's |
|
|
|
* {@link org.springframework.core.Ordered} interface as well as the |
|
|
|
* {@link org.springframework.core.Ordered} interface as well as the |
|
|
|
* {@link Order} annotation and the {@link javax.annotation.Priority} |
|
|
|
* {@link Order @Order} and {@link javax.annotation.Priority @Priority} |
|
|
|
* annotation, with an order value provided by an {@code Ordered} |
|
|
|
* annotations, with an order value provided by an {@code Ordered} |
|
|
|
* instance overriding a statically defined annotation value (if any). |
|
|
|
* instance overriding a statically defined annotation value (if any). |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Juergen Hoeller |
|
|
|
* @author Juergen Hoeller |
|
|
|
@ -36,7 +36,7 @@ import org.springframework.core.OrderComparator; |
|
|
|
* @author Stephane Nicoll |
|
|
|
* @author Stephane Nicoll |
|
|
|
* @since 2.0.1 |
|
|
|
* @since 2.0.1 |
|
|
|
* @see org.springframework.core.Ordered |
|
|
|
* @see org.springframework.core.Ordered |
|
|
|
* @see Order |
|
|
|
* @see org.springframework.core.annotation.Order |
|
|
|
* @see javax.annotation.Priority |
|
|
|
* @see javax.annotation.Priority |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class AnnotationAwareOrderComparator extends OrderComparator { |
|
|
|
public class AnnotationAwareOrderComparator extends OrderComparator { |
|
|
|
@ -61,7 +61,7 @@ public class AnnotationAwareOrderComparator extends OrderComparator { |
|
|
|
|
|
|
|
|
|
|
|
// Check for @Order annotation on various kinds of elements
|
|
|
|
// Check for @Order annotation on various kinds of elements
|
|
|
|
if (obj instanceof Class) { |
|
|
|
if (obj instanceof Class) { |
|
|
|
return OrderUtils.getOrder((Class) obj); |
|
|
|
return OrderUtils.getOrder((Class<?>) obj); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (obj instanceof Method) { |
|
|
|
else if (obj instanceof Method) { |
|
|
|
Order ann = AnnotationUtils.findAnnotation((Method) obj, Order.class); |
|
|
|
Order ann = AnnotationUtils.findAnnotation((Method) obj, Order.class); |
|
|
|
@ -83,14 +83,14 @@ public class AnnotationAwareOrderComparator extends OrderComparator { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This implementation checks retrieves a {@link javax.annotation.Priority} |
|
|
|
* This implementation retrieves an @{@link javax.annotation.Priority} |
|
|
|
* value, allowing for additional semantics over the regular {@link Order} |
|
|
|
* value, allowing for additional semantics over the regular @{@link Order} |
|
|
|
* annotation: typically, selecting one object over another in case of |
|
|
|
* annotation: typically, selecting one object over another in case of |
|
|
|
* multiple matches but only one object to be returned. |
|
|
|
* multiple matches but only one object to be returned. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Integer getPriority(Object obj) { |
|
|
|
public Integer getPriority(Object obj) { |
|
|
|
if (obj instanceof Class) { |
|
|
|
if (obj instanceof Class) { |
|
|
|
return OrderUtils.getPriority((Class) obj); |
|
|
|
return OrderUtils.getPriority((Class<?>) obj); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (obj != null) { |
|
|
|
else if (obj != null) { |
|
|
|
return OrderUtils.getPriority(obj.getClass()); |
|
|
|
return OrderUtils.getPriority(obj.getClass()); |
|
|
|
|