use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class CounterImpl0001 method increase.
public void increase() throws InvocationException {
try {
AtomicTransaction atomicTransaction = new AtomicTransaction();
try {
atomicTransaction.begin();
if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED) {
_value++;
atomicTransaction.commit(true);
} else {
atomicTransaction.rollback();
throw new InvocationException();
}
} catch (InvocationException invocationException) {
throw invocationException;
} catch (Exception exception) {
System.err.println("CounterImpl0001.increase: " + exception);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
throw new InvocationException();
}
} catch (InvocationException invocationException) {
throw invocationException;
} catch (Exception exception) {
System.err.println("CounterImpl0001.increase: " + exception);
throw new InvocationException();
}
throw new InvocationException();
}
use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class CounterImpl0001 method set.
public void set(int value) throws InvocationException {
try {
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) {
throw invocationException;
} catch (Exception exception) {
System.err.println("CounterImpl0001.set: " + exception);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
throw new InvocationException();
}
} catch (InvocationException invocationException) {
throw invocationException;
} catch (Exception exception) {
System.err.println("CounterImpl0001.set: " + exception);
throw new InvocationException();
}
}
use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class AITExplicitObjectImpl01 method tran_commit_writelock.
public void tran_commit_writelock(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) {
atomicTransaction.commit(true);
} else {
atomicTransaction.rollback();
throw new InvocationException();
}
} catch (InvocationException invocationException) {
interposition.unregisterTransaction();
throw invocationException;
} catch (Exception exception) {
System.err.println("AITExplicitObjectImpl01.tran_commit_writelock: " + exception);
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
interposition.unregisterTransaction();
throw new InvocationException();
} catch (Error error) {
System.err.println("AITExplicitObjectImpl01.tran_commit_writelock: " + 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("AITExplicitObjectImpl01.tran_commit_writelock: " + exception);
throw new InvocationException();
}
}
use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class AtomicObject method incr.
public void incr(int value) throws TestException {
AtomicAction A = new AtomicAction();
A.begin();
if (setlock(new Lock(LockMode.WRITE), retry) == LockResult.GRANTED) {
state += value;
if (A.commit() != ActionStatus.COMMITTED)
throw new TestException("Action commit error.");
else
return;
} else {
if (printDebug)
System.out.println("Error - could not set write lock.");
}
A.abort();
throw new TestException("Write lock error.");
}
Aggregations