public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyCreator
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.
findCandidateAdvisors()
,
Serialized FormDO_NOT_PROXY, logger, PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
AbstractAdvisorAutoProxyCreator() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
advisorsPreFiltered()
This auto-proxy creator always returns pre-filtered Advisors.
|
protected void |
extendAdvisors(java.util.List<Advisor> candidateAdvisors)
Extension hook that subclasses can override to register additional Advisors,
given the sorted Advisors obtained to date.
|
protected java.util.List<Advisor> |
findAdvisorsThatCanApply(java.util.List<Advisor> candidateAdvisors,
java.lang.Class<?> beanClass,
java.lang.String beanName)
Search the given candidate Advisors to find all Advisors that
can apply to the specified bean.
|
protected java.util.List<Advisor> |
findCandidateAdvisors()
Find all candidate Advisors to use in auto-proxying.
|
protected java.util.List<Advisor> |
findEligibleAdvisors(java.lang.Class<?> beanClass,
java.lang.String beanName)
Find all eligible Advisors for auto-proxying this class.
|
protected java.lang.Object[] |
getAdvicesAndAdvisorsForBean(java.lang.Class<?> beanClass,
java.lang.String beanName,
TargetSource targetSource)
Return whether the given bean is to be proxied, what additional
advices (e.g.
|
protected void |
initBeanFactory(ConfigurableListableBeanFactory beanFactory) |
protected boolean |
isEligibleAdvisorBean(java.lang.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 java.util.List<Advisor> |
sortAdvisors(java.util.List<Advisor> advisors)
Sort advisors based on ordering.
|
buildAdvisors, createProxy, customizeProxyFactory, determineCandidateConstructors, getBeanFactory, getCacheKey, getCustomTargetSource, getEarlyBeanReference, isFrozen, isInfrastructureClass, postProcessAfterInitialization, postProcessAfterInstantiation, postProcessBeforeInitialization, postProcessBeforeInstantiation, postProcessPropertyValues, predictBeanType, setAdvisorAdapterRegistry, setApplyCommonInterceptorsFirst, setCustomTargetSourceCreators, setFrozen, setInterceptorNames, shouldProxyTargetClass, shouldSkip, wrapIfNecessary
evaluateProxyInterfaces, getOrder, getProxyClassLoader, isConfigurationCallbackInterface, isInternalLanguageInterface, setBeanClassLoader, setOrder, setProxyClassLoader
copyFrom, isExposeProxy, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setOpaque, setOptimize, setProxyTargetClass, toString
public void setBeanFactory(BeanFactory beanFactory)
BeanFactoryAware
Invoked after the population of normal bean properties
but before an initialization callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method.
setBeanFactory
in interface BeanFactoryAware
setBeanFactory
in class AbstractAutoProxyCreator
beanFactory
- owning BeanFactory (never null
).
The bean can immediately call methods on the factory.BeanInitializationException
protected void initBeanFactory(ConfigurableListableBeanFactory beanFactory)
protected java.lang.Object[] getAdvicesAndAdvisorsForBean(java.lang.Class<?> beanClass, java.lang.String beanName, TargetSource targetSource)
AbstractAutoProxyCreator
getAdvicesAndAdvisorsForBean
in class AbstractAutoProxyCreator
beanClass
- the class of the bean to advisebeanName
- the name of the beantargetSource
- 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.null
if no proxy at all, not even with the common interceptors.
See constants DO_NOT_PROXY and PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS.AbstractAutoProxyCreator.DO_NOT_PROXY
,
AbstractAutoProxyCreator.PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS
protected java.util.List<Advisor> findEligibleAdvisors(java.lang.Class<?> beanClass, java.lang.String beanName)
beanClass
- the clazz to find advisors forbeanName
- the name of the currently proxied beannull
,
if there are no pointcuts or interceptorsfindCandidateAdvisors()
,
sortAdvisors(java.util.List<org.springframework.aop.Advisor>)
,
extendAdvisors(java.util.List<org.springframework.aop.Advisor>)
protected java.util.List<Advisor> findCandidateAdvisors()
protected java.util.List<Advisor> findAdvisorsThatCanApply(java.util.List<Advisor> candidateAdvisors, java.lang.Class<?> beanClass, java.lang.String beanName)
candidateAdvisors
- the candidate AdvisorsbeanClass
- the target's bean classbeanName
- the target's bean nameProxyCreationContext.getCurrentProxiedBeanName()
protected boolean isEligibleAdvisorBean(java.lang.String beanName)
beanName
- the name of the Advisor beanprotected java.util.List<Advisor> sortAdvisors(java.util.List<Advisor> advisors)
advisors
- the source List of AdvisorsOrdered
,
Order
,
AnnotationAwareOrderComparator
protected void extendAdvisors(java.util.List<Advisor> candidateAdvisors)
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 beanprotected boolean advisorsPreFiltered()
advisorsPreFiltered
in class AbstractAutoProxyCreator
AbstractAutoProxyCreator.getAdvicesAndAdvisorsForBean(java.lang.Class<?>, java.lang.String, org.springframework.aop.TargetSource)
,
Advised.setPreFiltered(boolean)