use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class AITCounterImpl01 method set.
public void set(int value, Control ctrl) throws InvocationException {
try {
com.arjuna.ats.jts.ExplicitInterposition interposition = new com.arjuna.ats.jts.ExplicitInterposition();
interposition.registerTransaction(ctrl);
AtomicTransaction atomicTransaction = new AtomicTransaction();
try {
atomicTransaction.begin();
if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED) {
_value = value;
atomicTransaction.commit(true);
} else {
atomicTransaction.rollback();
throw new InvocationException();
}
} catch (InvocationException invocationException) {
interposition.unregisterTransaction();
throw invocationException;
} catch (Exception exception) {
System.err.println("AITCounterImpl01.set: " + exception);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
interposition.unregisterTransaction();
throw new InvocationException();
} catch (Error error) {
System.err.println("AITCounterImpl01.set: " + error);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
interposition.unregisterTransaction();
throw new InvocationException();
}
interposition.unregisterTransaction();
} catch (InvocationException invocationException) {
throw invocationException;
} catch (Exception exception) {
System.err.println("AITCounterImpl01.set: " + exception);
throw new InvocationException();
}
}
use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class AITCounterImpl01 method get.
public void get(IntHolder value, Control ctrl) throws InvocationException {
try {
com.arjuna.ats.jts.ExplicitInterposition interposition = new com.arjuna.ats.jts.ExplicitInterposition();
interposition.registerTransaction(ctrl);
AtomicTransaction atomicTransaction = new AtomicTransaction();
try {
atomicTransaction.begin();
if (setlock(new Lock(LockMode.READ), 0) == LockResult.GRANTED) {
value.value = _value;
atomicTransaction.commit(true);
} else {
atomicTransaction.rollback();
throw new InvocationException();
}
} catch (InvocationException invocationException) {
interposition.unregisterTransaction();
throw invocationException;
} catch (Exception exception) {
System.err.println("AITCounterImpl01.get: " + exception);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
interposition.unregisterTransaction();
throw new InvocationException();
} catch (Error error) {
System.err.println("AITCounterImpl01.get: " + error);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
interposition.unregisterTransaction();
throw new InvocationException();
}
interposition.unregisterTransaction();
} catch (InvocationException invocationException) {
throw invocationException;
} catch (Exception exception) {
System.err.println("AITCounterImpl01.get: " + exception);
throw new InvocationException();
}
}
use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class AITPingPongImpl01 method get.
public void get(IntHolder value, Control ctrl) throws InvocationException {
try {
com.arjuna.ats.jts.ExplicitInterposition interposition = new com.arjuna.ats.jts.ExplicitInterposition();
interposition.registerTransaction(ctrl);
AtomicTransaction atomicTransaction = new AtomicTransaction();
try {
atomicTransaction.begin();
if (setlock(new Lock(LockMode.READ), 0) == LockResult.GRANTED) {
value.value = _value;
atomicTransaction.commit(true);
} else {
System.err.println("AITPingPongImpl01.get: failed to get lock");
atomicTransaction.rollback();
throw new InvocationException();
}
} catch (InvocationException invocationException) {
interposition.unregisterTransaction();
throw invocationException;
} catch (Exception exception) {
System.err.println("AITPingPongImpl01.get: " + exception);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
interposition.unregisterTransaction();
throw new InvocationException();
} catch (Error error) {
System.err.println("AITPingPongImpl01.get: " + error);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
interposition.unregisterTransaction();
throw new InvocationException();
}
interposition.unregisterTransaction();
} catch (InvocationException invocationException) {
throw invocationException;
} catch (Exception exception) {
System.err.println("AITPingPongImpl01.get: " + exception);
throw new InvocationException();
} catch (Error error) {
System.err.println("AITPingPongImpl01.get: " + error);
throw new InvocationException();
}
}
use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class AITPingPongImpl01 method hit.
public void hit(int count, PingPong ponger, PingPong pinger, Control ctrl) throws InvocationException {
try {
com.arjuna.ats.jts.ExplicitInterposition interposition = new com.arjuna.ats.jts.ExplicitInterposition();
interposition.registerTransaction(ctrl);
AtomicTransaction atomicTransaction = new AtomicTransaction();
try {
atomicTransaction.begin();
if (count != 0) {
ponger.hit(count - 1, pinger, ponger, OTS.current().get_control());
atomicTransaction.commit(true);
} else if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED) {
_value++;
atomicTransaction.commit(true);
} else {
System.err.println("AITPingPongImpl01.hit: failed to get lock");
atomicTransaction.rollback();
throw new InvocationException();
}
} catch (InvocationException invocationException) {
interposition.unregisterTransaction();
throw invocationException;
} catch (Exception exception) {
System.err.println("AITPingPongImpl01.hit: " + exception);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
interposition.unregisterTransaction();
throw new InvocationException();
} catch (Error error) {
System.err.println("AITPingPongImpl01.hit: " + error);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
interposition.unregisterTransaction();
throw new InvocationException();
}
interposition.unregisterTransaction();
} catch (InvocationException invocationException) {
throw invocationException;
} catch (Exception exception) {
System.err.println("AITPingPongImpl01.hit: " + exception);
throw new InvocationException();
} catch (Error error) {
System.err.println("AITPingPongImpl01.hit: " + error);
throw new InvocationException();
}
}
use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class AITCounterImpl04 method increase.
public void increase() throws InvocationException {
try {
AtomicTransaction atomicTransaction = new AtomicTransaction();
try {
atomicTransaction.begin();
if (setlock(new Lock(LockMode.WRITE), super.waitTotalTimeout) == LockResult.GRANTED) {
_value++;
atomicTransaction.commit(true);
} else {
atomicTransaction.rollback();
throw new InvocationException();
}
} catch (InvocationException invocationException) {
throw invocationException;
} catch (Exception exception) {
System.err.println("AITCounterImpl04.increase: " + exception);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
throw new InvocationException();
}
} catch (InvocationException invocationException) {
throw invocationException;
} catch (Exception exception) {
System.err.println("AITCounterImpl04.increase: " + exception);
throw new InvocationException();
}
}
Aggregations