bitronix.tm.resource.jdbc.lrc
Class LrcXAResource

java.lang.Object
  extended by bitronix.tm.resource.jdbc.lrc.LrcXAResource
All Implemented Interfaces:
XAResource

public class LrcXAResource
extends Object
implements XAResource

XAResource implementation for a non-XA JDBC connection emulating XA with Last Resource Commit.

The XA protocol flow is implemented by this state machine:

 NO_TX
   |
   | start(TMNOFLAGS)
   |
   |       end(TMFAIL)
 STARTED -------------- NO_TX
   |
   | end(TMSUCCESS)
   |
   |    start(TMJOIN)
 ENDED ---------------- STARTED
   |\
   | \  commit (one phase)
   |  ----------------- NO_TX
   |
   | prepare()
   |
   |       commit() or
   |       rollback()
 PREPARED ------------- NO_TX
 
XAResource.TMSUSPEND and XAResource.TMRESUME are not supported.

Author:
lorban

Field Summary
static int ENDED
           
static int NO_TX
           
static int PREPARED
           
static int STARTED
           
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Constructor Summary
LrcXAResource(Connection connection)
           
 
Method Summary
 void commit(Xid xid, boolean onePhase)
           
 void end(Xid xid, int flag)
           
 void forget(Xid xid)
           
 int getState()
           
 int getTransactionTimeout()
           
 boolean isSameRM(XAResource xaResource)
           
 int prepare(Xid xid)
           
 Xid[] recover(int flags)
           
 void rollback(Xid xid)
           
 boolean setTransactionTimeout(int seconds)
           
 void start(Xid xid, int flag)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_TX

public static final int NO_TX
See Also:
Constant Field Values

STARTED

public static final int STARTED
See Also:
Constant Field Values

ENDED

public static final int ENDED
See Also:
Constant Field Values

PREPARED

public static final int PREPARED
See Also:
Constant Field Values
Constructor Detail

LrcXAResource

public LrcXAResource(Connection connection)
Method Detail

getState

public int getState()

getTransactionTimeout

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

setTransactionTimeout

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

forget

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

recover

public Xid[] recover(int flags)
              throws XAException
Specified by:
recover in interface XAResource
Throws:
XAException

isSameRM

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

start

public void start(Xid xid,
                  int flag)
           throws XAException
Specified by:
start in interface XAResource
Throws:
XAException

end

public void end(Xid xid,
                int flag)
         throws XAException
Specified by:
end in interface XAResource
Throws:
XAException

prepare

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

commit

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

rollback

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

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved.