Package com.arjuna.ats.jts

Examples of com.arjuna.ats.jts.ExplicitInterposition


    if (tpc instanceof PropagationContextWrapper)
    {
      try
      {
        PropagationContext omgTpc = ((PropagationContextWrapper) tpc).getPropagationContext();
        ExplicitInterposition ei = new ExplicitInterposition(omgTpc, true);
        Transaction newTx = tm.getTransaction();

        if (log.isDebugEnabled())
        {
          log.debug("PropagationContextManager.importTransactionPropagationContext(Object) - transaction = " + newTx);
        }


        ei.unregisterTransaction();

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


  try
  {
      if (control != null)
      {
    ExplicitInterposition manager = new ExplicitInterposition();
   
    manager.registerTransaction(control);

    System.out.println("setget_i.set - managed to set up interposition hierarchy");
   
    CurrentImple current = OTSImpleManager.current();
    Control cont = current.get_control();

    if (cont == null)
        System.err.println("setget_i.set error - current returned no control!");
    else
    {
        System.out.println("setget_i.set - current returned a control!");

        cont = null;
    }
   
    System.out.println("setget_i.set - beginning nested action");

    current.begin();

    cont = current.get_control();

    if (cont != null)
    {
        Coordinator coord = cont.get_coordinator();

        System.out.println("setget_i.set - registering self");
   
        coord.register_resource(ref);

        coord = null;
        cont = null;
    }
    else
        System.err.println("setget_i.set - current did not return control after begin!");
     
    value = n;
     
    System.out.println("setget_i.set - committing nested action");
 
    current.commit(true);

    manager.unregisterTransaction();

    manager = null;
      }
      else
    System.err.println("setget_i::set error - no control!");
View Full Code Here

    public int push (int val, Control action) throws SystemException
    {
  AtomicTransaction A = new AtomicTransaction();
  int res = 0;
  ExplicitInterposition inter = new ExplicitInterposition();

  try
  {
      inter.registerTransaction(action);
  }
  catch (Exception e)
  {
      System.err.println("WARNING ExplicitStackImple::push - could not create interposition.");
      return -1;
  }

  String name = OTSImpleManager.current().get_transaction_name();
 
  System.out.println("Created push interposed transaction: "+name);

  name = null;

  try
  {
      A.begin();

      if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED)
      {
    if (top < ARRAY_SIZE)
    {
        array[top] = val;
        top++;
    }
    else
        res = -1;

    if (res == 0)
    {
        A.commit(false);
    }
    else
        A.rollback();
      }
      else
    A.rollback();
  }
  catch (Exception e1)
  {
      try
      {
    A.rollback();
      }
      catch (Exception e2)
      {
    System.err.println(e2);
      }
     
      res = -1;
  }

  inter.unregisterTransaction();
 
  return res;
    }
View Full Code Here

    public int pop (IntHolder val, Control action) throws SystemException
    {
  AtomicTransaction A = new AtomicTransaction();
  int res = 0;
  ExplicitInterposition inter = new ExplicitInterposition();

  try
  {
      inter.registerTransaction(action);
  }
  catch (Exception e)
  {
      System.err.println("WARNING ExplicitStackImple::push - could not create interposition.");
      return -1;
  }

  String name = OTSImpleManager.current().get_transaction_name();
 
  System.out.println("Created pop interposed transaction: "+name);

  name = null;

  try
  {
      A.begin();

      if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED)
      {
    if (top > 0)
    {
        top--;
        val.value = array[top];
    }
    else
        res = -1;

    if (res == 0)
    {
        A.commit(false);
    }
    else
        A.rollback();
      }
      else
      {
    A.rollback();
      }
  }
  catch (Exception e1)
  {
      try
      {
    A.rollback();
      }
      catch (Exception e2)
      {
    System.err.println(e2);
      }
     
      res = -1;
  }

  inter.unregisterTransaction();

  return res;
    }
View Full Code Here

    }

    public boolean incr (int value, Control control) throws SystemException
    {
  boolean res = false;
  ExplicitInterposition inter = new ExplicitInterposition();

  try
  {
      inter.registerTransaction(control);
  }
  catch (Exception e)
  {
      System.err.println("WARNING HammerObject.incr - could not do interposition");
      return false;
  }

  CurrentImple current = OTSImpleManager.current();

  try
  {
      current.begin();

      if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED)
      {
    _value = _value + value;

    current.commit(true);
    res = true;
      }
      else
    current.rollback();
  }
  catch (Exception e)
  {
      System.err.println("HammerObject.incr: "+e);
     
      res = false;
  }

  inter.unregisterTransaction();
 
  return res;
    }
