start page | rating of books | rating of authors | reviews | copyrights

Book Home Java Enterprise in a Nutshell Search this book

Chapter 29. The javax.transaction.xa Package

The javax.transaction.xa package represents a Java mapping of certain elements of the X/Open XA interface specification. The XA interface defines a standard two-way communication protocol between a transaction manager and a resource manager, such as a relational database, so that they can engage in distributed transactional processing. These interfaces are used internally by the JTA to implement its transaction management services. Normally, you shouldn't have to use these interfaces directly in application code. Figure 29-1 shows the class hierarchy of the package.

figure

Figure 29-1. The javax.transaction.xa package

XAExceptionJTA 1.0
javax.transaction.xaserializable checked

Thrown by a resource manager when an error occurs while handling a request from the transaction manager. The static error codes allow the transaction manager to determine the cause of the error.

public class XAException extends Exception {
// Public Constructors
public XAException ();
public XAException (String s);
public XAException (int errcode);
// Public Constants
public static final int XA_HEURCOM ; =7
public static final int XA_HEURHAZ ; =8
public static final int XA_HEURMIX ; =5
public static final int XA_HEURRB ; =6
public static final int XA_NOMIGRATE ; =9
public static final int XA_RBBASE ; =100
public static final int XA_RBCOMMFAIL ; =101
public static final int XA_RBDEADLOCK ; =102
public static final int XA_RBEND ; =107
public static final int XA_RBINTEGRITY ; =103
public static final int XA_RBOTHER ; =104
public static final int XA_RBPROTO ; =105
public static final int XA_RBROLLBACK ; =100
public static final int XA_RBTIMEOUT ; =106
public static final int XA_RBTRANSIENT ; =107
public static final int XA_RDONLY ; =3
public static final int XA_RETRY ; =4
public static final int XAER_ASYNC ; =-2
public static final int XAER_DUPID ; =-8
public static final int XAER_INVAL ; =-5
public static final int XAER_NOTA ; =-4
public static final int XAER_OUTSIDE ; =-9
public static final int XAER_PROTO ; =-6
public static final int XAER_RMERR ; =-3
public static final int XAER_RMFAIL ; =-7
// Public Instance Fields
public int errorCode ;
}

Hierarchy: Object-->Throwable(Serializable)-->Exception-->XAException

Thrown By: XAResource.{commit(), end(), forget(), getTransactionTimeout(), isSameRM(), prepare(), recover(), rollback(), setTransactionTimeout(), start()}

XAResourceJTA 1.0
javax.transaction.xa

The XAResource interface is implemented by shared resources that want to engage in distributed transactions. A single resource manager (e.g., a database server or message service) can export multiple transactional resources (database connections, sessions with a message service), represented as XAResource objects. The transaction manager uses the XAResource interface to associate a resource with a transaction using the start() method, to ask the resource to commit() or rollback() any work done while it was associated with a transaction, and finally to end() the association with a transaction. Other methods on XAResource manage the association of the resource with the transaction context.

public abstract interface XAResource {
// Public Constants
public static final int TMENDRSCAN ; =8388608
public static final int TMFAIL ; =536870912
public static final int TMJOIN ; =2097152
public static final int TMNOFLAGS ; =0
public static final int TMONEPHASE ; =1073741824
public static final int TMRESUME ; =134217728
public static final int TMSTARTRSCAN ; =16777216
public static final int TMSUCCESS ; =67108864
public static final int TMSUSPEND ; =33554432
public static final int XA_OK ; =0
public static final int XA_RDONLY ; =3
// Public Instance Methods
public abstract void commit (Xid xid, boolean onePhase) throws XAException;
public abstract void end (Xid xid, int flags) throws XAException;
public abstract void forget (Xid xid) throws XAException;
public abstract int getTransactionTimeout () throws XAException;
public abstract boolean isSameRM (XAResource xares) throws XAException;
public abstract int prepare (Xid xid) throws XAException;
public abstract Xid[ ] recover (int flag) throws XAException;
public abstract void rollback (Xid xid) throws XAException;
public abstract boolean setTransactionTimeout (int seconds) throws XAException;
public abstract void start (Xid xid, int flags) throws XAException;
}

Passed To: Transaction.{delistResource(), enlistResource()}, XAResource.isSameRM()

Returned By: javax.jms.XASession.getXAResource(), javax.sql.XAConnection.getXAResource()

XidJTA 1.0
javax.transaction.xa

An Xid is an identifier for a transaction. This interface is used by transaction managers and resource managers as the representation for transactions. The methods on the interface allow these two entities to query for specific components of the transaction identifier.

public abstract interface Xid {
// Public Constants
public static final int MAXBQUALSIZE ; =64
public static final int MAXGTRIDSIZE ; =64
// Public Instance Methods
public abstract byte[ ] getBranchQualifier ();
public abstract int getFormatId ();
public abstract byte[ ] getGlobalTransactionId ();
}

Passed To: XAResource.{commit(), end(), forget(), prepare(), rollback(), start()}

Returned By: XAResource.recover()



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.