Class AbstractAdvisorAutoProxyCreator
- All Implemented Interfaces:
Serializable,AopInfrastructureBean,Aware,BeanClassLoaderAware,BeanFactoryAware,BeanPostProcessor,InstantiationAwareBeanPostProcessor,SmartInstantiationAwareBeanPostProcessor,Ordered
- Direct Known Subclasses:
AspectJAwareAdvisorAutoProxyCreator,DefaultAdvisorAutoProxyCreator,InfrastructureAdvisorAutoProxyCreator
Subclasses may override the findCandidateAdvisors() method to
return a custom list of Advisors applying to any object. Subclasses can
also override the inherited AbstractAutoProxyCreator.shouldSkip(java.lang.Class<?>, java.lang.String) method to exclude certain
objects from auto-proxying.
Advisors or advices requiring ordering should be annotated with
@Order or implement the
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.
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
DO_NOT_PROXY, logger, PROXY_WITHOUT_ADDITIONAL_INTERCEPTORSFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanThis auto-proxy creator always returns pre-filtered Advisors.protected voidextendAdvisors(List<Advisor> candidateAdvisors) Extension hook that subclasses can override to register additional Advisors, given the sorted Advisors obtained to date.findAdvisorsThatCanApply(List<Advisor> candidateAdvisors, Class<?> beanClass, String beanName) Search the given candidate Advisors to find all Advisors that can apply to the specified bean.Find all candidate Advisors to use in auto-proxying.findEligibleAdvisors(Class<?> beanClass, String beanName) Find all eligible Advisors for auto-proxying this class.protected Object[]getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, TargetSource targetSource) Return whether the given bean is to be proxied, what additional advices (e.g.protected voidinitBeanFactory(ConfigurableListableBeanFactory beanFactory) protected booleanisEligibleAdvisorBean(String beanName) Return whether the Advisor bean with the given name is eligible for proxying in the first place.voidsetBeanFactory(BeanFactory beanFactory) Callback that supplies the owning factory to a bean instance.sortAdvisors(List<Advisor> advisors) Sort advisors based on ordering.Methods inherited from class org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
buildAdvisors, createProxy, customizeProxyFactory, determineCandidateConstructors, getBeanFactory, getCacheKey, getCustomTargetSource, getEarlyBeanReference, isFrozen, isInfrastructureClass, postProcessAfterInitialization, postProcessBeforeInstantiation, postProcessProperties, predictBeanType, setAdvisorAdapterRegistry, setApplyCommonInterceptorsFirst, setCustomTargetSourceCreators, setFrozen, setInterceptorNames, shouldProxyTargetClass, shouldSkip, wrapIfNecessaryMethods inherited from class org.springframework.aop.framework.ProxyProcessorSupport
evaluateProxyInterfaces, getOrder, getProxyClassLoader, isConfigurationCallbackInterface, isInternalLanguageInterface, setBeanClassLoader, setOrder, setProxyClassLoaderMethods inherited from class org.springframework.aop.framework.ProxyConfig
copyFrom, isExposeProxy, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setOpaque, setOptimize, setProxyTargetClass, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.config.BeanPostProcessor
postProcessBeforeInitializationMethods inherited from interface org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
postProcessAfterInstantiation
-
Constructor Details
-
AbstractAdvisorAutoProxyCreator
public AbstractAdvisorAutoProxyCreator()
-
-
Method Details
-
setBeanFactory
Description copied from interface:BeanFactoryAwareCallback 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.- Specified by:
setBeanFactoryin interfaceBeanFactoryAware- Overrides:
setBeanFactoryin classAbstractAutoProxyCreator- Parameters:
beanFactory- owning BeanFactory (nevernull). The bean can immediately call methods on the factory.- See Also:
-
initBeanFactory
-
getAdvicesAndAdvisorsForBean
@Nullable protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, @Nullable TargetSource targetSource) Description copied from class:AbstractAutoProxyCreatorReturn whether the given bean is to be proxied, what additional advices (e.g. AOP Alliance interceptors) and advisors to apply.- Specified by:
getAdvicesAndAdvisorsForBeanin classAbstractAutoProxyCreator- Parameters:
beanClass- the class of the bean to advisebeanName- the name of the beantargetSource- the TargetSource returned by theAbstractAutoProxyCreator.getCustomTargetSource(java.lang.Class<?>, java.lang.String)method: may be ignored. Will benullif 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
nullif no proxy at all, not even with the common interceptors. See constants DO_NOT_PROXY and PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS. - See Also:
-
findEligibleAdvisors
Find all eligible Advisors for auto-proxying this class.- Parameters:
beanClass- the clazz to find advisors forbeanName- the name of the currently proxied bean- Returns:
- the empty List, not
null, if there are no pointcuts or interceptors - See Also:
-
findCandidateAdvisors
Find all candidate Advisors to use in auto-proxying.- Returns:
- the List of candidate Advisors
-
findAdvisorsThatCanApply
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 AdvisorsbeanClass- the target's bean classbeanName- the target's bean name- Returns:
- the List of applicable Advisors
- See Also:
-
isEligibleAdvisorBean
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
-
sortAdvisors
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
- See Also:
-
extendAdvisors
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- the Advisors that have already been identified as applying to a given bean
-
advisorsPreFiltered
protected boolean advisorsPreFiltered()This auto-proxy creator always returns pre-filtered Advisors.- Overrides:
advisorsPreFilteredin classAbstractAutoProxyCreator- Returns:
- whether the Advisors are pre-filtered
- See Also:
-