Top Description Fields Constructors Methods
org.springframework.aop.framework.autoproxy

public abstract Class AbstractAutoProxyCreator

extends ProxyProcessorSupport
implements SmartInstantiationAwareBeanPostProcessor, BeanFactoryAware
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.Aware, org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor, org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor, org.springframework.beans.factory.config.BeanPostProcessor
Known Direct Subclasses
org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator, org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator
Annotations
@SuppressWarnings:serial
Imports
java.lang.reflect.Constructor, .Proxy, java.util.ArrayList, .Arrays, .Collections, .List, .Map, .Set, java.util.concurrent.ConcurrentHashMap, org.aopalliance.aop.Advice, org.apache.commons.logging.Log, .LogFactory, org.springframework.aop.Advisor, .Pointcut, .TargetSource, org.springframework.aop.framework.AopInfrastructureBean, .ProxyFactory, .ProxyProcessorSupport, org.springframework.aop.framework.adapter.AdvisorAdapterRegistry, .GlobalAdvisorAdapterRegistry, org.springframework.aop.target.EmptyTargetSource, .SingletonTargetSource, org.springframework.beans.BeansException, .PropertyValues, org.springframework.beans.factory.BeanFactory, .BeanFactoryAware, .FactoryBean, org.springframework.beans.factory.config.ConfigurableBeanFactory, .ConfigurableListableBeanFactory, .SmartInstantiationAwareBeanPostProcessor, org.springframework.core.SmartClassLoader, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils, .StringUtils

org.springframework.beans.factory.config.BeanPostProcessor implementation that wraps each eligible bean with an AOP proxy, delegating to specified interceptors before invoking the bean itself.

This class distinguishes between "common" interceptors: shared for all proxies it creates, and "specific" interceptors: unique per bean instance. There need not be any common interceptors. If there are, they are set using the interceptorNames property. As with org.springframework.aop.framework.ProxyFactoryBean, interceptors names in the current factory are used rather than bean references to allow correct handling of prototype advisors and interceptors: for example, to support stateful mixins. Any advice type is supported for "interceptorNames" entries.

Such auto-proxying is particularly useful if there's a large number of beans that need to be wrapped with similar proxies, i.e. delegating to the same interceptors. Instead of x repetitive proxy definitions for x target beans, you can register one single such post processor with the bean factory to achieve the same effect.

Subclasses can apply any strategy to decide if a bean is to be proxied, e.g. by type, by name, by definition details, etc. They can also return additional interceptors that should just be applied to the specific bean instance. A simple concrete implementation is BeanNameAutoProxyCreator, identifying the beans to be proxied via given names.

Any number of TargetSourceCreator implementations can be used to create a custom target source: for example, to pool prototype objects. Auto-proxying will occur even if there is no advice, as long as a TargetSourceCreator specifies a custom org.springframework.aop.TargetSource. If there are no TargetSourceCreators set, or if none matches, a org.springframework.aop.target.SingletonTargetSource will be used by default to wrap the target bean instance.

Authors
Juergen Hoeller, Rod Johnson, Rob Harrop, Sam Brannen
Since
13.10.2003
See Also
setInterceptorNames, getAdvicesAndAdvisorsForBean, BeanNameAutoProxyCreator, DefaultAdvisorAutoProxyCreator

Field Summary

Modifier and TypeField and Description
private final Map<Object, Boolean>
private AdvisorAdapterRegistry
advisorAdapterRegistry

Default is global AdvisorAdapterRegistry.

private boolean
private BeanFactory
private TargetSourceCreator[]
protected static final Object[]
DO_NOT_PROXY

Convenience constant for subclasses: Return value for "do not proxy".

private final Map<Object, Object>
private boolean
freezeProxy

Indicates whether the proxy should be frozen.

private String[]
interceptorNames

Default is no common interceptors.

protected final Log
logger

Logger available to subclasses.

