Search in sources :

Example 41 with ControlWrapper

use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.

the class AtomicTransaction method validTransaction.

/**
 * If this transaction current? Assume we have checked that we are actually
 * a transaction!
 *
 * If not valid then abort this transaction here. Leave current alone.
 */
protected final boolean validTransaction() {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("AtomicTransaction::validTransaction called for " + _theAction);
    }
    /*
		 * If we get here then _theAction is not null.
		 */
    CurrentImple current = OTSImpleManager.current();
    boolean valid = false;
    try {
        ControlWrapper currentTransaction = current.getControlWrapper();
        if (currentTransaction == null) {
            jtsLogger.i18NLogger.warn_extensions_atnovalidtx("AtomicTransaction.validTransaction");
            return false;
        }
        valid = _theAction.equals(currentTransaction);
        if (!valid) {
            String transactionName = get_transaction_name();
            String currentTransactionName = currentTransaction.get_transaction_name();
            jtsLogger.i18NLogger.warn_extensions_atoutofseq("AtomicTransaction", transactionName);
            jtsLogger.i18NLogger.warn_extensions_atwillabort(currentTransactionName);
            try {
                _theAction.rollback();
            } catch (Exception ex) {
                jtsLogger.i18NLogger.warn_extensions_atcannotabort("AtomicTransaction", transactionName);
            }
        }
    } catch (Exception e) {
        jtsLogger.i18NLogger.warn_extensions_atgenerror("AtomicTransaction", e);
    }
    return valid;
}
Also used : ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) SystemException(org.omg.CORBA.SystemException)

Example 42 with ControlWrapper

use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.

the class AtomicTransaction method equals.

public boolean equals(Object obj) {
    if (obj == null)
        return false;
    if (obj == this)
        return true;
    if (obj instanceof AtomicTransaction) {
        try {
            AtomicTransaction tx = (AtomicTransaction) obj;
            ControlWrapper txControl = tx._theAction;
            if ((_theAction == null) && (txControl == null)) {
                return true;
            } else if (_theAction == null) {
                return false;
            } else {
                return _theAction.equals(txControl);
            }
        } catch (Exception e) {
        }
    }
    return false;
}
Also used : ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) SystemException(org.omg.CORBA.SystemException)

Example 43 with ControlWrapper

use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.

the class JtsTransactionImple method controlToTx.

/**
 * Convert an IOR representing an OTS transaction into a JTA transaction
 *
 * @param orb
 *
 * @param ior the CORBA reference for the OTS transaction
 * @return a JTA transaction that wraps the OTS transaction
 */
private static Transaction controlToTx(String ior) {
    log.debug("controlToTx: ior: " + ior);
    ControlWrapper cw = createControlWrapper(ior);
    TransactionImple tx = (TransactionImple) TransactionImple.getTransactions().get(cw.get_uid());
    if (tx == null) {
        log.debug("controlToTx: creating a new tx - wrapper: " + cw);
        tx = new JtsTransactionImple(cw);
        putTransaction(tx);
    }
    return tx;
}
Also used : ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)

Example 44 with ControlWrapper

use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.

the class JtsTransactionImple method createControlWrapper.

private static ControlWrapper createControlWrapper(String ior) {
    org.omg.CORBA.Object obj = ORBManager.getORB().orb().string_to_object(ior);
    Control control = org.omg.CosTransactions.ControlHelper.narrow(obj);
    if (control == null)
        log.warn("createProxy: ior not a control");
    return new ControlWrapper(control);
}
Also used : Control(org.omg.CosTransactions.Control) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper)

Aggregations

ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)44 SystemException (org.omg.CORBA.SystemException)22 UNKNOWN (org.omg.CORBA.UNKNOWN)14 Any (org.omg.CORBA.Any)13 Coordinator (org.omg.CosTransactions.Coordinator)10 Unavailable (org.omg.CosTransactions.Unavailable)10 BAD_OPERATION (org.omg.CORBA.BAD_OPERATION)8 BAD_PARAM (org.omg.CORBA.BAD_PARAM)8 EmptyStackException (java.util.EmptyStackException)7 Control (org.omg.CosTransactions.Control)7 Stack (java.util.Stack)6 TRANSACTION_REQUIRED (org.omg.CORBA.TRANSACTION_REQUIRED)6 TransactionalObject (org.omg.CosTransactions.TransactionalObject)6 ServiceContext (org.omg.IOP.ServiceContext)6 PropagationContext (org.omg.CosTransactions.PropagationContext)5 SubtransactionsUnavailable (org.omg.CosTransactions.SubtransactionsUnavailable)4 ActionControl (com.arjuna.ArjunaOTS.ActionControl)3 TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)3 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)3 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)3