public int prepare (Xid xid) throws XAException
{
try
{
TransactionImple tx = TxImporter.getImportedTransaction(xid);
if (tx == null)
throw new XAException(XAException.XAER_INVAL);
switch (tx.doPrepare())
{
case TwoPhaseOutcome.PREPARE_READONLY:
TxImporter.removeImportedTransaction(xid);
return XAResource.XA_RDONLY;
case TwoPhaseOutcome.PREPARE_NOTOK:
// the JCA API spec limits what we can do in terms of reporting problems.
// try to use the exception code and cause to provide info whilst
// ramining API compliant. JBTM-427.
Exception initCause = null;
int xaExceptionCode = XAException.XA_RBROLLBACK;
try {
tx.doRollback();
} catch(HeuristicCommitException e) {
initCause = e;
xaExceptionCode = XAException.XAER_RMERR;
} catch (HeuristicMixedException e) {
initCause = e;