protected static final Object[]
PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS

Convenience constant for subclasses: Return value for "proxy without additional interceptors, just the common ones".

private final Map<Object, Class<?>>
private final Set<String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean

Returns:

whether the Advisors are pre-filtered
advisorsPreFiltered
()

Return whether the Advisors returned by the subclass are pre-filtered to match the bean's target class already, allowing the ClassFilter check to be skipped when building advisors chains for AOP invocations.

protected Advisor[]

Returns:

the list of Advisors for the given bean
buildAdvisors
(String
the name of the bean
beanName
,
Object[]
the set of interceptors that is specific to this bean (may be empty, but not null)
specificInterceptors
)

Determine the advisors for the given bean, including the specific interceptors as well as the common interceptor, all adapted to the Advisor interface.

private Object
buildProxy(Class<?> beanClass, String beanName, Object[] specificInterceptors, TargetSource targetSource, boolean classOnly)

protected Object

Returns:

the AOP proxy for the bean
createProxy
(Class<?>
the class of the bean
beanClass
,
String
the name of the bean
beanName
,
Object[]
the set of interceptors that is specific to this bean (may be empty, but not null)
specificInterceptors
,
TargetSource
the TargetSource for the proxy, already pre-configured to access the bean
targetSource
)

Create an AOP proxy for the given bean.

private Class<?>
createProxyClass(Class<?> beanClass, String beanName, Object[] specificInterceptors, TargetSource targetSource)

protected void
customizeProxyFactory(ProxyFactory
a ProxyFactory that is already configured with TargetSource and interfaces and will be used to create the proxy immediately after this method returns
proxyFactory
)

Subclasses may choose to implement this: for example, to change the interfaces exposed.

public Class<?>
determineBeanType(Class<?>
the raw class of the bean
beanClass
,
String
the name of the bean
beanName
)

Overrides default org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.determineBeanType.

Determine the type of the bean to be eventually returned from this processor's postProcessBeforeInstantiation callback.
public Constructor<?>[]
determineCandidateConstructors(Class<?>
the raw class of the bean (never null)
beanClass
,
String
the name of the bean
beanName
)

Overrides default org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.determineCandidateConstructors.

Determine the candidate constructors to use for the given bean.
protected abstract Object[]

Returns:

an array of additional interceptors for the particular bean; or an empty array if no additional interceptors but just the common ones; or null if no proxy at all, not even with the common interceptors. See constants DO_NOT_PROXY and PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS.
getAdvicesAndAdvisorsForBean
(Class<?>
the class of the bean to advise
beanClass
,
String
the name of the bean
beanName
,
TargetSource
the TargetSource returned by the getCustomTargetSource method: may be ignored. Will be null if no custom target source is in use.
customTargetSource
)

Return whether the given bean is to be proxied, what additional advices (e.g. AOP Alliance interceptors) and advisors to apply.

protected BeanFactory
getBeanFactory()

Return the owning BeanFactory.

protected Object

Returns:

the cache key for the given class and name
getCacheKey
(Class<?>
the bean class
beanClass
,
String
the bean name
beanName
)

Build a cache key for the given bean class and bean name.

protected TargetSource

Returns:

a TargetSource for this bean
getCustomTargetSource
(Class<?>
the class of the bean to create a TargetSource for
beanClass
,
String
the name of the bean
beanName
)

Create a target source for bean instances.

public Object
getEarlyBeanReference(Object
the raw bean instance
bean
,
String
the name of the bean
beanName
)

Overrides default org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.getEarlyBeanReference.

Obtain a reference for early access to the specified bean, typically for the purpose of resolving a circular reference.
public boolean
isFrozen()

Overrides org.springframework.aop.framework.ProxyConfig.isFrozen.

Return whether the config is frozen, and no advice changes can be made.
protected boolean

Returns:

whether the bean represents an infrastructure class
isInfrastructureClass
(Class<?>
the class of the bean
beanClass
)

