Search in sources :

Example 1 with Resource02

use of org.jboss.jbossts.qa.CrashRecovery12Resources.Resource02 in project narayana by jbosstm.

the class Client01 method main.

public static void main(String[] args) {
    int crashIn = Resource01.NOCRASH;
    ;
    if (args.length >= 1) {
        if (args[0].startsWith("p") || args[0].startsWith("P")) {
            crashIn = Resource01.PREPARE;
        }
        if (args[0].startsWith("c") || args[0].startsWith("C")) {
            crashIn = Resource01.COMMIT;
        }
        if (args[0].startsWith("r") || args[0].startsWith("R")) {
            crashIn = Resource01.ROLLBACK;
        }
    }
    if (args.length >= 2) {
        resultsFile = args[1];
    }
    try {
        ORB myORB = ORB.getInstance("Client01");
        RootOA myOA = OA.getRootOA(myORB);
        myORB.initORB(args, null);
        myOA.initOA();
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed");
    }
    System.out.println("Ready");
    try {
        UserTransaction ut = com.arjuna.ats.jta.UserTransaction.userTransaction();
        ut.begin();
        TransactionImple txImple = (TransactionImple) TransactionManager.transactionManager().getTransaction();
        txImple.enlistResource(new Resource01(crashIn, resultsFile));
        txImple.enlistResource(new Resource02());
        ut.commit();
        System.out.println("Passed");
    } catch (javax.transaction.RollbackException rbx) {
        System.out.println("Passed");
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed");
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) Resource01(org.jboss.jbossts.qa.CrashRecovery12Resources.Resource01) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) RootOA(com.arjuna.orbportability.RootOA) Resource02(org.jboss.jbossts.qa.CrashRecovery12Resources.Resource02) ORB(com.arjuna.orbportability.ORB)

Aggregations

TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)1 ORB (com.arjuna.orbportability.ORB)1 RootOA (com.arjuna.orbportability.RootOA)1 UserTransaction (javax.transaction.UserTransaction)1 Resource01 (org.jboss.jbossts.qa.CrashRecovery12Resources.Resource01)1 Resource02 (org.jboss.jbossts.qa.CrashRecovery12Resources.Resource02)1