|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.aop.framework.ProxyConfig org.springframework.transaction.interceptor.TransactionProxyFactoryBean
Proxy factory bean for simplified declarative transaction handling. Alternative to the standard AOP ProxyFactoryBean with a TransactionInterceptor.
This class is intended to cover the typical case of declarative transaction demarcation: namely, wrapping a (singleton) target object with a transactional proxy, proxying all the interfaces that the target implements.
In contrast to TransactionInterceptor, the transaction attributes are specified as properties, with method names as keys and transaction attribute descriptors as values. Method names are always applied to the target class.
Internally, a TransactionInterceptor instance is used, but the user of this class does not have to care. Optionally, a MethodPointcut can be specified to cause conditional invocation of the underlying TransactionInterceptor.
The preInterceptors and postInterceptors properties can be set to add additional interceptors to the mix, like PerformanceMonitorInterceptor or HibernateInterceptor/JdoInterceptor.
ProxyFactoryBean
,
TransactionInterceptor
,
setTransactionAttributes(java.util.Properties)
Field Summary |
Fields inherited from class org.springframework.aop.framework.ProxyConfig |
exposeProxy, logger |
Constructor Summary | |
TransactionProxyFactoryBean()
|
Method Summary | |
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware). |
protected TargetSource |
createTargetSource(java.lang.Object target)
Set the target or TargetSource. |
java.lang.Object |
getObject()
Return an instance (possibly shared or independent) of the object managed by this factory. |
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? |
void |
setPointcut(Pointcut pointcut)
Set a pointcut, i.e a bean that can cause conditional invocation of the TransactionInterceptor depending on method and attributes passed. |
void |
setPostInterceptors(java.lang.Object[] preInterceptors)
Set additional interceptors (or advisors) to be applied after the implicit transaction interceptor, e.g. |
void |
setPreInterceptors(java.lang.Object[] preInterceptors)
Set additional interceptors (or advisors) to be applied before the implicit transaction interceptor, e.g. |
void |
setProxyInterfaces(java.lang.String[] interfaceNames)
Optional: You only need to set this property to filter the set of interfaces being proxied (default is to pick up all interfaces on the target), or if providing a custom invoker interceptor instead of a target. |
void |
setTarget(java.lang.Object target)
Set the target object, i.e. the bean to be wrapped with a transactional proxy. |
void |
setTransactionAttributes(java.util.Properties transactionAttributes)
Set properties with method names as keys and transaction attribute descriptors (parsed via TransactionAttributeEditor) as values: e.g. key = "myMethod", value = "PROPAGATION_REQUIRED,readOnly". |
void |
setTransactionAttributeSource(TransactionAttributeSource transactionAttributeSource)
Set the transaction attribute source which is used to find transaction attributes. |
void |
setTransactionManager(PlatformTransactionManager transactionManager)
Set the transaction manager. |
Methods inherited from class org.springframework.aop.framework.ProxyConfig |
copyFrom, getAopProxyFactory, getExposeProxy, getOptimize, getProxyTargetClass, isFrozen, setAopProxyFactory, setExposeProxy, setFrozen, setOptimize, setProxyTargetClass, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public TransactionProxyFactoryBean()
Method Detail |
public void setTransactionManager(PlatformTransactionManager transactionManager)
public void setTarget(java.lang.Object target)
TargetSource
,
SingletonTargetSource
public void setProxyInterfaces(java.lang.String[] interfaceNames) throws org.aopalliance.aop.AspectException, java.lang.ClassNotFoundException
If left null (the default), the AOP infrastructure works out which interfaces need proxying.
org.aopalliance.aop.AspectException
java.lang.ClassNotFoundException
public void setTransactionAttributeSource(TransactionAttributeSource transactionAttributeSource)
setTransactionAttributes(java.util.Properties)
,
TransactionAttributeSourceEditor
,
MethodMapTransactionAttributeSource
,
NameMatchTransactionAttributeSource
public void setTransactionAttributes(java.util.Properties transactionAttributes)
Note: Method names are always applied to the target class, no matter if defined in an interface or the class itself.
Internally, a NameMatchTransactionAttributeSource will be created from the given properties.
setTransactionAttributeSource(org.springframework.transaction.interceptor.TransactionAttributeSource)
,
TransactionAttributeEditor
,
NameMatchTransactionAttributeSource
public void setPointcut(Pointcut pointcut)
setPreInterceptors(java.lang.Object[])
,
setPostInterceptors(java.lang.Object[])
public void setPreInterceptors(java.lang.Object[] preInterceptors)
PerformanceMonitorInterceptor
public void setPostInterceptors(java.lang.Object[] preInterceptors)
Note that this is just necessary if you rely on those interceptors in general: HibernateTemplate and JdoTemplate work nicely with JtaTransactionManager through implicit on-demand thread binding.
HibernateInterceptor
,
JdoInterceptor
public void afterPropertiesSet() throws AopConfigException
InitializingBean
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
AopConfigException
protected TargetSource createTargetSource(java.lang.Object target)
target
- target. If this is an implementation of TargetSource it is
used as our TargetSource; otherwise it is wrapped in a SingletonTargetSource.
public java.lang.Object getObject()
FactoryBean
getObject
in interface FactoryBean
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
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |