org.apache.ojb.odmg
Interface TransactionAware

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
Article, ProductGroup

public interface TransactionAware
extends java.io.Serializable

* TransactionAware is an interface that can be implemented * to provide hooks into the Transaction interface provided * by ObJectRelationalBridge. * Only objects which have a write lock acquired on them can * participate in a transaction. * To kill a transaction, implement beforeCommit() and throw * a TransactionAbortedException. This will force the entire * transaction to rollback. * * To rebuild an object after a rollback use the afterAbort() * call. This is a good place to populate transient or other * variables. * * beforeAbort and afterCommit are there for informational * purposes. * * Here are some common ways you can expect this interface * to be called: * * Sucessful commit: * beforeCommit() * afterCommit() * * Transaction Failure (1): * beforeCommit() * beforeAbort() * afterAbort() * * Transaction Failure (2): * beforeAbort() * afterAbort() * * Commits and Aborts aren't directly provided to TransactionAware classes. * The idea is that Transactions are difficult to handle, and most of it * will be handled by ObjectSnapshot. However, you use TransactionAware * to do one of two things, kill a transaction from happening, and clean * up after a rollback. * * @version $Id: TransactionAware.java,v 1.4 2004/01/07 11:41:19 thma Exp $


Field Summary
static long serialVersionUID
           
 
Method Summary
 void afterAbort()
          * afterAbort will be called after a transaction has been aborted.
 void afterCommit()
          * afterCommit is called only after a successful commit has taken * place.
 void beforeAbort()
          * beforeAbort is called before a transaction is aborted.
 void beforeCommit()
          * beforeCommit will give an object a chance to kill a * transaction before it is committed.
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Method Detail

beforeCommit

public void beforeCommit()
                  throws TransactionAbortedException
* beforeCommit will give an object a chance to kill a * transaction before it is committed. * To kill a transaction, throw a new TransactionAbortedException. *

Throws:
TransactionAbortedException

afterCommit

public void afterCommit()
* afterCommit is called only after a successful commit has taken * place. *


beforeAbort

public void beforeAbort()
* beforeAbort is called before a transaction is aborted. *


afterAbort

public void afterAbort()
* afterAbort will be called after a transaction has been aborted. * The values of fields which get persisted will have changed to * what they were at the begining of the transaction. This method * should be overridden to reset any transient or non-persistent * fields. *



Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14