Current
is the common implementation for both
UserTransaction
and
TransactionManager
.
UserTransaction
is used by clients that want to demarcate
transactions themselves. It is referenceable through JNDI.
TransactionManager
is used by an application server.
This object is unique in a VM, i. e. each application server has
ONE Current
object and each client program should
normally issue only
ONE lookup on JNDI.
Current
also implements
Referenceable
and
Serializable
because of JNDI.
actionXAResource
public int actionXAResource(String xaAction,
String xatx)
- Returns all XAResources that require administrator recovery action.
associateThreadTx
public void associateThreadTx(Xid xid)
Associate Thread to this transaction.
(used by iiop interceptor)
begin
public void begin()
throws NotSupportedException,
SystemException
Creates a new transaction and associate it with the current thread.
begin
public void begin(Xid passxid)
throws NotSupportedException,
SystemException
Creates a new inflow transaction and associates it with the current thread.
passxid
- Xid
of the inflow transaction.
begin
public void begin(Xid passxid,
long timeout)
throws NotSupportedException,
SystemException
Creates a new inflow transaction and associates it with the current thread.
passxid
- Xid
of the inflow transaction.timeout
- value of the timeout (in seconds). If the value is less than
or equal to zero, the value will be set to the default value.
clearThreadTx
public void clearThreadTx()
Clear transaction from this thread if not known.
Useful when another thread completes the current thread's transaction
commit
public void commit()
throws RollbackException,
HeuristicMixedException,
HeuristicRollbackException,
SecurityException,
IllegalStateException,
SystemException
Commits the transaction associated with the current thread. When this
method completes, the thread becomes associated with no transaction.
forgetTx
public void forgetTx(Xid xid)
Forget all about this transaction.
References to TransactionImpl
must be destroyed to allow
the garbage collector to free memory allocated to this transaction.
xid
- Xid
of the transaction
getAllRcTx
public String[] getAllRcTx()
Get all Transactions that may require recovery.
- array of all Transactions that may require recovery
getAllTx
public String[] getAllTx()
Get all executing transactions.
- array of all Transactions in execution
getAllXaTx
public String[] getAllXaTx(String stx)
Get all XAResources that may require recovery.
- array of all XAResources that may require recovery
getAllXid
public Xid[] getAllXid()
Get all Xid's associated with this transaction.
- array of all Xids
getCurrent
public static Current getCurrent()
Returns the unique instance of the class or null
if not
initialized in case of plain client.
- The
Current
object created
getDefaultRecovery
public static boolean getDefaultRecovery()
Gets the default recovery value
- default recovery value (true or false)
getDefaultTimeout
public int getDefaultTimeout()
Gets the default timeout value
- default timeout value (in seconds)
getJTM
public static TransactionFactory getJTM()
Returns the TMFactory (in JTM)
- TransactionFactory
getPreparedHeuristicXid
public Xid[] getPreparedHeuristicXid()
Get the Xid's of all prepared transactions.
- array of all Xids in the prepared state
getPropagationContext
public TransactionContext getPropagationContext(boolean hold)
Get the transaction context associated with the current thread or null
if the thread is not involved in a transaction.
getReference
public Reference getReference()
throws NamingException
Retrieves the Reference
of this object.
- The non-null
Reference
of this object.
getStatus
public int getStatus()
throws SystemException
Returns the status of the transaction associated with the current
thread.
- transaction status. If no transaction is associated with the
current thread, this method returns the Status.NoTransaction value.
getTotalBegunTransactions
public int getTotalBegunTransactions()
Returns the total number of begun transactions.
- total number of begun transactions
getTotalCommittedTransactions
public int getTotalCommittedTransactions()
Returns the total number of committed transactions.
- total number of commited transactions
getTotalCurrentTransactions
public int getTotalCurrentTransactions()
Returns the current number of transactions.
- current number of transaction
getTotalExpiredTransactions
public int getTotalExpiredTransactions()
Returns the total number of rolled back transactions due to timeout.
- number of rolled back transactions due to timeout
getTotalRolledbackTransactions
public int getTotalRolledbackTransactions()
Returns the total number of rolled back transactions.
- total number of rolled back transactions
getTransaction
public Transaction getTransaction()
throws SystemException
Gets the transaction object that represents the transaction context of
the calling thread.
- the Transaction object representing the transaction
associated with the calling thread. If the calling thread is
not associated with a transaction, a null object reference
is returned.
getTransactionCounters
public Integer[] getTransactionCounters()
Returns all counters.
- an array of all counters (current tx, begun tx, committed tx,
rolled back tx, timeouted tx)
getTransactionManager
public static TransactionManager getTransactionManager()
Gets the TransactionManager
instance.
- TransactionManager
getTransactionRecovery
public static TransactionRecovery getTransactionRecovery()
Returns the Transaction Recovery object
- TransactionRecovery
getTxByXid
public TransactionImpl getTxByXid(Xid xid)
Get the transaction referenced by Xid.
xid
- Xid
of the transaction
getXATerminator
public XATerminator getXATerminator()
throws XAException
Gets the inflow transaction object that represents the transaction context of
the calling thread.
- the XATerminator object representing the inflow transaction
associated with the calling thread. If the calling thread is
not associated with an inflow transaction, a null object reference
is returned.
pushThreadLocalRMEventList
public void pushThreadLocalRMEventList(List eventList)
- pushThreadLocalRMEventList in interface TransactionManager
org.objectweb.transaction.jta.TransactionManager.pushThreadLocalRMEventList(java.util.List)
resetAllTxTotalCounters
public void resetAllTxTotalCounters()
Resets total number of transactions.
resume
public void resume(Transaction tobj)
throws InvalidTransactionException,
IllegalStateException,
SystemException
Resumes the transaction context association of the calling thread with
the transaction represented by the supplied Transaction object. When this
method returns, the calling thread is associated with the transaction
context specified.
Warning: No XA start is done here. We suppose it is already
done after a
getConnection()
.
The supposed programming model is:
getConnection()
- SQL code
connection.close()
tobj
- The Transaction
object that represents the
transaction to be resumed.
rollback
public void rollback()
throws IllegalStateException,
SecurityException,
SystemException
Rolls back the transaction associated with the current thread. When this
method completes, the thread becomes associated with no transaction.
setDefaultRecovery
public static void setDefaultRecovery(boolean recovery)
Sets the default recovery value
recovery
- recovery value (true or false)
setDefaultTimeout
public void setDefaultTimeout(int timeout)
Sets the default timeout value
timeout
- timeout value (in seconds)
setPropagationContext
public void setPropagationContext(TransactionContext pctx,
boolean isReply)
Associate to the current thread a transaction represented by its
transaction context.
This is used internally by the implicit propagation of the
transactional context:
- in the skeleton, before calling the request (
isReply =
false
)
- in the stub, after receiving the reply (
isReply =
true
)
pctx
- TransactionContextisReply
- true
before calling a request,
false
after receiving a reply
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.
setTransactionRecovery
public void setTransactionRecovery(boolean recovery)
throws SystemException
Modifies the value of the recovery value that is associated with the
transactions started by the current thread with the begin method.
If an application has not called this method, the transaction
service uses the default value of 'false' for recovery.
recovery
- value of the recovery (true or faluse). If the value is
false, recovery of transactions is disabled.
setTransactionTimeout
public void setTransactionTimeout(int timeout)
throws SystemException
Modifies the value of the timeout value that is associated with the
transactions started by the current thread with the begin method.
If an application has not called this method, the transaction
service uses some default value for the transaction timeout.
timeout
- value of the timeout (in seconds). If the value is zero,
the transaction service restores the default value.
suspend
public Transaction suspend()
throws SystemException
Suspends the transaction currently associated with the calling thread
and return a
Transaction
object that represents the
transaction context being suspended.
If the calling thread is not
associated with a transaction, the method returns
null
. When this method returns, the calling thread is
associated with no transaction.
Warning: No XA start is done here. We suppose it is already
done after a
getConnection()
.
The supposed programming model is:
getConnection()
- SQL code
connection.close()
- Transaction object representing the suspended transaction.