use of org.omg.CORBA.WrongTransaction in project narayana by jbosstm.
the class AtomicTransaction method commit.
/*
* Commit the transaction. If the current transaction associated with the
* thread is not this transaction, then this transaction is rolled back and
* leave current alone.
*
* @param report_heuristics indicates whether heuristic reporting is
* desired.
*
* @exception org.omg.CosTransactions.NoTransaction if the transaction has
* already been terminated.
*
* @exception org.omg.CORBA.TRANSACTION_ROLLEDBACK if the transaction rolls
* back.
*
* @exception org.omg.CosTransactions.HeuristicMixed if some of the
* transaction participants committed, while some rolled back.
*
* @exception org.omg.CosTransactions.HeuristicHazard if some of the
* transaction participants committed, some rolled back, and the outcome of
* others is indeterminate.
*
* @exception org.omg.CORBA.WRONG_TRANSACTION if the current transaction is
* not this transaction.
*/
public void commit(boolean report_heuristics) throws NoTransaction, HeuristicMixed, HeuristicHazard, WrongTransaction, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("AtomicTransaction::commit ( " + report_heuristics + " ) for " + _theAction);
}
synchronized (_theStatus) {
if (_theAction == null) {
throw new NoTransaction();
}
}
if (!validTransaction()) {
throw new WrongTransaction();
}
/*
* OK to use current since we have just guaranteed that the transaction
* is the same as current. Use current rather than saved control since
* it will do thread tracking for us.
*/
CurrentImple current = OTSImpleManager.current();
try {
current.commit(report_heuristics);
_theStatus = Status.StatusCommitted;
} catch (NoTransaction e) {
_theStatus = Status.StatusNoTransaction;
throw e;
} catch (HeuristicMixed e) {
_theStatus = getStatus();
throw e;
} catch (HeuristicHazard e) {
_theStatus = getStatus();
throw e;
} catch (TRANSACTION_ROLLEDBACK e) {
_theStatus = Status.StatusRolledBack;
throw e;
} catch (SystemException e) {
_theStatus = getStatus();
throw e;
}
}
use of org.omg.CORBA.WrongTransaction in project narayana by jbosstm.
the class AtomicTransaction method rollback.
/*
* Rollback the transaction. If the current transaction associated with the
* thread is not this transaction, then this transaction is rolled back and
* leave current alone.
*
* @exception org.omg.CosTransactions.NoTransaction if the transaction has
* already been terminated.
*
* @exception org.omg.CORBA.WRONG_TRANSACTION if the current transaction is
* not this transaction.
*/
public void rollback() throws NoTransaction, WrongTransaction, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("AtomicTransaction::rollback for " + _theAction);
}
synchronized (_theStatus) {
if (_theAction == null) {
throw new NoTransaction();
}
}
if (!validTransaction()) {
throw new WrongTransaction();
}
/*
* OK to use current since we have just guaranteed that the transaction
* is the same as current. Use current rather than saved control since
* it will do thread tracking for us.
*/
CurrentImple current = OTSImpleManager.current();
try {
current.rollback();
_theStatus = Status.StatusRolledBack;
} catch (NoTransaction e) {
_theStatus = Status.StatusNoTransaction;
throw e;
} catch (TRANSACTION_ROLLEDBACK e) {
_theStatus = Status.StatusRolledBack;
} catch (SystemException e) {
_theStatus = getStatus();
throw e;
}
}
use of org.omg.CORBA.WrongTransaction 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.CORBA.WrongTransaction in project narayana by jbosstm.
the class SubordinateTxUnitTest method testAtomicTransaction.
@Test
public void testAtomicTransaction() throws Exception {
XidImple xid = new XidImple(new Uid());
SubordinateAtomicTransaction saa1 = new SubordinateAtomicTransaction(new Uid());
SubordinateAtomicTransaction saa2 = new SubordinateAtomicTransaction(new Uid(), xid, 0);
assertEquals(saa2.getXid(), xid);
try {
saa2.end(true);
fail();
} catch (final WrongTransaction ex) {
}
try {
saa2.abort();
fail();
} catch (final WrongTransaction ex) {
}
DummySubordinateAtomicTransaction dsat = new DummySubordinateAtomicTransaction();
assertFalse(dsat.checkForCurrent());
}
Aggregations