use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple 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 com.arjuna.ats.internal.jts.orbspecific.CurrentImple 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 com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class AtomicTransaction method begin.
/**
* Start the transaction.
*
* @exception org.omg.CosTransactions.SubtransactionsUnavailable
* if subtransactions have been disabled, and the invoking
* thread already has a transaction associated with it.
*
* @exception org.omg.CORBA.INVALID_TRANSACTION
* if the transaction has already begun or has completed.
*/
public void begin() throws SubtransactionsUnavailable, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("AtomicTransaction::begin ()");
}
// already begun?
CurrentImple current = OTSImpleManager.current();
synchronized (_theStatus) {
if (_theAction != null) {
throw new INVALID_TRANSACTION(ExceptionCodes.ALREADY_BEGUN, CompletionStatus.COMPLETED_NO);
}
current.begin();
_theAction = current.getControlWrapper();
}
_theStatus = current.get_status();
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("AtomicTransaction::begin create " + _theAction);
}
}
use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class OTSThread method terminate.
/*
* Can't use finalize since it may be called by
* some other thread than this one.
*/
public void terminate() {
try {
CurrentImple current = OTSImpleManager.current();
if (current != null) {
Control c = current.suspend();
c = null;
}
} catch (Exception e) {
}
}
use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class tx method tx_commit.
public static final synchronized int tx_commit() {
int toReturn = tx.TX_OK;
CurrentImple current = OTSImpleManager.current();
Boolean report_heuristics = (Boolean) __tx_report_heuristics.get(Thread.currentThread());
if (report_heuristics == null)
// default TRUE
report_heuristics = new Boolean(true);
try {
boolean when_return = report_heuristics.booleanValue();
current.commit(when_return);
} catch (NoTransaction e1) {
toReturn = tx.TX_NO_BEGIN;
} catch (HeuristicMixed e2) {
toReturn = tx.TX_HAZARD;
} catch (HeuristicHazard e3) {
toReturn = tx.TX_HAZARD;
} catch (TRANSACTION_ROLLEDBACK e4) {
toReturn = tx.TX_ROLLBACK;
} catch (Exception e5) {
toReturn = tx.TX_FAIL;
}
return toReturn;
}
Aggregations