Package com.arjuna.orbportability

Examples of com.arjuna.orbportability.RootOA


    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)
        {
            // The ORB has not been correctly configured!
            // Display as much help as possible to the user track down the configuration problem
View Full Code Here


    {
        // 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);
            pfile.println(reference);
            file.close();
        }
        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);
        }

        // 3. Start the object adapter listening for requests from the client
        try
        {
            // Display information to indicate that the client application may now be ran
            System.out.println("The bank server is now ready...");
            myOA.run();
        }
        catch (SystemException ex)
        {
            // The OA could not be ran
            // Display as much help as possible to the user track down the configuration problem
View Full Code Here

    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);
            e.printStackTrace(System.err);
View Full Code Here

      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

    }

    public void run(String[] args)
    {
        ORB orbInstance[] = new ORB[NUMBER_OF_ORBOAS];
        RootOA oaInstance[] = new RootOA[NUMBER_OF_ORBOAS];

        for (int count=0;count<NUMBER_OF_ORBOAS;count++)
        {
            logInformation("Creating ORB and OA #"+count);
            orbInstance[count] = ORB.getInstance("orb_"+count);
View Full Code Here

    }

    try
    {
      ORB myORB = ORB.getInstance("Client01");
      RootOA myOA = OA.getRootOA(myORB);

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

    }
    catch (Exception ex)
    {
      ex.printStackTrace();
View Full Code Here

            {
                String orbId = ORB_INSTANCE_NAME+orbCount;
                ORB orb = ORB.getInstance(orbId);
                logInformation("Initialising ORB Instance '"+orbId+"'");
                orb.initORB(args, null);
                RootOA rootOA = RootOA.getRootOA(orb);
                rootOA.initPOA(args);
                preInitExpectedValue++;

                if (PreInitialisation._count != preInitExpectedValue)
                {
                    logInformation("Checking: Failed, Pre-initialisation class not called as expected");
                    assertFailure();
                }
                else
                {
                    logInformation("Checking: Correct ("+preInitExpectedValue+")");
                }

                for (int oaCount=0;oaCount<numberOfOAsPerORB;oaCount++)
                {
                    String oaId = OA_INSTANCE_NAME+oaCount;
                    logInformation("Initialising OA instance '"+oaId+"' for ORB Instance '"+orbId+"'");

                    Policy p[] = new Policy[1];
                    p[0] = rootOA.rootPoa().create_implicit_activation_policy(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
                    OA oa = rootOA.createPOA(oaId, p);
                    preInitExpectedValue++;
                    myPoaExceptedValue++;
                }

                if (PreInitialisation2._count != myPoaExceptedValue)
                {
                    logInformation("Checking: Failed, Pre-initialisation of mypoa class not called as expected");
                    assertFailure();
                }
                else
                {
                    logInformation("Checking: myPOA Correct ("+myPoaExceptedValue+")");
                }


                if (PreInitialisation._count != preInitExpectedValue)
                {
                    logInformation("Checking: Failed, Pre-initialisation class not called as expected");
                    assertFailure();
                }
                else
                {
                    logInformation("Checking: Correct ("+preInitExpectedValue+")");
                }
            }
        }
        catch (Exception e)
        {
            logInformation("ERROR - "+e);
            e.printStackTrace(System.err);
            assertFailure();
        }

        for (int orbCount=0;orbCount<numberOfORBs;orbCount++)
        {
            try
            {
                String orbId = ORB_INSTANCE_NAME+orbCount;
                ORB orb = ORB.getInstance(orbId);

                RootOA oa = RootOA.getRootOA(orb);
                oa.destroy();
                orb.destroy();
            }
            catch (Exception e)
            {
                logInformation("ERROR - While destroying ORB instance '"+ORB_INSTANCE_NAME+orbCount+"' ("+e+")");
View Full Code Here

{
    public void run(String[] args)
    {
        ORB orb = ORB.getInstance("main_orb");
        ORB orb2 = ORB.getInstance("main_orb_2");
        RootOA oa = RootOA.getRootOA(orb);
        RootOA oa2 = RootOA.getRootOA(orb2);

        try
        {
            orb.initORB(args,null);
            oa.initOA(args);

            orb2.initORB(args,null);
            oa2.initOA(args);
        }
        catch (Exception e)
        {
            logInformation("ERROR - During ORB and OA initialisation ("+e+")");
            e.printStackTrace(System.err);
            assertFailure();
        }

        try
        {
            SimpleObjectImpl obj = new SimpleObjectImpl();

            oa.objectIsReady(obj);

            if (oa.objectIsReady(obj))
            {
                logInformation("Manage to activate a servant on the same OA twice - this is incorrect");
                assertFailure();
            }
            else
            {
                logInformation("Didn't managed to activate a servant on the same OA twice - correct");
            }

            if (oa2.objectIsReady(obj))
            {
                logInformation("OA2 did not contain the servant registered on OA - correct");
                oa2.shutdownObject(obj);
            }
            else
            {
                logInformation("OA2 already contained the servant registered on OA - this is incorrect");
                assertFailure();
            }
            assertSuccess();
        }
        catch (Exception e)
        {
            logInformation("ERROR - During object initialisation ("+e+")");
            e.printStackTrace(System.err);
            assertFailure();
        }
        oa.destroy();
  orb.shutdown();
        oa2.destroy();
  orb2.shutdown();
    }
View Full Code Here

  public static void main(String[] args) throws Exception
  {
    System.setProperty("XAConnectionRecovery1", "ExampleXAConnectionRecovery");

    ORB myORB = null;
    RootOA myOA = null;

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

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

      ORBManager.setORB(myORB);
      ORBManager.setPOA(myOA);
    }
    catch (Exception e)
View Full Code Here

   *             If the server cannot connect to the infrastructure configured
   */
  public BlackTieServer(String serverName) throws ConfigurationException,
      ConnectionException {
    ORB orb = com.arjuna.orbportability.ORB.getInstance("ClientSide");
    RootOA oa = com.arjuna.orbportability.OA.getRootOA(orb);
    orb.initORB(new String[] {}, null);

    try {
      oa.initOA();
    } catch (Throwable t) {
      throw new ConnectionException(Connection.TPESYSTEM,
          "Could not connect to the orb", t);
    }
    ORBManager.setORB(orb);
View Full Code Here

TOP

Related Classes of com.arjuna.orbportability.RootOA

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.