public abstract class

AbstractAdvisorAutoProxyCreator

extends AbstractAutoProxyCreator
java.lang.Object
   ↳ org.springframework.aop.framework.ProxyConfig
     ↳ org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
       ↳ org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Generic auto proxy creator that builds AOP proxies for specific beans based on detected Advisors for each bean.

Subclasses must implement the abstract findCandidateAdvisors() method to return a list of Advisors applying to any object. Subclasses can also override the inherited shouldSkip(Class, String) method to exclude certain objects from auto-proxying.

Advisors or advices requiring ordering should implement the Ordered interface. This class sorts Advisors by Ordered order value. Advisors that don't implement the Ordered interface will be considered as unordered; they will appear at the end of the advisor chain in undefined order.

Summary

[Expand]
Inherited Constants
From interface org.springframework.core.Ordered
[Expand]
Inherited Fields
From class org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
Public Constructors
AbstractAdvisorAutoProxyCreator()
Public Methods
void setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance.
Protected Methods
boolean advisorsPreFiltered()
This auto-proxy creator always returns pre-filtered Advisors.
void extendAdvisors(List<Advisor> candidateAdvisors)
Extension hook that subclasses can override to register additional Advisors, given the sorted Advisors obtained to date.
List<Advisor> findAdvisorsThatCanApply(List<Advisor> candidateAdvisors, Class beanClass, String beanName)
Search the given candidate Advisors to find all Advisors that can apply to the specified bean.
List<Advisor> findCandidateAdvisors()
Find all candidate Advisors to use in auto-proxying.
List<Advisor> findEligibleAdvisors(Class beanClass, String beanName)
Find all eligible Advisors for auto-proxying this class.
Object[] getAdvicesAndAdvisorsForBean(Class beanClass, String beanName, TargetSource targetSource)
Return whether the given bean is to be proxied, what additional advices (e.g.
void initBeanFactory(ConfigurableListableBeanFactory beanFactory)
boolean isEligibleAdvisorBean(String beanName)
Return whether the Advisor bean with the given name is eligible for proxying in the first place.
List<Advisor> sortAdvisors(List<Advisor> advisors)
Sort advisors based on ordering.
[Expand]
Inherited Methods
From class org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
From class org.springframework.aop.framework.ProxyConfig
From class java.lang.Object
From interface org.springframework.beans.factory.BeanClassLoaderAware
From interface org.springframework.beans.factory.BeanFactoryAware
From interface org.springframework.beans.factory.config.BeanPostProcessor
From interface org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
From interface org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor
From interface org.springframework.core.Ordered

Public Constructors

public AbstractAdvisorAutoProxyCreator ()

Public Methods

public void setBeanFactory (BeanFactory beanFactory)

Callback that supplies the owning factory to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as afterPropertiesSet() or a custom init-method.

Parameters
beanFactory owning BeanFactory (never null). The bean can immediately call methods on the factory.

Protected Methods

protected boolean advisorsPreFiltered ()

This auto-proxy creator always returns pre-filtered Advisors.

Returns
  • whether the Advisors are pre-filtered

protected void extendAdvisors (List<Advisor> candidateAdvisors)

Extension hook that subclasses can override to register additional Advisors, given the sorted Advisors obtained to date.

The default implementation is empty.

Typically used to add Advisors that expose contextual information required by some of the later advisors.

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

protected List<Advisor> findAdvisorsThatCanApply (List<Advisor> candidateAdvisors, Class beanClass, String beanName)

Search the given candidate Advisors to find all Advisors that can apply to the specified bean.

Parameters
candidateAdvisors the candidate Advisors
beanClass the target's bean class
beanName the target's bean name
Returns
  • the List of applicable Advisors

protected List<Advisor> findCandidateAdvisors ()

Find all candidate Advisors to use in auto-proxying.

Returns
  • the List of candidate Advisors

protected List<Advisor> findEligibleAdvisors (Class beanClass, String beanName)

Find all eligible Advisors for auto-proxying this class.

Parameters
beanClass the clazz to find advisors for
beanName the name of the currently proxied bean
Returns
  • the empty List, not null, if there are no pointcuts or interceptors

protected Object[] getAdvicesAndAdvisorsForBean (Class beanClass, String beanName, TargetSource targetSource)

Return whether the given bean is to be proxied, what additional advices (e.g. AOP Alliance interceptors) and advisors to apply.

Parameters
beanClass the class of the bean to advise
beanName the name of the bean
targetSource the TargetSource returned by the getCustomTargetSource(Class, String) method: may be ignored. Will be null if no custom target source is in use.
Returns
  • an array of additional interceptors for the particular bean; or an empty array if no additional interceptors but just the common ones; or null if no proxy at all, not even with the common interceptors. See constants DO_NOT_PROXY and PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS.

protected void initBeanFactory (ConfigurableListableBeanFactory beanFactory)

protected boolean isEligibleAdvisorBean (String beanName)

Return whether the Advisor bean with the given name is eligible for proxying in the first place.

Parameters
beanName the name of the Advisor bean
Returns
  • whether the bean is eligible

protected List<Advisor> sortAdvisors (List<Advisor> advisors)

Sort advisors based on ordering. Subclasses may choose to override this method to customize the sorting strategy.

Parameters
advisors the source List of Advisors
Returns
  • the sorted List of Advisors