public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig implements BeanPostProcessor, BeanClassLoaderAware, Ordered
BeanPostProcessor
implementations that apply a
Spring AOP Advisor
to specific beans.Modifier and Type | Field and Description |
---|---|
protected Advisor |
advisor |
private java.lang.ClassLoader |
beanClassLoader |
private java.util.Map<java.lang.String,java.lang.Boolean> |
eligibleBeans |
private int |
order
This should run after all other post-processors, so that it can just add
an advisor to existing proxies rather than double-proxy.
|
exposeProxy, opaque
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
AbstractAdvisingBeanPostProcessor() |
Modifier and Type | Method and Description |
---|---|
int |
getOrder()
Return the order value of this object, with a
higher value meaning greater in terms of sorting.
|
protected boolean |
isEligible(java.lang.Object bean,
java.lang.String beanName)
Check whether the given bean is eligible for advising with this
post-processor's
Advisor . |
java.lang.Object |
postProcessAfterInitialization(java.lang.Object bean,
java.lang.String beanName)
Apply this BeanPostProcessor to the given new bean instance after any bean
initialization callbacks (like InitializingBean's
afterPropertiesSet
or a custom init-method). |
java.lang.Object |
postProcessBeforeInitialization(java.lang.Object bean,
java.lang.String beanName)
Apply this BeanPostProcessor to the given new bean instance before any bean
initialization callbacks (like InitializingBean's
afterPropertiesSet
or a custom init-method). |
void |
setBeanClassLoader(java.lang.ClassLoader beanClassLoader)
Callback that supplies the bean
class loader to
a bean instance. |
void |
setOrder(int order) |
copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString
protected Advisor advisor
private java.lang.ClassLoader beanClassLoader
private int order
private final java.util.Map<java.lang.String,java.lang.Boolean> eligibleBeans
public void setBeanClassLoader(java.lang.ClassLoader beanClassLoader)
BeanClassLoaderAware
class loader
to
a bean instance.
Invoked after the population of normal bean properties but
before an initialization callback such as
InitializingBean's
InitializingBean.afterPropertiesSet()
method or a custom init-method.
setBeanClassLoader
in interface BeanClassLoaderAware
beanClassLoader
- the owning class loader; may be null
in
which case a default ClassLoader
must be used, for example
the ClassLoader
obtained via
ClassUtils.getDefaultClassLoader()
public void setOrder(int order)
public int getOrder()
Ordered
Normally starting with 0, with Integer.MAX_VALUE
indicating the greatest value. Same order values will result
in arbitrary positions for the affected objects.
Higher values can be interpreted as lower priority. As a consequence, the object with the lowest value has highest priority (somewhat analogous to Servlet "load-on-startup" values).
public java.lang.Object postProcessBeforeInitialization(java.lang.Object bean, java.lang.String beanName)
BeanPostProcessor
afterPropertiesSet
or a custom init-method). The bean will already be populated with property values.
The returned bean instance may be a wrapper around the original.postProcessBeforeInitialization
in interface BeanPostProcessor
bean
- the new bean instancebeanName
- the name of the beannull
, no subsequent BeanPostProcessors will be invokedInitializingBean.afterPropertiesSet()
public java.lang.Object postProcessAfterInitialization(java.lang.Object bean, java.lang.String beanName)
BeanPostProcessor
afterPropertiesSet
or a custom init-method). The bean will already be populated with property values.
The returned bean instance may be a wrapper around the original.
In case of a FactoryBean, this callback will be invoked for both the FactoryBean
instance and the objects created by the FactoryBean (as of Spring 2.0). The
post-processor can decide whether to apply to either the FactoryBean or created
objects or both through corresponding bean instanceof FactoryBean
checks.
This callback will also be invoked after a short-circuiting triggered by a
InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation(java.lang.Class<?>, java.lang.String)
method,
in contrast to all other BeanPostProcessor callbacks.
postProcessAfterInitialization
in interface BeanPostProcessor
bean
- the new bean instancebeanName
- the name of the beannull
, no subsequent BeanPostProcessors will be invokedInitializingBean.afterPropertiesSet()
,
FactoryBean
protected boolean isEligible(java.lang.Object bean, java.lang.String beanName)
Advisor
.
Implements caching of canApply
results per bean name.
bean
- the bean instancebeanName
- the name of the beanAopUtils.canApply(Advisor, Class)