org.springframework.aop.aspectj.autoproxy
Class AspectJPrecedenceComparator
java.lang.Object
org.springframework.aop.aspectj.autoproxy.AspectJPrecedenceComparator
- All Implemented Interfaces:
- java.util.Comparator
class AspectJPrecedenceComparator
- extends java.lang.Object
- implements java.util.Comparator
Orders AspectJ advice/advisors by precedence (not invocation order).
Given two pieces of advice, a
and b
:
- if
a
and b
are defined in different
aspects, then the advice in the aspect with the lowest order
value has the highest precedence
- if
a
and b
are defined in the same
aspect, then if one of a
or b
is a form of
after advice, then the advice declared last in the aspect has the
highest precedence. If neither a
nor b
is a
form of after advice, then the advice declared first in the aspect has
the highest precedence.
Important: Note that unlike a normal comparator a return of 0 means
we don't care about the ordering, not that the two elements must be sorted
identically. Used with AspectJ PartialOrder class.
- Since:
- 2.0
- Author:
- Adrian Colyer, Juergen Hoeller
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
HIGHER_PRECEDENCE
private static final int HIGHER_PRECEDENCE
- See Also:
- Constant Field Values
SAME_PRECEDENCE
private static final int SAME_PRECEDENCE
- See Also:
- Constant Field Values
LOWER_PRECEDENCE
private static final int LOWER_PRECEDENCE
- See Also:
- Constant Field Values
NOT_COMPARABLE
private static final int NOT_COMPARABLE
- See Also:
- Constant Field Values
advisorComparator
private final java.util.Comparator<? super Advisor> advisorComparator
AspectJPrecedenceComparator
public AspectJPrecedenceComparator()
- Create a default AspectJPrecedenceComparator.
AspectJPrecedenceComparator
public AspectJPrecedenceComparator(java.util.Comparator<? super Advisor> advisorComparator)
- Create a AspectJPrecedenceComparator, using the given Comparator
for comparing
Advisor
instances.
- Parameters:
advisorComparator
- the Comparator to use for Advisors
compare
public int compare(java.lang.Object o1,
java.lang.Object o2)
- Specified by:
compare
in interface java.util.Comparator
comparePrecedenceWithinAspect
private int comparePrecedenceWithinAspect(Advisor advisor1,
Advisor advisor2)
declaredInSameAspect
private boolean declaredInSameAspect(Advisor advisor1,
Advisor advisor2)
hasAspectName
private boolean hasAspectName(Advisor anAdvisor)
getAspectName
private java.lang.String getAspectName(Advisor anAdvisor)
getAspectDeclarationOrder
private int getAspectDeclarationOrder(Advisor anAdvisor)