Return whether the given bean class represents an infrastructure class that should never be proxied.

public Object
postProcessAfterInitialization(Object
the new bean instance
bean
,
String
the name of the bean
beanName
)

Overrides default org.springframework.beans.factory.config.BeanPostProcessor.postProcessAfterInitialization.

Create a proxy with the configured interceptors if the bean is identified as one to proxy by the subclass.
public Object
postProcessBeforeInstantiation(Class<?>
the class of the bean to be instantiated
beanClass
,
String
the name of the bean
beanName
)

Overrides default org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation.

Apply this BeanPostProcessor before the target bean gets instantiated.
public PropertyValues
postProcessProperties(PropertyValues
the property values that the factory is about to apply (never null)
pvs
,
Object
the bean instance created, but whose properties have not yet been set
bean
,
String
the name of the bean
beanName
)

Overrides default org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor.postProcessProperties.

Post-process the given property values before the factory applies them to the given bean.
public Class<?>
predictBeanType(Class<?>
the raw class of the bean
beanClass
,
String
the name of the bean
beanName
)

Overrides default org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.predictBeanType.

Predict the type of the bean to be eventually returned from this processor's postProcessBeforeInstantiation callback.
private Advisor[]
resolveInterceptorNames()

Resolves the specified interceptor names to Advisor objects.

public void
setAdvisorAdapterRegistry(AdvisorAdapterRegistry advisorAdapterRegistry)

Specify the AdvisorAdapterRegistry to use.

public void
setApplyCommonInterceptorsFirst(boolean applyCommonInterceptorsFirst)

Set whether the common interceptors should be applied before bean-specific ones.

public void
setBeanFactory(BeanFactory
owning BeanFactory (never null). The bean can immediately call methods on the factory.
beanFactory
)

Implements org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

Callback that supplies the owning factory to a bean instance.
public void
setCustomTargetSourceCreators(TargetSourceCreator...
the list of TargetSourceCreators. Ordering is significant: The TargetSource returned from the first matching TargetSourceCreator (that is, the first that returns non-null) will be used.
targetSourceCreators
)

Set custom TargetSourceCreators to be applied in this order.

public void
setFrozen(boolean frozen)

Overrides org.springframework.aop.framework.ProxyConfig.setFrozen.

Set whether the proxy should be frozen, preventing advice from being added to it once it is created.
public void
setInterceptorNames(String... interceptorNames)

Set the common interceptors.

protected boolean

Returns:

whether the given bean should be proxied with its target class
shouldProxyTargetClass
(Class<?>
the class of the bean
beanClass
,
String
the name of the bean
beanName
)

Determine whether the given bean should be proxied with its target class rather than its interfaces.

protected boolean

Returns:

whether to skip the given bean
shouldSkip
(Class<?>
the class of the bean
beanClass
,
String
the name of the bean
beanName
)

Subclasses should override this method to return true if the given bean should not be considered for auto-proxying by this post-processor.

protected Object

Returns:

a proxy wrapping the bean, or the raw bean instance as-is
wrapIfNecessary
(Object
the raw bean instance
bean
,
String
the name of the bean
beanName
,
Object
the cache key for metadata access
cacheKey
)

Wrap the given bean if necessary, i.e. if it is eligible for being proxied.

Inherited from org.springframework.aop.framework.ProxyProcessorSupport:
evaluateProxyInterfacesgetOrdergetProxyClassLoaderisConfigurationCallbackInterfaceisInternalLanguageInterfacesetBeanClassLoadersetOrdersetProxyClassLoader

Field Detail

advisedBeansback to summary
private final Map<Object, Boolean> advisedBeans
advisorAdapterRegistryback to summary
private AdvisorAdapterRegistry advisorAdapterRegistry

Default is global AdvisorAdapterRegistry.

