Search in sources :

Example 1 with TRANSACTION_UNAVAILABLE

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;
}
Also used : ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction) ServerNestedAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerNestedAction) Terminator(org.omg.CosTransactions.Terminator) Coordinator(org.omg.CosTransactions.Coordinator) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) SystemException(org.omg.CORBA.SystemException) TRANSACTION_UNAVAILABLE(org.omg.CORBA.TRANSACTION_UNAVAILABLE)

Aggregations

ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)1 ServerNestedAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerNestedAction)1 ServerTopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerTopLevelAction)1 SystemException (org.omg.CORBA.SystemException)1 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)1 TRANSACTION_UNAVAILABLE (org.omg.CORBA.TRANSACTION_UNAVAILABLE)1 Coordinator (org.omg.CosTransactions.Coordinator)1 Terminator (org.omg.CosTransactions.Terminator)1