org.springframework.transaction.support
Interface TransactionSynchronization

All Known Implementing Classes:
TransactionSynchronizationAdapter

public interface TransactionSynchronization

Interface for transaction synchronization callbacks. Supported by AbstractPlatformTransactionManager.

Since:
02.06.2003
Author:
Juergen Hoeller
See Also:
TransactionSynchronizationManager, AbstractPlatformTransactionManager

Field Summary
static int STATUS_COMMITTED
          Completion status in case of proper commit
static int STATUS_ROLLED_BACK
          Completion status in case of proper rollback
static int STATUS_UNKNOWN
          Completion status in case of heuristic mixed completion or system errors
 
Method Summary
 void afterCompletion(int status)
          Invoked after transaction commit/rollback.
 void beforeCommit(boolean readOnly)
          Invoked before transaction commit (before "beforeCompletion").
 void beforeCompletion()
          Invoked before transaction commit/rollback (after "beforeCommit", even if beforeCommit threw an exception).
 void resume()
          Resume this synchronization.
 void suspend()
          Suspend this synchronization.
 

Field Detail

STATUS_COMMITTED

public static final int STATUS_COMMITTED
Completion status in case of proper commit

See Also:
Constant Field Values

STATUS_ROLLED_BACK

public static final int STATUS_ROLLED_BACK
Completion status in case of proper rollback

See Also:
Constant Field Values

STATUS_UNKNOWN

public static final int STATUS_UNKNOWN
Completion status in case of heuristic mixed completion or system errors

See Also:
Constant Field Values
Method Detail

suspend

public void suspend()
Suspend this synchronization. Supposed to unbind resources from TransactionSynchronizationManager if managing any.

See Also:
TransactionSynchronizationManager.unbindResource(java.lang.Object)

resume

public void resume()
Resume this synchronization. Supposed to rebind resources to TransactionSynchronizationManager if managing any.

See Also:
TransactionSynchronizationManager.bindResource(java.lang.Object, java.lang.Object)

beforeCommit

public void beforeCommit(boolean readOnly)
Invoked before transaction commit (before "beforeCompletion"). Can e.g. flush transactional sessions to the database.

Note that exceptions will get propagated to the commit caller and cause a rollback of the transaction.

Parameters:
readOnly - if the transaction is defined as read-only transaction
Throws:
RuntimeException - in case of errors (note: do not throw TransactionException subclasses here!)
See Also:
beforeCompletion()

beforeCompletion

public void beforeCompletion()
Invoked before transaction commit/rollback (after "beforeCommit", even if beforeCommit threw an exception). Can e.g. perform resource cleanup.

Note that exceptions will get propagated to the commit caller and cause a rollback of the transaction.

Throws:
RuntimeException - in case of errors (note: do not throw TransactionException subclasses here!)
See Also:
beforeCommit(boolean), afterCompletion(int)

afterCompletion

public void afterCompletion(int status)
Invoked after transaction commit/rollback. Can e.g. perform resource cleanup, in this case after transaction completion.

Note that exceptions will get propagated to the commit or rollback caller, although they will not influence the outcome of the transaction.

Parameters:
status - completion status according to the STATUS_* constants
Throws:
RuntimeException - in case of errors (note: do not throw TransactionException subclasses here!)
See Also:
STATUS_COMMITTED, STATUS_ROLLED_BACK, STATUS_UNKNOWN, beforeCompletion()


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