applyCommonInterceptorsFirstback to summary
private boolean applyCommonInterceptorsFirst
beanFactoryback to summary
private BeanFactory beanFactory
Annotations
@Nullable
customTargetSourceCreatorsback to summary
private TargetSourceCreator[] customTargetSourceCreators
Annotations
@Nullable
DO_NOT_PROXYback to summary
protected static final Object[] DO_NOT_PROXY

Convenience constant for subclasses: Return value for "do not proxy".

Annotations
@Nullable
See Also
getAdvicesAndAdvisorsForBean
earlyBeanReferencesback to summary
private final Map<Object, Object> earlyBeanReferences
freezeProxyback to summary
private boolean freezeProxy

Indicates whether the proxy should be frozen. Overridden from super to prevent the configuration from becoming frozen too early.

interceptorNamesback to summary
private String[] interceptorNames

Default is no common interceptors.

loggerback to summary
protected final Log logger

Logger available to subclasses.

PROXY_WITHOUT_ADDITIONAL_INTERCEPTORSback to summary
protected static final Object[] PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS

Convenience constant for subclasses: Return value for "proxy without additional interceptors, just the common ones".

See Also
getAdvicesAndAdvisorsForBean
proxyTypesback to summary
private final Map<Object, Class<?>> proxyTypes
targetSourcedBeansback to summary
private final Set<String> targetSourcedBeans

Constructor Detail

AbstractAutoProxyCreatorback to summary
public AbstractAutoProxyCreator()

Method Detail

advisorsPreFilteredback to summary
protected boolean advisorsPreFiltered()

Return whether the Advisors returned by the subclass are pre-filtered to match the bean's target class already, allowing the ClassFilter check to be skipped when building advisors chains for AOP invocations.

Default is false. Subclasses may override this if they will always return pre-filtered Advisors.

Returns:boolean

whether the Advisors are pre-filtered

See Also
getAdvicesAndAdvisorsForBean, org.springframework.aop.framework.Advised#setPreFiltered
buildAdvisorsback to summary
protected Advisor[] buildAdvisors(String beanName, Object[] specificInterceptors)

Determine the advisors for the given bean, including the specific interceptors as well as the common interceptor, all adapted to the Advisor interface.

Parameters
beanName:String

the name of the bean

specificInterceptors:Object[]

the set of interceptors that is specific to this bean (may be empty, but not null)

Returns:Advisor[]

the list of Advisors for the given bean

buildProxyback to summary
private Object buildProxy(Class<?> beanClass, String beanName, Object[] specificInterceptors, TargetSource targetSource, boolean classOnly)
createProxyback to summary
protected Object createProxy(Class<?> beanClass, String beanName, Object[] specificInterceptors, TargetSource targetSource)

Create an AOP proxy for the given bean.

Parameters
beanClass:Class<?>

the class of the bean

beanName:String

the name of the bean

specificInterceptors:Object[]

the set of interceptors that is specific to this bean (may be empty, but not null)

targetSource:TargetSource

the TargetSource for the proxy, already pre-configured to access the bean

Returns:Object

the AOP proxy for the bean

See Also
buildAdvisors
createProxyClassback to summary
private Class<?> createProxyClass(Class<?> beanClass, String beanName, Object[] specificInterceptors, TargetSource targetSource)
customizeProxyFactoryback to summary
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:ProxyFactory

a ProxyFactory that is already configured with TargetSource and interfaces and will be used to create the proxy immediately after this method returns

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

Overrides default org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.determineBeanType.

Doc from org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.determineBeanType.

Determine the type of the bean to be eventually returned from this processor's postProcessBeforeInstantiation callback.

The default implementation returns the given bean class as-is. Specific implementations should fully evaluate their processing steps in order to create/initialize a potential proxy class upfront.

Parameters
beanClass:Class<?>

the raw class of the bean

beanName:String

the name of the bean

Returns:Class<?>

the type of the bean (never null)

