use of com.arjuna.ats.internal.jts.orbspecific.ControlImple in project narayana by jbosstm.
the class ExtendedResourceRecord method nestedCommit.
public int nestedCommit() {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ExtendedResourceRecord::nestedCommit() for " + order());
}
int o = TwoPhaseOutcome.FINISH_ERROR;
try {
resourceHandle().commit_subtransaction(_parentCoordHandle);
/*
* Now release the parent as it is about to be destroyed anyway.
*/
_parentCoordHandle = null;
if (_currentTransaction != null) {
/*
* Now change our notion of our parent for subsequent nested
* transaction commits. We were passed a reference to the
* current transaction, so we can just ask it for it's parent.
* If it doesn't have one, then generate an error.
*/
_currentTransaction = (ArjunaTransactionImple) _currentTransaction.parent();
ControlImple control = ((_currentTransaction == null) ? null : _currentTransaction.getControlHandle());
if (control != null) {
_parentCoordHandle = control.get_coordinator();
control = null;
o = TwoPhaseOutcome.FINISH_OK;
} else {
jtsLogger.i18NLogger.warn_resources_errnoparent("ExtendedResourceRecord.nestedCommit");
o = TwoPhaseOutcome.FINISH_ERROR;
}
} else {
jtsLogger.i18NLogger.warn_resources_noparent(get_uid());
o = TwoPhaseOutcome.FINISH_ERROR;
}
} catch (Exception e) {
jtsLogger.i18NLogger.warn_resources_errgenerr("ExtendedResourceRecord.nestedCommit", e);
o = TwoPhaseOutcome.FINISH_ERROR;
}
return o;
}
use of com.arjuna.ats.internal.jts.orbspecific.ControlImple 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.orbspecific.ControlImple in project narayana by jbosstm.
the class Helper method localControl.
public static final ControlImple localControl(org.omg.CosTransactions.Control control) {
if (control == null)
return null;
if (control instanceof ControlImple)
return (ControlImple) control;
try {
UidCoordinator uidCoord = Helper.getUidCoordinator(control);
if (uidCoord != null) {
Uid u = Helper.getUid(uidCoord);
ControlImple toReturn = null;
uidCoord = null;
if (ControlImple.allControls != null) {
synchronized (ControlImple.allControls) {
toReturn = (ControlImple) ControlImple.allControls.get(u);
}
}
if (toReturn == null) {
if (ServerControl.allServerControls != null) {
synchronized (ServerControl.allServerControls) {
toReturn = (ControlImple) ServerControl.allServerControls.get(u);
}
}
}
u = null;
return toReturn;
} else
throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
} catch (Exception e) {
/*
* Can't be an Arjuna action, so ignore.
*/
}
return null;
}
use of com.arjuna.ats.internal.jts.orbspecific.ControlImple in project narayana by jbosstm.
the class TransactionFactoryUnitTest method testContext.
@Test
public void testContext() throws Exception {
TransactionFactoryImple factory = new TransactionFactoryImple("test");
ControlImple tx = factory.createLocal(1000);
org.omg.CosTransactions.otid_t txId = Utility.uidToOtid(tx.get_uid());
Uid theUid = Utility.otidToUid(txId);
assertEquals(theUid, tx.get_uid());
// no state in OS yet!
assertEquals(factory.getOSStatus(tx.get_uid()), org.omg.CosTransactions.Status.StatusNoTransaction);
PropagationContext ctx = tx.get_coordinator().get_txcontext();
Control cont = factory.recreate(ctx);
String toString = Utility.getHierarchy(ctx);
System.out.println(toString);
assertTrue(toString != null);
assertTrue(toString.length() > 1);
assertTrue(Utility.getUid(cont).equals(tx.get_uid()));
try {
tx.getImplHandle().rollback();
} catch (final Throwable ex) {
}
}
use of com.arjuna.ats.internal.jts.orbspecific.ControlImple in project narayana by jbosstm.
the class OSIInterpositionUnitTest method test.
@Test
public void test() throws Exception {
OTSImpleManager.current().begin();
PropagationContext ctx = OTSImpleManager.current().get_control().get_coordinator().get_txcontext();
OSIInterpositionCreator creator = new OSIInterpositionCreator();
Control cnt = creator.recreate(ctx);
ControlImple impl = creator.recreateLocal(ctx);
assertTrue(cnt != null);
assertTrue(impl != null);
OTSImpleManager.current().rollback();
}
Aggregations