org.springframework.transaction.interceptor
Class TransactionInterceptor

java.lang.Object
  extended byorg.springframework.transaction.interceptor.TransactionInterceptor
All Implemented Interfaces:
org.aopalliance.aop.Advice, InitializingBean, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor

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

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.

Version:
$Id: TransactionInterceptor.java,v 1.20 2004/03/19 21:35:54 johnsonr Exp $
Author:
Rod Johnson, Juergen Hoeller
See Also:
ProxyFactoryBean, TransactionProxyFactoryBean, PlatformTransactionManager

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
TransactionInterceptor()
          Create a new TransactionInterceptor.
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
static TransactionStatus currentTransactionStatus()
          Return the transaction status of the current method invocation.
 TransactionAttributeSource getTransactionAttributeSource()
          Return the transaction attribute source.
 PlatformTransactionManager getTransactionManager()
          Return the transaction manager.
 java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
           
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
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

currentTransactionStatus

public static TransactionStatus currentTransactionStatus()
                                                  throws org.aopalliance.aop.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
org.aopalliance.aop.AspectException

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.


getTransactionManager

public PlatformTransactionManager getTransactionManager()
Return the transaction manager.


setTransactionAttributeSource

public void setTransactionAttributeSource(TransactionAttributeSource transactionAttributeSource)
Set the transaction attribute source which is used to find transaction attributes. If specifying a String property value, a PropertyEditor will create a MethodMapTransactionAttributeSource from the value.

See Also:
TransactionAttributeSourceEditor, MethodMapTransactionAttributeSource, NameMatchTransactionAttributeSource

getTransactionAttributeSource

public TransactionAttributeSource getTransactionAttributeSource()
Return the transaction attribute source.


afterPropertiesSet

public void afterPropertiesSet()
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

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.

Specified by:
afterPropertiesSet in interface InitializingBean

invoke

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


Copyright (C) 2003-2004 The Spring Framework Project.