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

public Class AspectJAwareAdvisorAutoProxyCreator

extends AbstractAdvisorAutoProxyCreator
Class Inheritance
Known Direct Subclasses
org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator
Annotations
@SuppressWarnings:serial
Imports
java.util.ArrayList, .Comparator, .List, org.aopalliance.aop.Advice, org.aspectj.util.PartialOrder, .PartialOrder.PartialComparable, org.springframework.aop.Advisor, org.springframework.aop.aspectj.AbstractAspectJAdvice, .AspectJPointcutAdvisor, .AspectJProxyUtils, org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator, org.springframework.aop.interceptor.ExposeInvocationInterceptor, org.springframework.core.Ordered, org.springframework.util.ClassUtils

org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator subclass that exposes AspectJ's invocation context and understands AspectJ's rules for advice precedence when multiple pieces of advice come from the same aspect.
Authors
Adrian Colyer, Juergen Hoeller, Ramnivas Laddad
Since
2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
AspectJAwareAdvisorAutoProxyCreator.PartiallyComparableAdvisorHolder

Implements AspectJ's PartialComparable interface for defining partial orderings.

Field Summary

Modifier and TypeField and Description
private static final Comparator<Advisor>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
extendAdvisors(List<Advisor>
the Advisors that have already been identified as applying to a given bean
candidateAdvisors
)

Overrides org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.extendAdvisors.

Add an ExposeInvocationInterceptor to the beginning of the advice chain.

protected boolean
shouldSkip(Class<?>
the class of the bean
beanClass
,
String
the name of the bean
beanName
)

Overrides org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.shouldSkip.

Subclasses should override this method to return true if the given bean should not be considered for auto-proxying by this post-processor.

protected List<Advisor>
sortAdvisors(List<Advisor>
the source List of Advisors
advisors
)

Overrides org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.sortAdvisors.

Sort the supplied Advisor instances according to AspectJ precedence.

Inherited from org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator:
advisorsPreFilteredfindAdvisorsThatCanApplyfindCandidateAdvisorsfindEligibleAdvisorsgetAdvicesAndAdvisorsForBeaninitBeanFactoryisEligibleAdvisorBeansetBeanFactory

Field Detail

DEFAULT_PRECEDENCE_COMPARATORback to summary
private static final Comparator<Advisor> DEFAULT_PRECEDENCE_COMPARATOR

Constructor Detail

AspectJAwareAdvisorAutoProxyCreatorback to summary
public AspectJAwareAdvisorAutoProxyCreator()

Method Detail

extendAdvisorsback to summary
protected void extendAdvisors(List<Advisor> candidateAdvisors)

Overrides org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.extendAdvisors.

Add an ExposeInvocationInterceptor to the beginning of the advice chain.

This additional advice is needed when using AspectJ pointcut expressions and when using AspectJ-style advice.

Parameters
candidateAdvisors:List<Advisor>

Doc from org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.extendAdvisors.

the Advisors that have already been identified as applying to a given bean

Annotations
@Override
shouldSkipback to summary
protected boolean shouldSkip(Class<?> beanClass, String beanName)

Overrides org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.shouldSkip.

Doc from org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.shouldSkip.

Subclasses should override this method to return true if the given bean should not be considered for auto-proxying by this post-processor.

Sometimes we need to be able to avoid this happening, e.g. if it will lead to a circular reference or if the existing target instance needs to be preserved. This implementation returns false unless the bean name indicates an "original instance" according to AutowireCapableBeanFactory conventions.

Parameters
beanClass:Class<?>

the class of the bean

beanName:String

the name of the bean

Returns:boolean

whether to skip the given bean

Annotations
@Override
sortAdvisorsback to summary
protected List<Advisor> sortAdvisors(List<Advisor> advisors)

Overrides org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.sortAdvisors.

Sort the supplied Advisor instances according to AspectJ precedence.

If two pieces of advice come from the same aspect, they will have the same order. Advice from the same aspect is then further ordered according to the following rules:

  • If either of the pair is after advice, then the advice declared last gets highest precedence (i.e., runs last).
  • Otherwise the advice declared first gets highest precedence (i.e., runs first).

Important Note

Advisors are sorted in precedence order, from the highest precedence to the lowest. "On the way in" to a join point, the highest precedence advisor should run first. "On the way out" of a join point, the highest precedence advisor should run last.

Parameters
advisors:List<Advisor>

Doc from org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.sortAdvisors.

the source List of Advisors

Returns:List<Advisor>

Doc from org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.sortAdvisors.

the sorted List of Advisors

Annotations
@Override
org.springframework.aop.aspectj.autoproxy back to summary

private Class AspectJAwareAdvisorAutoProxyCreator.PartiallyComparableAdvisorHolder

extends Object
implements PartialComparable
Class Inheritance
  • java.lang.Object
  • org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.PartiallyComparableAdvisorHolder
All Implemented Interfaces
org.aspectj.util.PartialOrder.PartialComparable

Implements AspectJ's PartialComparable interface for defining partial orderings.

Field Summary

Modifier and TypeField and Description
private final Advisor
private final Comparator<Advisor>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
public int
fallbackCompareTo(Object obj)

Implements org.aspectj.util.PartialOrder.PartialComparable.fallbackCompareTo.

This method can provide a deterministic ordering for elements that are strictly not comparable.

public Advisor
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

advisorback to summary
private final Advisor advisor
comparatorback to summary
private final Comparator<Advisor> comparator

Constructor Detail

PartiallyComparableAdvisorHolderback to summary
public PartiallyComparableAdvisorHolder(Advisor advisor, Comparator<Advisor> comparator)

Method Detail

compareToback to summary
public int compareTo(Object obj)

Implements org.aspectj.util.PartialOrder.PartialComparable.compareTo.

Returns:int

Doc from org.aspectj.util.PartialOrder.PartialComparable.compareTo.

  • +1 if this is greater than other
  • -1 if this is less than other
  • 0 if this is not comparable to other

Note

returning 0 from this method doesn't mean the same thing as returning 0 from java.util.Comparable.compareTo()

Annotations
@Override
fallbackCompareToback to summary
public int fallbackCompareTo(Object obj)

Implements org.aspectj.util.PartialOrder.PartialComparable.fallbackCompareTo.

Doc from org.aspectj.util.PartialOrder.PartialComparable.fallbackCompareTo.

This method can provide a deterministic ordering for elements that are strictly not comparable. If you have no need for this, this method can just return 0 whenever called.

Annotations
@Override
getAdvisorback to summary
public Advisor getAdvisor()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override