public abstract class AbstractBeanFactoryAwareAdvisingPostProcessor extends AbstractAdvisingBeanPostProcessor implements BeanFactoryAware
AbstractAutoProxyCreator
which implements BeanFactoryAware
,
adds exposure of the original target class for each proxied bean
(AutoProxyUtils.ORIGINAL_TARGET_CLASS_ATTRIBUTE
),
and participates in an externally enforced target-class mode for any given bean
(AutoProxyUtils.PRESERVE_TARGET_CLASS_ATTRIBUTE
).
This post-processor is therefore aligned with AbstractAutoProxyCreator
.AutoProxyUtils.shouldProxyTargetClass(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.lang.String)
,
AutoProxyUtils.determineTargetClass(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.lang.String)
,
Serialized Formadvisor, beforeExistingAdvisors
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
AbstractBeanFactoryAwareAdvisingPostProcessor() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
isEligible(Object bean,
String beanName)
Check whether the given bean is eligible for advising with this
post-processor's
Advisor . |
protected ProxyFactory |
prepareProxyFactory(Object bean,
String beanName)
Prepare a
ProxyFactory for the given bean. |
void |
setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance.
|
customizeProxyFactory, isEligible, postProcessAfterInitialization, postProcessBeforeInitialization, setBeforeExistingAdvisors
evaluateProxyInterfaces, getOrder, getProxyClassLoader, isConfigurationCallbackInterface, isInternalLanguageInterface, setBeanClassLoader, setOrder, setProxyClassLoader
copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString
public AbstractBeanFactoryAwareAdvisingPostProcessor()
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
beanFactory
- owning BeanFactory (never null
).
The bean can immediately call methods on the factory.BeanInitializationException
protected ProxyFactory prepareProxyFactory(Object bean, String beanName)
AbstractAdvisingBeanPostProcessor
ProxyFactory
for the given bean.
Subclasses may customize the handling of the target instance and in
particular the exposure of the target class. The default introspection
of interfaces for non-target-class proxies and the configured advisor
will be applied afterwards; AbstractAdvisingBeanPostProcessor.customizeProxyFactory(org.springframework.aop.framework.ProxyFactory)
allows for
late customizations of those parts right before proxy creation.
prepareProxyFactory
in class AbstractAdvisingBeanPostProcessor
bean
- the bean instance to create a proxy forbeanName
- the corresponding bean nameProxyConfig
settings and the specified beanAbstractAdvisingBeanPostProcessor.customizeProxyFactory(org.springframework.aop.framework.ProxyFactory)
protected boolean isEligible(Object bean, String beanName)
AbstractAdvisingBeanPostProcessor
Advisor
.
Delegates to AbstractAdvisingBeanPostProcessor.isEligible(Class)
for target class checking.
Can be overridden e.g. to specifically exclude certain beans by name.
Note: Only called for regular bean instances but not for existing
proxy instances which implement Advised
and allow for adding
the local Advisor
to the existing proxy's Advisor
chain.
For the latter, AbstractAdvisingBeanPostProcessor.isEligible(Class)
is being called directly,
with the actual target class behind the existing proxy (as determined
by AopUtils.getTargetClass(Object)
).
isEligible
in class AbstractAdvisingBeanPostProcessor
bean
- the bean instancebeanName
- the name of the beanAbstractAdvisingBeanPostProcessor.isEligible(Class)