Search in sources :

Example 1 with ControlWrapper

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

the class CurrentImple method get_transaction_name.

public String get_transaction_name() throws SystemException {
    ControlWrapper currentAction = _theManager.current();
    String ch = ((currentAction == null) ? "null" : currentAction.get_transaction_name());
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("CurrentImple::get_transaction_name - returning " + ch);
    }
    return ch;
}
Also used : ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper)

Example 2 with ControlWrapper

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

the class CurrentImple method suspend.

/*
	 * Problem: there is a general problem with the Orb and memory management.
	 * If this method, say, is invoked remotely then we must duplicate the
	 * reference before returning it since the Orb will call release on the
	 * return value once it has been sent to the caller. However, in the local
	 * case, if we call duplicate then there is nothing to call release and we
	 * get memory leaks!
	 *
	 * Also assume that BasicAction's notion of current is the same as
	 * CurrentImple's, if the action is local.
	 *
	 */
/**
 * The spec. states that after suspend we should have a null transaction
 * context, but is hazy as to what to do if we are nested. We shall assume
 * that the control returned is for the current transaction and that we
 * suspend the entire transaction hierarchy. Given the returned control, we
 * can always regenerate the hierarchy later if required by resume.
 */
public org.omg.CosTransactions.Control suspend() throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("CurrentImple::suspend ()");
    }
    ControlWrapper actPtr = _theManager.popAction();
    if (actPtr == null) {
        ThreadAssociationControl.updateAssociation(null, TX_SUSPENDED);
        return null;
    } else {
        ThreadAssociationControl.updateAssociation(actPtr, TX_SUSPENDED);
        /*
			 * Purge the remaining controls from the thread context. If the
			 * controls are remote and proxies then we delete them here, since
			 * we must recreate them next time we want to use them anyway.
			 */
        _theManager.purgeActions();
        if (actPtr.isLocal())
            return actPtr.getImple().getControl();
        else
            return actPtr.getControl();
    }
}
Also used : ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper)

Example 3 with ControlWrapper

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

the class CurrentImple method get_control.

public org.omg.CosTransactions.Control get_control() throws SystemException {
    ControlWrapper theControl = _theManager.current();
    if (theControl == null)
        return null;
    if (true) {
        try {
            return theControl.get_control();
        } catch (Unavailable e) {
            return null;
        }
    } else {
        Coordinator coord = null;
        try {
            coord = theControl.get_coordinator();
        } catch (Unavailable e) {
            coord = null;
            throw new UNKNOWN(ExceptionCodes.UNAVAILABLE_COORDINATOR, CompletionStatus.COMPLETED_NO);
        } catch (SystemException sysEx) {
            coord = null;
            throw sysEx;
        }
        org.omg.CosTransactions.Control proxyControl = TransactionFactoryImple.createPropagatedControl(coord);
        coord = null;
        theControl = null;
        return proxyControl;
    }
}
Also used : Control(org.omg.CosTransactions.Control) SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) UNKNOWN(org.omg.CORBA.UNKNOWN) Coordinator(org.omg.CosTransactions.Coordinator) SubtransactionsUnavailable(org.omg.CosTransactions.SubtransactionsUnavailable) Unavailable(org.omg.CosTransactions.Unavailable)

Example 4 with ControlWrapper

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

the class CurrentImple method suspendWrapper.

public ControlWrapper suspendWrapper() throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("CurrentImple::suspendWrapper ()");
    }
    ControlWrapper actPtr = _theManager.popAction();
    if (actPtr == null) {
        ThreadAssociationControl.updateAssociation(null, TX_SUSPENDED);
        return null;
    } else {
        ThreadAssociationControl.updateAssociation(actPtr, TX_SUSPENDED);
        /*
			 * Purge the remaining controls from the thread context. If the
			 * controls are remote and proxies then we delete them here, since
			 * we must recreate them next time we want to use them anyway.
			 */
        _theManager.purgeActions();
        return actPtr;
    }
}
Also used : ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper)

Example 5 with ControlWrapper

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

the class ArjunaTransactionImple method doAfterCompletion.

protected void doAfterCompletion(org.omg.CosTransactions.Status myStatus) throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::doAfterCompletion for " + get_uid());
    }
    if (myStatus == Status.StatusActive) {
        jtsLogger.i18NLogger.warn_orbspecific_coordinator_txrun("ArjunaTransactionImple.doAfterCompletion");
        return;
    }
    boolean problem = false;
    SystemException exp = null;
    if (_synchs != null) {
        ControlWrapper cw = null;
        boolean doSuspend = false;
        try {
            // cw = OTSImpleManager.systemCurrent().getControlWrapper();
            cw = OTSImpleManager.current().getControlWrapper();
            if ((cw == null) || (!controlHandle.equals(cw.getImple()))) {
                // OTSImpleManager.systemCurrent().resumeImple(controlHandle);
                OTSImpleManager.current().resumeImple(controlHandle);
                doSuspend = true;
            }
        } catch (Exception ex) {
            /*
	             * It should still be OK to make the call without a context
	             * because a Synchronization can only be associated with a
	             * single transaction.
	             */
            problem = true;
        }
        /*
	         * Regardless of failures, we must tell all synchronizations what
	         * happened.
	         */
        // afterCompletions should run in reverse order compared to beforeCompletions
        Stack stack = new Stack();
        Iterator iterator = _synchs.iterator();
        while (iterator.hasNext()) {
            stack.push(iterator.next());
        }
        iterator = stack.iterator();
        /*
	         * Regardless of failures, we must tell all synchronizations what
	         * happened.
	         */
        while (!stack.isEmpty()) {
            SynchronizationRecord value = (SynchronizationRecord) stack.pop();
            Synchronization c = value.contents();
            try {
                c.after_completion(myStatus);
            } catch (SystemException e) {
                if (jtsLogger.logger.isTraceEnabled()) {
                    jtsLogger.logger.trace("ArjunaTransactionImple.doAfterCompletion - caught exception " + e);
                }
                problem = true;
                if (exp == null)
                    exp = e;
            }
        }
        if (doSuspend) {
            try {
                if (cw != null)
                    OTSImpleManager.current().resumeWrapper(cw);
                else
                    OTSImpleManager.current().suspend();
            } catch (Exception ex) {
            }
        }
        _synchs = null;
    }
    boolean superProblem = !super.afterCompletion(myStatus == Status.StatusCommitted ? ActionStatus.COMMITTED : ActionStatus.ABORTED);
    if (problem || superProblem) {
        if (exp != null)
            throw exp;
        else
            throw new UNKNOWN(ExceptionCodes.SYNCHRONIZATION_EXCEPTION, CompletionStatus.COMPLETED_NO);
    }
}
Also used : SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) Iterator(java.util.Iterator) UNKNOWN(org.omg.CORBA.UNKNOWN) Synchronization(org.omg.CosTransactions.Synchronization) ManagedSynchronization(com.arjuna.ArjunaOTS.ManagedSynchronization) SystemException(org.omg.CORBA.SystemException) SynchronizationRecord(com.arjuna.ats.internal.jts.resources.SynchronizationRecord) 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