}
catch (Exception e)
{
}
throw new TRANSACTION_ROLLEDBACK();
}
tlAction.addChild(nestedAction);
}
nestedAction = null;
}
else
{
if (nestedAction != null)
{
/*
* If current transaction has a child then we should
* abort it, since it does not exist in the hierarchy
* we have just received.
*/
nestedAction = nestedAction.child();
if (nestedAction != null)
{
tlAction.abortChild(nestedAction);
nestedAction = null;
control = tlAction.deepestControl();
}
}
}
}
boolean newCurrent = false;
Uid sentCurrent = Utility.otidToUid(context.current.otid);
/*
* If differentIndex is not -1 then we already found a difference
* between the sent hierarchy and the one we already had, so we
* must have a new current.
*/
if (differenceIndex == -1)
{
/*
* Now determine whether we have to create any new nested actions.
*/
Uid currentUid = null;
/*
* Get hold of our local notion of current.
*/
if (nestedAction == null)
{
nestedAction = tlAction.child();
if (nestedAction != null)
{
while (nestedAction.child() != null)
nestedAction = nestedAction.child();
currentUid = nestedAction.get_uid();
}
else
currentUid = tlAction.get_uid();
}
else
currentUid = nestedAction.get_uid();
/*
* Is our notion of the current transaction the same as
* that sent?
*/
if (currentUid.notEquals(sentCurrent))
{
newCurrent = true;
}
}
else
newCurrent = true;
if (newCurrent)
{
if (depth == 1)
{
/*
* Old current is gone.
*/
nestedAction = tlAction.child();
if (nestedAction != null)
{
tlAction.abortChild(nestedAction);
nestedAction = null;
}
control = (ServerControl) tlAction.control();
}
else
control = tlAction.deepestControl();
TransIdentity currentID = context.current;
control = ServerFactory.create_subtransaction(sentCurrent,
currentID.coord, currentID.term, control);
nestedAction = new ServerRestrictedNestedAction(control);
if (!nestedAction.valid())
{
/*
* Just deal with current transaction. Others must have been
* registered successfully, and will be deal with automatically
* when the parent transaction terminates.
*/
try
{
nestedAction.rollback(); // does dispose as well!
nestedAction = null;
}
catch (Exception e)
{
}
throw new TRANSACTION_ROLLEDBACK();
}
tlAction.addChild(nestedAction);
nestedAction = null;