Ejemplo n.º 1
0
  public void set(int n, int m, int value, Control cp) throws SystemException {
    try {
      Coordinator co = cp.get_coordinator();

      if (co != null) co.register_resource(ref);
      else System.err.println("Error - no transaction coordinator!");

      m_a[n][m] = value;
    } catch (UserException e) {
      throw new UNKNOWN();
    } catch (SystemException e) {
      throw new UNKNOWN();
    }
  }
Ejemplo n.º 2
0
  @Test
  public void test() {
    org.omg.CosTransactions.Status status = Status.StatusUnknown;
    tranobject_i localObject = null;
    demosync sync = null;
    ORB myORB = null;
    RootOA myOA = null;

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

      myOA = OA.getRootOA(myORB);

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

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

      Control myControl = null;
      org.omg.CosTransactions.Current current = OTSManager.get_current();
      Coordinator coord = null;

      sync = new demosync();
      localObject = new tranobject_i();

      current.begin();

      myControl = current.get_control();

      coord = myControl.get_coordinator();

      coord.register_resource(localObject.getReference());
      coord.register_synchronization(sync.getReference());

      try {
        current.commit(true);
      } catch (TRANSACTION_ROLLEDBACK e1) {
        System.out.println("Transaction rolledback");
      }

      try {
        status = coord.get_status();
      } catch (SystemException ex) {
        // assume reference no longer valid!

        status = Status.StatusUnknown;
      }
    } catch (UserException e1) {
      fail("Caught UserException: " + e1);
      e1.printStackTrace();
    } catch (SystemException e2) {
      fail("Caught SystemException: " + e2);
      e2.printStackTrace();
    }

    System.out.print(
        "Final action status: " + com.arjuna.ats.jts.utils.Utility.stringStatus(status));
    System.out.println("\nTest completed successfully.");

    myOA.shutdownObject(sync);
    myOA.shutdownObject(localObject);

    myOA.destroy();
    myORB.shutdown();
  }