use of com.arjuna.ats.internal.jts.PseudoControlWrapper in project narayana by jbosstm.
the class OTSManager method destroyControl.
/**
* Destroy the transaction control.
*/
public static void destroyControl(Control control) throws ActiveTransaction, ActiveThreads, BadControl, Destroyed, SystemException {
if (control == null)
throw new BadControl();
ControlImple lCont = Helper.localControl(control);
if (lCont != null) {
destroyControl(lCont);
} else {
/*
* Just in case control is a top-level transaction, and has
* been registered with the reaper, we need to get it removed.
*
*/
Coordinator coord = null;
try {
coord = control.get_coordinator();
} catch (Exception e) {
// nothing else we can do!
coord = null;
}
if (coord != null) {
try {
if (coord.is_top_level_transaction()) {
// wrap the control so it gets compared against reaper list entries using the correct test
PseudoControlWrapper wrapper = new PseudoControlWrapper(control);
TransactionReaper.transactionReaper().remove(wrapper);
}
} catch (Exception e) {
}
coord = null;
}
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("OTS::destroyControl - remote control.");
}
/*
* Remote transaction, so memory management is different!
*/
ActionControl action = null;
try {
action = com.arjuna.ArjunaOTS.ActionControlHelper.narrow(control);
if (action == null)
throw new BAD_PARAM();
} catch (Exception e) {
action = null;
}
if (action != null) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("OTS::destroyControl - Arjuna control.");
}
/*
* Is an Arjuna control, so we can call destroy on it?
*/
action.destroy();
action = null;
control = null;
} else {
/*
* Just call release on the control.
*
* We could throw a BadControl exception, but
* what would that do for the programmer?
*/
control = null;
}
}
}
use of com.arjuna.ats.internal.jts.PseudoControlWrapper in project narayana by jbosstm.
the class OTSManager method destroyControl.
/**
* Used to destroy a transaction control. Normally garbage collection
* will take care of this, but in certain circumstances (e.g., a context
* is propagated implicitly but we do not use interposition and we
* have to manufacture a local control object) it is not possible for the
* OTS to know when controls can be removed. This is a problem with the
* specification and CORBA in general.
*/
public static void destroyControl(ControlImple control) throws ActiveTransaction, ActiveThreads, BadControl, Destroyed, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("OTS::destroyControl ( " + control + " )");
}
if (control == null)
throw new BadControl();
/*
* Just in case control is a top-level transaction, and has
* been registered with the reaper, we need to get it removed.
*
*/
Coordinator coord = null;
try {
coord = control.get_coordinator();
} catch (Exception e) {
// nothing else we can do!
coord = null;
}
if (coord != null) {
try {
if (coord.is_top_level_transaction()) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("OTS::destroyControl - removing control from reaper.");
}
// wrap the control so it gets compared against reaper list entries using the correct test
PseudoControlWrapper wrapper = new PseudoControlWrapper(control);
TransactionReaper.transactionReaper().remove(wrapper);
}
} catch (Exception e) {
}
coord = null;
}
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("OTS::destroyControl - local transaction: " + control.get_uid());
}
control.destroy();
control = null;
}
Aggregations