org.springframework.aop.framework.autoproxy
abstract public class: AbstractAdvisorAutoProxyCreator [javadoc |
source]
java.lang.Object
org.springframework.aop.framework.ProxyConfig
org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator
All Implemented Interfaces:
Ordered, BeanClassLoaderAware, AopInfrastructureBean, SmartInstantiationAwareBeanPostProcessor, BeanFactoryAware, Serializable
Direct Known Subclasses:
AspectJAwareAdvisorAutoProxyCreator, AnnotationAwareAspectJAutoProxyCreator, InfrastructureAdvisorAutoProxyCreator, DefaultAdvisorAutoProxyCreator
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 #shouldSkip method to exclude certain
objects from auto-proxying.
Advisors or advices requiring ordering should implement the
org.springframework.core.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.
Methods from org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator: |
---|
advisorsPreFiltered, buildAdvisors, createProxy, customizeProxyFactory, determineCandidateConstructors, getAdvicesAndAdvisorsForBean, getBeanFactory, getCacheKey, getCustomTargetSource, getEarlyBeanReference, getOrder, isFrozen, isInfrastructureClass, isInfrastructureClass, postProcessAfterInitialization, postProcessAfterInstantiation, postProcessBeforeInitialization, postProcessBeforeInstantiation, postProcessPropertyValues, predictBeanType, setAdvisorAdapterRegistry, setApplyCommonInterceptorsFirst, setBeanClassLoader, setBeanFactory, setCustomTargetSourceCreators, setFrozen, setInterceptorNames, setOrder, setProxyClassLoader, shouldProxyTargetClass, shouldSkip, wrapIfNecessary |
Methods from org.springframework.aop.framework.ProxyConfig: |
---|
copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator Detail: |
protected boolean advisorsPreFiltered() {
return true;
}
This auto-proxy creator always returns pre-filtered Advisors. |
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. |
protected List findAdvisorsThatCanApply(List candidateAdvisors,
Class beanClass,
String beanName) {
ProxyCreationContext.setCurrentProxiedBeanName(beanName);
try {
return AopUtils.findAdvisorsThatCanApply(candidateAdvisors, beanClass);
}
finally {
ProxyCreationContext.setCurrentProxiedBeanName(null);
}
}
Search the given candidate Advisors to find all Advisors that
can apply to the specified bean. |
protected List findCandidateAdvisors() {
return this.advisorRetrievalHelper.findAdvisorBeans();
}
Find all candidate Advisors to use in auto-proxying. |
protected List findEligibleAdvisors(Class beanClass,
String beanName) {
List candidateAdvisors = findCandidateAdvisors();
List eligibleAdvisors = findAdvisorsThatCanApply(candidateAdvisors, beanClass, beanName);
if (!eligibleAdvisors.isEmpty()) {
eligibleAdvisors = sortAdvisors(eligibleAdvisors);
}
extendAdvisors(eligibleAdvisors);
return eligibleAdvisors;
}
Find all eligible Advisors for auto-proxying this class. |
protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass,
String beanName,
TargetSource targetSource) {
List advisors = findEligibleAdvisors(beanClass, beanName);
if (advisors.isEmpty()) {
return DO_NOT_PROXY;
}
return advisors.toArray();
}
|
protected void initBeanFactory(ConfigurableListableBeanFactory beanFactory) {
this.advisorRetrievalHelper = new BeanFactoryAdvisorRetrievalHelperAdapter(beanFactory);
}
|
protected boolean isEligibleAdvisorBean(String beanName) {
return true;
}
Return whether the Advisor bean with the given name is eligible
for proxying in the first place. |
public void setBeanFactory(BeanFactory beanFactory) {
super.setBeanFactory(beanFactory);
if (!(beanFactory instanceof ConfigurableListableBeanFactory)) {
throw new IllegalStateException("Cannot use AdvisorAutoProxyCreator without a ConfigurableListableBeanFactory");
}
initBeanFactory((ConfigurableListableBeanFactory) beanFactory);
}
|
protected List sortAdvisors(List advisors) {
Collections.sort(advisors, new OrderComparator());
return advisors;
}
Sort advisors based on ordering. Subclasses may choose to override this
method to customize the sorting strategy. |