org.jboss.tm
Class TransactionLocal

java.lang.Object
  extended byorg.jboss.tm.TransactionLocal

public class TransactionLocal
extends java.lang.Object

A TransactionLocal is similar to ThreadLocal except it is keyed on the Transactions. A transaction local variable is cleared after the transaction completes.


Field Summary
protected  TransactionLocalDelegate (src) delegate
          The delegate
protected  TransactionManager (src) transactionManager
          The transaction manager is maintained by the system and manges the assocation of transaction to threads.
 
Constructor Summary
TransactionLocal()
          Creates a thread local variable.
TransactionLocal(TransactionManager (src)  tm)
          Creates a thread local variable.
 
Method Summary
protected  boolean containsValue(Transaction (src)  tx)
          does Transaction contain object?
 java.lang.Object get()
          Returns the value of this TransactionLocal variable associated with the thread context transaction.
 java.lang.Object get(Transaction (src)  transaction)
          Returns the value of this TransactionLocal variable associated with the specified transaction.
 Transaction (src) getTransaction()
           
protected  java.lang.Object getValue(Transaction (src)  tx)
          get the transaction local value.
protected  void initDelegate()
          Initialise the delegate
protected  java.lang.Object initialValue()
          Returns the initial value for this thransaction local.
 void set(java.lang.Object value)
          Sets the value of this TransactionLocal variable associtated with the thread context transaction.
 void set(Transaction (src)  transaction, java.lang.Object value)
          Sets the value of this TransactionLocal variable associtated with the specified transaction.
protected  void storeValue(Transaction (src)  tx, java.lang.Object value)
          put the value in the TransactionImpl map
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transactionManager

protected final TransactionManager (src)  transactionManager
The transaction manager is maintained by the system and manges the assocation of transaction to threads.


delegate

protected TransactionLocalDelegate (src)  delegate
The delegate

Constructor Detail

TransactionLocal

public TransactionLocal()
Creates a thread local variable.

Throws:
java.lang.IllegalStateException - if there is no system transaction manager

TransactionLocal

public TransactionLocal(TransactionManager (src)  tm)
Creates a thread local variable. Using the given transaction manager

Parameters:
tm - the transaction manager
Method Detail

initialValue

protected java.lang.Object initialValue()
Returns the initial value for this thransaction local. This method will be called once per accessing transaction for each TransactionLocal, the first time each transaction accesses the variable with get or set. If the programmer desires TransactionLocal variables to be initialized to some value other than null, TransactionLocal must be subclassed, and this method overridden. Typically, an anonymous inner class will be used. Typical implementations of initialValue will call an appropriate constructor and return the newly constructed object.

Returns:
the initial value for this TransactionLocal

getValue

protected java.lang.Object getValue(Transaction (src)  tx)
get the transaction local value.


storeValue

protected void storeValue(Transaction (src)  tx,
                          java.lang.Object value)
put the value in the TransactionImpl map


containsValue

protected boolean containsValue(Transaction (src)  tx)
does Transaction contain object?


get

public java.lang.Object get()
Returns the value of this TransactionLocal variable associated with the thread context transaction. Creates and initializes the copy if this is the first time the method is called in a transaction.

Returns:
the value of this TransactionLocal

get

public java.lang.Object get(Transaction (src)  transaction)
Returns the value of this TransactionLocal variable associated with the specified transaction. Creates and initializes the copy if this is the first time the method is called in a transaction.

Parameters:
transaction - the transaction for which the variable it to be retrieved
Returns:
the value of this TransactionLocal
Throws:
java.lang.IllegalStateException - if an error occures while registering a synchronization callback with the transaction

set

public void set(java.lang.Object value)
Sets the value of this TransactionLocal variable associtated with the thread context transaction. This is only used to change the value from the one assigned by the initialValue method, and many applications will have no need for this functionality.

Parameters:
value - the value to be associated with the thread context transactions's TransactionLocal

set

public void set(Transaction (src)  transaction,
                java.lang.Object value)
Sets the value of this TransactionLocal variable associtated with the specified transaction. This is only used to change the value from the one assigned by the initialValue method, and many applications will have no need for this functionality.

Parameters:
transaction - the transaction for which the value will be set
value - the value to be associated with the thread context transactions's TransactionLocal

getTransaction

public Transaction (src)  getTransaction()

initDelegate

protected void initDelegate()
Initialise the delegate