{
/*
* Remember to conver timeout to seconds.
*/
TransactionImple tx = TxImporter.importTransaction(xid, (int) timeout/1000);
switch (tx.getStatus())
{
case Status.STATUS_NO_TRANSACTION:
case Status.STATUS_UNKNOWN:
throw new WorkCompletedException(
jbossatxLogger.logMesg.getString("com.arjuna.ats.jbossatx.jts.jca.inactive"),
WorkException.TX_RECREATE_FAILED);
case Status.STATUS_ACTIVE:
break;
default:
throw new WorkCompletedException(
jbossatxLogger.logMesg.getString("com.arjuna.ats.jbossatx.jts.jca.completing"),
WorkException.TX_CONCURRENT_WORK_DISALLOWED);
}
TxWorkManager.addWork(work, tx);
/*
* TODO currently means one synchronization per work item and that
* instance isn't removed when/if the work item is cancelled and
* another work item is later added.
*
* Synchronizations are pretty lightweight and this add/remove/add
* scenario will hopefully not happen that much. So, we don't
* optimise for it at the moment. Re-evaluate if it does become an
* overhead.
*/
tx.registerSynchronization(new WorkSynchronization(tx));
}
catch (WorkCompletedException ex)
{
throw ex;
}