Package com.arjuna.ats.internal.jts.orbspecific

Examples of com.arjuna.ats.internal.jts.orbspecific.CurrentImple


      if (OTSImpleManager._current == null)
      {
        try
        {
          OTSImpleManager._current = new CurrentImple();
          OTSImpleManager._currentRef = OTSImpleManager._current;
        }
        catch (Exception e)
        {
          OTSImpleManager._current = null;
View Full Code Here


  {
      System.err.println("Initialisation failed: "+e);
      assertFailure();
  }

  CurrentImple current = OTSImpleManager.current();
  Control theControl = null;
  String objectReference = "/tmp/object.ref";
  String serverName = "SetGet";

  if (System.getProperty("os.name").startsWith("Windows"))
  {
      objectReference = "C:\\temp\\object.ref";
  }
 
  for (int i = 0; i < args.length; i++)
  {
      if (args[i].compareTo("-object") == 0)
    objectReference = args[i+1];
      if (args[i].compareTo("-help") == 0)
      {
    System.out.println("Usage: ExplicitInterClient [-object <reference>] [-help]");
    assertFailure();
      }
  }

  SetGet SetGetVar = null;
  short h = 0;

  try
  {
      current.begin();
      current.begin();
      current.begin();
  }
  catch (Exception e)
  {
      System.err.println("Caught exception during begin: "+e);
      e.printStackTrace(System.err);
      assertFailure();
  }

  try
  {
      Services serv = new Services(myORB);
     
      SetGetVar = SetGetHelper.narrow(myORB.orb().string_to_object(getService(objectReference)));
  }
  catch (Exception ex)
  {
      System.err.println("Failed to bind to setget server: "+ex);
      ex.printStackTrace(System.err);
      assertFailure();
  }

  try
  {
      theControl = current.get_control();
 
      SetGetVar.set((short) 2, theControl);
      //      SetGetVar.set((short) 2, theControl);     

      theControl = null;
     
      System.out.println("Set value.");
  }
  catch (Exception ex1)
  {
      System.err.println("Unexpected system exception during set: "+ex1);
      ex1.printStackTrace(System.err);
      assertFailure();
  }

  try
  {
      System.out.println("committing first nested action");
   
      current.commit(true);

      //      SetGetVar.set((short) 4, current.get_control());
     
      System.out.println("committing second nested action");
   
      current.commit(true);
  }
  catch (Exception sysEx)
  {
      System.err.println("Caught unexpected exception during commit: "+sysEx);
      sysEx.printStackTrace(System.err);
      assertFailure();
  }
   
  try
  {
      theControl = current.get_control();
 
      h = SetGetVar.get(theControl);

      theControl = null;
 
      System.out.println("Got value.");
  }
  catch (Exception ex2)
  {
      System.err.println("Unexpected system exception during get: "+ex2);
      ex2.printStackTrace(System.err);
      assertFailure();
  }

  try
  {
      current.commit(true);

      System.out.println("committed top-level action");

      assertSuccess();
  }
View Full Code Here

  {
      System.err.println("Initialisation failed: "+e);
      assertFailure();
  }
   
  CurrentImple current = OTSImpleManager.current();
  Control myControl = null;
  String gridReference = "/tmp/grid.ref";
  String serverName = "Grid";
  grid gridVar = null// pointer the grid object that will be used.
  int h = -1, w = -1, v = -1;

  if (System.getProperty("os.name").startsWith("Windows"))
  {
      gridReference = "C:\\temp\\grid.ref";
  }
 
  for (int i = 0; i < args.length; i++)
  {
      if (args[i].compareTo("-help") == 0)
      {
    System.out.println("Usage: CurrentTest [-reffile <file>] [-help]");
    assertFailure();
      }
      if (args[i].compareTo("-reffile") == 0)
    gridReference = args[i+1];
  }

  System.out.println("Beginning transaction.");
 
  try
  {
      current.begin();
     
      myControl = current.get_control();

      if (myControl == null)
      {
    System.err.println("Error - control is null!");
    assertFailure();
      }
  }
  catch (Exception sysEx)
  {
      sysEx.printStackTrace(System.err);
      assertFailure();
  }
 
  try
  {
      Services serv = new Services(myORB);
     
      gridVar = gridHelper.narrow(myORB.orb().string_to_object(getService(gridReference)));
  }
  catch (Exception sysEx)
  {
      System.err.println("failed to bind to grid: "+sysEx);
      sysEx.printStackTrace(System.err);
      assertFailure();
  }

  try
  {
      h = gridVar.height();
      w = gridVar.width();
  }
  catch (Exception sysEx)
  {
      System.err.println("grid height/width failed: "+sysEx);
      sysEx.printStackTrace(System.err);
      assertFailure();
  }

  System.out.println("height is "+h);
  System.out.println("width  is "+w);

  try
  {
      gridVar.set(2, 4, 123, myControl);
      v = gridVar.get(2, 4, myControl);
  }
  catch (Exception sysEx)
  {
      System.err.println("grid set/get failed: "+sysEx);
      sysEx.printStackTrace(System.err);
      assertFailure();
  }

  // no problem setting and getting the elememt:
  System.out.println("grid[2,4] is "+v);

  // sanity check: make sure we got the value 123 back:
  if (v != 123)
  {
      assertFailure();
      // oops - we didn't:
      System.err.println("something went seriously wrong");

      try
      {
    current.rollback();
      }
      catch (Exception e)
      {
    System.err.println("rollback error: "+e);
    e.printStackTrace(System.err);
    assertFailure();
      }
 
      assertFailure();
  }
  else
  {
      System.out.println("Committing transaction.");
     
      try
      {
    current.commit(true);

    assertSuccess();
      }
      catch (Exception e)
      {
View Full Code Here

    assertFailure();

      }
  }

  CurrentImple current = OTSImpleManager.current();
     
  TranGrid TranGridVar = null;   // pointer the grid object that will be used.
  short h = 0, w = 0, v = 0;

  try
  {
      current.begin();
     
      Services serv = new Services(myORB);
      TranGridVar = TranGridHelper.narrow(myORB.orb().string_to_object(getService(refFile)));

      try
      {
    h = TranGridVar.height();
    w = TranGridVar.width();
      }
      catch (Exception e)
      {
    System.err.println("Invocation failed: "+e);

    e.printStackTrace();
   
    assertFailure();
      }

      System.out.println("height is "+h);
      System.out.println("width  is "+w);

      try
      {
    System.out.println("calling set");
   
    TranGridVar.set((short) 2, (short) 4, (short) 123);
   
    System.out.println("calling get");
   
    v = TranGridVar.get((short) 2, (short) 4);
      }
      catch (Exception sysEx)
      {
    System.err.println("Grid set/get failed: "+sysEx);
    sysEx.printStackTrace(System.err);
    assertFailure();
      }

      // no problem setting and getting the element:
     
      System.out.println("trangrid[2,4] is "+v);

      // sanity check: make sure we got the value 123 back:
     
      if (v != 123)
      {
    // oops - we didn't:
 
    current.rollback();
          System.out.println("Result not as expected");
    assertFailure();
      }
      else
      {
    current.commit(true);
    assertSuccess();
      }
  }
  catch (Exception e)
  {
View Full Code Here

      if (OTSImpleManager._current == null)
      {
        try
        {
          OTSImpleManager._current = new CurrentImple();
          OTSImpleManager._currentRef = OTSImpleManager._current;
        }
        catch (Exception e)
        {
          OTSImpleManager._current = null;
View Full Code Here

   * thread may not be the same one which does the work, so we
   * cannot do thread association at the interceptor level. We must
   * do it when the invoked method actually gets called.
   */

  CurrentImple curr = OTSImpleManager.current();

  /*
   * Probably separate the underlying work out so that we can
   * call that directly. No real harm at present since the hard
   * work represents most of the overhead and has to be done
   * anyway.
   */

  curr.contextManager().associate();
    }
View Full Code Here

      myOA.initOA();

      ORBManager.setORB(myORB);
      ORBManager.setPOA(myOA);

      CurrentImple current = OTSImpleManager.current();
      AtomicResource aImpl = new AtomicResource(shouldCommit);
      Resource atomicObject = aImpl.getReference();

      System.out.println("beginning top-level transaction.");
     
      current.begin();

      Control myControl = current.get_control();

      if (myControl == null)
      {
    System.err.println("Error - myControl is nil");
    System.exit(0);
      }
     
      System.out.println("getting coordinator");
     
      coord = myControl.get_coordinator();

      myControl = null;
     
      System.out.println("registering resources.");

      RecoveryCoordinator rc = null;
     
      try
      {
    rc = coord.register_resource(atomicObject);
      }
      catch (Exception ex)
      {
    System.out.println("Failed to register resources: "+ex);
    ex.printStackTrace();
   
    System.exit(0);
      }

      if (rc == null)
    System.out.println("No recovery coordinator reference.");
      else
      {
    Status s = Status.StatusUnknown;
   
    try
    {
        System.out.println("Attempting to use recovery coordinator.");
       
        s = rc.replay_completion(atomicObject);
    }
    catch (NotPrepared e)
    {
        s = Status.StatusActive;
    }
    catch (Exception ex)
    {
        System.err.println("Caught: "+ex);
       
        ex.printStackTrace();
       
        System.exit(0);
    }

    System.out.println("Got: "+com.arjuna.ats.jts.utils.Utility.stringStatus(s));

    if (s == Status.StatusActive)
        passed = true;
      }
     
      System.out.println("committing top-level transaction.");

      if (shouldCommit)
    current.commit(true);
      else
    current.rollback();

      if (rc == null)
    System.out.println("No recovery coordinator reference.");
      else
      {
View Full Code Here

      myOA.initOA();

      ORBManager.setORB(myORB);
      ORBManager.setPOA(myOA);
     
      CurrentImple current = OTSImpleManager.current();
      Control theControl = null;
      String objectReference = "/tmp/object.ref";
      String serverName = "SetGet";

      if (System.getProperty("os.name").startsWith("Windows"))
    objectReference = "C:\\temp\\object.ref";
     
      for (int i = 0; i < args.length; i++)
      {
    if (args[i].compareTo("-reffile") == 0)
        objectReference = args[i+1];
    if (args[i].compareTo("-help") == 0)
    {
        System.out.println("Usage: TimeoutClient [-reffile <file>] [-help]");
        assertFailure();
    }
      }

      SetGet SetGetVar = null;

      System.out.println("Setting transaction timeout to 2 seconds.");
 
      current.set_timeout(2);
 
      current.begin();
      current.begin();
   
      try
      {
    Services serv = new Services(myORB);
   
    SetGetVar = SetGetHelper.narrow(myORB.orb().string_to_object(getService(objectReference)));
      }
      catch (Exception e)
      {
    System.err.println("Bind to object failed: "+e);
    e.printStackTrace(System.err);
    assertFailure();
      }

      try
      {
    theControl = current.get_control();
 
    SetGetVar.set((short) 2, theControl);

    theControl = null;

    System.out.println("Set value.");
      }
      catch (Exception e)
      {
    System.err.println("Call to set or get failed: "+e);
    e.printStackTrace(System.err);
    assertFailure();
      }

      try
      {
    System.out.println("Now sleeping for 5 seconds.");
 
    Thread.sleep(5000);
      }
      catch (Exception e)
      {
      }

      System.out.println("\ncommitting nested action.");

      try
      {
    current.commit(true);
    assertFailure();
      }
      catch (TRANSACTION_ROLLEDBACK  e1)
      {
    System.out.println("Caught TransactionRolledBack");
      }
      catch (INVALID_TRANSACTION  e1/* For JacORB */
      {
    System.out.println("Caught InvalidTransaction");
      }

      System.out.println("\ncommitting top-level action");

      try
      {
    current.commit(true);
    assertFailure();
      }
      catch (TRANSACTION_ROLLEDBACK  e2)
      {
    System.out.println("Caught TransactionRolledBack");
View Full Code Here

      assertFailure();
  }

  String refFile = "/tmp/stack.ref";
  String serverName = "Stack";
  CurrentImple current = OTSImpleManager.current();

  if (System.getProperty("os.name").startsWith("Windows"))
  {
      refFile = "C:\\temp\\stack.ref"}
 
  for (int i = 0; i < args.length; i++)
  {
      if (args[i].compareTo("-reffile") == 0)
    refFile = args[i+1];
      if (args[i].compareTo("-help") == 0)
      {
    System.out.println("Usage: ImplicitArjunaClient [-reffile <file>] [-help]");
    assertFailure();
      }
  }
 
  stack stackVar = null;   // pointer the grid object that will be used.

  try
  {
      current.begin();

      try
      {
    Services serv = new Services(myORB);
   
    stackVar = stackHelper.narrow(myORB.orb().string_to_object(getService(refFile)));
      }
      catch (Exception e)
      {
    e.printStackTrace(System.err);
    assertFailure();
      }

      System.out.println("pushing 1 onto stack");
 
      stackVar.push(1);

      System.out.println("pushing 2 onto stack");

      stackVar.push(2);
  }
  catch (Exception e)
  {
      e.printStackTrace(System.err);
      assertFailure();
  }

  try
  {
      current.commit(false);

      current.begin();

      IntHolder val = new IntHolder(-1);

      if (stackVar.pop(val) == 0)
      {
    System.out.println("popped top of stack "+val.value);

    current.begin();
 
    stackVar.push(3);

    System.out.println("pushed 3 onto stack. Aborting nested action.");
 
    current.rollback();

    stackVar.pop(val);

    System.out.println("popped top of stack is "+val.value);

    current.commit(false);

    if (val.value == 1)
    {
        System.out.println("\nThis is correct.");
        assertSuccess();
    }
    else
    {
        System.out.println("\nThis is incorrect.");
        assertFailure();
    }
      }
      else
      {
    assertFailure();
    System.err.println("Error getting stack value.");
 
    current.rollback();
      }
  }
  catch (Exception e)
  {
      e.printStackTrace(System.err);
View Full Code Here

  {
      System.err.println("Initialisation failed: "+e);
      assertFailure();
  }
   
  CurrentImple current = OTSImpleManager.current();
  String refFile = "/tmp/explicitstack.ref";
  String serverName = "ExplicitStack";
  int value = 1;
  Control cont = null;

  if (System.getProperty("os.name").startsWith("Windows"))
  {
      refFile = "C:\\temp\\explicitstack.ref";
  }
 
  for (int i = 0; i < args.length; i++)
  {
      if (args[i].compareTo("-reffile") == 0)
    refFile = args[i+1];
      if (args[i].compareTo("-value") == 0)
      {
    try
    {
        Integer val = new Integer(args[i+1]);
        value = val.intValue();
    }
    catch (Exception e)
    {
        System.err.println(e);
        assertFailure();
    }
      }
      if (args[i].compareTo("-help") == 0)
      {
    System.out.println("Usage: ExplicitArjunaClient [-reffile <file>] [-value <number>] [-help]");
    assertFailure();
      }
  }

  try
  {
      System.out.println("Starting initialising top-level transaction.");
 
      current.begin();

      System.out.println("Initialising transaction name: "+current.get_transaction_name());
  }
  catch (Exception e)
  {
      e.printStackTrace(System.err);
      assertFailure();
  }

  ExplicitStack stackVar = null;   // pointer the grid object that will be used.
 
  try
  {
      stackVar = ExplicitStackHelper.narrow(myORB.orb().string_to_object(getService(refFile)));
  }
  catch (Exception e)
  {
      System.err.println("Bind error: "+e);
      assertFailure();
  }

  try
  {
      System.out.println("pushing "+value+" onto stack");

      cont = current.get_control();
      stackVar.push(value, cont);

      System.out.println("\npushing "+(value+1)+" onto stack");

      stackVar.push(value+1, cont);

      cont = null;
  }
  catch (Exception e)
  {
      e.printStackTrace(System.err);
      assertFailure();
  }

  try
  {
      current.commit(true);

      System.out.println("Committed top-level transaction");
      System.out.println("\nBeginning top-level transaction");
   
      current.begin();

      System.out.println("Top-level name: "+current.get_transaction_name());
   
      IntHolder val = new IntHolder(-1);
   
      cont = current.get_control();
   
      if (stackVar.pop(val, cont) == 0)
      {
    System.out.println("popped top of stack "+val.value);
    System.out.println("\nbeginning nested transaction");

    current.begin();

    System.out.println("nested name: "+current.get_transaction_name());

    cont = null;
    cont = current.get_control();   
    stackVar.push(value+2, cont);

    System.out.println("pushed "+(value+2)+" onto stack. Aborting nested action.");

    cont = null// current will destroy this control!
    current.rollback();
    cont = current.get_control();
 
    System.out.println("current transaction name: "+current.get_transaction_name());
    System.out.println("rolledback nested transaction");

    stackVar.pop(val, cont);

    System.out.println("\npopped top of stack is "+val.value);

    System.out.println("\nTrying to print stack contents - should fail.");
 
    stackVar.printStack();
 
    cont = null;
    current.commit(true);

    System.out.println("\nCommitted top-level transaction");
 
    if (current.get_transaction_name() == null)
        System.out.println("current transaction name: null");
    else
        System.out.println("Error - current transaction name: "
               +current.get_transaction_name());
 
    if (val.value == value)
    {
        System.out.println("\nThis is correct.");
        assertSuccess();
    }
    else
    {
        System.out.println("\nThis is incorrect. Value should be "+value);
        assertFailure();
    }
      }
      else
      {
    System.out.println("Error getting stack value.");
 
    current.rollback();

    System.out.println("\nRolledback top-level transaction.");
      }

      try
View Full Code Here

TOP

Related Classes of com.arjuna.ats.internal.jts.orbspecific.CurrentImple

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.