|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.objectweb.jotm.Current
public class Current
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.
| Constructor Summary | |
|---|---|
Current()
Default constructor. |
|
Current(TransactionFactory tmfact)
Constructor for an application server. |
|
| Method Summary | |
|---|---|
int |
actionXAResource(String xaAction,
String xatx)
|
void |
associateThreadTx(Xid xid)
Associate Thread to this transaction. |
void |
begin()
Creates a new transaction and associate it with the current thread. |
void |
begin(Xid passxid)
Creates a new inflow transaction and associates it with the current thread. |
void |
begin(Xid passxid,
long timeout)
Creates a new inflow transaction and associates it with the current thread. |
void |
clearThreadTx()
Clear transaction from this thread if not known. |
void |
commit()
Commits the transaction associated with the current thread. |
void |
connectionClosed(ResourceManagerEvent event)
This method is called by the resource manager when a logical connection that was opened without transaction context is closed. |
void |
connectionErrorOccured(ResourceManagerEvent event)
This method is called by the resource manager when a logical connection that was opened without transaction context is about to throw an exception. |
void |
connectionOpened(ResourceManagerEvent event)
This method is called by the resource manager when a getConnection call is made without a transaction
context. |
void |
forgetTx(Xid xid)
Forget all about this transaction. |
String[] |
getAllRcTx()
Get all Transactions that may require recovery. |
String[] |
getAllTx()
Get all executing transactions. |
String[] |
getAllXaTx(String stx)
Get all XAResources that may require recovery. |
Xid[] |
getAllXid()
Get all Xid's associated with this transaction. |
static boolean |
getAppServer()
Gets the Application Server enabled value |
static Current |
getCurrent()
Returns the unique instance of the class or null if not
initialized in case of plain client. |
static boolean |
getDefaultRecovery()
Gets the default recovery value |
int |
getDefaultTimeout()
Gets the default timeout value |
static TransactionFactory |
getJTM()
Returns the TMFactory (in JTM) |
Xid[] |
getPreparedHeuristicXid()
Get the Xid's of all prepared transactions. |
TransactionContext |
getPropagationContext(boolean hold)
Get the transaction context associated with the current thread or null if the thread is not involved in a transaction. |
Reference |
getReference()
Retrieves the Reference of this object. |
int |
getStatus()
Returns the status of the transaction associated with the current thread. |
int |
getTotalBegunTransactions()
Returns the total number of begun transactions. |
int |
getTotalCommittedTransactions()
Returns the total number of committed transactions. |
int |
getTotalCurrentTransactions()
Returns the current number of transactions. |
int |
getTotalExpiredTransactions()
Returns the total number of rolled back transactions due to timeout. |
int |
getTotalRolledbackTransactions()
Returns the total number of rolled back transactions. |
Transaction |
getTransaction()
Gets the transaction object that represents the transaction context of the calling thread. |
Integer[] |
getTransactionCounters()
Returns all counters. |
static TransactionManager |
getTransactionManager()
Gets the TransactionManager instance. |
static TransactionRecovery |
getTransactionRecovery()
Returns the Transaction Recovery object |
int |
getTransactionTimeout()
Gets the transaction timeout value |
TransactionImpl |
getTxByXid(Xid xid)
Get the transaction referenced by Xid. |
XATerminator |
getXATerminator()
Gets the inflow transaction object that represents the transaction context of the calling thread. |
List |
popThreadLocalRMEventList()
|
void |
pushThreadLocalRMEventList(List eventList)
|
void |
resetAllTxTotalCounters()
Resets total number of transactions. |
void |
resume(Transaction tobj)
Resumes the transaction context association of the calling thread with the transaction represented by the supplied Transaction object. |
void |
rollback()
Rolls back the transaction associated with the current thread. |
static void |
setAppServer(boolean appserver)
Sets indicator if running with Application Server |
static void |
setDefaultRecovery(boolean recovery)
Sets the default recovery value |
void |
setDefaultTimeout(int timeout)
Sets the default timeout value |
void |
setPropagationContext(TransactionContext pctx,
boolean isReply)
Associate to the current thread a transaction represented by its transaction context. |
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. |
static void |
setTMFactory(TransactionFactory tmfact)
The TM factory is passed as an argument. |
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. |
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. |
Transaction |
suspend()
Suspends the transaction currently associated with the calling thread and return a Transaction object that represents the
transaction context being suspended. |
static void |
transactionRecovery()
Initiate transaction recovery if enabled. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Current()
public Current(TransactionFactory tmfact)
tmfact - TM Factory to use| Method Detail |
|---|
public static void setTMFactory(TransactionFactory tmfact)
tmfact - TM Factory to usepublic static void transactionRecovery()
public static TransactionManager getTransactionManager()
TransactionManager instance.
public void begin()
throws NotSupportedException,
SystemException
begin in interface TransactionManagerbegin in interface UserTransactionNotSupportedException - Thrown if the thread is already
associated with a transaction. (nested transaction are not
supported)
SystemException - Thrown if the transaction manager
encounters an unexpected error condition
public void begin(Xid passxid)
throws NotSupportedException,
SystemException
passxid - Xid of the inflow transaction.
NotSupportedException - Thrown if the thread is already
associated with a transaction. (nested transaction are not
supported)
SystemException - Thrown if the transaction manager
encounters an unexpected error condition
public void begin(Xid passxid,
long timeout)
throws NotSupportedException,
SystemException
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.
NotSupportedException - Thrown if the thread is already
associated with a transaction. (nested transaction are not
supported)
SystemException - Thrown if the transaction manager
encounters an unexpected error condition
public XATerminator getXATerminator()
throws XAException
XAException - Thrown if the transaction manager
encounters an unexpected error condition
public void commit()
throws RollbackException,
HeuristicMixedException,
HeuristicRollbackException,
SecurityException,
IllegalStateException,
SystemException
commit in interface TransactionManagercommit in interface UserTransactionRollbackException - 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
public void rollback()
throws IllegalStateException,
SecurityException,
SystemException
rollback in interface TransactionManagerrollback in interface UserTransactionSecurityException - Thrown to indicate that the thread is not
allowed to roll back 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
public void setRollbackOnly()
throws IllegalStateException,
SystemException
setRollbackOnly in interface TransactionManagersetRollbackOnly in interface UserTransactionIllegalStateException - Thrown if the current thread is not
associated with a transaction.
SystemException - Thrown if the transaction manager
encounters an unexpected error condition
public int getStatus()
throws SystemException
getStatus in interface TransactionManagergetStatus in interface UserTransactionSystemException - Thrown if the transaction manager
encounters an unexpected error condition
public void setTransactionTimeout(int timeout)
throws SystemException
setTransactionTimeout in interface TransactionManagersetTransactionTimeout in interface UserTransactiontimeout - value of the timeout (in seconds). If the value is zero,
the transaction service restores the default value.
SystemException - Thrown if the transaction manager
encounters an unexpected error conditionpublic int getTransactionTimeout()
public void setTransactionRecovery(boolean recovery)
throws SystemException
recovery - value of the recovery (true or false). If the value is
false, recovery of transactions is disabled.
SystemException - Thrown if the transaction manager
encounters an unexpected error condition
public Transaction getTransaction()
throws SystemException
getTransaction in interface TransactionManagerSystemException - Thrown if the transaction manager
encounters an unexpected error condition
public void resume(Transaction tobj)
throws InvalidTransactionException,
IllegalStateException,
SystemException
Warning: No XA start is done here. We suppose it is already
done after a getConnection().
getConnection()connection.close()
resume in interface TransactionManagertobj - The Transaction object that represents the
transaction to be resumed.
InvalidTransactionException - Thrown if the parameter
transaction object contains an invalid transaction
IllegalStateException - Thrown if the thread is already
associated with another transaction.
SystemException - Thrown if the transaction manager
encounters an unexpected error condition
public Transaction suspend()
throws SystemException
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().
getConnection()connection.close()
suspend in interface TransactionManagerSystemException - Thrown if the transaction manager
encounters an unexpected error conditionpublic void connectionOpened(ResourceManagerEvent event)
ResourceManagerEventListenergetConnection call is made without a transaction
context. The ResourceManagerEvent is to be used
by the listener to keep track of those events and perform a late
enrolment of those logical connection when the transaction begins.
connectionOpened in interface ResourceManagerEventListenerevent - the event representing the connectionResourceManagerEventListener.connectionOpened(org.objectweb.transaction.jta.ResourceManagerEvent)public void connectionClosed(ResourceManagerEvent event)
ResourceManagerEventListener
connectionClosed in interface ResourceManagerEventListenerevent - the event representing the connectionResourceManagerEventListener.connectionClosed(org.objectweb.transaction.jta.ResourceManagerEvent)public void connectionErrorOccured(ResourceManagerEvent event)
ResourceManagerEventListener
connectionErrorOccured in interface ResourceManagerEventListenerevent - the event representing the connectionResourceManagerEventListener.connectionErrorOccured(org.objectweb.transaction.jta.ResourceManagerEvent)public void pushThreadLocalRMEventList(List eventList)
eventList - Event list to be put on the StackTransactionManager.pushThreadLocalRMEventList(java.util.List)public List popThreadLocalRMEventList()
TransactionManager.popThreadLocalRMEventList()
public Reference getReference()
throws NamingException
Reference of this object.
getReference in interface ReferenceableReference of this object.
NamingException - If a naming exception was encountered while retrieving the reference.public static Current getCurrent()
null if not
initialized in case of plain client.
Current object createdpublic static TransactionFactory getJTM()
public static TransactionRecovery getTransactionRecovery()
public void setDefaultTimeout(int timeout)
timeout - timeout value (in seconds)public int getDefaultTimeout()
public static void setDefaultRecovery(boolean recovery)
recovery - recovery value (true or false)public static boolean getDefaultRecovery()
public static void setAppServer(boolean appserver)
appserver - application server enabled value (true or false)public static boolean getAppServer()
public void setPropagationContext(TransactionContext pctx,
boolean isReply)
pctx - TransactionContext. May be null to clean the thread (server side)isReply - true when receiving a reply (client side)public TransactionContext getPropagationContext(boolean hold)
hold - true if hold the object while used. (Not used any longer)
public void forgetTx(Xid xid)
TransactionImpl must be destroyed to allow
the garbage collector to free memory allocated to this transaction.
xid - Xid of the transactionpublic TransactionImpl getTxByXid(Xid xid)
xid - Xid of the transaction
public Xid[] getPreparedHeuristicXid()
public Xid[] getAllXid()
public String[] getAllTx()
public String[] getAllRcTx()
public String[] getAllXaTx(String stx)
stx - identifies the transaction
public int actionXAResource(String xaAction,
String xatx)
xaAction - String "commit" "rollback" or "forget"xatx - String representing the transaction
public void associateThreadTx(Xid xid)
xid - the transaction xidpublic void clearThreadTx()
public int getTotalCurrentTransactions()
public int getTotalBegunTransactions()
public int getTotalRolledbackTransactions()
public int getTotalCommittedTransactions()
public void resetAllTxTotalCounters()
public int getTotalExpiredTransactions()
public Integer[] getTransactionCounters()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||