Search in sources :

Example 1 with InvalidControl

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

the class Test25 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        boolean correct = true;
        Current current = OTS.get_current();
        try {
            current.resume(null);
        } catch (InvalidControl invalidControl) {
            correct = false;
        }
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Test25.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Test25.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : Current(org.omg.CosTransactions.Current) InvalidControl(org.omg.CosTransactions.InvalidControl)

Example 2 with InvalidControl

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

the class Test26 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        boolean correct = true;
        Current current = OTS.get_current();
        current.begin();
        Control control = current.get_control();
        current.commit(true);
        try {
            current.resume(control);
        } catch (InvalidControl invalidControl) {
            System.err.println("Failed to resume committed transaction!");
            correct = false;
        }
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Test26.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Test26.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : Control(org.omg.CosTransactions.Control) InvalidControl(org.omg.CosTransactions.InvalidControl) Current(org.omg.CosTransactions.Current) InvalidControl(org.omg.CosTransactions.InvalidControl)

Example 3 with InvalidControl

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

the class Test28 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        boolean correct = true;
        Current current = OTS.get_current();
        current.begin();
        Control control = current.get_control();
        current.rollback();
        try {
            current.resume(control);
        } catch (InvalidControl invalidControl) {
            System.err.println("Failed to resume rolled-back transaction!");
            correct = false;
        }
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Test28.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Test28.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : Control(org.omg.CosTransactions.Control) InvalidControl(org.omg.CosTransactions.InvalidControl) Current(org.omg.CosTransactions.Current) InvalidControl(org.omg.CosTransactions.InvalidControl)

Example 4 with InvalidControl

use of org.omg.CosTransactions.InvalidControl 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 5 with InvalidControl

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

the class CurrentImple method resumeImple.

public void resumeImple(ControlImple which) throws InvalidControl, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("CurrentImple::resumeImple ( " + 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;
    }
    boolean invalidControl = _theManager.addControlImpleHierarchy(which);
    try {
        if (!invalidControl) {
            ControlWrapper wrap = new ControlWrapper(which);
            ThreadAssociationControl.updateAssociation(wrap, TX_RESUMED);
            _theManager.pushAction(wrap);
        }
    } catch (NullPointerException npx) {
        npx.printStackTrace();
        invalidControl = true;
    }
    if (invalidControl)
        throw new InvalidControl();
}
Also used : ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) InvalidControl(org.omg.CosTransactions.InvalidControl)

Aggregations

InvalidControl (org.omg.CosTransactions.InvalidControl)6 Control (org.omg.CosTransactions.Control)4 Current (org.omg.CosTransactions.Current)4 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)2 ActionControl (com.arjuna.ArjunaOTS.ActionControl)1 BAD_OPERATION (org.omg.CORBA.BAD_OPERATION)1 BAD_PARAM (org.omg.CORBA.BAD_PARAM)1 OBJECT_NOT_EXIST (org.omg.CORBA.OBJECT_NOT_EXIST)1 SystemException (org.omg.CORBA.SystemException)1 UNKNOWN (org.omg.CORBA.UNKNOWN)1 UserException (org.omg.CORBA.UserException)1 Coordinator (org.omg.CosTransactions.Coordinator)1