org.springframework.transaction.interceptor
Class TransactionInterceptor


public class TransactionInterceptor
implements InitializingBean, MethodInterceptor

Interceptor providing declarative transaction management using the common Spring transaction infrastructure. TransactionInterceptors are thread-safe.

Uses the Strategy design pattern. A PlatformTransactionManager implementation will perform the actual transaction management.

This class could set JTA as default transaction manager as that implementation does not need any specific configuration. JTA is not the default though to avoid unnecessary dependencies.

Author:
Rod Johnson
Version: $Id: TransactionInterceptor.java,v 1.17 2004/02/04 17:10:13 jhoeller Exp $
See Also: ProxyFactoryBean, TransactionProxyFactoryBean, PlatformTransactionManager

Constructor Summary
TransactionInterceptor()
          Create a new TransactionInterceptor.

Method Summary
 voidafterPropertiesSet()
           
 static TransactionStatuscurrentTransactionStatus()
          Return the transaction status of the current method invocation.
 TransactionAttributeSourcegetTransactionAttributeSource()
          Return the transaction attribute source.
 PlatformTransactionManagergetTransactionManager()
          Return the transaction manager.
 final Objectinvoke(MethodInvocation invocation)
           
 voidsetTransactionAttributeSource(TransactionAttributeSource transactionAttributeSource)
          Set the transaction attribute source which is used to find transaction attributes.
 voidsetTransactionManager(PlatformTransactionManager transactionManager)
          Set the transaction manager.

Constructor Detail

TransactionInterceptor

public TransactionInterceptor()
Create a new TransactionInterceptor. Does not set a default transaction manager!
See Also:
setTransactionManager(org.springframework.transaction.PlatformTransactionManager), setTransactionAttributeSource(org.springframework.transaction.interceptor.TransactionAttributeSource)
Method Detail

afterPropertiesSet

public void afterPropertiesSet()

currentTransactionStatus

public static TransactionStatus currentTransactionStatus()
throws AspectException
Return the transaction status of the current method invocation. Mainly intended for code that wants to set the current transaction rollback-only but not throw an application exception.
Throws:
NoTransactionException if - the invocation cannot be found, because the method was invoked outside an AOP invocation context

getTransactionAttributeSource

public TransactionAttributeSource getTransactionAttributeSource()
Return the transaction attribute source.

getTransactionManager

public PlatformTransactionManager getTransactionManager()
Return the transaction manager.

invoke

public final Object invoke(MethodInvocation invocation)
throws java.lang.Throwable

setTransactionAttributeSource

public void setTransactionAttributeSource(TransactionAttributeSource transactionAttributeSource)
Set the transaction attribute source which is used to find transaction attributes. The default implementation looks at the metadata attributes associated with the current invocation.

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 java.lang.ThreadLocal

Holder to support the currentTransactionStatus() method

to Class org.springframework.transaction.PlatformTransactionManager

Delegate used to create, commit and rollback transactions

to Class org.springframework.transaction.interceptor.TransactionAttributeSource

Helper used to find transaction attributes