org.objectweb.jotm
Class TransactionImpl

java.lang.Object
  extended by org.objectweb.jotm.TransactionImpl
All Implemented Interfaces:
Transaction, org.objectweb.jotm.TimerEventListener

public class TransactionImpl
extends Object
implements Transaction, org.objectweb.jotm.TimerEventListener

TransactionImpl is the implementation of the Transaction interface, defined in JTA specifications. This object is intended to be used by the EJBServer for transaction management. It is used indirectly by the UserTransaction implementation too, i.e. the Current object. The goal is to use the JTA interface to hide the JTM interface to the caller (EJBServer, Bean or Client).


Constructor Summary
TransactionImpl(org.objectweb.jotm.TransactionContext pctx)
          New Transaction for this thread (setPropagationContext)
TransactionImpl(org.objectweb.jotm.Xid xid, int timeout)
          New transaction (begin).
 
Method Summary
 void cleanup()
           
 void commit()
          Complete the transaction represented by this Transaction object The calling thread is not required to have the same transaction associated with the thread.
 boolean delistResource(XAResource xares, int flag)
          Delist the resource specified from the current transaction associated with the calling thread.
 void doAttach(int flag)
          enlist/clear all suspended resource
 void doDetach(int flag)
          delist all enlisted resources and move to suspended
 boolean enlistResource(XAResource xares)
          Enlist the resource specified with the current transaction context of the calling thread
 boolean equals(Object obj2)
          return true if objects are identical
 List getEnlistedXAResource()
          get a copy of the list of currently enlisted resource
 org.objectweb.jotm.TransactionContext getPropagationContext(boolean hold)
          Return associated PropagationContext Used for implicit Context propagation.
 int getStatus()
          Obtain the status of the transaction associated with the current thread.
 Date getTxDate()
          get the date time stamp for the transaction
 Object getUserResource(Object key)
          Get User Resource
 org.objectweb.jotm.Xid getXid()
          Get the Xid of the transaction
 int hashCode()
          return a hashcode value for this object
 int prepare()
          Prepare the transaction represented by this Transaction object.
 void putUserResource(Object key, Object value)
          Save User Resource
 void registerInterposedSynchronization(Synchronization sync)
          Register InterposedSynchronization
 void registerSynchronization(Synchronization sync)
          Register a synchronization object for the transaction currently associated with the calling thread.
 void rollback()
          Rollback the transaction represented by this Transaction object.
 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.
 void setTimer(org.objectweb.jotm.TimerEvent timer)
          set a timer for the transaction
 void setTxDate(Date date)
          set the date time stamp for the transaction
 void timeoutExpired(Object arg)
          timeout for that transaction has expired
 boolean toRemove()
           
 String toString()
          string form
 void unsetTimer()
          unset the timer
 void updatePropagationContext(org.objectweb.jotm.TransactionContext pctx)
          update the propagation context We should be inside the reply of a request involved in a tx here!
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransactionImpl

public TransactionImpl(org.objectweb.jotm.Xid xid,
                       int timeout)
                throws SystemException
New transaction (begin).

Parameters:
xid - transaction Xid
timeout - The value of the timeout in seconds.
Throws:
SystemException - could not build Transaction Context

TransactionImpl

public TransactionImpl(org.objectweb.jotm.TransactionContext pctx)
New Transaction for this thread (setPropagationContext)

Parameters:
pctx - propagation context
Method Detail

putUserResource

public void putUserResource(Object key,
                            Object value)
Save User Resource

Parameters:
key - object
value - object

getUserResource

public Object getUserResource(Object key)
Get User Resource

Parameters:
key - object
Returns:
Object object

registerInterposedSynchronization

public void registerInterposedSynchronization(Synchronization sync)
                                       throws IllegalStateException
Register InterposedSynchronization

Parameters:
sync - synchronization
Throws:
IllegalStateException - could not register synchronization

commit

public void commit()
            throws RollbackException,
                   HeuristicMixedException,
                   HeuristicRollbackException,
                   SecurityException,
                   SystemException
Complete the transaction represented by this Transaction object The calling thread is not required to have the same transaction associated with the thread. (JTA 3.3.3)

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

