org.objectweb.jotm

Class TransactionImpl

Implemented Interfaces:
Transaction, TimerEventListener

public class TransactionImpl
extends Object
implements Transaction, 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(TransactionContext pctx)
New Transaction for this thread (setPropagationContext)
TransactionImpl(Xid xid, int timeout)
New transaction (begin).

Method Summary

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)
void
doDetach(int flag)
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()
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.
String
getTxDate()
get the date time stamp for the transaction
Xid
getXid()
Get the Xid of the transaction
int
hashCode()
return a hashcode value for this object
boolean
isRemovable()
return true if object is no more used (= removable)
int
prepare()
Prepare the transaction represented by this Transaction object.
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(TimerEvent timer)
set a timer for the transaction
void
setTxDate(String date)
set the date time stamp for the transaction
void
timeoutExpired(Object arg)
timeout for that transaction has expired
String
toString()
string form
void
unsetTimer()
unset the timer
void
updatePropagationContext(TransactionContext pctx)
update the propagation context We should be inside the reply of a request involved in a tx here!

Constructor Details

TransactionImpl

public TransactionImpl(TransactionContext pctx)
New Transaction for this thread (setPropagationContext)

Parameters:
pctx - propagation context


TransactionImpl

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

Parameters:
timeout - The value of the timeout in seconds.

Method Details

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)


delistResource

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

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.


doAttach

public void doAttach(int flag)
            throws SystemException,
                   RollbackException


doDetach

public void doDetach(int flag)
            throws SystemException


enlistResource

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

Parameters:
xares - The XAResource object representing the resource to enlist

Returns:
true if the resource was enlisted successfully; otherwise false.


equals

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


getEnlistedXAResource

public List getEnlistedXAResource()


getPropagationContext

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

Returns:
PropagationContext associated with the transaction.


getStatus

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

Returns:
The transaction status. If no transaction is associated with the current thread, this method returns the Status.NoTransaction value.


getTxDate

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


getXid

public Xid getXid()
Get the Xid of the transaction


hashCode

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


isRemovable

public boolean isRemovable()
return true if object is no more used (= removable)


prepare

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


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.

Parameters:
sync - The javax.transaction.Synchronization object for the transaction associated with the target object


rollback

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


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.


setTimer

public void setTimer(TimerEvent timer)
set a timer for the transaction


setTxDate

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


timeoutExpired

public void timeoutExpired(Object arg)
timeout for that transaction has expired
Specified by:
timeoutExpired in interface TimerEventListener


toString

public String toString()
string form


unsetTimer

public void unsetTimer()
unset the timer


updatePropagationContext

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