Annotations
@Override
determineCandidateConstructorsback to summary
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName)

Overrides default org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.determineCandidateConstructors.

Doc from org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.determineCandidateConstructors.

Determine the candidate constructors to use for the given bean.

The default implementation returns null.

Parameters
beanClass:Class<?>

the raw class of the bean (never null)

beanName:String

the name of the bean

Returns:Constructor<?>[]

the candidate constructors, or null if none specified

Annotations
@Override
@Nullable
getAdvicesAndAdvisorsForBeanback to summary
protected abstract Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, TargetSource customTargetSource) throws BeansException

Return whether the given bean is to be proxied, what additional advices (e.g. AOP Alliance interceptors) and advisors to apply.

Parameters
beanClass:Class<?>

the class of the bean to advise

beanName:String

the name of the bean

customTargetSource:TargetSource

the TargetSource returned by the getCustomTargetSource method: may be ignored. Will be null if no custom target source is in use.

Returns:Object[]

an array of additional interceptors for the particular bean; or an empty array if no additional interceptors but just the common ones; or null if no proxy at all, not even with the common interceptors. See constants DO_NOT_PROXY and PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS.

Annotations
@Nullable
Exceptions
BeansException:
in case of errors
See Also
DO_NOT_PROXY, PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS
getBeanFactoryback to summary
protected BeanFactory getBeanFactory()

Return the owning BeanFactory. May be null, as this post-processor doesn't need to belong to a bean factory.

Annotations
@Nullable
getCacheKeyback to summary
protected Object getCacheKey(Class<?> beanClass, String beanName)

Build a cache key for the given bean class and bean name.

Note

As of 4.2.3, this implementation does not return a concatenated class/name String anymore but rather the most efficient cache key possible: a plain bean name, prepended with BeanFactory#FACTORY_BEAN_PREFIX in case of a FactoryBean; or if no bean name specified, then the given bean Class as-is.

Parameters
beanClass:Class<?>

the bean class

beanName:String

the bean name

Returns:Object

the cache key for the given class and name

getCustomTargetSourceback to summary
protected TargetSource getCustomTargetSource(Class<?> beanClass, String beanName)

Create a target source for bean instances. Uses any TargetSourceCreators if set. Returns null if no custom TargetSource should be used.

This implementation uses the "customTargetSourceCreators" property. Subclasses can override this method to use a different mechanism.

Parameters
beanClass:Class<?>

the class of the bean to create a TargetSource for

beanName:String

the name of the bean

Returns:TargetSource

a TargetSource for this bean

Annotations
@Nullable
See Also
setCustomTargetSourceCreators
getEarlyBeanReferenceback to summary
public Object getEarlyBeanReference(Object bean, String beanName)

Overrides default org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.getEarlyBeanReference.

Doc from org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.getEarlyBeanReference.

Obtain a reference for early access to the specified bean, typically for the purpose of resolving a circular reference.

This callback gives post-processors a chance to expose a wrapper early - that is, before the target bean instance is fully initialized. The exposed object should be equivalent to the what postProcessBeforeInitialization / postProcessAfterInitialization would expose otherwise. Note that the object returned by this method will be used as bean reference unless the post-processor returns a different wrapper from said post-process callbacks. In other words: Those post-process callbacks may either eventually expose the same reference or alternatively return the raw bean instance from those subsequent callbacks (if the wrapper for the affected bean has been built for a call to this method already, it will be exposes as final bean reference by default).

The default implementation returns the given bean as-is.

Parameters
bean:Object

the raw bean instance

beanName:String

the name of the bean

Returns:Object

the object to expose as bean reference (typically with the passed-in bean instance as default)

Annotations
@Override
isFrozenback to summary
public boolean isFrozen()

Overrides org.springframework.aop.framework.ProxyConfig.isFrozen.

Doc from org.springframework.aop.framework.ProxyConfig.isFrozen.

