The Spring Framework

org.springframework.aop.framework.autoproxy
Class AbstractAdvisorAutoProxyCreator

java.lang.Object
  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, BeanFactoryAware, BeanPostProcessor, InstantiationAwareBeanPostProcessor, Ordered
Direct Known Subclasses:
AspectJAwareAdvisorAutoProxyCreator, DefaultAdvisorAutoProxyCreator

public abstract class AbstractAdvisorAutoProxyCreator
extends AbstractAutoProxyCreator

Abstract BeanPostProcessor implementation that creates AOP proxies. This class is completely generic; it contains no special code to handle any particular aspects, such as pooling aspects.

Subclasses must implement the abstract findCandidateAdvisors() method to return a list of Advisors applying to any object. Subclasses can also override the inherited shouldSkip method to exclude certain objects from auto-proxying, but they must be careful to invoke the base shouldSkip method, which tries to avoid circular reference problems and infinite loops.

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 to be unordered, and will appear at the end of the advisor chain in undefined order.

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

Field Summary
 
Fields inherited from class org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
DO_NOT_PROXY, PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS
 
Fields inherited from class org.springframework.aop.framework.ProxyConfig
exposeProxy, logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AbstractAdvisorAutoProxyCreator()
           
 
Method Summary
protected  void extendAdvisors(List candidateAdvisors)
          Extension hook that subclasses can choose 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  boolean isEligibleAdvisorBean(String beanName)
          Return whether the Advisor bean with the given name is eligible for proxying in the first place.
protected  List sortAdvisors(List advisors)
          Sort advisors based on ordering.
 
Methods inherited from class org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
createProxy, customizeProxyFactory, getBeanFactory, getCustomTargetSource, getOrder, isFrozen, isInfrastructureClass, isInfrastructureClass, postProcessAfterInitialization, postProcessAfterInstantiation, postProcessBeforeInitialization, postProcessBeforeInstantiation, postProcessPropertyValues, setAdvisorAdapterRegistry, setApplyCommonInterceptorsFirst, setBeanFactory, setCustomTargetSourceCreators, setFrozen, setInterceptorNames, setOrder, shouldSkip
 
Methods inherited from class org.springframework.aop.framework.ProxyConfig
copyFrom, getAopProxyFactory, isExposeProxy, isOpaque, isOptimize, isProxyTargetClass, setAopProxyFactory, setExposeProxy, setOpaque, setOptimize, setProxyTargetClass, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractAdvisorAutoProxyCreator

public AbstractAdvisorAutoProxyCreator()
Method Detail

getAdvicesAndAdvisorsForBean

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.

The previous name of this method was "getInterceptorAndAdvisorForBean". It has been renamed in the course of general terminology clarification in Spring 1.1. An AOP Alliance Interceptor is just a special form of Advice, so the generic Advice term is preferred now.

The third parameter, customTargetSource, is new in Spring 1.1; add it to existing implementations of this method.

Specified by:
getAdvicesAndAdvisorsForBean in class AbstractAutoProxyCreator
Parameters:
beanClass - the class of the bean to advise
name - the name of the bean
targetSource - targetSource returned by getTargetSource() method: may be ignored. Will be null unless a 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.
See Also:
AbstractAutoProxyCreator.postProcessAfterInitialization(java.lang.Object, java.lang.String), AbstractAutoProxyCreator.DO_NOT_PROXY, AbstractAutoProxyCreator.PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS

findEligibleAdvisors

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

Returns:
the empty list, not null, if there are no pointcuts or interceptors
See Also:
findCandidateAdvisors(), sortAdvisors(java.util.List), extendAdvisors(java.util.List)

findCandidateAdvisors

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

Returns:
list of candidate Advisors

isEligibleAdvisorBean

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

sortAdvisors

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

See Also:
Ordered, OrderComparator

extendAdvisors

protected void extendAdvisors(List candidateAdvisors)
Extension hook that subclasses can choose 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

The Spring Framework

Copyright © 2002-2006 The Spring Framework.