org.objectweb.jonas.jdbc_xa
Class XAResourceImpl

java.lang.Object
  |
  +--org.objectweb.jonas.jdbc_xa.XAResourceImpl
All Implemented Interfaces:
javax.transaction.xa.XAResource

public class XAResourceImpl
extends java.lang.Object
implements javax.transaction.xa.XAResource

This is the implementation of the XAResource interface for our pseudo JDBC-XA driver. This object is used to demarcate the transactions and associate an XID to the SQL requests (start-end). Actually, no real 2PC is done here because the std JDBC driver do not support a java XA interface for it (only commit/rollback but no prepare!) So we choose to return always OK at prepare. The goal is more to offer a standard JDBC-XA interface to the EJB Container than to achieve a real distributed 2PC. Anyway, when database vendors will offer real JDBC-XA drivers, the JOnAS Server will be OK without any change.

Author:
Philippe Durieux Contributor(s):

Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Constructor Summary
XAResourceImpl(org.objectweb.jonas.jdbc_xa.XAConnectionImpl xac, java.sql.Connection actual, XADataSourceImpl ds)
           
 
Method Summary
 void commit(javax.transaction.xa.Xid xid, boolean onePhase)
          Commit the global transaction specified by xid.
 void end(javax.transaction.xa.Xid xid, int flags)
          Ends the work performed on behalf of a transaction branch.
 void forget(javax.transaction.xa.Xid xid)
          Tell the resource manager to forget about a heuristically completed transaction branch.
 java.lang.String getRMID()
           
 int getTransactionTimeout()
          Obtain the current transaction timeout value set for this XAResource instance.
 boolean isSameRM(javax.transaction.xa.XAResource xares)
          Determine if the resource manager instance represented by the target object is the same as the resource manager instance represented by the parameter xares
 int prepare(javax.transaction.xa.Xid xid)
          Ask the resource manager to prepare for a transaction commit of the transaction specified in xid.
 javax.transaction.xa.Xid[] recover(int flag)
          Obtain a list of prepared transaction branches from a resource manager.
 void rollback(javax.transaction.xa.Xid xid)
          Inform the resource manager to roll back work done on behalf of a transaction branch
 boolean setTransactionTimeout(int seconds)
          Set the current transaction timeout value for this XAResource instance.
 void start(javax.transaction.xa.Xid xid, int flags)
          Start work on behalf of a transaction branch specified in xid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XAResourceImpl

public XAResourceImpl(org.objectweb.jonas.jdbc_xa.XAConnectionImpl xac,
                      java.sql.Connection actual,
                      XADataSourceImpl ds)
Method Detail

commit

public void commit(javax.transaction.xa.Xid xid,
                   boolean onePhase)
            throws javax.transaction.xa.XAException
Commit the global transaction specified by xid.
Specified by:
commit in interface javax.transaction.xa.XAResource

end

public void end(javax.transaction.xa.Xid xid,
                int flags)
         throws javax.transaction.xa.XAException
Ends the work performed on behalf of a transaction branch.
Specified by:
end in interface javax.transaction.xa.XAResource

forget

public void forget(javax.transaction.xa.Xid xid)
            throws javax.transaction.xa.XAException
Tell the resource manager to forget about a heuristically completed transaction branch.
Specified by:
forget in interface javax.transaction.xa.XAResource

getTransactionTimeout

public int getTransactionTimeout()
                          throws javax.transaction.xa.XAException
Obtain the current transaction timeout value set for this XAResource instance.
Specified by:
getTransactionTimeout in interface javax.transaction.xa.XAResource

isSameRM

public boolean isSameRM(javax.transaction.xa.XAResource xares)
                 throws javax.transaction.xa.XAException
Determine if the resource manager instance represented by the target object is the same as the resource manager instance represented by the parameter xares
Specified by:
isSameRM in interface javax.transaction.xa.XAResource
Parameters:
xares - An XAResource object
Returns:
True if same RM instance, otherwise false.

prepare

public int prepare(javax.transaction.xa.Xid xid)
            throws javax.transaction.xa.XAException
Ask the resource manager to prepare for a transaction commit of the transaction specified in xid.
Specified by:
prepare in interface javax.transaction.xa.XAResource

recover

public javax.transaction.xa.Xid[] recover(int flag)
                                   throws javax.transaction.xa.XAException
Obtain a list of prepared transaction branches from a resource manager.
Specified by:
recover in interface javax.transaction.xa.XAResource

rollback

public void rollback(javax.transaction.xa.Xid xid)
              throws javax.transaction.xa.XAException
Inform the resource manager to roll back work done on behalf of a transaction branch
Specified by:
rollback in interface javax.transaction.xa.XAResource

setTransactionTimeout

public boolean setTransactionTimeout(int seconds)
                              throws javax.transaction.xa.XAException
Set the current transaction timeout value for this XAResource instance.
Specified by:
setTransactionTimeout in interface javax.transaction.xa.XAResource

start

public void start(javax.transaction.xa.Xid xid,
                  int flags)
           throws javax.transaction.xa.XAException
Start work on behalf of a transaction branch specified in xid
Specified by:
start in interface javax.transaction.xa.XAResource

getRMID

public java.lang.String getRMID()