The Spring Framework

Class AbstractAdvisorAutoProxyCreator

  extended by org.springframework.aop.framework.ProxyConfig
      extended by org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
          extended by org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator
All Implemented Interfaces:
Serializable, AopInfrastructureBean, BeanClassLoaderAware, BeanFactoryAware, BeanPostProcessor, InstantiationAwareBeanPostProcessor, Ordered
Direct Known Subclasses:
AspectJAwareAdvisorAutoProxyCreator, DefaultAdvisorAutoProxyCreator, InfrastructureAdvisorAutoProxyCreator

public abstract class AbstractAdvisorAutoProxyCreator
extends AbstractAutoProxyCreator

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 AbstractAutoProxyCreator.shouldSkip(java.lang.Class, java.lang.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.

Rod Johnson, Juergen Hoeller
See Also:
findCandidateAdvisors(), Serialized Form

Field Summary
Fields inherited from class org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
Fields inherited from interface org.springframework.core.Ordered
Constructor Summary
Method Summary
protected  void extendAdvisors(List candidateAdvisors)
          Extension hook that subclasses can override to register additional Advisors, given the sorted Advisors obtained to date.
protected  List findCandidateAdvisors()
          Find all candidate advisors to use in auto-proxying.
protected  List findEligibleAdvisors(Class clazz)
          Find all eligible advices for auto-proxying this class.
protected  Object[] getAdvicesAndAdvisorsForBean(Class beanClass, String name, TargetSource targetSource)
          Return whether the given bean is to be proxied, what additional advices (e.g.
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.
 void setBeanFactory(BeanFactory beanFactory)
          Callback that supplies the owning factory to a bean instance.
protected  List sortAdvisors(List advisors)
          Sort advisors based on ordering.
Methods inherited from class org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
buildAdvisors, createProxy, customizeProxyFactory, getBeanFactory, getCacheKey, getCustomTargetSource, getOrder, isFrozen, isInfrastructureClass, isInfrastructureClass, postProcessAfterInitialization, postProcessAfterInstantiation, postProcessBeforeInitialization, postProcessBeforeInstantiation, postProcessPropertyValues, setAdvisorAdapterRegistry, setApplyCommonInterceptorsFirst, setBeanClassLoader, setCustomTargetSourceCreators, setFrozen, setInterceptorNames, setOrder, shouldProxyTargetClass, shouldSkip
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

Constructor Detail


public AbstractAdvisorAutoProxyCreator()
Method Detail


public void setBeanFactory(BeanFactory beanFactory)
Description copied from interface: BeanFactoryAware
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.

Specified by:
setBeanFactory in interface BeanFactoryAware
setBeanFactory in class AbstractAutoProxyCreator
beanFactory - owning BeanFactory (never null). The bean can immediately call methods on the factory.
See Also:


protected void initBeanFactory(ConfigurableListableBeanFactory beanFactory)


protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass,
                                                String name,
                                                TargetSource targetSource)
Description copied from class: AbstractAutoProxyCreator
Return whether the given bean is to be proxied, what additional advices (e.g. AOP Alliance interceptors) and advisors to apply.

Specified by:
getAdvicesAndAdvisorsForBean in class AbstractAutoProxyCreator
beanClass - the class of the bean to advise
name - the name of the bean
targetSource - the TargetSource returned by the AbstractAutoProxyCreator.getCustomTargetSource(java.lang.Class, java.lang.String) method: may be ignored. Will be null if no custom target source is in use.
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.
See Also:


protected List findEligibleAdvisors(Class clazz)
Find all eligible advices for auto-proxying this class.

clazz - the clazz to find advisors for
the empty list, not null, if there are no pointcuts or interceptors
See Also:
findCandidateAdvisors(), sortAdvisors(java.util.List), extendAdvisors(java.util.List)


protected List findCandidateAdvisors()
Find all candidate advisors to use in auto-proxying.

list of candidate Advisors


protected boolean isEligibleAdvisorBean(String beanName)
Return whether the Advisor bean with the given name is eligible for proxying in the first place.

beanName - the name of the Advisor bean
whether the bean is eligible


protected List sortAdvisors(List advisors)
Sort advisors based on ordering. Subclasses may choose to override this method to customize the sorting strategy.

advisors - the source List of Advisors
the sorted List of Advisors
See Also:
Ordered, OrderComparator


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

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

The Spring Framework

Copyright © 2002-2007 The Spring Framework.