com.objectwave.transactionalSupport
Class TransactionManager

java.lang.Object
  |
  +--com.objectwave.transactionalSupport.TransactionManager
Direct Known Subclasses:
EjbTransactionManager

public class TransactionManager
extends java.lang.Object

Version:
$Id: TransactionManager.java,v 2.1 2001/06/15 13:46:33 dave_hoag Exp $
Author:
dhoag

Nested Class Summary
static class TransactionManager.MyLockManager
          A very efficient lock manager that takes advantage of the following assumptions.
 
Field Summary
protected  TransactionManager.MyLockManager lockManager
           
 
Constructor Summary
TransactionManager()
          Constructor for the TransactionManager object
 
Method Summary
 void addTransactionSupport(java.lang.String name, java.lang.Class transactionClass)
          Register the 'name' with the class.
 void dumpContext(java.io.OutputStream os)
          Used for debugging.
 void dumpContext(java.io.Writer w)
           
protected  TransactionLog getCurrentDefaultInstance()
          The defaultInstance is the root transaction for the current context.
 TransactionLog getCurrentInstance()
          Find the most nested transaction.
protected  TransactionLog getCurrentInstance(TransactionLog log)
          Find the most nested transaction.
 TransactionLog getDefaultInstance()
           
 TransactionManager.MyLockManager getLockManager()
          Gets the LockManager attribute of the TransactionManager object
 TransactionLog getNewTransaction(java.lang.String name)
          Attempt to create a new TransactionLog for the transaction type of 'name'.
 boolean hasTransactions()
           
 boolean isAllowingNesting()
           
protected  boolean isUsingSessions()
          Gets the UsingSessions attribute of the TransactionManager object
protected  java.lang.Object[] lookupTransaction(java.lang.String name)
          Find the Object [] that contains the name and the class of the specified transaction name.
static void main(java.lang.String[] args)
          Benchmark lock manager performance
protected  void maintainContextList(TransactionLog log)
          Clean up our context list of transactions.
protected  void managedTransactionComplete(TransactionLog log)
          The non session type.
protected  void sessionTransactionComplete()
           
 void setContext(java.lang.Object obj)
          Transactions can have multiple contexts.
protected  void setDefaultInstance(TransactionLog log)
          Use this method sparingly.
 TransactionLog startRootTransaction(java.lang.String name, java.lang.Object context)
          Used to provide seperation between a particular transaction instance and the desire to have a transaction.
 TransactionLog startRootTransaction(java.lang.String name, Session session)
          Used to provide seperation between a particular transaction instance and the desire to have a transaction.
 void startRootTransaction(TransactionLog log, java.lang.Object context)
          Only use this method if you KNOW that you want the provided transaction to be a root transaction.
 TransactionLog startTransaction(java.lang.String name, java.lang.Object context)
          Used to provide seperation between a particular transaction instance and the desire to have a transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lockManager

protected final TransactionManager.MyLockManager lockManager
Constructor Detail

TransactionManager

public TransactionManager()
Constructor for the TransactionManager object

Method Detail

main

public static void main(java.lang.String[] args)
Benchmark lock manager performance

Parameters:
args - The command line arguments

setContext

public void setContext(java.lang.Object obj)
Transactions can have multiple contexts. This may be driven by thread, by window activation, or some way I haven't even dreamed of.

Parameters:
obj - The new Context value

setDefaultInstance

protected void setDefaultInstance(TransactionLog log)
Use this method sparingly. Good only for root transactions. Existing transactions could/would be lost. Actually, I now think that you shouldn't use this method. Start transaction works MUCH better.

Parameters:
log - The new DefaultInstance value

getLockManager

public TransactionManager.MyLockManager getLockManager()
Gets the LockManager attribute of the TransactionManager object

Returns:
The LockManager value

getCurrentInstance

public TransactionLog getCurrentInstance()
Find the most nested transaction. This is the one without any subtransactions. The defaultInstance will always be the root transaction.

Returns:
The CurrentInstance value

getNewTransaction

public TransactionLog getNewTransaction(java.lang.String name)
Attempt to create a new TransactionLog for the transaction type of 'name'.

Parameters:
name -
Returns:
The NewTransaction value

getDefaultInstance

public TransactionLog getDefaultInstance()
Returns:
The DefaultInstance value

isAllowingNesting

public boolean isAllowingNesting()
Returns:
The AllowingNesting value

isUsingSessions

protected boolean isUsingSessions()
Gets the UsingSessions attribute of the TransactionManager object

Returns:
The UsingSessions value

getCurrentDefaultInstance

protected final TransactionLog getCurrentDefaultInstance()
The defaultInstance is the root transaction for the current context. There are no callers to this method that are not synchronized.

Returns:
The CurrentDefaultInstance value

getCurrentInstance

protected TransactionLog getCurrentInstance(TransactionLog log)
Find the most nested transaction. This is the one without any subtransactions. The defaultInstance will always be the root transaction.

Parameters:
log -
Returns:
The CurrentInstance value

addTransactionSupport

public void addTransactionSupport(java.lang.String name,
                                  java.lang.Class transactionClass)
Register the 'name' with the class. This will allow the application to create a transaction simply by specifying a transaction name. This seperates implementation from usage. Similar to Java's security support.

Parameters:
transactionClass - must be an instance of TransactionLog. Must also have a default constructor.
name - The feature to be added to the TransactionSupport attribute

dumpContext

public void dumpContext(java.io.OutputStream os)
Used for debugging.

Parameters:
os -

hasTransactions

public boolean hasTransactions()
Returns:

startRootTransaction

public TransactionLog startRootTransaction(java.lang.String name,
                                           Session session)
Used to provide seperation between a particular transaction instance and the desire to have a transaction. The 'name' must have a registered transaction type. This implementation is specific to session support.

Parameters:
name - The name of a registered transaction type.
session -
Returns:
See Also:
addTransactionSupport(java.lang.String, java.lang.Class)

startTransaction

public TransactionLog startTransaction(java.lang.String name,
                                       java.lang.Object context)
Used to provide seperation between a particular transaction instance and the desire to have a transaction. The 'name' must have a registered transaction type.

Parameters:
context - The context of the transaction.
name - The name of a registered transaction type.
Returns:
See Also:
addTransactionSupport(java.lang.String, java.lang.Class)

startRootTransaction

public void startRootTransaction(TransactionLog log,
                                 java.lang.Object context)
Only use this method if you KNOW that you want the provided transaction to be a root transaction.

Parameters:
log - The transaction that is to be the root transaction for the provided context.
context - The context of the transaction.

startRootTransaction

public TransactionLog startRootTransaction(java.lang.String name,
                                           java.lang.Object context)
Used to provide seperation between a particular transaction instance and the desire to have a transaction. The 'name' must have a registered transaction type.

Parameters:
context - The context of the transaction.
name - The name of a registered transaction type.
Returns:
See Also:
addTransactionSupport(java.lang.String, java.lang.Class)

dumpContext

public void dumpContext(java.io.Writer w)
Parameters:
w -

sessionTransactionComplete

protected void sessionTransactionComplete()

managedTransactionComplete

protected void managedTransactionComplete(TransactionLog log)
The non session type.

Parameters:
log -

maintainContextList

protected void maintainContextList(TransactionLog log)
Clean up our context list of transactions. Not used for Session support.

Parameters:
log -

lookupTransaction

protected java.lang.Object[] lookupTransaction(java.lang.String name)
Find the Object [] that contains the name and the class of the specified transaction name.

Parameters:
name -
Returns: