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

public abstract Class AbstractAdvisorAutoProxyCreator

extends AbstractAutoProxyCreator
Class Inheritance
Known Direct Subclasses
org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator, org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator, org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator
Annotations
@SuppressWarnings:serial
Imports
java.util.List, org.springframework.aop.Advisor, .TargetSource, org.springframework.aop.support.AopUtils, org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.config.ConfigurableListableBeanFactory, org.springframework.core.annotation.AnnotationAwareOrderComparator, org.springframework.lang.Nullable, org.springframework.util.Assert

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

Subclasses may override the findCandidateAdvisors() method to return a custom list of Advisors applying to any object. Subclasses can also override the inherited shouldSkip method to exclude certain objects from auto-proxying.

Advisors or advices requiring ordering should be annotated with @Order or implement the org.springframework.core.Ordered interface. This class sorts advisors using the AnnotationAwareOrderComparator. Advisors that are not annotated with @Order or don't implement the Ordered interface will be considered as unordered; they will appear at the end of the advisor chain in an undefined order.

Authors
Rod Johnson, Juergen Hoeller
See Also
findCandidateAdvisors

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
AbstractAdvisorAutoProxyCreator.BeanFactoryAdvisorRetrievalHelperAdapter

Subclass of BeanFactoryAdvisorRetrievalHelper that delegates to surrounding AbstractAdvisorAutoProxyCreator facilities.

Field Summary

Modifier and TypeField and Description
private BeanFactoryAdvisorRetrievalHelper
Inherited from org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator:
DO_NOT_PROXYloggerPROXY_WITHOUT_ADDITIONAL_INTERCEPTORS

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
advisorsPreFiltered()

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

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

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

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

protected List<Advisor>

Returns:

the List of applicable Advisors
findAdvisorsThatCanApply
(List<Advisor>
the candidate Advisors
candidateAdvisors
,
Class<?>
the target's bean class
beanClass
,
String
the target's bean name
beanName
)

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

protected List<Advisor>

Returns:

the List of candidate Advisors
findCandidateAdvisors
()

Find all candidate Advisors to use in auto-proxying.

protected List<Advisor>

Returns:

the empty List, not null, if there are no pointcuts or interceptors
findEligibleAdvisors
(Class<?>
the clazz to find advisors for
beanClass
,
String
the name of the currently proxied bean
beanName
)

Find all eligible Advisors for auto-proxying this class.

protected Object[]
getAdvicesAndAdvisorsForBean(Class<?>
the class of the bean to advise
beanClass
,
String
the name of the bean
beanName
,
TargetSource
the TargetSource returned by the getCustomTargetSource method: may be ignored. Will be null if no custom target source is in use.
targetSource
)

Implements abstract org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.getAdvicesAndAdvisorsForBean.

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

protected void
protected boolean

Returns:

whether the bean is eligible
isEligibleAdvisorBean
(String
the name of the Advisor bean
beanName
)

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

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

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

Implements org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

Callback that supplies the owning factory to a bean instance.

protected List<Advisor>

Returns:

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

Sort advisors based on ordering.

Inherited from org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator:
buildAdvisorscreateProxycustomizeProxyFactorydetermineBeanTypedetermineCandidateConstructorsgetBeanFactorygetCacheKeygetCustomTargetSourcegetEarlyBeanReferenceisFrozenisInfrastructureClasspostProcessAfterInitializationpostProcessBeforeInstantiationpostProcessPropertiespredictBeanTypesetAdvisorAdapterRegistrysetApplyCommonInterceptorsFirstsetCustomTargetSourceCreatorssetFrozensetInterceptorNamesshouldProxyTargetClassshouldSkipwrapIfNecessary

Field Detail

advisorRetrievalHelperback to summary
private BeanFactoryAdvisorRetrievalHelper advisorRetrievalHelper
Annotations
@Nullable

Constructor Detail