Return whether the config is frozen, and no advice changes can be made.

Annotations
@Override
isInfrastructureClassback to summary
protected boolean isInfrastructureClass(Class<?> beanClass)

Return whether the given bean class represents an infrastructure class that should never be proxied.

The default implementation considers Advices, Advisors and AopInfrastructureBeans as infrastructure classes.

Parameters
beanClass:Class<?>

the class of the bean

Returns:boolean

whether the bean represents an infrastructure class

See Also
org.aopalliance.aop.Advice, org.springframework.aop.Advisor, org.springframework.aop.framework.AopInfrastructureBean, shouldSkip
postProcessAfterInitializationback to summary
public Object postProcessAfterInitialization(Object bean, String beanName)

Overrides default org.springframework.beans.factory.config.BeanPostProcessor.postProcessAfterInitialization.

Create a proxy with the configured interceptors if the bean is identified as one to proxy by the subclass.

Parameters
bean:Object

Doc from org.springframework.beans.factory.config.BeanPostProcessor.postProcessAfterInitialization.

the new bean instance

beanName:String

Doc from org.springframework.beans.factory.config.BeanPostProcessor.postProcessAfterInitialization.

the name of the bean

Returns:Object

Doc from org.springframework.beans.factory.config.BeanPostProcessor.postProcessAfterInitialization.

the bean instance to use, either the original or a wrapped one; if null, no subsequent BeanPostProcessors will be invoked

Annotations
@Override
See Also
getAdvicesAndAdvisorsForBean
postProcessBeforeInstantiationback to summary
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName)

Overrides default org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation.

Doc from org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation.

Apply this BeanPostProcessor before the target bean gets instantiated. The returned bean object may be a proxy to use instead of the target bean, effectively suppressing default instantiation of the target bean.

If a non-null object is returned by this method, the bean creation process will be short-circuited. The only further processing applied is the postProcessAfterInitialization callback from the configured BeanPostProcessors.

This callback will be applied to bean definitions with their bean class, as well as to factory-method definitions in which case the returned bean type will be passed in here.

Post-processors may implement the extended SmartInstantiationAwareBeanPostProcessor interface in order to predict the type of the bean object that they are going to return here.

The default implementation returns null.

Parameters
beanClass:Class<?>

the class of the bean to be instantiated

beanName:String

the name of the bean

Returns:Object

the bean object to expose instead of a default instance of the target bean, or null to proceed with default instantiation

Annotations
@Override
postProcessPropertiesback to summary
public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName)

Overrides default org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor.postProcessProperties.

Doc from org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor.postProcessProperties.

Post-process the given property values before the factory applies them to the given bean.

The default implementation returns the given pvs as-is.

Parameters
pvs:PropertyValues

the property values that the factory is about to apply (never null)

bean:Object

the bean instance created, but whose properties have not yet been set

beanName:String

the name of the bean

Returns:PropertyValues

the actual property values to apply to the given bean (can be the passed-in PropertyValues instance), or null to skip property population

Annotations
@Override
predictBeanTypeback to summary
public Class<?> predictBeanType(Class<?> beanClass, String beanName)

Overrides default org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.predictBeanType.

Doc from org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor.predictBeanType.

Predict the type of the bean to be eventually returned from this processor's postProcessBeforeInstantiation callback.

The default implementation returns null. Specific implementations should try to predict the bean type as far as known/cached already, without extra processing steps.

Parameters
beanClass:Class<?>

the raw class of the bean

beanName:String

the name of the bean

Returns:Class<?>

the type of the bean, or null if not predictable

Annotations
@Override
@Nullable
resolveInterceptorNamesback to summary
private Advisor[] resolveInterceptorNames()

Resolves the specified interceptor names to Advisor objects.

See Also
setInterceptorNames
setAdvisorAdapterRegistryback to summary
public void setAdvisorAdapterRegistry(AdvisorAdapterRegistry advisorAdapterRegistry)

