Search in sources :

Example 16 with ControlWrapper

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

the class JtsTransactionImple method getTransactionIOR.

/**
 * If the current transaction represents an OTS transaction then return it IOR
 *
 * @return the IOR or null if the current transaction is not an OTS transaction
 * @throws NamingException
 * @throws org.omg.CORBA.SystemException
 * @throws SystemException
 * @throws Unavailable
 */
public static String getTransactionIOR() throws org.omg.CORBA.SystemException, SystemException, Unavailable {
    log.debug("getTransactionIOR");
    TransactionImpl curr = TransactionImpl.current();
    if (curr != null) {
        log.debug("have JtsTransactionImple");
        return curr.getControlIOR();
    } else if (hasTransaction()) {
        log.debug("have tx mgr");
        Transaction tx = tm.getTransaction();
        log.debug("have arjuna tx");
        TransactionImple atx = (TransactionImple) tx;
        ControlWrapper cw = atx.getControlWrapper();
        log.debug("lookup control");
        Control c = cw.get_control();
        String ior = ORBManager.getORB().orb().object_to_string(c);
        log.debug("getTransactionIOR: ior: " + ior);
        return ior;
    } else {
        return null;
    }
}
Also used : Control(org.omg.CosTransactions.Control) Transaction(javax.transaction.Transaction) AtomicTransaction(com.arjuna.ats.internal.jta.transaction.jts.AtomicTransaction) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) TransactionImpl(org.jboss.narayana.blacktie.jatmibroker.core.tx.TransactionImpl)

Example 17 with ControlWrapper

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

the class ContextManager method popAction.

public final ControlWrapper popAction(String threadId) {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ContextManager::popAction ()");
    }
    ControlWrapper action = null;
    Object arg = threadId == null ? null : otsCurrent.get(threadId);
    if (arg != null) {
        Stack sl = (Stack) arg;
        try {
            /*
		 * When we pushed the action we did the check for whether
		 * it was local to save time now.
		 */
            action = (ControlWrapper) sl.pop();
        } catch (EmptyStackException e) {
        }
        if (sl.size() == 0) {
            sl = null;
            otsCurrent.remove(threadId);
            disassociateContext(OTSManager.getLocalSlotId());
        }
    }
    if (action != null) {
        if (action.isLocal()) {
            try {
                ThreadActionData.popAction(threadId);
            } catch (EmptyStackException e) {
            }
        }
    }
    return action;
}
Also used : EmptyStackException(java.util.EmptyStackException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) Stack(java.util.Stack)

Example 18 with ControlWrapper

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

the class ContextManager method addControlImpleHierarchy.

/*
     * Given a ControlWrapper we can create the hierarchy quickly, since
     * we have the implementation information to hand.
     */
public final boolean addControlImpleHierarchy(ControlImple which) {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ContextManager::addControlImpleHierarchy ()");
    }
    boolean isError = false;
    try {
        ControlImple curr = which.getParentImple();
        Stack hier = new Stack();
        while (curr != null) {
            hier.push(new ControlWrapper(curr));
            curr = curr.getParentImple();
        }
        try {
            ControlWrapper wrapper = (ControlWrapper) hier.pop();
            while (wrapper != null) {
                pushAction(wrapper);
                wrapper = null;
                wrapper = (ControlWrapper) hier.pop();
            }
        } catch (EmptyStackException e) {
        }
    } catch (Exception e) {
        jtsLogger.i18NLogger.warn_context_genfail("ContextManager.addActionControlImple", e);
        isError = true;
    }
    return isError;
}
Also used : EmptyStackException(java.util.EmptyStackException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) SystemException(org.omg.CORBA.SystemException) EmptyStackException(java.util.EmptyStackException) Stack(java.util.Stack)

Example 19 with ControlWrapper

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

the class ContextManager method currentPIContext.

public ControlWrapper currentPIContext() throws SystemException {
    if (_piCurrent != null) {
        try {
            int slotId = OTSManager.getReceivedSlotId();
            if (slotId == -1)
                return null;
            org.omg.CORBA.Any ctx = _piCurrent.get_slot(slotId);
            if (ctx.type().kind().value() != TCKind._tk_null) {
                ControlWrapper control = null;
                if (ctx.type().kind().value() == TCKind._tk_string) {
                    control = createProxy(ctx);
                } else {
                    control = createHierarchy(ctx);
                }
                org.omg.CORBA.Any threadData = ORBManager.getORB().orb().create_any();
                threadData.insert_string(ThreadUtil.getThreadId());
                _piCurrent.set_slot(slotId, threadData);
                return control;
            } else
                return null;
        } catch (NullPointerException e) {
            return null;
        } catch (InvalidSlot is) {
            throw new org.omg.CORBA.INTERNAL();
        }
    } else
        return null;
}
Also used : Any(org.omg.CORBA.Any) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) InvalidSlot(org.omg.PortableInterceptor.InvalidSlot)

Example 20 with ControlWrapper

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

the class ContextManager method current.

/**
 * Get the transaction for the invoking thread. If there isn't one in
 * the normal thread associated data then look in the PI implementation.
 *
 * @return the current transaction for the invoking thread.
 */
public ControlWrapper current() throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ContextManager::current ()");
    }
    Object arg = otsCurrent.get(ThreadUtil.getThreadId());
    ControlWrapper wrapper = null;
    if (arg != null) {
        try {
            Stack hier = (Stack) arg;
            wrapper = (ControlWrapper) hier.peek();
        } catch (EmptyStackException e) {
            e.printStackTrace();
        }
    }
    if (wrapper == null) {
        wrapper = currentPIContext();
        try {
            if (wrapper != null) {
                pushAction(wrapper);
            }
        } catch (Throwable ex) {
            jtsLogger.i18NLogger.warn_context_genfail("ContextManager.current", ex);
            throw new BAD_OPERATION();
        }
    }
    return wrapper;
}
Also used : EmptyStackException(java.util.EmptyStackException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) Stack(java.util.Stack)

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