delistResource

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

Specified by:
delistResource in interface Transaction
Parameters:
xares - The XAResource object representing the resource to delist
flag - One of the values of TMSUCCESS, TMSUSPEND, or TMFAIL.
Returns:
true if the dissociation of the Resource is successful; false otherwise.
Throws:
IllegalStateException - Thrown if the transaction in the target object is inactive.
SystemException - Thrown if the transaction manager encounters an unexpected error condition

enlistResource

public boolean enlistResource(XAResource xares)
                       throws RollbackException,
                              IllegalStateException,
                              SystemException
Enlist the resource specified with the current transaction context of the calling thread

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

doDetach

public void doDetach(int flag)
              throws SystemException
delist all enlisted resources and move to suspended

Throws:
SystemException

doAttach

public void doAttach(int flag)
              throws SystemException,
                     RollbackException
enlist/clear all suspended resource

Throws:
SystemException
RollbackException

getEnlistedXAResource

public List getEnlistedXAResource()
get a copy of the list of currently enlisted resource


getStatus

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

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

registerSynchronization

public void registerSynchronization(Synchronization sync)
                             throws RollbackException,
                                    IllegalStateException,
                                    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 Transaction
Parameters:
sync - The javax.transaction.Synchronization object for the transaction associated with the target object
Throws:
RollbackException - Thrown to indicate that the transaction has been marked for rollback only.
IllegalStateException - Thrown if the transaction in the target object is in prepared state or the transaction is inactive.
SystemException - Thrown if the transaction manager encounters an unexpected error condition

rollback

public void rollback()
              throws IllegalStateException,
                     SystemException
Rollback the transaction represented by this Transaction object.

Specified by:
rollback in interface Transaction
Throws:
IllegalStateException - Thrown if the transaction in the target object is in prepared state or the transaction is inactive.
SystemException - Thrown if the transaction manager encounters an unexpected error condition

prepare

public int prepare()
            throws IllegalStateException,
                   SystemException
Prepare the transaction represented by this Transaction object.

Returns:
prepare status
Throws:
IllegalStateException - Thrown if the transaction in the target object is in prepared state or the transaction is inactive.
SystemException - Thrown if the transaction manager encounters an unexpected error condition

setRollbackOnly

public void setRollbackOnly()
                     throws IllegalStateException,
                            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 Transaction
Throws:
IllegalStateException - Thrown if the current thread is not associated with any transaction.
SystemException - Thrown if the transaction manager encounters an unexpected error condition

timeoutExpired

public void timeoutExpired(Object arg)
timeout for that transaction has expired

Specified by:
timeoutExpired in interface org.objectweb.jotm.TimerEventListener

equals

public boolean equals(Object obj2)
return true if objects are identical

Overrides:
equals in class Object

hashCode

public int hashCode()
return a hashcode value for this object

Overrides:
hashCode in class Object

toString

public String toString()
string form

Overrides:
toString in class Object

getPropagationContext

public org.objectweb.jotm.TransactionContext getPropagationContext(boolean hold)
Return associated PropagationContext Used for implicit Context propagation.

Parameters:
hold - true if must increment the count to hold the object (not used!)
Returns:
PropagationContext associated with the transaction.

setTimer

public void setTimer(org.objectweb.jotm.TimerEvent timer)
set a timer for the transaction

Parameters:
timer - the timer event to set

unsetTimer

public void unsetTimer()
unset the timer


setTxDate

public void setTxDate(Date date)
set the date time stamp for the transaction

Parameters:
date - the Date to set for the transaction

getTxDate

public Date getTxDate()
get the date time stamp for the transaction

Returns:
the timestamp

updatePropagationContext

public void updatePropagationContext(org.objectweb.jotm.TransactionContext pctx)
update the propagation context We should be inside the reply of a request involved in a tx here!

Parameters:
pctx - propagation context

getXid

public org.objectweb.jotm.Xid getXid()
Get the Xid of the transaction

Returns:
the Xid

toRemove

public boolean toRemove()

cleanup

public void cleanup()


Copyright © 2005-2013 The Kuali Foundation. All Rights Reserved.