org.apache.qpid.client
Class XAResourceImpl

java.lang.Object
  extended by org.apache.qpid.client.XAResourceImpl
All Implemented Interfaces:
XAResource

public class XAResourceImpl
extends Object
implements XAResource

This is an implementation of javax.njms.XAResource.


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
protected XAResourceImpl(XASessionImpl xaSession)
          Create an XAResource associated with a XASession
 
Method Summary
 void commit(Xid xid, boolean b)
          Commits the global transaction specified by xid.
 void end(Xid xid, int flag)
          Ends the work performed on behalf of a transaction branch.
 void forget(Xid xid)
          Tells the resource manager to forget about a heuristically completed transaction branch.
 int getTransactionTimeout()
          Obtains the current transaction timeout value set for this XAResource instance.
 boolean isSameRM(XAResource xaResource)
          This method is called to determine if the resource manager instance represented by the target object is the same as the resouce manager instance represented by the parameter xaResource.
 int prepare(Xid xid)
          Prepare for a transaction commit of the transaction specified in Xid.
 Xid[] recover(int flag)
          Obtains a list of prepared transaction branches.
 void rollback(Xid xid)
          Informs the resource manager to roll back work done on behalf of a transaction branch
 boolean setTransactionTimeout(int timeout)
          Sets the current transaction timeout value for this XAResource instance.
 void start(Xid xid, int flag)
          Starts 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

protected XAResourceImpl(XASessionImpl xaSession)
Create an XAResource associated with a XASession

Parameters:
xaSession - The session XAresource
Method Detail

commit

public void commit(Xid xid,
                   boolean b)
            throws XAException
Commits the global transaction specified by xid.

Specified by:
commit in interface XAResource
Parameters:
xid - A global transaction identifier
b - If true, use a one-phase commit protocol to commit the work done on behalf of xid.
Throws:
XAException - An error has occurred. An error has occurred. Possible XAExceptions are XA_HEURHAZ, XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.

end

public void end(Xid xid,
                int flag)
         throws XAException
Ends the work performed on behalf of a transaction branch. The resource manager disassociates the XA resource from the transaction branch specified and lets the transaction complete.

forget

public void forget(Xid xid)
            throws XAException
Tells the resource manager to forget about a heuristically completed transaction branch.

Specified by:
forget in interface XAResource
Parameters:
xid - String(xid.getGlobalTransactionId() A global transaction identifier
Throws:
XAException - An error has occurred. Possible exception values are XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.

getTransactionTimeout

public int getTransactionTimeout()
                          throws XAException
Obtains the current transaction timeout value set for this XAResource instance. If XAResource.setTransactionTimeout was not used prior to invoking this method, the return value is the default timeout i.e. 0;

Specified by:
getTransactionTimeout in interface XAResource
Returns:
The transaction timeout value in seconds.
Throws:
XAException - An error has occurred. Possible exception values are XAER_RMERR, XAER_RMFAIL.

isSameRM

public boolean isSameRM(XAResource xaResource)
                 throws XAException
This method is called to determine if the resource manager instance represented by the target object is the same as the resouce manager instance represented by the parameter xaResource.

Specified by:
isSameRM in interface XAResource
Parameters:
xaResource - An XAResource object whose resource manager instance is to be compared with the resource manager instance of the target object
Returns:
true if it's the same RM instance; otherwise false.
Throws:
XAException - An error has occurred. Possible exception values are XAER_RMERR, XAER_RMFAIL.

prepare

public int prepare(Xid xid)
            throws XAException
Prepare for a transaction commit of the transaction specified in Xid.

Specified by:
prepare in interface XAResource
Parameters:
xid - A global transaction identifier.
Returns:
A value indicating the resource manager's vote on the outcome of the transaction. The possible values are: XA_RDONLY or XA_OK.
Throws:
XAException - An error has occurred. Possible exception values are: XAER_RMERR or XAER_NOTA

recover

public Xid[] recover(int flag)
              throws XAException
Obtains a list of prepared transaction branches.

The transaction manager calls this method during recovery to obtain the list of transaction branches that are currently in prepared or heuristically completed states.

Specified by:
recover in interface XAResource
Parameters:
flag - One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other flags are set in the parameter.
Returns:
zero or more XIDs of the transaction branches that are currently in a prepared or heuristically completed state.
Throws:
XAException - An error has occurred. Possible value is XAER_INVAL.

rollback

public void rollback(Xid xid)
              throws XAException
Informs the resource manager to roll back work done on behalf of a transaction branch

Specified by:
rollback in interface XAResource
Parameters:
xid - A global transaction identifier.
Throws:
XAException - An error has occurred.

setTransactionTimeout

public boolean setTransactionTimeout(int timeout)
                              throws XAException
Sets the current transaction timeout value for this XAResource instance. Once set, this timeout value is effective until setTransactionTimeout is invoked again with a different value. To reset the timeout value to the default value used by the resource manager, set the value to zero.

Specified by:
setTransactionTimeout in interface XAResource
Parameters:
timeout - The transaction timeout value in seconds.
Returns:
true if transaction timeout value is set successfully; otherwise false.
Throws:
XAException - An error has occurred. Possible exception values are XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.

start

public void start(Xid xid,
                  int flag)
           throws XAException
Starts work on behalf of a transaction branch specified in xid.

Specified by:
start in interface XAResource
Parameters:
xid - A global transaction identifier to be associated with the resource
flag - One of TMNOFLAGS, TMJOIN, or TMRESUME
Throws:
XAException - An error has occurred. Possible exceptions are XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_DUPID, XAER_OUTSIDE, XAER_NOTA, XAER_INVAL, or XAER_PROTO.


Licensed to the Apache Software Foundation