org.axonframework.unitofwork
Class SpringTransactionManager

java.lang.Object
  extended by org.axonframework.unitofwork.SpringTransactionManager
All Implemented Interfaces:
TransactionManager<org.springframework.transaction.TransactionStatus>

public class SpringTransactionManager
extends Object
implements TransactionManager<org.springframework.transaction.TransactionStatus>

TransactionManager implementation that uses a PlatformTransactionManager as underlying transaction manager.

Since:
2.0
Author:
Allard Buijze

Constructor Summary
SpringTransactionManager()
          Default constructor.
SpringTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
          Initializes the SpringTransactionManager with the given transactionManager and the default transaction definition.
SpringTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager, org.springframework.transaction.TransactionDefinition transactionDefinition)
           
 
Method Summary
 void commitTransaction(org.springframework.transaction.TransactionStatus tx)
          Commits the transaction identifier by given transactionStatus.
 void rollbackTransaction(org.springframework.transaction.TransactionStatus tx)
          Rolls back the transaction identifier by given transactionStatus.
 void setTransactionDefinition(org.springframework.transaction.TransactionDefinition transactionDefinition)
          The TransactionDefinition to use by the transaction manager.
 void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
          The PlatformTransactionManager that manages the transactions with the underlying data source.
 org.springframework.transaction.TransactionStatus startTransaction()
          Starts a transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringTransactionManager

public SpringTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager,
                                org.springframework.transaction.TransactionDefinition transactionDefinition)
Parameters:
transactionManager - The transaction manager to use
transactionDefinition - The definition for transactions to create

SpringTransactionManager

public SpringTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
Initializes the SpringTransactionManager with the given transactionManager and the default transaction definition.

Parameters:
transactionManager - the transaction manager to use

SpringTransactionManager

public SpringTransactionManager()
Default constructor. Requires the transaction manager to be set using setter injection.

Method Detail

startTransaction

public org.springframework.transaction.TransactionStatus startTransaction()
Description copied from interface: TransactionManager
Starts a transaction. The return value is an object representing the transaction status and must be passed as an argument when invoking TransactionManager.commitTransaction(Object) or TransactionManager.rollbackTransaction(Object).

The returned object must never be null if a transaction was successfully created.

Specified by:
startTransaction in interface TransactionManager<org.springframework.transaction.TransactionStatus>
Returns:
The object representing the transaction status

commitTransaction

public void commitTransaction(org.springframework.transaction.TransactionStatus tx)
Description copied from interface: TransactionManager
Commits the transaction identifier by given transactionStatus.

Specified by:
commitTransaction in interface TransactionManager<org.springframework.transaction.TransactionStatus>
Parameters:
tx - The status object provided by TransactionManager.startTransaction().

rollbackTransaction

public void rollbackTransaction(org.springframework.transaction.TransactionStatus tx)
Description copied from interface: TransactionManager
Rolls back the transaction identifier by given transactionStatus.

Specified by:
rollbackTransaction in interface TransactionManager<org.springframework.transaction.TransactionStatus>
Parameters:
tx - The status object provided by TransactionManager.startTransaction().

setTransactionManager

public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
The PlatformTransactionManager that manages the transactions with the underlying data source.

Parameters:
transactionManager - the transaction manager that manages transactions with underlying data sources

setTransactionDefinition

public void setTransactionDefinition(org.springframework.transaction.TransactionDefinition transactionDefinition)
The TransactionDefinition to use by the transaction manager. Defaults to a DefaultTransactionDefinition.

Parameters:
transactionDefinition - the TransactionDefinition to use by the transaction manager


Copyright © 2010-2016. All Rights Reserved.