Hello,
I will try to give an outline here.
The exact code sequence may differ, but the main point is the
enlistResource method (
http://download.oracle.com/javaee/5/api/javax/
transaction/Transaction.html#enlistResource
%28javax.transaction.xa.XAResource%29). This is the method provided by
JTA standard to enlist *any* JTA compliant resource with a JTA
transaction. And this remains true independent of the JTA transaction-
manager implementation, whether it is Atomikos or something else.
The enlistResource method accepts an XAResource object. An XAResource
is provided by the vendor of any resource which claims to support
participation in a JTA transaction.
In case of XADisk, this XAResource can be obtained like this:
________________________________________________________
XAFileSystem xafs = ............;
XASession xaSession = xafs.createSessionForXATransaction();
XAResource xarXADisk = xaSession.getXAResource();
________________________________________________________
Similarly, XAResource can also be obtained from the other resources
which are to participate in the JTA transaction:
________________________________________________________
XAResource xarJDBC = ......;
XAResource xarMQ = ........;
XAResource xarXYZ = ........;
________________________________________________________
The way to start a new JTA transaction and obtaining the JTA's
standard Transaction object (
http://download.oracle.com/javaee/5/api/
javax/transaction/Transaction.html) can vary. Here
is one of the ways for Atomikos:
________________________________________________________
TransactionManager tm = new
com.atomikos.icatch.jta.UserTransactionManager();
tm.begin();
Transaction transaction = tm.getTransaction();
________________________________________________________
Now, the XAResource objects need to be enlisted with the JTA
transaction using the standard enlistResource method.
________________________________________________________
transaction .enlistResource(xarXADisk );
transaction .enlistResource(xarJDBC);
transaction .enlistResource(xarMQ);
transaction .enlistResource(xarXYZ);
________________________________________________________
Once enlisted, the application performs operations over these
resources and at the end, commits the JTA transaction.
________________________________________________________
transaction.commit().
________________________________________________________
I hope this gives you a general idea. Please feel free to write to me
if you have any questions.
Cheers,
Nitin