org.slim3.datasource
Class XAResourceImpl

java.lang.Object
  extended by org.slim3.datasource.XAResourceImpl
All Implemented Interfaces:
XAResource

public class XAResourceImpl
extends Object
implements XAResource

An implementation class for XAResource.

Since:
3.0
Author:
higa

Field Summary
protected  Connection connection
          The connection.
protected  Xid currentXid
          The current transaction identifier.
protected  XAConnectionImpl pooledConnection
          The pooled connection.
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Constructor Summary
XAResourceImpl(XAConnectionImpl pooledConnection)
          Constructor.
 
Method Summary
protected  void assertSameXid(Xid xid)
          Asserts the transaction identifier is same current transaction identifier.
protected  void begin(Xid xid)
          Begins transaction.
 void commit(Xid xid, boolean onePhase)
           
 void end(Xid xid, int flags)
           
 void forget(Xid xid)
           
 Connection getConnection()
          Returns the connection.
 Xid getCurrentXid()
          Returns the current transaction identifier.
 int getTransactionTimeout()
           
 boolean isSameRM(XAResource xar)
           
 int prepare(Xid xid)
           
 Xid[] recover(int flag)
           
protected  void resume(Xid xid)
          Resumes transaction.
 void rollback(Xid xid)
           
 boolean setTransactionTimeout(int timeout)
           
 void start(Xid xid, int flags)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentXid

protected Xid currentXid
The current transaction identifier.


pooledConnection

protected XAConnectionImpl pooledConnection
The pooled connection.


connection

protected Connection connection
The connection.

Constructor Detail

XAResourceImpl

public XAResourceImpl(XAConnectionImpl pooledConnection)
               throws NullPointerException
Constructor.

Parameters:
pooledConnection - the pooled connection
Throws:
NullPointerException - if the pooledConnection parameter is null
Method Detail

start

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

begin

protected void begin(Xid xid)
              throws XAException
Begins transaction.

Parameters:
xid - the transaction identifier.
Throws:
XAException - if a SQLException is encountered.

resume

protected void resume(Xid xid)
               throws XAException
Resumes transaction.

Parameters:
xid - the transaction identifier
Throws:
XAException - if an exception is encountered.

end

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

prepare

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

commit

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

rollback

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

forget

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

recover

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

isSameRM

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

getTransactionTimeout

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

setTransactionTimeout

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

getCurrentXid

public Xid getCurrentXid()
Returns the current transaction identifier.

Returns:
the current transaction identifier

getConnection

public Connection getConnection()
Returns the connection.

Returns:
the connection

assertSameXid

protected void assertSameXid(Xid xid)
                      throws IllegalStateException
Asserts the transaction identifier is same current transaction identifier.

Parameters:
xid - the transaction identifier
Throws:
IllegalStateException - if the transaction identifier is not same current transaction identifier


Copyright © 2008-2009 The Slim3 project. All Rights Reserved.