Search in sources :

Example 21 with Coordinator

use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.

the class grid_i method set.

public void set(int n, int m, int value, Control cp) throws SystemException {
    try {
        Coordinator co = cp.get_coordinator();
        if (co != null)
            co.register_resource(ref);
        else
            System.err.println("Error - no transaction coordinator!");
        m_a[n][m] = value;
    } catch (UserException e) {
        throw new UNKNOWN();
    } catch (SystemException e) {
        throw new UNKNOWN();
    }
}
Also used : SystemException(org.omg.CORBA.SystemException) UserException(org.omg.CORBA.UserException) UNKNOWN(org.omg.CORBA.UNKNOWN) Coordinator(org.omg.CosTransactions.Coordinator)

Example 22 with Coordinator

use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.

the class BaseTransaction method checkTransactionState.

/**
 * Called when we want to make sure this thread does not already have a
 * transaction associated with it.
 */
final void checkTransactionState() throws IllegalStateException, javax.transaction.SystemException {
    try {
        Control cont = OTSManager.get_current().get_control();
        if (cont != null) {
            Coordinator coord = cont.get_coordinator();
            if (coord != null) {
                if ((coord.get_status() == org.omg.CosTransactions.Status.StatusActive) && (!_supportSubtransactions)) {
                    throw new IllegalStateException("BaseTransaction.checkTransactionState - " + jtaxLogger.i18NLogger.get_jtax_transaction_jts_alreadyassociated());
                }
            }
            cont = null;
        }
    } catch (org.omg.CORBA.SystemException e1) {
        javax.transaction.SystemException systemException = new javax.transaction.SystemException(e1.toString());
        systemException.initCause(e1);
        throw systemException;
    } catch (org.omg.CosTransactions.Unavailable e2) {
    // ok, no transaction currently associated with thread.
    } catch (NullPointerException ex) {
    // ok, no transaction currently associated with thread.
    }
}
Also used : Coordinator(org.omg.CosTransactions.Coordinator) Control(org.omg.CosTransactions.Control)

Example 23 with Coordinator

use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.

the class ControlWrapper method register_synchronization.

public final void register_synchronization(Synchronization sync) throws Inactive, SynchronizationUnavailable, SystemException {
    try {
        if (_controlImpl != null)
            _controlImpl.getImplHandle().register_synchronization(sync);
        else {
            try {
                Coordinator coord = _control.get_coordinator();
                coord.register_synchronization(sync);
            } catch (final Unavailable e2) {
                throw new Inactive();
            } catch (final Exception e3) {
                throw new UNKNOWN();
            }
        }
    } catch (final NullPointerException e1) {
        throw new Inactive();
    }
}
Also used : Inactive(org.omg.CosTransactions.Inactive) UNKNOWN(org.omg.CORBA.UNKNOWN) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) Coordinator(org.omg.CosTransactions.Coordinator) SystemException(org.omg.CORBA.SystemException) SynchronizationUnavailable(org.omg.CosTransactions.SynchronizationUnavailable) SubtransactionsUnavailable(org.omg.CosTransactions.SubtransactionsUnavailable) Unavailable(org.omg.CosTransactions.Unavailable)

Example 24 with Coordinator

use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.

the class CurrentImple method resume.

/**
 * To support checked transactions we can only resume if the action is local
 * or we received it implicitly.
 *
 * If the control refers to a nested transaction then we must recreate the
 * entire hierarchy, i.e., the effect of a suspend/resume on the same
 * control should be the same as never calling suspend in the first place.
 *
 * If the control is for a local transaction then it is simple to recreate
 * the hierarchy. Otherwise we rely upon the PropagationContext to recreate
 * it.
 *
 * If this control is a "proxy" then create a new proxy instance, so we can
 * delete proxies whenever suspend is called.
 *
 * Should check if "new" transaction is not actually the current one anyway.
 * If so, just return. The spec. doesn't mention what to do in this case, so
 * for now we go to the overhead of the work regardless.
 */