AbstractAdvisorAutoProxyCreatorback to summary
public AbstractAdvisorAutoProxyCreator()

Method Detail

advisorsPreFilteredback to summary
protected boolean advisorsPreFiltered()

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

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

Returns:boolean

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

whether the Advisors are pre-filtered

Annotations
@Override
extendAdvisorsback to summary
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:List<Advisor>

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

findAdvisorsThatCanApplyback to summary
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:List<Advisor>

the candidate Advisors

beanClass:Class<?>

the target's bean class

beanName:String

the target's bean name

Returns:List<Advisor>

the List of applicable Advisors

See Also
ProxyCreationContext#getCurrentProxiedBeanName()
findCandidateAdvisorsback to summary
protected List<Advisor> findCandidateAdvisors()

Find all candidate Advisors to use in auto-proxying.

Returns:List<Advisor>

the List of candidate Advisors

findEligibleAdvisorsback to summary
protected List<Advisor> findEligibleAdvisors(Class<?> beanClass, String beanName)

Find all eligible Advisors for auto-proxying this class.

Parameters
beanClass:Class<?>

the clazz to find advisors for

beanName:String

the name of the currently proxied bean

Returns:List<Advisor>

the empty List, not null, if there are no pointcuts or interceptors

See Also
findCandidateAdvisors, sortAdvisors, extendAdvisors
getAdvicesAndAdvisorsForBeanback to summary
protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, TargetSource targetSource)

Implements abstract org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.getAdvicesAndAdvisorsForBean.

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

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

Parameters
beanClass:Class<?>

the class of the bean to advise

beanName:String

the name of the bean

targetSource:TargetSource

the TargetSource returned by the getCustomTargetSource method: may be ignored. Will be null if no custom target source is in use.

Returns:Object[]

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.

Annotations
@Override
@Nullable
initBeanFactoryback to summary
protected void initBeanFactory(ConfigurableListableBeanFactory beanFactory)
isEligibleAdvisorBeanback to summary
protected boolean isEligibleAdvisorBean(String beanName)

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

Parameters
beanName:String

the name of the Advisor bean

Returns:boolean

whether the bean is eligible

setBeanFactoryback to summary
public void setBeanFactory(BeanFactory beanFactory)

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

Implements org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

Doc from org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

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 InitializingBean#afterPropertiesSet() or a custom init-method.

Parameters
beanFactory:BeanFactory

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

Annotations
@Override
sortAdvisorsback to summary
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:List<Advisor>

the source List of Advisors

Returns:List<Advisor>

the sorted List of Advisors

See Also
org.springframework.core.Ordered, org.springframework.core.annotation.Order, org.springframework.core.annotation.AnnotationAwareOrderComparator
org.springframework.aop.framework.autoproxy back to summary

private Class AbstractAdvisorAutoProxyCreator.BeanFactoryAdvisorRetrievalHelperAdapter

extends BeanFactoryAdvisorRetrievalHelper
Class Inheritance

Subclass of BeanFactoryAdvisorRetrievalHelper that delegates to surrounding AbstractAdvisorAutoProxyCreator facilities.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
isEligibleBean(String
the name of the aspect bean
beanName
)

Overrides org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.isEligibleBean.

Determine whether the aspect bean with the given name is eligible.

Inherited from org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper:
findAdvisorBeans

Constructor Detail

BeanFactoryAdvisorRetrievalHelperAdapterback to summary
public BeanFactoryAdvisorRetrievalHelperAdapter(ConfigurableListableBeanFactory beanFactory)

Method Detail

isEligibleBeanback to summary
protected boolean isEligibleBean(String beanName)

Overrides org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.isEligibleBean.

Doc from org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.isEligibleBean.

Determine whether the aspect bean with the given name is eligible.

The default implementation always returns true.

Parameters
beanName:String

the name of the aspect bean

Returns:boolean

whether the bean is eligible

Annotations
@Override