Package org.springframework.aop.aspectj.autoproxy

# Class AspectJAwareAdvisorAutoProxyCreator

java.lang.Object
org.springframework.aop.framework.ProxyConfig
org.springframework.aop.framework.ProxyProcessorSupport
org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator
org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator

All Implemented Interfaces:
  `Serializable`, `AopInfrastructureBean`, `org.springframework.beans.factory.Aware`, `org.springframework.beans.factory.BeanClassLoaderAware`, `org.springframework.beans.factory.BeanFactoryAware`, `org.springframework.beans.factory.config.BeanPostProcessor`, `org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor`, `org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor`, `org.springframework.beans.factory.DisposableBean`, `org.springframework.beans.factory.SmartInitializingSingleton`, `org.springframework.core.Ordered`

Direct Known Subclasses:
  `AnnotationAwareAspectJAutoProxyCreator`

public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator implements org.springframework.beans.factory.SmartInitializingSingleton, org.springframework.beans.factory.DisposableBean
`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.

Since:
  2.0
Author:
  Adrian Colyer, Juergen Hoeller, Ramnivas Laddad
See Also:
  - Serialized Form

## Field Summary

### Fields inherited from class org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator

`DO_NOT_PROXY, logger, PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS`

### Fields inherited from interface org.springframework.core.Ordered

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

## Constructor Summary

Constructors
Constructor
Description
`AspectJAwareAdvisorAutoProxyCreator()`

## Method Summary

Modifier and Type
Method
Description
`void`
`afterSingletonsInstantiated()`
`void`
`destroy()`
`protected void`
`extendAdvisors(List<Advisor> candidateAdvisors)`
Add an `ExposeInvocationInterceptor` to the beginning of the advice chain.
`protected boolean`
`shouldSkip(Class<?> beanClass, String beanName)`
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> advisors)`
Sort the supplied `Advisor` instances according to AspectJ precedence.

### Methods inherited from class org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator

`advisorsPreFiltered, findAdvisorsThatCanApply, findCandidateAdvisors, findEligibleAdvisors, getAdvicesAndAdvisorsForBean, initBeanFactory, isEligibleAdvisorBean, setBeanFactory`

### Methods inherited from class org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator

`buildAdvisors, createProxy, customizeProxyFactory, determineBeanType, determineCandidateConstructors, getBeanFactory, getCacheKey, getCustomTargetSource, getEarlyBeanReference, isFrozen, isInfrastructureClass, postProcessAfterInitialization, postProcessBeforeInstantiation, postProcessProperties, predictBeanType, setAdvisorAdapterRegistry, setApplyCommonInterceptorsFirst, setCustomTargetSourceCreators, setFrozen, setInterceptorNames, shouldProxyTargetClass, wrapIfNecessary`

### Methods inherited from class org.springframework.aop.framework.ProxyProcessorSupport

`evaluateProxyInterfaces, getOrder, getProxyClassLoader, isConfigurationCallbackInterface, isInternalLanguageInterface, setBeanClassLoader, setOrder, setProxyClassLoader`

### Methods inherited from class org.springframework.aop.framework.ProxyConfig

`copyFrom, isExposeProxy, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setOpaque, setOptimize, setProxyTargetClass, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.beans.factory.config.BeanPostProcessor

`postProcessBeforeInitialization`

### Methods inherited from interface org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor

`postProcessAfterInstantiation`

## Constructor Details

### AspectJAwareAdvisorAutoProxyCreator

public AspectJAwareAdvisorAutoProxyCreator()

## Method Details

### sortAdvisors

protected List<Advisor> sortAdvisors(List<Advisor> advisors)
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: 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.

Overrides:
  `sortAdvisors` in class `AbstractAdvisorAutoProxyCreator`
Parameters:
  `advisors` - the source List of Advisors
Returns:
  the sorted List of Advisors
See Also:
  - `Ordered`
  - `Order`
  - `AnnotationAwareOrderComparator`

### extendAdvisors

protected void extendAdvisors(List<Advisor> candidateAdvisors)
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.

Overrides:
  `extendAdvisors` in class `AbstractAdvisorAutoProxyCreator`
Parameters:
  `candidateAdvisors` - the Advisors that have already been identified as applying to a given bean

### shouldSkip

protected boolean shouldSkip(Class<?> beanClass, String beanName)
Description copied from class: `AbstractAutoProxyCreator`
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, for example, 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.

Overrides:
  `shouldSkip` in class `AbstractAutoProxyCreator`
Parameters:
  `beanClass` - the class of the bean
  `beanName` - the name of the bean
Returns:
  whether to skip the given bean
See Also:
  - `AutowireCapableBeanFactory.ORIGINAL_INSTANCE_SUFFIX`

### afterSingletonsInstantiated

public void afterSingletonsInstantiated()

Specified by:
  `afterSingletonsInstantiated` in interface `org.springframework.beans.factory.SmartInitializingSingleton`

### destroy

public void destroy()

Specified by:
  `destroy` in interface `org.springframework.beans.factory.DisposableBean`