|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.aop.framework.ProxyConfig
org.springframework.aop.framework.AdvisedSupport
org.springframework.aop.framework.ProxyFactoryBean
FactoryBean implementation for use to source AOP proxies from a Spring BeanFactory.
Interceptors and Advisors are identified by a list of bean names in the current bean factory. These beans should be of type Interceptor or an Advisor subtype (presently InterceptionAroundAdvisor or InterceptionIntroductionAdvisor). The last entry in the list can be the name of any bean in the factory. If it's neither an Interceptor nor a MethodPointcut, a new InvokerInterceptor is added to wrap it.
Global interceptors and advisors can be added at the factory level. The specified ones are expanded in an interceptor list where an "xxx*" entry is included in the list, matching the given prefix with the bean names (e.g. "global*" would match both "globalBean1" and "globalBean2", "*" all defined interceptors). The matching interceptors get applied according to their returned order value, if they implement the Ordered interface. An interceptor name list may not conclude with a global "xxx*" pattern, as global interceptors cannot invoke targets.
Creates a J2SE proxy when proxy interfaces are given, a CGLIB proxy for the actual target class if not. Note that the latter will only work if the target class does not have final methods, as a dynamic subclass will be created at runtime.
It's possible to cast a proxy obtained from this factory to Advisor, or to obtain the ProxyFactoryBean reference and programmatically manipulate it. This won't work for existing prototype references, which are independent. However, it will work for prototypes subsequently obtained from the factory. Changes to interception will work immediately on singletons (including existing references). However, to change interfaces or target it's necessary to obtain a new instance from the factory. This means that singleton instances obtained from the factory do not have the same object identity. However, they do have the same interceptors and target, and changing any reference will change all objects.
setInterceptorNames(java.lang.String[])
,
setProxyInterfaces(java.lang.String[])
,
MethodInterceptor
Field Summary | |
static java.lang.String |
GLOBAL_SUFFIX
This suffix in a value in an interceptor list indicates to expand globals. |
Fields inherited from class org.springframework.aop.framework.AdvisedSupport |
advisorChainFactory, EMPTY_TARGET_SOURCE, targetSource |
Fields inherited from class org.springframework.aop.framework.ProxyConfig |
exposeProxy, logger |
Constructor Summary | |
ProxyFactoryBean()
|
Method Summary | |
void |
activated(AdvisedSupport advisedSupport)
Invoked when first proxy is created |
void |
adviceChanged(AdvisedSupport advisedSupport)
Blow away and recache singleton to allow for advice changes. |
java.lang.Object |
getObject()
Return a proxy. |
java.lang.Class |
getObjectType()
Return the type of object that this FactoryBean creates, or null if not known in advance. |
boolean |
isSingleton()
Is the bean managed by this factory a singleton or a prototype? That is, will getObject() always return the same object? |
void |
setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance. |
void |
setInterceptorNames(java.lang.String[] interceptorNames)
Set the list of Interceptor/Advisor bean names. |
void |
setProxyInterfaces(java.lang.String[] interfaceNames)
Set the names of the interfaces we're proxying. |
void |
setSingleton(boolean singleton)
Set the value of the singleton property. |
Methods inherited from class org.springframework.aop.framework.ProxyConfig |
copyFrom, getAopProxyFactory, getExposeProxy, getOptimize, getProxyTargetClass, isFrozen, setAopProxyFactory, setExposeProxy, setFrozen, setOptimize, setProxyTargetClass |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.aop.framework.Advised |
getExposeProxy, getProxyTargetClass, isFrozen |
Field Detail |
public static final java.lang.String GLOBAL_SUFFIX
Constructor Detail |
public ProxyFactoryBean()
Method Detail |
public void setProxyInterfaces(java.lang.String[] interfaceNames) throws org.aopalliance.aop.AspectException, java.lang.ClassNotFoundException
org.aopalliance.aop.AspectException
java.lang.ClassNotFoundException
public void setInterceptorNames(java.lang.String[] interceptorNames)
public void setSingleton(boolean singleton)
singleton
- public void setBeanFactory(BeanFactory beanFactory) throws BeansException
BeanFactoryAware
Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method.
setBeanFactory
in interface BeanFactoryAware
beanFactory
- owning BeanFactory (may not be null).
The bean can immediately call methods on the factory.
BeansException
- in case of initialization errorsBeanInitializationException
public java.lang.Object getObject() throws BeansException
getObject
in interface FactoryBean
BeansException
FactoryBean.getObject()
public java.lang.Class getObjectType()
FactoryBean
For a singleton, this can simply return getObject().getClass(), or even null, as autowiring will always check the actual objects for singletons. For prototypes, returning a meaningful type here is highly advisable, as autowiring will simply ignore them else.
getObjectType
in interface FactoryBean
ListableBeanFactory.getBeansOfType(java.lang.Class, boolean, boolean)
public boolean isSingleton()
FactoryBean
The singleton status of the FactoryBean itself will generally be provided by the owning BeanFactory.
isSingleton
in interface FactoryBean
public void activated(AdvisedSupport advisedSupport)
AdvisedSupportListener
activated
in interface AdvisedSupportListener
advisedSupport
- AdvisedSupportListener.activated(org.springframework.aop.framework.AdvisedSupport)
public void adviceChanged(AdvisedSupport advisedSupport)
adviceChanged
in interface AdvisedSupportListener
advisedSupport
- AdvisedSupportListener.adviceChanged(org.springframework.aop.framework.AdvisedSupport)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |