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
ONECurrent object and each client program should
normally issue only ONE lookup on JNDI.
Current also implements Referenceable and
Serializable because of JNDI.
begin() Creates a new transaction and associate it with the current thread.
exception: NotSupportedException - Thrown if the thread is alreadyassociated with a transaction.
public void
begin(javax.transaction.xa.Xid passxid) Creates a new inflow transaction and associates it with the current thread.
Parameters: passxid - Xid of the inflow transaction. exception: NotSupportedException - Thrown if the thread is alreadyassociated with a transaction.
public void
begin(javax.transaction.xa.Xid passxid, long timeout) Creates a new inflow transaction and associates it with the current thread.
Parameters: passxid - Xid of the inflow transaction. Parameters: timeout - value of the timeout (in seconds).
public void
clearThreadTx() Clear transaction from this thread if not known.
public void
commit() Commits the transaction associated with the current thread.
getPropagationContext(boolean hold) Get the transaction context associated with the current thread or null
if the thread is not involved in a transaction.
getTransaction() Gets the transaction object that represents the transaction context of
the calling thread.
the Transaction object representing the transaction associated with the calling thread.
getTxByXid(Xid xid) Get the transaction referenced by Xid.
public XATerminator
getXATerminator() 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.
resume(Transaction tobj) Resumes the transaction context association of the calling thread with
the transaction represented by the supplied Transaction object.
public void
rollback() Rolls back the transaction associated with the current thread.
setRollbackOnly() Modify the transaction associated with the current thread such that the
only possible outcome of the transaction is to roll back the transaction.
public void
setTransactionRecovery(boolean recovery) 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.
Parameters: recovery - value of the recovery (true or faluse).
public void
setTransactionTimeout(int timeout) 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.
Parameters: timeout - value of the timeout (in seconds).
public Transaction
suspend() Suspends the transaction currently associated with the calling thread
and return a Transaction object that represents the
transaction context being suspended.
Constructor for an application server.
The TM factory is passed as an argument. Note that the TM factory can be
either local or remote.
Parameters: tmfact - TM Factory to use
Associate Thread to this transaction.
(used by iiop interceptor)
begin
public void begin() throws NotSupportedException, SystemException(Code)
Creates a new transaction and associate it with the current thread.
exception: NotSupportedException - Thrown if the thread is alreadyassociated with a transaction. (nested transaction are notsupported) exception: SystemException - Thrown if the transaction manager encounters an unexpected error condition
Creates a new inflow transaction and associates it with the current thread.
Parameters: passxid - Xid of the inflow transaction. exception: NotSupportedException - Thrown if the thread is alreadyassociated with a transaction. (nested transaction are notsupported) exception: SystemException - Thrown if the transaction manager encounters an unexpected error condition
Creates a new inflow transaction and associates it with the current thread.
Parameters: passxid - Xid of the inflow transaction. Parameters: 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. exception: NotSupportedException - Thrown if the thread is alreadyassociated with a transaction. (nested transaction are notsupported) exception: SystemException - Thrown if the transaction manager encounters an unexpected error condition
Commits the transaction associated with the current thread. When this
method completes, the thread becomes associated with no transaction.
exception: RollbackException - Thrown to indicate that the transactionhas been rolled back rather than committed. exception: HeuristicMixedException - Thrown to indicate that a heuristicdecision was made and that some relevant updates have been committedwhile others have been rolled back. exception: HeuristicRollbackException - Thrown to indicate that aheuristic decision was made and that some relevant updates have beenrolled back. exception: SecurityException - Thrown to indicate that the thread is notallowed to commit the transaction. exception: IllegalStateException - Thrown if the current thread is notassociated with a transaction. exception: SystemException - Thrown if the transaction manager encountersan unexpected error condition
Forget all about this transaction.
References to TransactionImpl must be destroyed to allow
the garbage collector to free memory allocated to this transaction.
Parameters: xid - Xid of the transaction
Retrieves the Reference of this object.
The non-null Reference of this object. exception: NamingException - If a naming exception was encountered while retrieving the reference.
getStatus
public int getStatus() throws SystemException(Code)
Returns the status of the transaction associated with the current
thread.
transaction status. If no transaction is associated with thecurrent thread, this method returns the Status.NoTransaction value. exception: SystemException - Thrown if the transaction managerencounters an unexpected error condition
Returns the total number of rolled back transactions.
total number of rolled back transactions
getTransaction
public Transaction getTransaction() throws SystemException(Code)
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 isnot associated with a transaction, a null object referenceis returned. exception: SystemException - Thrown if the transaction manager encounters an unexpected error condition
getTransactionCounters
public synchronized Integer[] getTransactionCounters()(Code)
Returns all counters.
an array of all counters (current tx, begun tx, committed tx,rolled back tx, timeouted tx)
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 isnot associated with an inflow transaction, a null object referenceis returned. exception: XAException - Thrown if the transaction manager encounters an unexpected error condition
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()
Parameters: tobj - The Transaction object that represents thetransaction to be resumed. exception: InvalidTransactionException - Thrown if the parametertransaction object contains an invalid transaction exception: IllegalStateException - Thrown if the thread is alreadyassociated with another transaction. exception: SystemException - Thrown if the transaction managerencounters an unexpected error condition
Rolls back the transaction associated with the current thread. When this
method completes, the thread becomes associated with no transaction.
exception: SecurityException - Thrown to indicate that the thread is notallowed to roll back the transaction. exception: IllegalStateException - Thrown if the current thread is notassociated with a transaction. exception: SystemException - Thrown if the transaction managerencounters an unexpected error condition
setDefaultRecovery
public static void setDefaultRecovery(boolean recovery)(Code)
Sets the default recovery value
Parameters: recovery - recovery value (true or false)
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)
Parameters: pctx - TransactionContext Parameters: isReply - true before calling a request,false after receiving a reply
Modify the transaction associated with the current thread such that the
only possible outcome of the transaction is to roll back the transaction.
exception: IllegalStateException - Thrown if the current thread is notassociated with a transaction. exception: SystemException - Thrown if the transaction managerencounters an unexpected error condition
setTransactionRecovery
public void setTransactionRecovery(boolean recovery) throws SystemException(Code)
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.
Parameters: recovery - value of the recovery (true or faluse). If the value isfalse, recovery of transactions is disabled. exception: SystemException - Thrown if the transaction managerencounters an unexpected error condition
setTransactionTimeout
public void setTransactionTimeout(int timeout) throws SystemException(Code)
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.
Parameters: timeout - value of the timeout (in seconds). If the value is zero,the transaction service restores the default value. exception: SystemException - Thrown if the transaction managerencounters an unexpected error condition
suspend
public Transaction suspend() throws SystemException(Code)
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. exception: SystemException - Thrown if the transaction managerencounters an unexpected error condition exception: SystemException - Thrown if the transaction managerencounters an unexpected error condition