Framework Professional Edition Package


org.mbs.services.transaction
Interface TransactionResource

All Known Implementing Classes:
FileTransactionResource

public interface TransactionResource

A TransactionResource represents a participant in a transaction. When a subsystem is used and it can participate in a transaction, it should register itself with the current by calling the join method. The resource manager should carefully lock its objects to provide the appropriate guarantees. At the end of a transaction, the transaction manager will call-back the resource manager and ask for the outcome of this transaction with the prepare(TransactionContext) method. If the resource manager has not experienced any problems for this transaction, it should silently return. If the transaction could not be persisted, it should throw an appropriate exception. After all the participating resource managers have been consulted, the transaction manager will call commit(TransactionContext) to make the changes persistent or rollback(TransactionContext) to undo all the changes that were made since the transaction started.

Author:
Valentin Valchev

Method Summary
 void commit(TransactionContext transaction)
          Commit all the changes associated with the given transaction.
 void prepare(TransactionContext transaction)
          Prepare for the changes to be made persistent, no further changes in this transaction will be made.
 void rollback(TransactionContext transaction)
          Undo all the changes made to this subsystem that are associated with the given transaction.
 

Method Detail

prepare

void prepare(TransactionContext transaction)
             throws java.lang.Exception
Prepare for the changes to be made persistent, no further changes in this transaction will be made. This method should verify any constraints that could not have been checked before and throw an exception if anything is not correct. This method may be called on another thread then the thread associated with the transaction to speed up the 2-phase commit. I.e. the getCurrentThread() may return null.

Parameters:
transaction - The associated transaction.
Throws:
java.lang.Exception - When there is an inconsistency or other error, the exception will reflect this. An exception indicates that the transaction will be rolled back. The rollback(TransactionContext) method will still be called.

rollback

void rollback(TransactionContext transaction)
Undo all the changes made to this subsystem that are associated with the given transaction. The method may be called on another thread than the one associated with the transaction object.

Parameters:
transaction - The associated transaction.

commit

void commit(TransactionContext transaction)
Commit all the changes associated with the given transaction.

Parameters:
transaction -

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved