case javax.transaction.Status.STATUS_ACTIVE:
break;
case javax.transaction.Status.STATUS_MARKED_ROLLBACK:
break;
default:
throw new IllegalStateException(
jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.inactivetx"));
}
TxInfo info = null;
try
{
synchronized (this)
{
info = (TxInfo) _resources.get(xaRes);
if (info == null)
info = (TxInfo) _duplicateResources.get(xaRes);
}
if (info == null)
{
if (jtaLogger.loggerI18N.isWarnEnabled())
{
jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.jts.unknownres", new Object[]
{ "TransactionImple.delistResource" });
}
return false;
}
else
{
boolean optimizedRollback = false;
try
{
/*
* If we know the transaction is going to rollback, then we
* can try to rollback the RM now. Just an optimisation.
*/
if (status == javax.transaction.Status.STATUS_MARKED_ROLLBACK)
{
if (XAUtils.canOptimizeDelist(xaRes))
{
xaRes.end(info.xid(), XAResource.TMFAIL);
xaRes.rollback(info.xid());
info.setState(TxInfo.OPTIMIZED_ROLLBACK);
optimizedRollback = true;
}
}
}
catch (Exception e)
{
// failed, so try again when transaction does rollback
}
switch (info.getState())
{
case TxInfo.ASSOCIATED:
{
if ((flags & XAResource.TMSUCCESS) != 0)
{
xaRes.end(info.xid(), XAResource.TMSUCCESS);
info.setState(TxInfo.NOT_ASSOCIATED);
}
else
{
if ((flags & XAResource.TMSUSPEND) != 0)
{
xaRes.end(info.xid(), XAResource.TMSUSPEND);
info.setState(TxInfo.ASSOCIATION_SUSPENDED);
synchronized (this)
{
_suspendCount++;
}
}
else
{
xaRes.end(info.xid(), XAResource.TMFAIL);
info.setState(TxInfo.FAILED);
}
}
}
break;
case TxInfo.ASSOCIATION_SUSPENDED:
{
if ((flags & XAResource.TMSUCCESS) != 0)
{
// Oracle barfs if we don't resume first, despite what
// XA says!
if (XAUtils.mustEndSuspendedRMs(xaRes))
xaRes.start(info.xid(), XAResource.TMRESUME);
xaRes.end(info.xid(), XAResource.TMSUCCESS);
info.setState(TxInfo.NOT_ASSOCIATED);
synchronized (this)
{
_suspendCount--;
}
}
else
{
if ((flags & XAResource.TMSUSPEND) != 0)
{
// Note: this exception will be caught by our catch
// block
throw new IllegalStateException(
"TransactionImple.delistResource - "
+ jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.ressusp"));
}
else
{
xaRes.end(info.xid(), XAResource.TMFAIL);
info.setState(TxInfo.FAILED);
synchronized (this)
{
_suspendCount--;
}
}
}
}
break;
default:
if (!optimizedRollback)
throw new IllegalStateException(
"TransactionImple.delistResource - "
+ jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.illegalstate")
+ info.getState());
}