|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.objectweb.jotm.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 | |
void |
associateThreadTx(Xid xid)
Associate Thread to this transaction. |
void |
begin()
Creates a new transaction and associate it with the current thread. |
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. |
static Current |
getCurrent()
Returns the unique instance of the class or null if not
initialized in case of plain client. |
int |
getDefaultTimeout()
Gets the default timeout value |
static TransactionFactory |
getJTM()
Returns the TMFactory (in JTM) |
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. |
void |
incrementBeginCounter()
Increments number of begun transactions by one. |
List |
popThreadLocalRMEventList()
Pop the current set from the stack of thread local resource event sets The list contains ResourceManagerEvent objects. |
void |
pushThreadLocalRMEventList(List eventList)
Push a new event list on the stack of thread local resource event sets. |
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. |
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. |
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. |
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 useMethod Detail |
public static TransactionManager getTransactionManager()
TransactionManager
instance.
public void begin() throws NotSupportedException, SystemException
begin
in interface UserTransaction
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 conditionpublic void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException
commit
in interface UserTransaction
RollbackException
- 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 conditionpublic void rollback() throws IllegalStateException, SecurityException, SystemException
rollback
in interface UserTransaction
SecurityException
- 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 conditionpublic void setRollbackOnly() throws IllegalStateException, SystemException
setRollbackOnly
in interface UserTransaction
IllegalStateException
- Thrown if the current thread is not
associated with a transaction.
SystemException
- Thrown if the transaction manager
encounters an unexpected error conditionpublic int getStatus() throws SystemException
getStatus
in interface UserTransaction
SystemException
- Thrown if the transaction manager
encounters an unexpected error conditionpublic void setTransactionTimeout(int timeout) throws SystemException
setTransactionTimeout
in interface UserTransaction
timeout
- 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 Transaction getTransaction() throws SystemException
getTransaction
in interface TransactionManager
SystemException
- Thrown if the transaction manager
encounters an unexpected error conditionpublic 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 TransactionManager
tobj
- 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 conditionpublic 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 TransactionManager
SystemException
- Thrown if the transaction manager
encounters an unexpected error condition
SystemException
- Thrown if the transaction manager
encounters an unexpected error conditionpublic void connectionOpened(ResourceManagerEvent event)
ResourceManagerEventListener
getConnection
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 ResourceManagerEventListener
event
- event sent to the listenerResourceManagerEventListener.connectionOpened(org.objectweb.transaction.jta.ResourceManagerEvent)
public void connectionClosed(ResourceManagerEvent event)
ResourceManagerEventListener
connectionClosed
in interface ResourceManagerEventListener
event
- event sent to the listenerResourceManagerEventListener.connectionClosed(org.objectweb.transaction.jta.ResourceManagerEvent)
public void connectionErrorOccured(ResourceManagerEvent event)
ResourceManagerEventListener
connectionErrorOccured
in interface ResourceManagerEventListener
event
- event sent to the listenerResourceManagerEventListener.connectionErrorOccured(org.objectweb.transaction.jta.ResourceManagerEvent)
public void pushThreadLocalRMEventList(List eventList)
TransactionManager
ResourceManagerEvent
objects.
pushThreadLocalRMEventList
in interface TransactionManager
eventList
- the possibly null list of events to store forecoming
ResourceManagerEvent
events occuring in the current thread.TransactionManager.pushThreadLocalRMEventList(java.util.List)
public List popThreadLocalRMEventList()
TransactionManager
ResourceManagerEvent
objects.
popThreadLocalRMEventList
in interface TransactionManager
ResourceManagerEvent
list of events that have occured in the current thread since the last
call of pushThreadLocalRMEventList
or since the thread
started.TransactionManager.popThreadLocalRMEventList()
public Reference getReference() throws NamingException
Reference
of this object.
getReference
in interface Referenceable
Reference
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 void setDefaultTimeout(int timeout)
timeout
- timeout value (in seconds)public int getDefaultTimeout()
public void setPropagationContext(TransactionContext pctx, boolean isReply)
isReply =
false
)isReply =
true
)
pctx
- TransactionContextisReply
- true
before calling a request,
false
after receiving a replypublic TransactionContext getPropagationContext(boolean hold)
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 void associateThreadTx(Xid xid)
public int getTotalCurrentTransactions()
public void incrementBeginCounter()
public int getTotalBegunTransactions()
public int getTotalRolledbackTransactions()
public int getTotalCommittedTransactions()
public int getTotalExpiredTransactions()
public Integer[] getTransactionCounters()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |