use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class ContextManager method addRemoteHierarchy.
/**
* We could maintain a list of suspended action hierarchies and resume
* the right one (and the right place!) given the control. However, this
* can lead to memory leaks, since we never know when to remove this
* hierarchy information. So, for now we simply rely on the propagation
* context.
*/
public final boolean addRemoteHierarchy(Control cont) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ContextManager::addRemoteHierarchy ()");
}
if (false) {
pushAction(new ControlWrapper(cont));
return true;
} else {
boolean isError = false;
try {
Coordinator coord = cont.get_coordinator();
PropagationContext ctx = coord.get_txcontext();
if (ctx != null) {
/*
* Depth must be non-zero or we wouldn't be here!
*/
int depth = ctx.parents.length;
for (int i = depth - 1; i >= 0; i--) {
/*
* No memory leak as we delete either when suspend
* is called, or the transaction is terminated.
*/
Coordinator tmpCoord = ctx.parents[i].coord;
Terminator tmpTerm = ctx.parents[i].term;
Control theControl = TransactionFactoryImple.createProxy(tmpCoord, tmpTerm);
// takes care of thread/BasicAction for us.
pushAction(new ControlWrapper(theControl));
}
ctx = null;
} else {
/*
* If we can't get a propagation context then we cannot
* create the hierarchy!
*/
isError = true;
}
coord = null;
} catch (Exception e) {
isError = true;
}
return isError;
}
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class ContextManager method addActionControlHierarchy.
/*
* All OTSArjuna controls have a method for getting their parent.
*/
public final boolean addActionControlHierarchy(ActionControl cont) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ContextManager::addActionControlHierarchy ()");
}
boolean isError = false;
try {
ActionControl actControl = cont;
Control parentControl = actControl.getParentControl();
Stack hier = new Stack();
while (parentControl != null) {
hier.push(new ControlWrapper(parentControl));
actControl = com.arjuna.ArjunaOTS.ActionControlHelper.narrow(parentControl);
if (actControl != null)
parentControl = actControl.getParentControl();
else
parentControl = null;
}
actControl = null;
try {
ControlWrapper wrapper = (ControlWrapper) hier.pop();
while (wrapper != null) {
pushAction(wrapper);
wrapper = null;
wrapper = (ControlWrapper) hier.pop();
}
} catch (EmptyStackException e) {
}
} catch (Exception e) {
jtsLogger.i18NLogger.warn_context_genfail("ContextManager.addActionControlHierarchy", e);
isError = true;
}
return isError;
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class FactoryList method recreate.
public static Control recreate(PropagationContext ctx, int formatID) throws SystemException {
Control toReturn = null;
if (ctx == null)
throw new INVALID_TRANSACTION();
FactoryElement ptr = find(formatID);
if (ptr != null) {
toReturn = ptr.recreate(ctx);
}
return toReturn;
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class ServerFactory method create_subtransaction.
public static ServerControl create_subtransaction(Uid actUid, Coordinator realCoord, Terminator realTerm, ServerControl parent) {
if (parent == null) {
jtsLogger.i18NLogger.warn_interposition_sfnoparent("ServerFactory.create_subtransaction");
return null;
}
ServerControl toReturn = null;
try {
Control handle = parent.getControl();
ArjunaTransactionImple tranHandle = parent.getImplHandle();
toReturn = new ServerControl(actUid, handle, tranHandle, realCoord, realTerm);
handle = null;
tranHandle = null;
} catch (Exception e) {
if (toReturn != null) {
try {
// will delete itself
toReturn.destroy();
} catch (Exception ex) {
}
}
}
return toReturn;
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class TransactionImpleUnitTest method testEnlist.
@Test
public void testEnlist() throws Exception {
ThreadActionData.purgeActions();
OTSImpleManager.current().contextManager().purgeActions();
TransactionImple tx = new TransactionImple();
tx.setRollbackOnly();
try {
tx.enlistResource(null);
fail();
} catch (final SystemException ex) {
}
try {
tx.enlistResource(new DummyXA(false));
fail();
} catch (final RollbackException ex) {
}
try {
tx.commit();
fail();
} catch (final RollbackException ex) {
}
try {
tx.enlistResource(new DummyXA(false));
fail();
} catch (final IllegalStateException ex) {
}
Control suspend = OTSImpleManager.current().suspend();
tx = new TransactionImple();
DummyXA res = new DummyXA(false);
tx.enlistResource(res);
tx.delistResource(res, XAResource.TMSUSPEND);
tx.enlistResource(res);
tx.commit();
}
Aggregations