Search in sources :

Example 6 with UidCoordinator

use of com.arjuna.ArjunaOTS.UidCoordinator in project narayana by jbosstm.

the class ArjunaTransactionImple method is_same_transaction.

public boolean is_same_transaction(Coordinator tc) throws SystemException {
    if (tc == null)
        return false;
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::is_same_transaction comparing hash codes: < " + tc.hash_transaction() + ", " + hash_transaction() + " >");
    }
    if (tc.hash_transaction() != hash_transaction())
        return false;
    boolean result = false;
    try {
        UidCoordinator ptr = com.arjuna.ArjunaOTS.UidCoordinatorHelper.narrow(tc);
        if (ptr != null) {
            /*
				 * Must be an Arjuna coordinator.
				 */
            String myUid = uid();
            String compareUid = ptr.uid();
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ArjunaTransactionImple::is_same_transaction comparing uids < " + compareUid + ", " + myUid + " >");
            }
            if (myUid.compareTo(compareUid) == 0)
                result = true;
            myUid = null;
            compareUid = null;
            ptr = null;
        } else
            throw new BAD_PARAM();
    } catch (SystemException e) {
    /*
			 * Narrow failed, so can't be an Arjuna Uid. Therefore, the answer
			 * must be false.
			 */
    }
    return result;
}
Also used : UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) SystemException(org.omg.CORBA.SystemException) BAD_PARAM(org.omg.CORBA.BAD_PARAM)

Example 7 with UidCoordinator

use of com.arjuna.ArjunaOTS.UidCoordinator in project narayana by jbosstm.

the class TransactionFactoryImple method createProxy.

public static Control createProxy(Coordinator coordinator, Terminator terminator, Control parentControl) {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("TransactionFactoryImple::createProxy ( " + coordinator + ", " + terminator + ", " + parentControl + " )");
    }
    /*
		 * Different from the C++ version in that we can cache proxy
		 * implementations and reuse them, since we rely upon the Java garbage
		 * collection facility to remove them when all outstanding references
		 * have gone.
		 */
    /*
		 * If not an Arjuna UidCoordinator then we may have a memory leak since
		 * there is no way to remove this control.
		 */
    UidCoordinator uidCoord = Helper.getUidCoordinator(coordinator);
    Uid theUid = null;
    if (uidCoord != null) {
        try {
            theUid = Helper.getUid(uidCoord);
            if (ServerControl.allServerControls != null) {
                synchronized (ServerControl.allServerControls) {
                    ControlImple c = (ControlImple) ServerControl.allServerControls.get(theUid);
                    if (c != null)
                        return c.getControl();
                }
            }
        } catch (Exception e) {
            /*
				 * Not a JBoss transaction, so allocate any Uid.
				 */
            theUid = new Uid();
        }
        uidCoord = null;
    } else
        theUid = new Uid();
    ControlImple proxy = new ControlImple(coordinator, terminator, parentControl, theUid);
    return proxy.getControl();
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) SystemException(org.omg.CORBA.SystemException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 8 with UidCoordinator

use of com.arjuna.ArjunaOTS.UidCoordinator in project narayana by jbosstm.

the class Helper method localAction.

/**
 * Given a Control_ptr determine if this is a reference to a local
 * action, and if so return the raw BasicAction pointer.
 */
public static final BasicAction localAction(org.omg.CosTransactions.Control control) {
    if (control == null)
        return null;
    if (control instanceof ControlImple) {
        try {
            ControlImple c = (ControlImple) control;
            return (BasicAction) c.getImplHandle();
        } catch (Exception e) {
        }
    }
    try {
        UidCoordinator coord = Helper.getUidCoordinator(control);
        if (coord != null) {
            Uid u = Helper.getUid(coord);
            coord = null;
            return ActionManager.manager().get(u);
        } else
            throw new BAD_PARAM();
    } catch (Exception e) {
    /*
	     * Can't be an Arjuna action, so ignore.
	     */
    }
    return null;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) BAD_PARAM(org.omg.CORBA.BAD_PARAM) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple)

Aggregations

UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)8 BAD_PARAM (org.omg.CORBA.BAD_PARAM)7 SystemException (org.omg.CORBA.SystemException)5 Uid (com.arjuna.ats.arjuna.common.Uid)4 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)2 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)2 ActionControl (com.arjuna.ArjunaOTS.ActionControl)1 BadControl (com.arjuna.ArjunaOTS.BadControl)1 TxControl (com.arjuna.ats.arjuna.coordinator.TxControl)1 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)1 Control (org.omg.CosTransactions.Control)1 Coordinator (org.omg.CosTransactions.Coordinator)1 PropagationContext (org.omg.CosTransactions.PropagationContext)1 TransIdentity (org.omg.CosTransactions.TransIdentity)1