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 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. The default concrete implementation is BeanNameAutoProxyCreator, identifying the beans to be proxied via a list of bean names.
Any number of TargetSourceCreator implementations can be used with any subclass, to create a custom target source - for example, to pool prototype objects. Autoproxying will occur even if there is no advice if a TargetSourceCreator specifies a custom TargetSource. If there are no TargetSourceCreators set, or if none matches, a SingletonTargetSource will be used by default to wrap the bean to be autoproxied.
| Field Summary | |
|---|---|
| protected static Object[] |
Convenience constant for subclasses: Return value for "do not proxy". |
| protected static Object[] |
Convenience constant for subclasses: Return value for "proxy without additional interceptors, just the common ones". |
| Fields inherited from org.springframework.aop.frameworkProxyConfig |
|---|
| Constructor Summary |
|---|
|
No description provided. |
| Method Summary | |
|---|---|
| protected Object |
Create an AOP proxy for the given bean. |
| protected void |
Subclasses may choose to implement this: for example, to change the interfaces exposed. |
| protected Object[] |
Return whether the given bean is to be proxied, what additional advices (e.g. |
| protected BeanFactory |
Return the owning BeanFactory May be null, as this object doesn't need to belong to a bean factory.
|
| protected TargetSource |
Create a target source for bean instances. |
| int |
No description provided. |
| boolean |
No description provided. |
| protected boolean |
Return whether the given bean class and bean name represents an infrastructure class that should never be proxied. |
| Object |
Create a proxy with the configured interceptors if the bean is identified as one to proxy by the subclass. |
| Object |
No description provided. |
| Object |
No description provided. |
| void |
Specify the AdvisorAdapterRegistry to use. |
| void |
Set whether the common interceptors should be applied before bean-specific ones. |
| void |
No description provided. |
| void |
Set custom TargetSourceCreators to be applied in this order. |
| void |
Sets whether or not the proxy should be frozen, preventing advice from being added to it once it is created. |
| void |
Set the common interceptors. |
| void |
Set the ordering which will apply to this class's implementation of Ordered, used when applying multiple BeanPostProcessors. |
| protected boolean |
Subclasses should override this method to return true if this bean should not be considered for auto-proxying by this post processor. |
| Methods inherited from java.langObject |
|---|
| Methods inherited from org.springframework.aop.frameworkProxyConfig |
|---|
protected
Object
createProxy
(
Class
beanClass,
String
beanName,
Object
[]
specificInterceptors,
TargetSource
targetSource
)
Default implementation is emty.
protected
Object[]
getAdvicesAndAdvisorsForBean
(
Class
beanClass,
String
beanName,
TargetSource
customTargetSource
)
The previous name of this method was "getInterceptorAndAdvisorForBean". It has been renamed in the course of general terminology clarification in Spring 1.1. An AOP Alliance Interceptor is just a special form of Advice, so the generic Advice term is preferred now.
The third parameter, customTargetSource, is new in Spring 1.1; add it to existing implementations of this method.
null, as this object doesn't need to belong to a bean factory. null if no custom TargetSource should be used.
This implementation uses the "customTargetSourceCreators" property. Subclasses can override this method to use a different mechanism.
public
int
getOrder
(
)
public
boolean
isFrozen
(
)
Default implementation considers Advisors, MethodInterceptors
and AbstractAutoProxyCreators as infrastructure classes, and
consults the shouldSkip method.
public
void
setApplyCommonInterceptorsFirst
(
boolean
applyCommonInterceptorsFirst
)
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 used.
public
void
setFrozen
(
boolean
frozen
)
public
void
setOrder
(
int
order
)
false.