org.apache.activemq.ra
Class ManagedTransactionContext

java.lang.Object
  extended by org.apache.activemq.TransactionContext
      extended by org.apache.activemq.ra.ManagedTransactionContext
All Implemented Interfaces:
XAResource

public class ManagedTransactionContext
extends TransactionContext

Allows us to switch between using a shared transaction context, or using a local transaction context.


Field Summary
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Constructor Summary
ManagedTransactionContext(TransactionContext sharedContext)
           
 
Method Summary
 void addSynchronization(Synchronization s)
           
 void begin()
          Start a local transaction.
 void commit()
          Commits all work done in this transaction and releases any locks currently held.
 void commit(Xid xid, boolean onePhase)
           
 void end(Xid xid, int flags)
           
 void forget(Xid xid)
           
 TransactionId getTransactionId()
           
 int getTransactionTimeout()
           
 boolean isInLocalTransaction()
           
 boolean isInTransaction()
           
 boolean isInXATransaction()
           
 boolean isSameRM(XAResource xaResource)
           
 int prepare(Xid xid)
           
 Xid[] recover(int flag)
           
 void rollback()
          Rolls back any work done in this transaction and releases any locks currently held.
 void rollback(Xid xid)
           
 boolean setTransactionTimeout(int seconds)
           
 void setUseSharedTxContext(boolean enable)
           
 void start(Xid xid, int flags)
          Associates a transaction with the resource.
 
Methods inherited from class org.apache.activemq.TransactionContext
cleanup, getConnection, getLocalTransactionEventListener, setLocalTransactionEventListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ManagedTransactionContext

public ManagedTransactionContext(TransactionContext sharedContext)
Method Detail

setUseSharedTxContext

public void setUseSharedTxContext(boolean enable)
                           throws JMSException
Throws:
JMSException

begin

public void begin()
           throws JMSException
Description copied from class: TransactionContext
Start a local transaction.

Overrides:
begin in class TransactionContext
Throws:
JMSException - on internal error

commit

public void commit()
            throws JMSException
Description copied from class: TransactionContext
Commits all work done in this transaction and releases any locks currently held.

Overrides:
commit in class TransactionContext
Throws:
JMSException - if the JMS provider fails to commit the transaction due to some internal error.
IllegalStateException - if the method is not called by a transacted session.

commit

public void commit(Xid xid,
                   boolean onePhase)
            throws XAException
Specified by:
commit in interface XAResource
Overrides:
commit in class TransactionContext
Throws:
XAException

end

public void end(Xid xid,
                int flags)
         throws XAException
Specified by:
end in interface XAResource
Overrides:
end in class TransactionContext
Throws:
XAException

forget

public void forget(Xid xid)
            throws XAException
Specified by:
forget in interface XAResource
Overrides:
forget in class TransactionContext
Throws:
XAException

getTransactionId

public TransactionId getTransactionId()
Overrides:
getTransactionId in class TransactionContext

getTransactionTimeout

public int getTransactionTimeout()
                          throws XAException
Specified by:
getTransactionTimeout in interface XAResource
Overrides:
getTransactionTimeout in class TransactionContext
Throws:
XAException

isInLocalTransaction

public boolean isInLocalTransaction()
Overrides:
isInLocalTransaction in class TransactionContext

isInXATransaction

public boolean isInXATransaction()
Overrides:
isInXATransaction in class TransactionContext

isInTransaction

public boolean isInTransaction()
Overrides:
isInTransaction in class TransactionContext

isSameRM

public boolean isSameRM(XAResource xaResource)
                 throws XAException
Specified by:
isSameRM in interface XAResource
Overrides:
isSameRM in class TransactionContext
Throws:
XAException

prepare

public int prepare(Xid xid)
            throws XAException
Specified by:
prepare in interface XAResource
Overrides:
prepare in class TransactionContext
Throws:
XAException

recover

public Xid[] recover(int flag)
              throws XAException
Specified by:
recover in interface XAResource
Overrides:
recover in class TransactionContext
Throws:
XAException

rollback

public void rollback()
              throws JMSException
Description copied from class: TransactionContext
Rolls back any work done in this transaction and releases any locks currently held.

Overrides:
rollback in class TransactionContext
Throws:
JMSException - if the JMS provider fails to roll back the transaction due to some internal error.
IllegalStateException - if the method is not called by a transacted session.

rollback

public void rollback(Xid xid)
              throws XAException
Specified by:
rollback in interface XAResource
Overrides:
rollback in class TransactionContext
Throws:
XAException

setTransactionTimeout

public boolean setTransactionTimeout(int seconds)
                              throws XAException
Specified by:
setTransactionTimeout in interface XAResource
Overrides:
setTransactionTimeout in class TransactionContext
Throws:
XAException

start

public void start(Xid xid,
                  int flags)
           throws XAException
Description copied from class: TransactionContext
Associates a transaction with the resource.

Specified by:
start in interface XAResource
Overrides:
start in class TransactionContext
Throws:
XAException

addSynchronization

public void addSynchronization(Synchronization s)
Overrides:
addSynchronization in class TransactionContext


Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.