com.arsdigita.persistence
Class TransactionContext

java.lang.Object
  extended bycom.arsdigita.persistence.TransactionContext

public class TransactionContext
extends Object

Title: TransactionContext class This class is intentionally NOT threadsafe; it should not be shared across threads. Description: The TransactionContext class encapsulates a database transaction.

Version:
$Revision: #20 $ $Date: 2004/04/07 $
Author:
rhs@mit.edu

Method Summary
 void abortTxn()
          Aborts the current transaction.
 void addTransactionListener(TransactionListener listener)
          Register a one time transaction event listener
 void beginTxn()
          Begins a new transaction.
 void commitTxn()
          Commits the current transaction.
 Object getAttribute(String name)
          Get an attribute inside of this TransactionContext.
 int getTransactionIsolation()
          Returns the isolation level of the current transaction.
 boolean inTxn()
          Returns true if there is currently a transaction in progress.
 void removeAttribute(String name)
          Remove an attribute from this TransactionContext.
 void removeTransactionListener(TransactionListener listener)
          Unregister a transaction event listener.
 void setAttribute(String name, Object value)
          Set an attribute inside of this TransactionContext.
 void setTransactionIsolation(int level)
          Sets the isolation level of the current transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

beginTxn

public void beginTxn()
Begins a new transaction. Update 8/7/01: This now makes a connection available, but doesn't actually open a connection and associate it with the thread. The 'transaction' will not actually start until the first data modification, at which point the connection will be married to the thread. This should be a transparent behavior change introduced as a performance optimization, SDM #159142.


commitTxn

public void commitTxn()
Commits the current transaction.


abortTxn

public void abortTxn()
Aborts the current transaction.


addTransactionListener

public void addTransactionListener(TransactionListener listener)
Register a one time transaction event listener


removeTransactionListener

public void removeTransactionListener(TransactionListener listener)
Unregister a transaction event listener. There is generally no need to call this method, since transaction listeners are automatically removed after they have been invoked to prevent infinite recursion.


inTxn

public boolean inTxn()
Returns true if there is currently a transaction in progress.

Returns:
True if a transaction is in progress, false otherwise.

getTransactionIsolation

public int getTransactionIsolation()
Returns the isolation level of the current transaction.

Returns:
The isolation level of the current transaction.

setTransactionIsolation

public void setTransactionIsolation(int level)
Sets the isolation level of the current transaction.

Parameters:
level - The desired isolation level.

setAttribute

public void setAttribute(String name,
                         Object value)
Set an attribute inside of this TransactionContext. The attribute will exist as long as the transaction is opened. When the transaction is closed or aborted, the attribute will be discarded. This method is analogous to ServletRequest.setAttribute(String, Object)

Parameters:
name - the name of the attribute
value - the value of the attribute

getAttribute

public Object getAttribute(String name)
Get an attribute inside of this TransactionContext. The attribute will exist as long as the transaction is opened. When the transaction is closed or aborted, the attribute will be discarded. This method is analogous to ServletRequest.getAttribute(String)

Parameters:
name - the name of the attribute
Returns:
the value of the attribute, or null if no attribute with this value has been stored

removeAttribute

public void removeAttribute(String name)
Remove an attribute from this TransactionContext. be discarded. This method is analogous to ServletRequest.removeAttribute(String)

Parameters:
name - the name of the attribute to remove


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC