Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.tm
Class TransactionLocal

    java.lang.Object
      org.jboss.tm.TransactionLocal

public class TransactionLocal
extends Object

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

Version:
  $Revision: 1.10 $
Author:
  Dain Sundstrom, Bill Burke

Field Summary
`protected TransactionLocalDelegate` | `delegate` The delegate
`protected TransactionManager` | `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 tm)` Creates a thread local variable.

Method Summary
`protected boolean` | `containsValue(Transaction tx)` does Transaction contain object?
`Object` | `get()` Returns the value of this TransactionLocal variable associated with the thread context transaction.
`Object` | `get(Transaction transaction)` Returns the value of this TransactionLocal variable associated with the specified transaction.
`Transaction` | `getTransaction()`
`protected Object` | `getValue(Transaction tx)` get the transaction local value.
`protected void` | `initDelegate()` Initialise the delegate
`protected Object` | `initialValue()` Returns the initial value for this thransaction local.
`void` | `set(Object value)` Sets the value of this TransactionLocal variable associtated with the thread context transaction.
`void` | `set(Transaction transaction, Object value)` Sets the value of this TransactionLocal variable associtated with the specified transaction.
`protected void` | `storeValue(Transaction tx, 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 transactionManager

  The transaction manager is maintained by the system and manges the assocation of transaction to threads.

### delegate

    protected TransactionLocalDelegate delegate

  The delegate

Constructor Detail

### TransactionLocal

    public TransactionLocal()

  Creates a thread local variable.

Throws:
  `IllegalStateException` - if there is no system transaction manager

### TransactionLocal

    public TransactionLocal(TransactionManager tm)

  Creates a thread local variable. Using the given transaction manager

Parameters:
  `tm` - the transaction manager

Method Detail

### initialValue

    protected 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 Object getValue(Transaction tx)

  get the transaction local value.

### storeValue

    protected void storeValue(Transaction tx,
                              Object value)

  put the value in the TransactionImpl map

### containsValue

    protected boolean containsValue(Transaction tx)

  does Transaction contain object?

### get

    public 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 Object get(Transaction 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:
    `IllegalStateException` - if an error occures while registering a synchronization callback with the transaction

### set

    public void set(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 transaction,
                    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 getTransaction()

### initDelegate

    protected void initDelegate()

  Initialise the delegate

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 JBoss Group, LLC. All Rights Reserved.