use of org.omg.CORBA.TRANSACTION_UNAVAILABLE in project narayana by jbosstm.
the class Interposition method createHierarchy.
protected synchronized ControlImple createHierarchy(PropagationContext ctx, Uid tlUid) throws SystemException {
/*
* Start at the parent and work our way down to "current". The current
* transaction is not in the IDL sequence, but sent as separate field
* of the propagation context. This tends to make the code more
* complex than it would be if the entire hierarchy was represented in
* one place.
*/
int depth = ctx.parents.length;
ServerResource action = null;
Coordinator tmpCoord = null;
Terminator tmpTerm = null;
if (depth == 0) {
tmpCoord = ctx.current.coord;
tmpTerm = ctx.current.term;
} else {
tmpCoord = ctx.parents[depth - 1].coord;
tmpTerm = ctx.parents[depth - 1].term;
}
if (// terminator may correctly be null
tmpCoord == null) {
return null;
}
ServerControl control = ServerFactory.create_transaction(tlUid, null, null, tmpCoord, tmpTerm, ctx.timeout);
action = new ServerTopLevelAction(control);
if (!action.valid()) {
try {
// does dispose as well!
((ServerTopLevelAction) action).rollback();
} catch (Exception e) {
}
if (((ServerTopLevelAction) action).isTransactionInactive()) {
throw new TRANSACTION_UNAVAILABLE(jtsLogger.i18NLogger.get_transaction_was_inactive(), 1, CompletionStatus.COMPLETED_NO);
} else {
throw new TRANSACTION_ROLLEDBACK();
}
}
ServerTopLevelAction newElement = (ServerTopLevelAction) action;
_head.add(newElement);
if (// current is a nested transaction
depth > 0) {
/*
* Now deal with any nested transactions.
* As we create, register with the original transactions.
*/
ServerResource nestedAction = null;
for (int i = depth - 2; i >= 0; i--) {
tmpCoord = ctx.parents[i].coord;
tmpTerm = ctx.parents[i].term;
control = ServerFactory.create_subtransaction(Utility.otidToUid(ctx.parents[i].otid), tmpCoord, tmpTerm, control);
nestedAction = new ServerNestedAction(control);
if (!nestedAction.valid()) {
try {
// does dispose as well!
((ServerNestedAction) nestedAction).rollback_subtransaction();
nestedAction = null;
} catch (Exception e) {
}
throw new TRANSACTION_ROLLEDBACK();
}
/*
* Add transaction resource to list.
*/
action.addChild((ServerNestedAction) nestedAction);
action = nestedAction;
}
/*
* Now deal with current transaction. If there is
* only one transaction we do nothing.
*/
tmpCoord = ctx.current.coord;
tmpTerm = ctx.current.term;
control = ServerFactory.create_subtransaction(Utility.otidToUid(ctx.current.otid), tmpCoord, tmpTerm, control);
nestedAction = new ServerNestedAction(control);
if (!nestedAction.valid()) {
try {
// does dispose as well!
((ServerNestedAction) nestedAction).rollback_subtransaction();
nestedAction = null;
} catch (Exception e) {
}
throw new TRANSACTION_ROLLEDBACK();
}
action.addChild((ServerNestedAction) nestedAction);
}
if (jtsLogger.logger.isTraceEnabled())
compareHierarchies(ctx, newElement);
return control;
}
Aggregations