View Full Code Here

    }

    public boolean set (int value, Control control) throws SystemException
    {
  boolean res = false;
  ExplicitInterposition inter = new ExplicitInterposition();

  try
  {
      inter.registerTransaction(control);
  }
  catch (Exception e)
  {
      System.err.println("WARNING HammerObject.set - could not do interposition");
      return false;
  }

  CurrentImple current = OTSImpleManager.current();   

  try
  {
      current.begin();

      if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED)
      {
    _value = value;

    current.commit(true);
    res = true;
      }
      else
    current.rollback();
  }
  catch (Exception e)
  {
      System.err.println("HammerObject.set: "+e);

      res = false;
  }

  inter.unregisterTransaction();

  return res;
    }
View Full Code Here

    }

    public boolean get (IntHolder value, Control control) throws SystemException
    {
  boolean res = false;
  ExplicitInterposition inter = new ExplicitInterposition();

  try
  {
      inter.registerTransaction(control);
  }
  catch (Exception e)
  {
      System.err.println("WARNING HammerObject.incr - could not do interposition");
      return false;
  }

  CurrentImple current = OTSImpleManager.current();

  try
  {
      current.begin();

      if (setlock(new Lock(LockMode.READ), 0) == LockResult.GRANTED)
      {
    value.value = _value;

    current.commit(true);
    res = true;
      }
      else
    current.rollback();
  }
  catch (Exception e)
  {
      System.err.println("HammerObject.get: "+e);
     
      res = false;
  }

  inter.unregisterTransaction();
 
  return res;
    }
View Full Code Here

    public int push (int val, Control action) throws SystemException
    {
  AtomicTransaction A = new AtomicTransaction();
  int res = 0;
  ExplicitInterposition inter = new ExplicitInterposition();

  try
  {
      inter.registerTransaction(action);
  }
  catch (Exception e)
  {
      System.err.println("WARNING ExplicitStackImple::push - could not create interposition.");
      return -1;
  }

  String name = OTSImpleManager.current().get_transaction_name();
 
  System.out.println("Created push interposed transaction: "+name);

  name = null;

  try
  {
      A.begin();

      if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED)
      {
    if (top < ARRAY_SIZE)
    {
        array[top] = val;
        top++;
    }
    else
        res = -1;

    if (res == 0)
    {
        A.commit(false);
    }
    else
        A.rollback();
      }
      else
    A.rollback();
  }
  catch (Exception e1)
  {
      try
      {
    A.rollback();
      }
      catch (Exception e2)
      {
    System.err.println(e2);
      }
     
      res = -1;
  }

  inter.unregisterTransaction();
 
  return res;
    }
View Full Code Here

    public int pop (IntHolder val, Control action) throws SystemException
    {
  AtomicTransaction A = new AtomicTransaction();
  int res = 0;
  ExplicitInterposition inter = new ExplicitInterposition();

  try
  {
      inter.registerTransaction(action);
  }
  catch (Exception e)
  {
      System.err.println("WARNING ExplicitStackImple::push - could not create interposition.");
      return -1;
  }

  String name = OTSImpleManager.current().get_transaction_name();
 
  System.out.println("Created pop interposed transaction: "+name);

  name = null;

  try
  {
      A.begin();

      if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED)
      {
    if (top > 0)
    {
        top--;
        val.value = array[top];
    }
    else
        res = -1;

    if (res == 0)
    {
        A.commit(false);
    }
    else
        A.rollback();
      }
      else
      {
    A.rollback();
      }
  }
  catch (Exception e1)
  {
      try
      {
    A.rollback();
      }
      catch (Exception e2)
      {
    System.err.println(e2);
      }
     
      res = -1;
  }

  inter.unregisterTransaction();

  return res;
    }
View Full Code Here

  try
  {
      if (control != null)
      {
    ExplicitInterposition manager = new ExplicitInterposition();
   
    manager.registerTransaction(control);

    System.out.println("setget_i.set - managed to set up interposition hierarchy");
   
    CurrentImple current = OTSImpleManager.current();
    Control cont = current.get_control();

    if (cont == null)
        System.err.println("setget_i.set error - current returned no control!");
    else
    {
        System.out.println("setget_i.set - current returned a control!");

        cont = null;
    }
   
    System.out.println("setget_i.set - beginning nested action");

    current.begin();

    cont = current.get_control();

    if (cont != null)
    {
        Coordinator coord = cont.get_coordinator();

        System.out.println("setget_i.set - registering self");
   
        coord.register_resource(ref);

        coord = null;
        cont = null;
    }
    else
        System.err.println("setget_i.set - current did not return control after begin!");
     
    value = n;
     
    System.out.println("setget_i.set - committing nested action");
 
    current.commit(true);

    manager.unregisterTransaction();

    manager = null;
      }
      else
    System.err.println("setget_i::set error - no control!");
View Full Code Here

TOP

Related Classes of com.arjuna.ats.jts.ExplicitInterposition

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.