Search in sources :

Example 16 with TransactionFactory

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

the class Client04 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        TransactionFactory transactionFactory = null;
        String[] transactionFactoryParams = new String[1];
        transactionFactoryParams[0] = ORBServices.otsKind;
        transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
        boolean correct;
        Control control = transactionFactory.create(4);
        Thread.sleep(8000);
        try {
            control.get_terminator().commit(true);
            correct = false;
        } catch (INVALID_TRANSACTION invalidTransaction) {
            correct = true;
        } catch (BAD_OPERATION badOperation) {
            correct = true;
        } catch (org.omg.CORBA.OBJECT_NOT_EXIST object_not_exist_exception) {
            // This test creates a transaction with timeout period of 4 seconds then
            // sleeps for 8 seconds.
            // When the timeout goes off at the transaction service, the transaction is
            // rolled back and destroyed.
            // The subsequent call to commit on the transaction results in an
            // org.omg.CORBA.OBJECT_NOT_EXIST exception being thrown.
            // The JTS specification appears to be quite vague in this area, however our
            // implementation is compliant with this vagueness.
            // Hence, For the purposes of this test, org.omg.CORBA.OBJECT_NOT_EXIST being thrown
            // does not indicate a failure - BD 20/06/01
            correct = true;
        } catch (Exception exception) {
            System.err.println("Client04.main: commit exception = " + exception);
            correct = false;
        }
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client04.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client04.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : Control(org.omg.CosTransactions.Control) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) TransactionFactory(org.omg.CosTransactions.TransactionFactory) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION)

Example 17 with TransactionFactory

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

the class Client06 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        TransactionFactory transactionFactory = null;
        String[] transactionFactoryParams = new String[1];
        transactionFactoryParams[0] = ORBServices.otsKind;
        transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
        boolean correct;
        Control control = transactionFactory.create(4);
        Thread.sleep(8000);
        try {
            control.get_terminator().rollback();
            correct = false;
        } catch (INVALID_TRANSACTION invalidTransaction) {
            correct = true;
        } catch (BAD_OPERATION badOperation) {
            correct = true;
        } catch (org.omg.CORBA.OBJECT_NOT_EXIST object_not_exist_exception) {
            // This test creates a transaction with timeout period of 4 seconds then
            // sleeps for 8 seconds.
            // When the timeout goes off at the transaction service, the transaction is
            // rolled back and destroyed.
            // The subsequent call to rollback the transaction results in an
            // org.omg.CORBA.OBJECT_NOT_EXIST exception being thrown.
            // The JTS specification appears to be quite vague in this area, however our
            // implementation is compliant with this vagueness.
            // Hence, For the purposes of this test, org.omg.CORBA.OBJECT_NOT_EXIST being thrown
            // does not indicate a failure - BD 20/06/01
            correct = true;
        } catch (Exception exception) {
            System.err.println("Client06.main: rollback exception = " + exception);
            correct = false;
        }
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client06.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client06.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : Control(org.omg.CosTransactions.Control) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) TransactionFactory(org.omg.CosTransactions.TransactionFactory) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION)

Example 18 with TransactionFactory

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

the class Client10 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        TransactionFactory transactionFactory = null;
        String[] transactionFactoryParams = new String[1];
        transactionFactoryParams[0] = ORBServices.otsKind;
        transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
        int numberOfControls = Integer.parseInt(args[args.length - 1]);
        boolean correct = true;
        Control[] controls = new Control[numberOfControls];
        for (int index = 0; correct && (index < controls.length); index++) {
            controls[index] = transactionFactory.create(0);
            correct = correct && (controls[index].get_coordinator().get_status() == Status.StatusActive);
        }
        for (int index = 0; correct && (index < controls.length); index++) {
            controls[index].get_terminator().commit(true);
        }
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client10.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client10.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : Control(org.omg.CosTransactions.Control) TransactionFactory(org.omg.CosTransactions.TransactionFactory)

Example 19 with TransactionFactory

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

the class RegisterOTSServer2 method main.

public static void main(String[] args) {
    String bindName = System.getProperty(NAME_SERVICE_BIND_NAME_PROPERTY);
    if (bindName != null) {
        System.out.println("Registering OTS Server '" + bindName + "'");
        try {
            ORBInterface.initORB(args, null);
            String[] transactionFactoryParams = new String[1];
            transactionFactoryParams[0] = ORBServices.otsKind;
            TransactionFactory transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
            registerService(bindName, ORBInterface.orb().object_to_string(transactionFactory));
            System.out.println("Ready");
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.out.println("Failed");
        }
    } else {
        System.out.println("Bind name '" + NAME_SERVICE_BIND_NAME_PROPERTY + "' not specified");
        System.out.println("Failed");
    }
}
Also used : TransactionFactory(org.omg.CosTransactions.TransactionFactory) IOException(java.io.IOException)

Aggregations

TransactionFactory (org.omg.CosTransactions.TransactionFactory)19 Control (org.omg.CosTransactions.Control)16 ORB (com.arjuna.orbportability.ORB)4 RootOA (com.arjuna.orbportability.RootOA)4 Test (org.junit.Test)4 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)4 Services (com.arjuna.orbportability.Services)3 BAD_OPERATION (org.omg.CORBA.BAD_OPERATION)3 Terminator (org.omg.CosTransactions.Terminator)2 TestModule.grid (com.hp.mwtests.ts.jts.TestModule.grid)1 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)1 IOException (java.io.IOException)1 IntHolder (org.omg.CORBA.IntHolder)1 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)1