com.interface21.transaction.interceptor
Class TransactionInterceptor

java.lang.Object
  |
  +--com.interface21.transaction.interceptor.TransactionInterceptor
All Implemented Interfaces:
org.aopalliance.Interceptor, org.aopalliance.MethodInterceptor

public class TransactionInterceptor
extends java.lang.Object
implements org.aopalliance.MethodInterceptor

Interceptor providing declarative transaction management using the common Spring transaction infrastructure. TransactionInterceptors are threadsafe.
Uses the Strategy design pattern. Implementations of the PlatformTransactionManager interface will associate an object with a transaction.
Uses JTA as the default transaction infrastructure.

Version:
$Id: TransactionInterceptor.java,v 1.1 2003/06/13 13:40:39 jhoeller Exp $
Author:
Rod Johnson

Field Summary
protected  org.apache.commons.logging.Log logger
           
static java.lang.String TRANSACTION_STATUS_ATTACHMENT_NAME
          Name of transaction attribute in Invocation.
 
Constructor Summary
TransactionInterceptor()
           
 
Method Summary
 TransactionAttributeSource getTransactionAttributeSource()
           
 PlatformTransactionManager getTransactionManager()
           
 java.lang.Object invoke(org.aopalliance.MethodInvocation invocation)
           
 void setTransactionAttributeSource(TransactionAttributeSource transactionAttributeSource)
          Sets the transactionAttributeSource helper, which is used to find transaction attributes.
 void setTransactionManager(PlatformTransactionManager platformTxManager)
          Sets the platformTxManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSACTION_STATUS_ATTACHMENT_NAME

public static final java.lang.String TRANSACTION_STATUS_ATTACHMENT_NAME
Name of transaction attribute in Invocation. Target classes can use this to find TransactionStatus. NB: the AOP proxy owning this TransactionInterceptor must be set to expose invocations for this to be accessible.

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

TransactionInterceptor

public TransactionInterceptor()
Method Detail

getTransactionManager

public PlatformTransactionManager getTransactionManager()
Returns:
PlatformTransactionManager helper

setTransactionManager

public void setTransactionManager(PlatformTransactionManager platformTxManager)
Sets the platformTxManager. This will perform actual transaction management: this class is just a way of invoking it.
Parameters:
platformTxManager - The platformTxManager to set

getTransactionAttributeSource

public TransactionAttributeSource getTransactionAttributeSource()
Returns:
TransactionAttributeSource helper

setTransactionAttributeSource

public void setTransactionAttributeSource(TransactionAttributeSource transactionAttributeSource)
Sets the transactionAttributeSource helper, which is used to find transaction attributes. The default implementation looks at the metadata attributes associated with the current invocation.
Parameters:
transactionAttributeSource - The transactionAttributeSource to set

invoke

public final java.lang.Object invoke(org.aopalliance.MethodInvocation invocation)
                              throws java.lang.Throwable
Specified by:
invoke in interface org.aopalliance.MethodInterceptor
See Also:
MethodInterceptor.invoke(org.aopalliance.MethodInvocation)


Rod Johnson and Spring contributors 2001-2003.