Package org.springframework.aop.framework

# Class AbstractAdvisingBeanPostProcessor

java.lang.Object
org.springframework.aop.framework.ProxyConfig
org.springframework.aop.framework.ProxyProcessorSupport
org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor

All Implemented Interfaces:
  `Serializable`, `AopInfrastructureBean`, `org.springframework.beans.factory.Aware`, `org.springframework.beans.factory.BeanClassLoaderAware`, `org.springframework.beans.factory.config.BeanPostProcessor`, `org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor`, `org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor`, `org.springframework.core.Ordered`

Direct Known Subclasses:
  `AbstractBeanFactoryAwareAdvisingPostProcessor`

public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSupport implements org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor
Base class for `BeanPostProcessor` implementations that apply a Spring AOP `Advisor` to specific beans.

Since:
  3.2
Author:
  Juergen Hoeller
See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Advisor`
`advisor`
`protected boolean`
`beforeExistingAdvisors`

### Fields inherited from interface org.springframework.core.Ordered

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

## Constructor Summary

Constructors
Constructor
Description
`AbstractAdvisingBeanPostProcessor()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`customizeProxyFactory(ProxyFactory proxyFactory)`
Subclasses may choose to implement this: for example, to change the interfaces exposed.
`Class<?>`
`determineBeanType(Class<?> beanClass, String beanName)`
`protected boolean`
`isEligible(Class<?> targetClass)`
Check whether the given class is eligible for advising with this post-processor's `Advisor`.
`protected boolean`
`isEligible(Object bean, String beanName)`
Check whether the given bean is eligible for advising with this post-processor's `Advisor`.
`Object`
`postProcessAfterInitialization(Object bean, String beanName)`
`protected ProxyFactory`
`prepareProxyFactory(Object bean, String beanName)`
Prepare a `ProxyFactory` for the given bean.
`void`
`setBeforeExistingAdvisors(boolean beforeExistingAdvisors)`
Set whether this post-processor's advisor is supposed to apply before existing advisors when encountering a pre-advised object.

### Methods inherited from class org.springframework.aop.framework.ProxyProcessorSupport

`evaluateProxyInterfaces, getOrder, getProxyClassLoader, isConfigurationCallbackInterface, isInternalLanguageInterface, setBeanClassLoader, setOrder, setProxyClassLoader`

### Methods inherited from class org.springframework.aop.framework.ProxyConfig

`copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.beans.factory.config.BeanPostProcessor

`postProcessBeforeInitialization`

### Methods inherited from interface org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor

`postProcessAfterInstantiation, postProcessBeforeInstantiation, postProcessProperties`

### Methods inherited from interface org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor

`determineCandidateConstructors, getEarlyBeanReference, predictBeanType`

## Field Details

### advisor

@Nullable protected Advisor advisor

### beforeExistingAdvisors

protected boolean beforeExistingAdvisors

## Constructor Details

### AbstractAdvisingBeanPostProcessor

public AbstractAdvisingBeanPostProcessor()

## Method Details

### setBeforeExistingAdvisors

public void setBeforeExistingAdvisors(boolean beforeExistingAdvisors)
Set whether this post-processor's advisor is supposed to apply before existing advisors when encountering a pre-advised object.

Default is "false", applying the advisor after existing advisors, i.e. as close as possible to the target method. Switch this to "true" in order for this post-processor's advisor to wrap existing advisors as well.

Note: Check the concrete post-processor's javadoc whether it possibly changes this flag by default, depending on the nature of its advisor.

### determineBeanType

public Class<?> determineBeanType(Class<?> beanClass, String beanName)

Specified by:
  `determineBeanType` in interface `org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor`

### postProcessAfterInitialization

public Object postProcessAfterInitialization(Object bean, String beanName)

Specified by:
  `postProcessAfterInitialization` in interface `org.springframework.beans.factory.config.BeanPostProcessor`

### isEligible

protected boolean isEligible(Object bean, String beanName)
Check whether the given bean is eligible for advising with this post-processor's `Advisor`.

Delegates to `isEligible(Class)` for target class checking. Can be overridden, for example, 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, `isEligible(Class)` is being called directly, with the actual target class behind the existing proxy (as determined by `AopUtils.getTargetClass(Object)`).

Parameters:
  `bean` - the bean instance
  `beanName` - the name of the bean
See Also:
  - `isEligible(Class)`

### isEligible

protected boolean isEligible(Class<?> targetClass)
Check whether the given class is eligible for advising with this post-processor's `Advisor`.

Implements caching of `canApply` results per bean target class.

Parameters:
  `targetClass` - the class to check against
See Also:
  - `AopUtils.canApply(Advisor, Class)`

### prepareProxyFactory

protected ProxyFactory prepareProxyFactory(Object bean, String beanName)
Prepare a `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; `customizeProxyFactory(org.springframework.aop.framework.ProxyFactory)` allows for late customizations of those parts right before proxy creation.

Parameters:
  `bean` - the bean instance to create a proxy for
  `beanName` - the corresponding bean name
Returns:
  the ProxyFactory, initialized with this processor's `ProxyConfig` settings and the specified bean
Since:
  4.2.3
See Also:
  - `customizeProxyFactory(org.springframework.aop.framework.ProxyFactory)`

### customizeProxyFactory

protected void customizeProxyFactory(ProxyFactory proxyFactory)
Subclasses may choose to implement this: for example, to change the interfaces exposed.

The default implementation is empty.

Parameters:
  `proxyFactory` - the ProxyFactory that is already configured with target, advisor and interfaces and will be used to create the proxy immediately after this method returns
Since:
  4.2.3
See Also:
  - `prepareProxyFactory(java.lang.Object, java.lang.String)`