com.caucho.transaction
Class TransactionImpl

java.lang.Object
  extended by com.caucho.transaction.TransactionImpl
All Implemented Interfaces:
AlarmListener, java.util.EventListener, Transaction

public class TransactionImpl
extends java.lang.Object
implements Transaction, AlarmListener

Implementation of the transaction. Transactions are normally associated with a single thread.


Field Summary
 
Fields inherited from interface javax.transaction.Transaction
TMFAIL, TMSUCCESS, TMSUSPEND
 
Method Summary
 boolean allowLocalTransactionOptimization()
          Returns true if the local transaction optimization would be allowed.
 void close()
          Close the transaction, rolling back everything and removing all enlisted resources.
 void commit()
          Commit the transaction.
 boolean delistResource(XAResource resource, int flag)
          delists a resource from the current transaction
 boolean enlistResource(XAResource resource)
          Enlists a resource with the current transaction.
 java.lang.Object getAttribute(java.lang.String var)
          Gets an attribute.
 int getEnlistedResourceCount()
          Returns the current number of resources.
 int getStatus()
          Returns the status of this transaction
 int getTransactionTimeout()
          sets the timeout for the transaction
 Xid getXid()
           
 void handleAlarm(Alarm alarm)
          Handles a callback from an alarm.
 boolean isEmpty()
          Return true if the transaction has no resources.
 void registerSynchronization(Synchronization sync)
          Register a synchronization callback
 void rollback()
          Rollback the transaction.
 void setAttribute(java.lang.String var, java.lang.Object value)
          Adds an attribute.
 void setRollbackOnly()
          Force any completion to be a rollback.
 void setRollbackOnly(java.lang.Throwable exn)
          Force any completion to be a rollback.
 void setTransactionTimeout(int seconds)
          sets the timeout for the transaction
 void setUserTransaction(UserTransactionImpl ut)
          Sets the user transaction.
 java.lang.String toString()
          Printable version of the transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

setUserTransaction

public void setUserTransaction(UserTransactionImpl ut)
Sets the user transaction.


isEmpty

public boolean isEmpty()
Return true if the transaction has no resources.


enlistResource

public boolean enlistResource(XAResource resource)
                       throws RollbackException,
                              SystemException
Enlists a resource with the current transaction. Example resources are database or JMS connections.

Specified by:
enlistResource in interface Transaction
Returns:
true if successful
Throws:
RollbackException
SystemException

allowLocalTransactionOptimization

public boolean allowLocalTransactionOptimization()
Returns true if the local transaction optimization would be allowed.


getEnlistedResourceCount

public int getEnlistedResourceCount()
Returns the current number of resources.


delistResource

public boolean delistResource(XAResource resource,
                              int flag)
                       throws SystemException
delists a resource from the current transaction

Specified by:
delistResource in interface Transaction
Parameters:
resource - the resource to delist
flag - XXX: ???
Returns:
true if successful
Throws:
SystemException

setAttribute

public void setAttribute(java.lang.String var,
                         java.lang.Object value)
Adds an attribute.


getAttribute

public java.lang.Object getAttribute(java.lang.String var)
Gets an attribute.


getXid

public Xid getXid()

getStatus

public int getStatus()
Returns the status of this transaction

Specified by:
getStatus in interface Transaction

registerSynchronization

public void registerSynchronization(Synchronization sync)
Register a synchronization callback

Specified by:
registerSynchronization in interface Transaction

setRollbackOnly

public void setRollbackOnly()
                     throws SystemException
Force any completion to be a rollback.

Specified by:
setRollbackOnly in interface Transaction
Throws:
SystemException

setRollbackOnly

public void setRollbackOnly(java.lang.Throwable exn)
Force any completion to be a rollback.


commit

public void commit()
            throws RollbackException,
                   HeuristicMixedException,
                   HeuristicRollbackException,
                   SystemException
Commit the transaction.

Specified by:
commit in interface Transaction
Throws:
RollbackException
HeuristicMixedException
HeuristicRollbackException
SystemException

rollback

public void rollback()
Rollback the transaction.

Specified by:
rollback in interface Transaction

setTransactionTimeout

public void setTransactionTimeout(int seconds)
                           throws SystemException
sets the timeout for the transaction

Throws:
SystemException

getTransactionTimeout

public int getTransactionTimeout()
                          throws SystemException
sets the timeout for the transaction

Throws:
SystemException

handleAlarm

public void handleAlarm(Alarm alarm)
Description copied from interface: AlarmListener
Handles a callback from an alarm.

Specified by:
handleAlarm in interface AlarmListener

close

public void close()
Close the transaction, rolling back everything and removing all enlisted resources.


toString

public java.lang.String toString()
Printable version of the transaction.

Overrides:
toString in class java.lang.Object