public void resume(Control which) throws InvalidControl, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("CurrentImple::resume ( " + which + " )");
    }
    /*
		 * We must now "forget" any current transaction information. This is
		 * because when we end this transaction we must be associated with no
		 * transaction.
		 */
    _theManager.purgeActions();
    if (// if null then return
    which == null) {
        ThreadAssociationControl.updateAssociation(null, TX_RESUMED);
        return;
    }
    /*
		 * Must duplicate because it is an 'in' parameter which we want to keep.
		 */
    org.omg.CosTransactions.Control cont = which;
    boolean invalidControl = false;
    try {
        Coordinator coord = cont.get_coordinator();
        if (!coord.is_top_level_transaction()) {
            /*
				 * Is the Control an ActionControl? If so then it has methods to
				 * allow us to get the parent directly. Otherwise, rely on the
				 * PropagationContext.
				 */
            ActionControl actControl = null;
            try {
                actControl = com.arjuna.ArjunaOTS.ActionControlHelper.narrow(cont);
                if (actControl == null)
                    throw new BAD_PARAM();
            } catch (Exception e) {
                /*
					 * Not an ActionControl.
					 */
                actControl = null;
            }
            if (actControl != null) {
                invalidControl = _theManager.addActionControlHierarchy(actControl);
            } else {
                invalidControl = _theManager.addRemoteHierarchy(cont);
            }
        }
        coord = null;
    } catch (OBJECT_NOT_EXIST one) {
    // throw new InvalidControl();
    } catch (// JacORB 1.4.5 bug
    UNKNOWN ue) {
    } catch (// JacORB 2.0 beta 2 bug
    org.omg.CORBA.OBJ_ADAPTER oae) {
    } catch (SystemException sysEx) {
        throw new InvalidControl();
    } catch (UserException usrEx) {
        throw new InvalidControl();
    } catch (NullPointerException npx) {
        throw new InvalidControl();
    } catch (Exception ex) {
        throw new BAD_OPERATION("CurrentImple.resume: " + ex.toString());
    }
    try {
        if (!invalidControl) {
            ControlWrapper wrap = new ControlWrapper(cont);
            ThreadAssociationControl.updateAssociation(wrap, TX_RESUMED);
            _theManager.pushAction(wrap);
        }
    } catch (NullPointerException npx) {
        invalidControl = true;
    }
    cont = null;
    if (invalidControl)
        throw new InvalidControl();
}
Also used : Control(org.omg.CosTransactions.Control) BAD_PARAM(org.omg.CORBA.BAD_PARAM) Coordinator(org.omg.CosTransactions.Coordinator) SystemException(org.omg.CORBA.SystemException) UserException(org.omg.CORBA.UserException) InvalidControl(org.omg.CosTransactions.InvalidControl) ActionControl(com.arjuna.ArjunaOTS.ActionControl) OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) UNKNOWN(org.omg.CORBA.UNKNOWN) UserException(org.omg.CORBA.UserException) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION)

Example 25 with Coordinator

use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.

the class OSIInterposition method createHierarchy.

protected synchronized ControlImple createHierarchy(PropagationContext ctx, Uid currentUid) 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.
	 */
    /*
	 * We only ever register the current transaction with its parent, and
	 * as each transaction commits, it registers its parent with the
	 * "real" parent.
	 */
    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(currentUid, null, null, tmpCoord, tmpTerm, ctx.timeout);
    action = new ServerOSITopLevelAction(control, ((depth == 0) ? true : false));
    if (!action.valid()) {
        try {
            // does dispose as well!
            ((ServerOSITopLevelAction) action).rollback();
            action = null;
        } catch (Exception e) {
        }
        throw new TRANSACTION_ROLLEDBACK();
    }
    ServerTopLevelAction newElement = (ServerOSITopLevelAction) 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(OTIDMap.find(ctx.parents[i].otid), tmpCoord, tmpTerm, control);
            // not current, so don't register
            nestedAction = new ServerOSINestedAction(control, false);
            if (!nestedAction.valid()) {
                try {
                    // does dispose as well!
                    ((ServerOSINestedAction) nestedAction).rollback_subtransaction();
                    nestedAction = null;
                } catch (Exception e) {
                }
                throw new TRANSACTION_ROLLEDBACK();
            }
            /*
		 * Add transaction resource to list.
		 */
            action.addChild((ServerOSINestedAction) 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(OTIDMap.find(ctx.current.otid), tmpCoord, tmpTerm, control);
        // current, so register
        nestedAction = new ServerOSINestedAction(control, true);
        if (!nestedAction.valid()) {
            try {
                // does dispose as well!
                ((ServerOSINestedAction) nestedAction).rollback_subtransaction();
                nestedAction = null;
            } catch (Exception e) {
            }
            throw new TRANSACTION_ROLLEDBACK();
        }
        action.addChild((ServerOSINestedAction) 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) ServerOSINestedAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSINestedAction) ServerResource(com.arjuna.ats.internal.jts.interposition.resources.arjuna.ServerResource) Terminator(org.omg.CosTransactions.Terminator) Coordinator(org.omg.CosTransactions.Coordinator) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) SystemException(org.omg.CORBA.SystemException) ServerOSITopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.osi.ServerOSITopLevelAction)

Aggregations

Coordinator (org.omg.CosTransactions.Coordinator)47 SystemException (org.omg.CORBA.SystemException)32 UNKNOWN (org.omg.CORBA.UNKNOWN)15 Control (org.omg.CosTransactions.Control)14 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)13 BAD_PARAM (org.omg.CORBA.BAD_PARAM)12 Unavailable (org.omg.CosTransactions.Unavailable)11 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)10 Terminator (org.omg.CosTransactions.Terminator)10 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)9 UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)6 Uid (com.arjuna.ats.arjuna.common.Uid)6 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)6 ORB (com.arjuna.orbportability.ORB)6 Any (org.omg.CORBA.Any)6 TRANSACTION_REQUIRED (org.omg.CORBA.TRANSACTION_REQUIRED)6 TransactionalObject (org.omg.CosTransactions.TransactionalObject)6 ServiceContext (org.omg.IOP.ServiceContext)6 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)5 PropagationContext (org.omg.CosTransactions.PropagationContext)5