Specify the AdvisorAdapterRegistry to use.

Default is the global AdvisorAdapterRegistry.

See Also
org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry
setApplyCommonInterceptorsFirstback to summary
public void setApplyCommonInterceptorsFirst(boolean applyCommonInterceptorsFirst)

Set whether the common interceptors should be applied before bean-specific ones. Default is "true"; else, bean-specific interceptors will get applied first.

setBeanFactoryback to summary
public void setBeanFactory(BeanFactory beanFactory)

Implements org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

Doc from org.springframework.beans.factory.BeanFactoryAware.setBeanFactory.

Callback that supplies the owning factory to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean#afterPropertiesSet() or a custom init-method.

Parameters
beanFactory:BeanFactory

owning BeanFactory (never null). The bean can immediately call methods on the factory.

Annotations
@Override
setCustomTargetSourceCreatorsback to summary
public void setCustomTargetSourceCreators(TargetSourceCreator... targetSourceCreators)

Set custom TargetSourceCreators to be applied in this order. If the list is empty, or they all return null, a SingletonTargetSource will be created for each bean.

Note that TargetSourceCreators will kick in even for target beans where no advices or advisors have been found. If a TargetSourceCreator returns a TargetSource for a specific bean, that bean will be proxied in any case.

TargetSourceCreators can only be invoked if this post processor is used in a BeanFactory and its BeanFactoryAware callback is triggered.

Parameters
targetSourceCreators:TargetSourceCreator[]

the list of TargetSourceCreators. Ordering is significant: The TargetSource returned from the first matching TargetSourceCreator (that is, the first that returns non-null) will be used.

setFrozenback to summary
public void setFrozen(boolean frozen)

Overrides org.springframework.aop.framework.ProxyConfig.setFrozen.

Set whether the proxy should be frozen, preventing advice from being added to it once it is created.

Overridden from the superclass to prevent the proxy configuration from being frozen before the proxy is created.

Annotations
@Override
setInterceptorNamesback to summary
public void setInterceptorNames(String... interceptorNames)

Set the common interceptors. These must be bean names in the current factory. They can be of any advice or advisor type Spring supports.

If this property isn't set, there will be zero common interceptors. This is perfectly valid, if "specific" interceptors such as matching Advisors are all we want.

shouldProxyTargetClassback to summary
protected boolean shouldProxyTargetClass(Class<?> beanClass, String beanName)

Determine whether the given bean should be proxied with its target class rather than its interfaces.

Checks the "preserveTargetClass" attribute of the corresponding bean definition.

Parameters
beanClass:Class<?>

the class of the bean

beanName:String

the name of the bean

Returns:boolean

whether the given bean should be proxied with its target class

See Also
AutoProxyUtils#shouldProxyTargetClass
shouldSkipback to summary
protected boolean shouldSkip(Class<?> beanClass, String beanName)

Subclasses should override this method to return true if the given bean should not be considered for auto-proxying by this post-processor.

Sometimes we need to be able to avoid this happening, e.g. if it will lead to a circular reference or if the existing target instance needs to be preserved. This implementation returns false unless the bean name indicates an "original instance" according to AutowireCapableBeanFactory conventions.

Parameters
beanClass:Class<?>

the class of the bean

beanName:String

the name of the bean

Returns:boolean

whether to skip the given bean

See Also
org.springframework.beans.factory.config.AutowireCapableBeanFactory#ORIGINAL_INSTANCE_SUFFIX
wrapIfNecessaryback to summary
protected Object wrapIfNecessary(Object bean, String beanName, Object cacheKey)

Wrap the given bean if necessary, i.e. if it is eligible for being proxied.

Parameters
bean:Object

the raw bean instance

beanName:String

the name of the bean

cacheKey:Object

the cache key for metadata access

Returns:Object

a proxy wrapping the bean, or the raw bean instance as-is