org.springframework.transaction.interceptor
Class TransactionProxyFactoryBean

org.springframework.aop.framework.ProxyConfig
  |
  +--org.springframework.transaction.interceptor.TransactionProxyFactoryBean

public class TransactionProxyFactoryBean
extends ProxyConfig
implements FactoryBean, InitializingBean

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.

Author:
Juergen Hoeller, Dmitriy Kopylenko, Rod Johnson
Version: $Id: TransactionProxyFactoryBean.java,v 1.20 2004/02/11 17:11:05 jhoeller Exp $
Since: 21.08.2003
See Also: ProxyFactoryBean, TransactionInterceptor, setTransactionAttributes(java.util.Properties)

Method Summary
 voidafterPropertiesSet()
           
 ObjectgetObject()
           
 ClassgetObjectType()
           
 booleanisSingleton()
           
 voidsetPointcut(Pointcut pointcut)
          Set a pointcut, i.e a bean that can cause conditional invocation of the TransactionInterceptor depending on method and attributes passed.
 voidsetPostInterceptors(Object[] preInterceptors)
          Set additional interceptors (or advisors) to be applied after the implicit transaction interceptor, e.g.
 voidsetPreInterceptors(Object[] preInterceptors)
          Set additional interceptors (or advisors) to be applied before the implicit transaction interceptor, e.g.
 voidsetProxyInterfaces(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.
 voidsetTarget(Object target)
          Set the target object, i.e.
 voidsetTransactionAttributes(Properties transactionAttributes)
          Set properties with method names as keys and transaction attribute descriptors (parsed via TransactionAttributeEditor) as values: e.g.
 voidsetTransactionManager(PlatformTransactionManager transactionManager)
          Set the transaction manager.

Methods inherited from class org.springframework.aop.framework.ProxyConfig
copyFrom, getExposeProxy, getOptimize, getProxyTargetClass, setExposeProxy, setOptimize, setProxyTargetClass, toString

Method Detail

afterPropertiesSet

public void afterPropertiesSet()
throws org.springframework.aop.framework.AopConfigException

getObject

public Object getObject()

getObjectType

public Class getObjectType()

isSingleton

public boolean isSingleton()

setPointcut

public 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. Note: Additional interceptors are always invoked.
See Also:
setPreInterceptors(java.lang.Object[]), setPostInterceptors(java.lang.Object[])

setPostInterceptors

public void setPostInterceptors(Object[] preInterceptors)
Set additional interceptors (or advisors) to be applied after the implicit transaction interceptor, e.g. HibernateInterceptors for eagerly binding Sessions to the current thread when using JTA.

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.

See Also:
HibernateInterceptor, JdoInterceptor

setPreInterceptors

public void setPreInterceptors(Object[] preInterceptors)
Set additional interceptors (or advisors) to be applied before the implicit transaction interceptor, e.g. PerformanceMonitorInterceptor.
See Also:
PerformanceMonitorInterceptor

setProxyInterfaces

public void setProxyInterfaces(String[] interfaceNames)
throws AspectException,
java.lang.ClassNotFoundException
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.

If left null (the default), the AOP infrastructure works out which interfaces need proxying.


setTarget

public void setTarget(Object target)
Set the target object, i.e. the bean to be wrapped with a transactional proxy. The target may be any object, in case an InvokerInterceptor will be created. If it is a MethodInterceptor, no wrapper interceptor is created. This enables the use of a pooling target or prototype interceptor etc.

setTransactionAttributes

public void setTransactionAttributes(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".

Note: Method names are always applied to the target class, no matter if defined in an interface or the class itself.

See Also:
TransactionAttributeEditor

setTransactionManager

public void setTransactionManager(PlatformTransactionManager transactionManager)
Set the transaction manager. This will perform actual transaction management: This class is just a way of invoking it.

Association Links

to Class org.springframework.transaction.PlatformTransactionManager

to Class java.lang.Class

to Class java.util.Properties

to Class org.springframework.aop.Pointcut