Top Description Fields Constructors Methods
org.springframework.aop.aspectj.autoproxy

pack-priv Class AspectJPrecedenceComparator

extends Object
implements Comparator<Advisor>
Class Inheritance
All Implemented Interfaces
java.util.Comparator
Imports
java.util.Comparator, org.springframework.aop.Advisor, org.springframework.aop.aspectj.AspectJAopUtils, .AspectJPrecedenceInformation, org.springframework.core.annotation.AnnotationAwareOrderComparator, org.springframework.util.Assert

Orders AspectJ advice/advisors by precedence (not invocation order).

Given two pieces of advice, A and B:

Important Note

This comparator is used with AspectJ's PartialOrder sorting utility. Thus, unlike a normal Comparator, a return value of 0 from this comparator means we don't care about the ordering, not that the two elements must be sorted identically.

Authors
Adrian Colyer, Juergen Hoeller
Since
2.0

Field Summary

Modifier and TypeField and Description
private final Comparator<? super Advisor>
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public
AspectJPrecedenceComparator()

Create a default AspectJPrecedenceComparator.

public
AspectJPrecedenceComparator(Comparator<? super Advisor>
the Comparator to use for advisors
advisorComparator
)

Create an AspectJPrecedenceComparator, using the given Comparator for comparing org.springframework.aop.Advisor instances.

Method Summary

Modifier and TypeMethod and Description
public int
compare(Advisor
the first object to be compared.
o1
,
Advisor
the second object to be compared.
o2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
private int
private boolean
declaredInSameAspect(Advisor advisor1, Advisor advisor2)

private int
private String
private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

advisorComparatorback to summary
private final Comparator<? super Advisor> advisorComparator
HIGHER_PRECEDENCEback to summary
private static final int HIGHER_PRECEDENCE
LOWER_PRECEDENCEback to summary
private static final int LOWER_PRECEDENCE
SAME_PRECEDENCEback to summary
private static final int SAME_PRECEDENCE

Constructor Detail

AspectJPrecedenceComparatorback to summary
public AspectJPrecedenceComparator()

Create a default AspectJPrecedenceComparator.

AspectJPrecedenceComparatorback to summary
public AspectJPrecedenceComparator(Comparator<? super Advisor> advisorComparator)

Create an AspectJPrecedenceComparator, using the given Comparator for comparing org.springframework.aop.Advisor instances.

Parameters
advisorComparator:Comparator<? super Advisor>

the Comparator to use for advisors

Method Detail

compareback to summary
public int compare(Advisor o1, Advisor o2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
o1:Advisor

the first object to be compared.

o2:Advisor

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override
comparePrecedenceWithinAspectback to summary
private int comparePrecedenceWithinAspect(Advisor advisor1, Advisor advisor2)
declaredInSameAspectback to summary
private boolean declaredInSameAspect(Advisor advisor1, Advisor advisor2)
getAspectDeclarationOrderback to summary
private int getAspectDeclarationOrder(Advisor advisor)
getAspectNameback to summary
private String getAspectName(Advisor advisor)
hasAspectNameback to summary
private boolean hasAspectName(Advisor advisor)