use of org.omg.CosTransactions.NoTransaction in project narayana by jbosstm.
the class Test12 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
boolean correct = true;
Current current = OTS.get_current();
current.begin();
current.commit(false);
try {
current.rollback_only();
correct = false;
} catch (NoTransaction noTransaction) {
}
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Test12.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Test12.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CosTransactions.NoTransaction in project narayana by jbosstm.
the class TransactionImple method rollback.
public void rollback() throws java.lang.IllegalStateException, java.lang.SecurityException, javax.transaction.SystemException {
if (jtaxLogger.logger.isTraceEnabled()) {
jtaxLogger.logger.trace("TransactionImple.rollback");
}
boolean endSuspendedFailed = false;
if (_theTransaction != null) {
try {
if ((getStatus() != Status.STATUS_ACTIVE) && (getStatus() != Status.STATUS_MARKED_ROLLBACK))
throw new NoTransaction();
/*
* Call end on any suspended resources. If this fails, then there's
* not a lot else we can do because the transaction is about to roll
* back anyway!
*/
endSuspendedFailed = !endSuspendedRMs();
if (endSuspendedFailed) {
jtaxLogger.i18NLogger.warn_jtax_transaction_jts_endsuspendfailed1();
}
_theTransaction.abort();
} catch (WrongTransaction e1) {
InactiveTransactionException inactiveTransactionException = new InactiveTransactionException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_wrongstatetx());
inactiveTransactionException.initCause(e1);
throw inactiveTransactionException;
} catch (org.omg.CORBA.NO_PERMISSION e2) {
throw new SecurityException(e2);
} catch (INVALID_TRANSACTION e3) {
InactiveTransactionException inactiveTransactionException = new InactiveTransactionException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_invalidtx2());
inactiveTransactionException.initCause(e3);
throw inactiveTransactionException;
} catch (NoTransaction e4) {
throw new IllegalStateException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_notx(), e4);
} catch (org.omg.CORBA.SystemException e5) {
javax.transaction.SystemException systemException = new javax.transaction.SystemException(e5.toString());
systemException.initCause(e5);
throw systemException;
} finally {
TransactionImple.removeTransaction(this);
}
if (endSuspendedFailed)
throw new InvalidTerminationStateException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_endsuspendfailed2());
} else
throw new IllegalStateException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_inactivetx());
}
use of org.omg.CosTransactions.NoTransaction in project narayana by jbosstm.
the class CurrentImple method commit.
/**
* It's not possible to commit/abort out of order using the current
* interface.
*
* Do we delete the control if the transaction gives an heuristic result?
* CurrentImplely we do.
*
* If another thread has already terminated the transaction then: (i) if it
* committed, we do nothing - could throw TransactionRequired of
* INVALID_TRANSACTION, or NoTransaction. Probably not NoTransaction, since
* it would be better to distinguish between the situation where the
* transaction has already been terminated and there really is no
* transaction for this thread. (ii) if it rolledback, we throw
* TRANSACTION_ROLLEDBACK.
*/
public void commit(boolean report_heuristics) throws NoTransaction, HeuristicMixed, HeuristicHazard, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("CurrentImple::commit ( " + report_heuristics + " )");
}
ControlWrapper currentAction = _theManager.current();
if (currentAction != null) {
try {
ThreadAssociationControl.updateAssociation(currentAction, TX_COMMITTED);
} catch (Exception e) {
/*
* An error happened, so mark the transaction as rollback only
* (in case it hasn't already been so marked.)
*/
rollback_only();
}
try {
currentAction.commit(report_heuristics);
_theManager.popAction();
} catch (TRANSACTION_ROLLEDBACK e1) {
/*
* Is ok to destroy transaction. Different for heuristics.
*/
_theManager.popAction();
throw e1;
} catch (HeuristicMixed e2) {
_theManager.popAction();
if (report_heuristics)
throw e2;
} catch (HeuristicHazard e3) {
_theManager.popAction();
if (report_heuristics)
throw e3;
} catch (SystemException e4) {
_theManager.popAction();
throw e4;
} catch (Unavailable e5) {
/*
* If terminated by some other thread then the reference we have
* will no longer be valid.
*/
_theManager.popAction();
throw new INVALID_TRANSACTION();
}
} else
throw new NoTransaction();
}
use of org.omg.CosTransactions.NoTransaction in project narayana by jbosstm.
the class TransactionFactoryImple method unresolvedTransactions.
private final org.omg.CosTransactions.otid_t[] unresolvedTransactions() throws Inactive, NoTransaction, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("TransactionFactoryImple::terminatedTransactions ()");
}
InputObjectState uids = new InputObjectState();
if (!TxStoreLog.getTransactions(uids, StateStatus.OS_COMMITTED_HIDDEN)) {
throw new NoTransaction();
} else {
Uid theUid = null;
int count = 0;
boolean finished = false;
while (!finished) {
try {
theUid = UidHelper.unpackFrom(uids);
if (theUid.equals(Uid.nullUid()))
finished = true;
else
count++;
} catch (Exception e) {
finished = true;
}
}
org.omg.CosTransactions.otid_t[] ids = new org.omg.CosTransactions.otid_t[count];
uids.reread();
for (int i = 0; i < count; i++) {
try {
theUid = UidHelper.unpackFrom(uids);
ids[i] = Utility.uidToOtid(theUid.stringForm());
} catch (Exception e) {
}
}
return ids;
}
}
use of org.omg.CosTransactions.NoTransaction in project narayana by jbosstm.
the class CurrentImple method rollback.
/**
* If another thread has already terminated the transaction then: (i) if it
* rolled back, we do nothing - could throw TransactionRequired of
* INVALID_TRANSACTION, or NoTransaction. Probably not NoTransaction, since
* it would be better to distinguish between the situation where the
* transaction has already been terminated and there really is no
* transaction for this thread. (ii) if it committed, we throw
* INVALID_TRANSACTION.
*/
public void rollback() throws NoTransaction, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("CurrentImple::rollback ()");
}
ControlWrapper currentAction = _theManager.current();
if (currentAction != null) {
ThreadAssociationControl.updateAssociation(currentAction, TX_ABORTED);
try {
currentAction.rollback();
_theManager.popAction();
} catch (INVALID_TRANSACTION e1) {
/*
* If transaction has already terminated, then throw
* INVALID_TRANSACTION. Differentiates between this stat and not
* actually having a transaction associated with the thread.
*/
_theManager.popAction();
throw e1;
} catch (SystemException e2) {
_theManager.popAction();
throw e2;
} catch (Unavailable e) {
/*
* If no terminator then not allowed!
*/
_theManager.popAction();
throw new INVALID_TRANSACTION();
}
} else
throw new NoTransaction();
}
Aggregations