org.objectweb.jonas.resource
Class LocalXAWrapper

java.lang.Object
  extended byorg.objectweb.jonas.resource.LocalXAWrapper
All Implemented Interfaces:
javax.transaction.xa.XAResource

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

A LocalXAWrapper that intercepts the XA calls for an RAR that only supports LocalTransactions and translates them to the appropriate Local Transaction methods.

Author:
Eric.Hardesty@bull.com

Field Summary
protected  javax.resource.spi.LocalTransaction localTrans
          The LocalTransaction object to make the begin(), commit(), and rollback() calls.
protected  int txstate
           
protected static int XA_ENDED
           
protected static int XA_FAILED
           
protected static int XA_NONE
          State of the transaction (See XA protocol)
protected static int XA_STARTED
           
protected static int XA_SUSPENDED
           
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Method Summary
 void commit(javax.transaction.xa.Xid xid, boolean onePhase)
          Commit the localTransaction
 void end(javax.transaction.xa.Xid xid, int flags)
          Ends the transaction No method to map for a local transaction.
 void forget(javax.transaction.xa.Xid xid)
          No method to map for a local transaction.
 int getTransactionTimeout()
          No method to map for a local transaction, just return no timeout.
 boolean isSameRM(javax.transaction.xa.XAResource xaresource)
          Determine if the wrapper instance is the same as the wrapper instance being passed in
 int prepare(javax.transaction.xa.Xid xid)
          No method to map for a local transaction, just return XA_OK.
 javax.transaction.xa.Xid[] recover(int i)
          No method to map for a local transaction.
 void rollback(javax.transaction.xa.Xid xid)
          Rollback the localTransaction
 boolean setTransactionTimeout(int i)
          No method to map for a local transaction, just return no timeout.
 void start(javax.transaction.xa.Xid xid, int flags)
          Only start a local transaction if a new transaction is being attempted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XA_NONE

protected static final int XA_NONE
State of the transaction (See XA protocol)

See Also:
Constant Field Values

XA_STARTED

protected static final int XA_STARTED
See Also:
Constant Field Values

XA_SUSPENDED

protected static final int XA_SUSPENDED
See Also:
Constant Field Values

XA_ENDED

protected static final int XA_ENDED
See Also:
Constant Field Values

XA_FAILED

protected static final int XA_FAILED
See Also:
Constant Field Values

txstate

protected int txstate

localTrans

protected javax.resource.spi.LocalTransaction localTrans
The LocalTransaction object to make the begin(), commit(), and rollback() calls.

Method Detail

start

public void start(javax.transaction.xa.Xid xid,
                  int flags)
           throws javax.transaction.xa.XAException
Only start a local transaction if a new transaction is being attempted

Specified by:
start in interface javax.transaction.xa.XAResource
Parameters:
xid - transaction xid
Throws:
javax.transaction.xa.XAException - Transaction already started or error starting a new local transaction

end

public void end(javax.transaction.xa.Xid xid,
                int flags)
         throws javax.transaction.xa.XAException
Ends the transaction No method to map for a local transaction.

Specified by:
end in interface javax.transaction.xa.XAResource
Parameters:
xid - transaction xid
flags - One of TMSUCCESS, TMFAIL, or TMSUSPEND.
Throws:
javax.transaction.xa.XAException

forget

public void forget(javax.transaction.xa.Xid xid)
            throws javax.transaction.xa.XAException
No method to map for a local transaction.

Specified by:
forget in interface javax.transaction.xa.XAResource
Parameters:
xid - transaction xid
Throws:
javax.transaction.xa.XAException

getTransactionTimeout

public int getTransactionTimeout()
                          throws javax.transaction.xa.XAException
No method to map for a local transaction, just return no timeout.

Specified by:
getTransactionTimeout in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

isSameRM

public boolean isSameRM(javax.transaction.xa.XAResource xaresource)
                 throws javax.transaction.xa.XAException
Determine if the wrapper instance is the same as the wrapper instance being passed in

Specified by:
isSameRM in interface javax.transaction.xa.XAResource
Parameters:
xaresource - An XAResource object
Returns:
True if same RM instance, otherwise false.
Throws:
javax.transaction.xa.XAException - no throw in this implementation

prepare

public int prepare(javax.transaction.xa.Xid xid)
            throws javax.transaction.xa.XAException
No method to map for a local transaction, just return XA_OK.

Specified by:
prepare in interface javax.transaction.xa.XAResource
Parameters:
xid - transaction xid
Throws:
javax.transaction.xa.XAException

recover

public javax.transaction.xa.Xid[] recover(int i)
                                   throws javax.transaction.xa.XAException
No method to map for a local transaction.

Specified by:
recover in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

commit

public void commit(javax.transaction.xa.Xid xid,
                   boolean onePhase)
            throws javax.transaction.xa.XAException
Commit the localTransaction

Specified by:
commit in interface javax.transaction.xa.XAResource
Parameters:
xid - transaction xid
onePhase - for interface compliance (ignored because forced)
Throws:
javax.transaction.xa.XAException - Exception trying to commit local transaction

rollback

public void rollback(javax.transaction.xa.Xid xid)
              throws javax.transaction.xa.XAException
Rollback the localTransaction

Specified by:
rollback in interface javax.transaction.xa.XAResource
Parameters:
xid - transaction xid
Throws:
javax.transaction.xa.XAException - Exception trying to rollback local transaction

setTransactionTimeout

public boolean setTransactionTimeout(int i)
                              throws javax.transaction.xa.XAException
No method to map for a local transaction, just return no timeout.

Specified by:
setTransactionTimeout in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException