org.axonframework.commandhandling.interceptors
Class SpringTransactionalInterceptor

java.lang.Object
  extended by org.axonframework.commandhandling.interceptors.TransactionInterceptor<org.springframework.transaction.TransactionStatus>
      extended by org.axonframework.commandhandling.interceptors.SpringTransactionalInterceptor
All Implemented Interfaces:
CommandHandlerInterceptor

public class SpringTransactionalInterceptor
extends TransactionInterceptor<org.springframework.transaction.TransactionStatus>

A CommandHandlerInterceptor that uses a PlatformTransactionManager to manage transactions around command handling. If any events are handled synchronously (i.e. in the thread that processes the command), these handlers can use the same transaction.

Since:
0.5
Author:
Allard Buijze
See Also:
PlatformTransactionManager

Constructor Summary
SpringTransactionalInterceptor()
           
 
Method Summary
protected  void commitTransaction(org.springframework.transaction.TransactionStatus transaction)
          Commits the transaction for the command execution described by the given context.
protected  void rollbackTransaction(org.springframework.transaction.TransactionStatus transaction)
          Rolls back a transaction for a command execution described by the given context.
 void setTransactionDefinition(org.springframework.transaction.TransactionDefinition definition)
          Sets the definition of the transaction to use.
 void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
          Sets the transactionManager to use to manage transactions.
protected  org.springframework.transaction.TransactionStatus startTransaction()
          Start a new transaction for a command execution described by the given context.
 
Methods inherited from class org.axonframework.commandhandling.interceptors.TransactionInterceptor
handle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringTransactionalInterceptor

public SpringTransactionalInterceptor()
Method Detail

startTransaction

protected org.springframework.transaction.TransactionStatus startTransaction()
Description copied from class: TransactionInterceptor
Start a new transaction for a command execution described by the given context. The given unitOfWork is the unitOfWork bound to the current thread.

Specified by:
startTransaction in class TransactionInterceptor<org.springframework.transaction.TransactionStatus>
Returns:
A reference to the current transaction

commitTransaction

protected void commitTransaction(org.springframework.transaction.TransactionStatus transaction)
Description copied from class: TransactionInterceptor
Commits the transaction for the command execution described by the given context. The given unitOfWork is the unitOfWork bound to the current thread.

Specified by:
commitTransaction in class TransactionInterceptor<org.springframework.transaction.TransactionStatus>
Parameters:
transaction - The transaction object returned during during TransactionInterceptor.startTransaction()

rollbackTransaction

protected void rollbackTransaction(org.springframework.transaction.TransactionStatus transaction)
Description copied from class: TransactionInterceptor
Rolls back a transaction for a command execution described by the given context. The given unitOfWork is the unitOfWork bound to the current thread.

Specified by:
rollbackTransaction in class TransactionInterceptor<org.springframework.transaction.TransactionStatus>
Parameters:
transaction - The transaction object returned during during TransactionInterceptor.startTransaction()

setTransactionManager

public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
Sets the transactionManager to use to manage transactions.

Parameters:
transactionManager - the transactionManager to use to manage transactions.

setTransactionDefinition

public void setTransactionDefinition(org.springframework.transaction.TransactionDefinition definition)
Sets the definition of the transaction to use.

Defaults to the DefaultTransactionDefinition, which uses propagation "REQUIRED" and the default isolation level of the underlying database.

Parameters:
definition - The transaction definition to use


Copyright © 2011. All Rights Reserved.