org.apache.slide.transaction
Class SlideTransaction

java.lang.Object
  extended byorg.apache.slide.transaction.SlideTransaction
All Implemented Interfaces:
javax.transaction.Transaction

public final class SlideTransaction
extends java.lang.Object
implements javax.transaction.Transaction

JTA Transaction implementation.

Version:
$Revision: 1.23 $

Field Summary
protected static java.lang.String LOG_CHANNEL
           
 
Constructor Summary
SlideTransaction(SlideTransactionManager transactionManager)
          Constructor.
 
Method Summary
 void commit()
          Complete the transaction represented by this Transaction object.
 boolean delistResource(javax.transaction.xa.XAResource xaRes, int flag)
          Delist the resource specified from the current transaction associated with the calling thread.
 boolean enlistResource(javax.transaction.xa.XAResource xaRes)
          Enlist the resource specified with the current transaction context of the calling thread.
 int getStatus()
          Obtain the status of the transaction associated with the current thread.
static java.lang.String getXAErrorCode(java.lang.Throwable throww)
          Return a String representation of the error code contained in a XAException.
static java.lang.String getXAErrorCode(javax.transaction.xa.XAException xae)
          Return a String representation of the error code contained in a XAException.
static java.lang.String getXAFlag(int flag)
          Return a String representation of a flag.
 void registerSynchronization(javax.transaction.Synchronization sync)
          Register a synchronization object for the transaction currently associated with the calling thread.
 void rollback()
          Roll back the transaction associated with the current thread.
 void setRollbackOnly()
          Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.
 java.lang.String toString()
          Print the Transaction object in a debugger friendly manner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG_CHANNEL

protected static final java.lang.String LOG_CHANNEL
Constructor Detail

SlideTransaction

public SlideTransaction(SlideTransactionManager transactionManager)
Constructor.

Method Detail

commit

public void commit()
            throws javax.transaction.RollbackException,
                   javax.transaction.HeuristicMixedException,
                   javax.transaction.HeuristicRollbackException,
                   java.lang.SecurityException,
                   java.lang.IllegalStateException,
                   javax.transaction.SystemException
Complete the transaction represented by this Transaction object.

Specified by:
commit in interface javax.transaction.Transaction
Throws:
javax.transaction.RollbackException - Thrown to indicate that the transaction has been rolled back rather than committed.
javax.transaction.HeuristicMixedException - Thrown to indicate that a heuristic decision was made and that some relevant updates have been committed while others have been rolled back.
javax.transaction.HeuristicRollbackException - Thrown to indicate that a heuristic decision was made and that some relevant updates have been rolled back.
java.lang.SecurityException - Thrown to indicate that the thread is not allowed to commit the transaction.
java.lang.IllegalStateException - Thrown if the current thread is not associated with a transaction.
javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.

delistResource

public boolean delistResource(javax.transaction.xa.XAResource xaRes,
                              int flag)
                       throws java.lang.IllegalStateException,
                              javax.transaction.SystemException
Delist the resource specified from the current transaction associated with the calling thread.

Specified by:
delistResource in interface javax.transaction.Transaction
Parameters:
xaRes - The XAResource object representing the resource to delist
flag - One of the values of TMSUCCESS, TMSUSPEND, or TMFAIL
Throws:
java.lang.IllegalStateException - Thrown if the transaction in the target object is inactive.
javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.

enlistResource

public boolean enlistResource(javax.transaction.xa.XAResource xaRes)
                       throws javax.transaction.RollbackException,
                              java.lang.IllegalStateException,
                              javax.transaction.SystemException
Enlist the resource specified with the current transaction context of the calling thread.

Specified by:
enlistResource in interface javax.transaction.Transaction
Parameters:
xaRes - The XAResource object representing the resource to delist
Returns:
true if the resource was enlisted successfully; otherwise false.
Throws:
javax.transaction.RollbackException - Thrown to indicate that the transaction has been marked for rollback only.
java.lang.IllegalStateException - Thrown if the transaction in the target object is in prepared state or the transaction is inactive.
javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.

rollback

public void rollback()
              throws java.lang.SecurityException,
                     java.lang.IllegalStateException,
                     javax.transaction.SystemException
Roll back the transaction associated with the current thread. When this method completes, the thread becomes associated with no transaction.

Specified by:
rollback in interface javax.transaction.Transaction
Throws:
java.lang.SecurityException - Thrown to indicate that the thread is not allowed to commit the transaction.
java.lang.IllegalStateException - Thrown if the current thread is not associated with a transaction.
javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.

setRollbackOnly

public void setRollbackOnly()
                     throws java.lang.IllegalStateException,
                            javax.transaction.SystemException
Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.

Specified by:
setRollbackOnly in interface javax.transaction.Transaction
Throws:
java.lang.IllegalStateException - Thrown if the current thread is not associated with a transaction.
javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.

getStatus

public int getStatus()
              throws javax.transaction.SystemException
Obtain the status of the transaction associated with the current thread.

Specified by:
getStatus in interface javax.transaction.Transaction
Returns:
The transaction status. If no transaction is associated with the current thread, this method returns the Status.NoTransaction value.
Throws:
javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.

registerSynchronization

public void registerSynchronization(javax.transaction.Synchronization sync)
                             throws javax.transaction.RollbackException,
                                    java.lang.IllegalStateException,
                                    javax.transaction.SystemException
Register a synchronization object for the transaction currently associated with the calling thread. The transction manager invokes the beforeCompletion method prior to starting the transaction commit process. After the transaction is completed, the transaction manager invokes the afterCompletion method.

Specified by:
registerSynchronization in interface javax.transaction.Transaction
Parameters:
sync - The Synchronization object for the transaction associated with the target object.
Throws:
javax.transaction.RollbackException - Thrown to indicate that the transaction has been marked for rollback only.
java.lang.IllegalStateException - Thrown if the transaction in the target object is in prepared state or the transaction is inactive.
javax.transaction.SystemException - Thrown if the transaction manager encounters an unexpected error condition.

getXAErrorCode

public static java.lang.String getXAErrorCode(java.lang.Throwable throww)
Return a String representation of the error code contained in a XAException.


getXAErrorCode

public static java.lang.String getXAErrorCode(javax.transaction.xa.XAException xae)
Return a String representation of the error code contained in a XAException.


getXAFlag

public static java.lang.String getXAFlag(int flag)
Return a String representation of a flag.


toString

public java.lang.String toString()
Print the Transaction object in a debugger friendly manner