use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class ContextManager method current.
/**
* Get the current transaction associated with the invoking thread. Do
* not look in the PI thread data.
*
* Does not need to be synchronized since it is implicitly single-threaded.
*
* @return the context.
*/
public ControlWrapper current(String threadId) throws SystemException {
Object arg = otsCurrent.get(threadId);
ControlWrapper wrapper = null;
if (arg != null) {
try {
Stack hier = (Stack) arg;
return (ControlWrapper) hier.peek();
} catch (EmptyStackException e) {
}
}
return null;
}
use of com.arjuna.ats.internal.jts.ControlWrapper 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 com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class ContextManager method purgeActions.
public final void purgeActions(String threadId) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ContextManager::purgeActions ()");
}
/*
* Don't do anything with these actions, i.e., do
* not commit/abort them. Just because this thread is
* finished with them does not mean other threads
* are!
*/
ControlWrapper ptr = popAction(threadId);
while (ptr != null) {
ptr = null;
ptr = popAction(threadId);
}
while (ptr != null) ;
}
use of com.arjuna.ats.internal.jts.ControlWrapper 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 com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class PropagationContextManager method getTransactionPropagationContext.
/**
* Return a transaction propagation context for the transaction currently
* associated with the invoking thread, or <code>null</code> if the invoking
* thread is not associated with a transaction.
*/
public Object getTransactionPropagationContext() {
if (jbossatxLogger.logger.isTraceEnabled()) {
jbossatxLogger.logger.trace("PropagationContextManager.getTransactionPropagationContext - called");
}
final String threadId = ThreadUtil.getThreadId();
ControlWrapper theControl;
if (threadId != null) {
theControl = OTSImpleManager.current().contextManager().current(threadId);
} else {
theControl = OTSImpleManager.current().contextManager().current();
}
try {
final PropagationContext cxt = theControl.get_coordinator().get_txcontext();
PropagationContextWrapper pcw = new PropagationContextWrapper(cxt);
if (jbossatxLogger.logger.isTraceEnabled()) {
jbossatxLogger.logger.trace("PropagationContextManager.getTransactionPropagationContext() - returned tpc = " + pcw);
}
return pcw;
} catch (Exception e) {
}
return null;
}
Aggregations