Package com.arjuna.orbportability

Examples of com.arjuna.orbportability.ORB


     * @param args Not used by this entry point.
     */
    public static void main(String[] args)
    {
        // Define an ORB suitable for use by the JBoss Transactions product ORB portability layer.
        ORB myORB = null;
        // Define an object adapter suitable for use by the JBoss Transactions product ORB portability layer.
        RootOA myOA = null;
        try
        {
            // Initialize the ORB reference using the JBoss Transactions product ORB portability layer.
            myORB = ORB.getInstance("ClientSide");
            // Initialize the object adapter reference using the JBoss Transactions product ORB portability layer.
            myOA = OA.getRootOA(myORB);
            // Initialize the ORB using the JBoss Transactions product ORB portability layer.
            myORB.initORB(args, null);
            // Initialize the object adapter reference using the JBoss Transactions product ORB portability layer.
            myOA.initOA();
        }
        catch (Exception e)
        {
            // The ORB has not been correctly configured!
            // Display as much help as possible to the user track down the configuration problem
            System.err.println("Trailmap Error: ORB Initialisation failed: " + e);
            e.printStackTrace();
            System.exit(0);
        }

        // Obtain a reference to the BankImpl CORBA representation inorder to be able to use it to transactionally
        // invoke banking operations as part of the JBoss Transactions product trailmap
        // Define the reference to invoke
        Bank bank = null;
        // Obtain the reference for bank
        try
        {
            // Read the IOR from file
            java.io.FileInputStream file = new java.io.FileInputStream("ObjectId");
            java.io.InputStreamReader input = new java.io.InputStreamReader(file);
            java.io.BufferedReader reader = new java.io.BufferedReader(input);
            // This contains the IOR
            String stringTarget = reader.readLine();

            // Convert the IOR into a CORBA object
            org.omg.CORBA.Object obj = myORB.orb().string_to_object(stringTarget);
            // Narrow the object into an object implementing <CODE>Hello</CODE>
            System.out.println("Try to convert the obj ref to a Bank object !");
            bank = BankHelper.narrow(obj);
        }
        catch (java.io.IOException ioe)
View Full Code Here


{
    protected void work() throws Exception
    {
        try
        {
            ORB orb = ORB.getInstance( PerformanceFramework.ORB_INSTANCE_NAME );
            OA oa = OA.getRootOA(orb);

            String ref1 = getServiceConfig(0);
            String ref2 = getServiceConfig(1);

            org.omg.CORBA.Object obj1 = orb.orb().string_to_object(ref1);
            PerfTestInterface d1 = (PerfTestInterface) PerfTestInterfaceHelper.narrow(obj1);

            OTSManager.get_current().begin();
            d1.work();

            org.omg.CORBA.Object obj2 = orb.orb().string_to_object(ref2);
            PerfTestInterface d2 = (PerfTestInterface) PerfTestInterfaceHelper.narrow(obj2);

            OTSManager.get_current().begin();
            d2.work();
View Full Code Here

     * @param args Not used in this example.
     */
    public static void main(String[] args)
    {
        // Define an ORB suitable for use by the JBoss Transactions product ORB portability layer.
        ORB myORB = null;
        // Define an object adapter suitable for use by the JBoss Transactions product ORB portability layer.
        RootOA myOA = null;
        try
        {
            // Initialize the ORB reference using the JBoss Transactions product ORB portability layer.
            myORB = ORB.getInstance("test");
            // Initialize the object adapter reference using the JBoss Transactions product ORB portability layer.
            myOA = OA.getRootOA(myORB);
            // Initialize the ORB using the JBoss Transactions product ORB portability layer.
            myORB.initORB(args, null);
            // Initialize the object adapter reference using the JBoss Transactions product ORB portability layer.
            myOA.initOA();
        }
        catch (Exception e)
        {
View Full Code Here

public class NestedOnePhaseTrx extends PerformanceTest
{
    protected void work() throws Exception
    {
        ORB orb = ORB.getInstance( PerformanceFramework.ORB_INSTANCE_NAME );
        OA oa = OA.getRootOA(orb);

        String ref1 = getServiceConfig(0);
        String ref2 = getServiceConfig(1);

        org.omg.CORBA.Object obj1 = orb.orb().string_to_object(ref1);
        PerfTestInterface d1 = (PerfTestInterface) PerfTestInterfaceHelper.narrow(obj1);

        OTSManager.get_current().begin();
        d1.work();

        org.omg.CORBA.Object obj2 = orb.orb().string_to_object(ref2);
        PerfTestInterface d2 = (PerfTestInterface) PerfTestInterfaceHelper.narrow(obj2);

        OTSManager.get_current().begin();
        d2.work();
View Full Code Here

        log.info("Starting transaction recovery manager");

        try
        {
            /** Create an ORB portability wrapper around the CORBA ORB services orb **/
            ORB orb = ORB.getInstance("jboss-atx");

            org.omg.PortableServer.POA rootPOA = org.omg.PortableServer.POAHelper.narrow(theCorbaORB.resolve_initial_references("RootPOA"));

            orb.setOrb(theCorbaORB);
            OA oa = OA.getRootOA(orb);
            oa.setPOA(rootPOA);

            RecoveryORBManager.setORB(orb);
            RecoveryORBManager.setPOA(oa);
View Full Code Here

     */
    public static void main(String[] args)
    {
        // 0. Define and create the ORB
        // Define an ORB suitable for use by the JBoss Transactions product ORB portability layer.
        ORB myORB = null;
        // Define an object adapter suitable for use by the JBoss Transactions product ORB portability layer.
        RootOA myOA = null;
        try
        {
            // Initialize the ORB reference using the JBoss Transactions product ORB portability layer.
            myORB = ORB.getInstance("ServerSide");
            // Initialize the object adapter reference using the JBoss Transactions product ORB portability layer.
            myOA = OA.getRootOA(myORB);
            // Initialize the ORB using the JBoss Transactions product ORB portability layer.
            myORB.initORB(args, null);
            // Initialize the object adapter reference using the JBoss Transactions product ORB portability layer.
            myOA.initOA();
        }
        catch (Exception e)
        {
            // The ORB has not been correctly configured!
            // Display as much help as possible to the user track down the configuration problem
            System.err.println("Trailmap Error: ORB Initialisation failed: " + e);
            e.printStackTrace();
            System.exit(0);
        }

        // 1. Create the workhorse of this section of the trailmap, the BankImpl which responds to calls under
        // transactional control
        BankImpl bank = null;
        // See if the bank has already been created before
        File uidBankFile = new File("UidBankFile");
        if (uidBankFile.exists())
        {
            try
            {
                // Read the banks UID from the file
                FileInputStream file = new FileInputStream(uidBankFile);
                InputStreamReader input = new InputStreamReader(file);
                BufferedReader reader = new BufferedReader(input);
                String stringUid = reader.readLine();
                file.close();

                // Recreate the bank from its UID
                bank = new BankImpl(new Uid(stringUid), myOA);
                boolean bankActivated = bank.activate();
                System.out.println("File Found, bank was activated?: " + bankActivated);
            }
            catch (java.io.IOException ioe)
            {
                // The IOR could not be persisted
                // Display as much help as possible to the user track down the configuration problem
                System.out.println("Trailmap Error: Could not persist the IOR of the BankImpl: " + ioe);
                ioe.printStackTrace();
                System.exit(0);
            }
        }
        else
        {
            // This section is executed when the bank server is executed for the first time.
            // Create the bank to obtain it's UID
            bank = new BankImpl(myOA);
            try
            {
                // Write the UID to file
                FileOutputStream file = new FileOutputStream(uidBankFile);
                PrintStream pfile = new PrintStream(file);
                pfile.println(bank.get_uid().toString());
                file.close();

                // Report the success
                System.out.println("File not Found and created ");
            }
            catch (java.io.IOException ioe)
            {
                // The IOR could not be persisted
                // Display as much help as possible to the user track down the configuration problem
                System.out.println("Trailmap Error: Could not persist the UID of the BankImpl: " + ioe);
                ioe.printStackTrace();
                System.exit(0);
            }
        }
        // Create the POA reference to bind
        System.out.println("About to create Bank Object");
        BankPOATie bankTieClass = new BankPOATie(bank);
        System.out.println("Bank Object created");

        // 2. Create an IOR reference to the <CODE>BankImpl</CODE> that can be used by the <CODE>BankClient</CODE>
        // to locate the server
        // Create the reference
        String reference = myORB.orb().object_to_string(myOA.corbaReference(bankTieClass));
        try
        {
            // Write the reference to disk for the client to read
            java.io.FileOutputStream file = new java.io.FileOutputStream("ObjectId");
            java.io.PrintStream pfile = new java.io.PrintStream(file);
View Full Code Here

    private final static String ORB_NAME = "testorb";

    public void run(String[] args)
    {
        boolean staticSet = false;
        ORB myORB = null;
  RootOA myOA = null;

        for (int count=0;count<args.length;count++)
        {
            if ( args[count].equalsIgnoreCase("-setstatically") )
            {
                staticSet = true;
            }
        }

        System.setProperty( PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_NAME), "com.arjuna.ats.jts.utils.ORBSetup");

  try
  {
      myORB = ORB.getInstance(ORB_NAME);
      myOA = OA.getRootOA(myORB);

            if (staticSet)
            {
                ORBManager.setORB(myORB);
            }

            try
            {
                myORB.initORB(args, null);
                myOA.initOA();

                if (ORBManager.getORB() != myORB)
                {
                    logInformation("The ORB reference returned by ORBManager was not the ORB previously initialised");
                    assertFailure();
                }
                else
                {
                    logInformation("The ORB reference returned by ORBManager is the previously initialised ORB");
                    assertSuccess();
                }
            }
            catch (FatalError e)
            {
                if (staticSet)
                {
                    logInformation("FatalError thrown as expected");
                    assertSuccess();
                }
                else
                {
                    logInformation("Error: "+e);
                    e.printStackTrace(System.err);
                    assertFailure();
                }
            }

            myORB.destroy();
            myOA.destroy();
  }
  catch (Throwable e)
  {
      logInformation("Error: "+e);
View Full Code Here

            try
            {
                jtaPropertyManager.propertyManager.setProperty(Environment.JTA_TM_IMPLEMENTATION, com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple.class.getName());
                jtaPropertyManager.propertyManager.setProperty(Environment.JTA_UT_IMPLEMENTATION, com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple.class.getName());

                ORB orb = ORB.getInstance("implicitserver-orb");
                OA oa = OA.getRootOA(orb);

                orb.initORB(args, null);
                oa.initPOA(args);

                org.omg.CORBA.Object obj = orb.orb().string_to_object(getService(args[0]));

                Example.test test = Example.testHelper.narrow(obj);

                TransactionManager.transactionManager().begin();

                test.invoke();

                TransactionManager.transactionManager().commit();

                assertSuccess();

                oa.destroy();
                orb.destroy();
            }
            catch (Exception e)
            {
                e.printStackTrace(System.err);
                assertFailure();
View Full Code Here

public class JTATransactionCommitTest extends Test
{
    public void run(String[] args)
    {
        ORB orb = ORB.getInstance("test-orb");
        OA oa = OA.getRootOA(orb);

        try
        {
            orb.initORB(args, null);
            oa.initPOA(args);
        }
        catch (Exception e)
        {
            System.out.println("Failed to setup and initiate ORB: "+e);
            assertFailure();
        }

        /** Ensure underlying JTA implementation is JTS **/
        jtaPropertyManager.propertyManager.setProperty(Environment.JTA_TM_IMPLEMENTATION, TransactionManagerImple.class.getName());

        try
        {
            TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();

            System.out.println("Beginning new transaction");
            tm.begin();

            Transaction tx = tm.suspend();

            System.out.println("Beginning second transaction");
            tm.begin();

            System.out.println("Committing original transaction (via Transaction interface)");
            tx.commit();

            System.out.println("Committing second transaction (via TransactionManager interface)");
            tm.commit();

            assertSuccess();
        }
        catch (Exception e)
        {
            System.out.println("Unexpected exception: "+e);
            e.printStackTrace(System.err);
            assertFailure();
        }

        try
        {
            oa.destroy();
            orb.shutdown();
        }
        catch (Exception e)
        {
            System.out.println("Failed to shutdown and destroy the ORB/OA: "+e);
            e.printStackTrace(System.err);
View Full Code Here

      HeuristicMixedException, HeuristicRollbackException,
      InterruptedException {

    String mode = "jts";
    if (mode.equals("jts")) {
      ORB myORB = ORB.getInstance("test");
      RootOA myOA = OA.getRootOA(myORB);

      myORB.initORB(new String[0], null);
      myOA.initOA();

      com.arjuna.ats.internal.jts.ORBManager.setORB(myORB);
      com.arjuna.ats.internal.jts.ORBManager.setPOA(myOA);

      RecoveryManager.manager().initialize();
    }

    TransactionManager transactionManager = mode.equals("jts") ? new com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple()
        : new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple();
    transactionManager.setTransactionTimeout(2);
    transactionManager.begin();
    transactionManager.getTransaction().enlistResource(
        new TimeoutOnFirstRollbackResource());

    // Business logic
    Thread.currentThread().sleep(5000);

    try {
      transactionManager.commit();
      fail("Should not have been able to commit");
    } catch (RollbackException e) {
      // This is fine
    } finally {
      if (mode.equals("jts")) {
        RecoveryManager.manager().terminate();

        ORB myORB = ORB.getInstance("test");
        RootOA myOA = OA.getRootOA(myORB);
        myOA.destroy();
        myORB.shutdown();
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.arjuna.orbportability.ORB

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.