org.springframework.transaction.support
Class DefaultTransactionStatus

java.lang.Object
  extended byorg.springframework.transaction.support.DefaultTransactionStatus
All Implemented Interfaces:
TransactionStatus

public class DefaultTransactionStatus
extends java.lang.Object
implements TransactionStatus

Default implementation of the TransactionStatus interface, used by AbstractPlatformTransactionManager.

Holds all status information that AbstractPlatformTransactionManager needs internally, including a generic transaction object determined by the concrete transaction manager implementation.

Since:
19.01.2004
Author:
Juergen Hoeller
See Also:
AbstractPlatformTransactionManager

Constructor Summary
DefaultTransactionStatus(java.lang.Object transaction, boolean newTransaction, boolean newSynchronization, boolean readOnly, boolean debug, java.lang.Object suspendedResources)
          Create a new TransactionStatus instance.
 
Method Summary
 java.lang.Object getSuspendedResources()
           
 java.lang.Object getTransaction()
          Return the underlying transaction object, e.g.
 boolean isDebug()
          Return whether the progress of this transaction is debugged.
 boolean isNewSynchronization()
          Return if a new transaction synchronization has been opened for this transaction.
 boolean isNewTransaction()
          Return if the transaction is new, else participating in an existing transaction.
 boolean isReadOnly()
          Return if this transaction is defined as read-only transaction.
 boolean isRollbackOnly()
          Return if the transaction has been set rollback-only.
 void setRollbackOnly()
          Set the transaction rollback-only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTransactionStatus

public DefaultTransactionStatus(java.lang.Object transaction,
                                boolean newTransaction,
                                boolean newSynchronization,
                                boolean readOnly,
                                boolean debug,
                                java.lang.Object suspendedResources)
Create a new TransactionStatus instance.

Parameters:
transaction - underlying transaction object, e.g. a JTA UserTransaction
newTransaction - if the transaction is new, else participating in an existing transaction
newSynchronization - if a new transaction synchronization has been opened for the given transaction
debug - should debug logging be enabled for the handling of this transaction? Caching it in here can prevent repeated calls to ask the logging system whether debug logging should be enabled.
Method Detail

getTransaction

public java.lang.Object getTransaction()
Return the underlying transaction object, e.g. a JTA UserTransaction.


isNewTransaction

public boolean isNewTransaction()
Description copied from interface: TransactionStatus
Return if the transaction is new, else participating in an existing transaction.

Specified by:
isNewTransaction in interface TransactionStatus

isNewSynchronization

public boolean isNewSynchronization()
Return if a new transaction synchronization has been opened for this transaction.


isReadOnly

public boolean isReadOnly()
Return if this transaction is defined as read-only transaction.


isDebug

public boolean isDebug()
Return whether the progress of this transaction is debugged. This is used by AbstractPlatformTransactionManager as an optimization, to prevent repeated calls to logger.isDebug(). Not really intended for client code.


getSuspendedResources

public java.lang.Object getSuspendedResources()

setRollbackOnly

public void setRollbackOnly()
Description copied from interface: TransactionStatus
Set the transaction rollback-only. This instructs the transaction manager that the only possible outcome of the transaction may be a rollback, proceeding with the normal applicaiton workflow though (i.e. no exception).

For transactions managed by TransactionTemplate or TransactionInterceptor. An alternative way to trigger a rollback is throwing an application exception.

Specified by:
setRollbackOnly in interface TransactionStatus
See Also:
TransactionCallback.doInTransaction(org.springframework.transaction.TransactionStatus), TransactionAttribute.rollbackOn(java.lang.Throwable)

isRollbackOnly

public boolean isRollbackOnly()
Description copied from interface: TransactionStatus
Return if the transaction has been set rollback-only.

Specified by:
isRollbackOnly in interface TransactionStatus


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