public class TransactionImpl extends java.lang.Object implements javax.transaction.Transaction, TimerEventListener
Constructor and Description |
---|
TransactionImpl(TransactionContext pctx)
New Transaction for this thread (setPropagationContext)
|
TransactionImpl(Xid xid,
int timeout)
New transaction (begin).
|
Modifier and Type | Method and Description |
---|---|
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(javax.transaction.xa.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(javax.transaction.xa.XAResource xares)
Enlist the resource specified with the current transaction
context of the calling thread
|
boolean |
equals(java.lang.Object obj2)
return true if objects are identical
|
java.util.List |
getEnlistedXAResource()
get a copy of the list of currently enlisted resource
|
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.
|
java.util.Date |
getTxDate()
get the date time stamp for the transaction
|
java.lang.Object |
getUserResource(java.lang.Object key)
Get User Resource
|
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(java.lang.Object key,
java.lang.Object value)
Save User Resource
|
void |
registerInterposedSynchronization(javax.transaction.Synchronization sync)
Register InterposedSynchronization
|
void |
registerSynchronization(javax.transaction.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(java.util.Date date)
set the date time stamp for the transaction
|
void |
timeoutExpired(java.lang.Object arg)
timeout for that transaction has expired
|
boolean |
toRemove() |
java.lang.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!
|
public TransactionImpl(Xid xid, int timeout) throws javax.transaction.SystemException
xid
- transaction Xidtimeout
- The value of the timeout in seconds.javax.transaction.SystemException
- could not build Transaction Contextpublic TransactionImpl(TransactionContext pctx)
pctx
- propagation contextpublic void putUserResource(java.lang.Object key, java.lang.Object value)
key
- objectvalue
- objectpublic java.lang.Object getUserResource(java.lang.Object key)
key
- objectpublic void registerInterposedSynchronization(javax.transaction.Synchronization sync) throws java.lang.IllegalStateException
sync
- synchronizationjava.lang.IllegalStateException
- could not register synchronizationpublic void commit() throws javax.transaction.RollbackException, javax.transaction.HeuristicMixedException, javax.transaction.HeuristicRollbackException, java.lang.SecurityException, javax.transaction.SystemException
commit
in interface javax.transaction.Transaction
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 conditionpublic boolean delistResource(javax.transaction.xa.XAResource xares, int flag) throws java.lang.IllegalStateException, javax.transaction.SystemException
delistResource
in interface javax.transaction.Transaction
xares
- The XAResource object representing the resource to delistflag
- One of the values of TMSUCCESS, TMSUSPEND, or TMFAIL.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 conditionpublic boolean enlistResource(javax.transaction.xa.XAResource xares) throws javax.transaction.RollbackException, java.lang.IllegalStateException, javax.transaction.SystemException
enlistResource
in interface javax.transaction.Transaction
xares
- The XAResource object representing the resource to enlistjavax.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 conditionpublic void doDetach(int flag) throws javax.transaction.SystemException
javax.transaction.SystemException
public void doAttach(int flag) throws javax.transaction.SystemException, javax.transaction.RollbackException
javax.transaction.SystemException
javax.transaction.RollbackException
public java.util.List getEnlistedXAResource()
public int getStatus() throws javax.transaction.SystemException
getStatus
in interface javax.transaction.Transaction
javax.transaction.SystemException
- Thrown if the transaction manager
encounters an unexpected error conditionpublic void registerSynchronization(javax.transaction.Synchronization sync) throws javax.transaction.RollbackException, java.lang.IllegalStateException, javax.transaction.SystemException
registerSynchronization
in interface javax.transaction.Transaction
sync
- The javax.transaction.Synchronization object for the
transaction associated with the target objectjavax.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 conditionpublic void rollback() throws java.lang.IllegalStateException, javax.transaction.SystemException
rollback
in interface javax.transaction.Transaction
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 conditionpublic int prepare() throws java.lang.IllegalStateException, javax.transaction.SystemException
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 conditionpublic void setRollbackOnly() throws java.lang.IllegalStateException, javax.transaction.SystemException
setRollbackOnly
in interface javax.transaction.Transaction
java.lang.IllegalStateException
- Thrown if the current thread is
not associated with any transaction.javax.transaction.SystemException
- Thrown if the transaction manager
encounters an unexpected error conditionpublic void timeoutExpired(java.lang.Object arg)
timeoutExpired
in interface TimerEventListener
public boolean equals(java.lang.Object obj2)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public TransactionContext getPropagationContext(boolean hold)
hold
- true if must increment the count to hold the object (not used!)public void setTimer(TimerEvent timer)
timer
- the timer event to setpublic void unsetTimer()
public void setTxDate(java.util.Date date)
date
- the Date to set for the transactionpublic java.util.Date getTxDate()
public void updatePropagationContext(TransactionContext pctx)
pctx
- propagation contextpublic Xid getXid()
public boolean toRemove()
public void cleanup()