use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class JtsTransactionImple method getTransactionIOR.
/**
* If the current transaction represents an OTS transaction then return it IOR
*
* @return the IOR or null if the current transaction is not an OTS transaction
* @throws NamingException
* @throws org.omg.CORBA.SystemException
* @throws SystemException
* @throws Unavailable
*/
public static String getTransactionIOR() throws org.omg.CORBA.SystemException, SystemException, Unavailable {
log.debug("getTransactionIOR");
TransactionImpl curr = TransactionImpl.current();
if (curr != null) {
log.debug("have JtsTransactionImple");
return curr.getControlIOR();
} else if (hasTransaction()) {
log.debug("have tx mgr");
Transaction tx = tm.getTransaction();
log.debug("have arjuna tx");
TransactionImple atx = (TransactionImple) tx;
ControlWrapper cw = atx.getControlWrapper();
log.debug("lookup control");
Control c = cw.get_control();
String ior = ORBManager.getORB().orb().object_to_string(c);
log.debug("getTransactionIOR: ior: " + ior);
return ior;
} else {
return null;
}
}
use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class ContextManager method popAction.
public final ControlWrapper popAction(String threadId) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ContextManager::popAction ()");
}
ControlWrapper action = null;
Object arg = threadId == null ? null : otsCurrent.get(threadId);
if (arg != null) {
Stack sl = (Stack) arg;
try {
/*
* When we pushed the action we did the check for whether
* it was local to save time now.
*/
action = (ControlWrapper) sl.pop();
} catch (EmptyStackException e) {
}
if (sl.size() == 0) {
sl = null;
otsCurrent.remove(threadId);
disassociateContext(OTSManager.getLocalSlotId());
}
}
if (action != null) {
if (action.isLocal()) {
try {
ThreadActionData.popAction(threadId);
} catch (EmptyStackException e) {
}
}
}
return action;
}
use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class ContextManager method addControlImpleHierarchy.
/*
* Given a ControlWrapper we can create the hierarchy quickly, since
* we have the implementation information to hand.
*/
public final boolean addControlImpleHierarchy(ControlImple which) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ContextManager::addControlImpleHierarchy ()");
}
boolean isError = false;
try {
ControlImple curr = which.getParentImple();
Stack hier = new Stack();
while (curr != null) {
hier.push(new ControlWrapper(curr));
curr = curr.getParentImple();
}
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.addActionControlImple", e);
isError = true;
}
return isError;
}
use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class ContextManager method currentPIContext.
public ControlWrapper currentPIContext() throws SystemException {
if (_piCurrent != null) {
try {
int slotId = OTSManager.getReceivedSlotId();
if (slotId == -1)
return null;
org.omg.CORBA.Any ctx = _piCurrent.get_slot(slotId);
if (ctx.type().kind().value() != TCKind._tk_null) {
ControlWrapper control = null;
if (ctx.type().kind().value() == TCKind._tk_string) {
control = createProxy(ctx);
} else {
control = createHierarchy(ctx);
}
org.omg.CORBA.Any threadData = ORBManager.getORB().orb().create_any();
threadData.insert_string(ThreadUtil.getThreadId());
_piCurrent.set_slot(slotId, threadData);
return control;
} else
return null;
} catch (NullPointerException e) {
return null;
} catch (InvalidSlot is) {
throw new org.omg.CORBA.INTERNAL();
}
} else
return null;
}
use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class ContextManager method current.
/**
* Get the transaction for the invoking thread. If there isn't one in
* the normal thread associated data then look in the PI implementation.
*
* @return the current transaction for the invoking thread.
*/
public ControlWrapper current() throws SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ContextManager::current ()");
}
Object arg = otsCurrent.get(ThreadUtil.getThreadId());
ControlWrapper wrapper = null;
if (arg != null) {
try {
Stack hier = (Stack) arg;
wrapper = (ControlWrapper) hier.peek();
} catch (EmptyStackException e) {
e.printStackTrace();
}
}
if (wrapper == null) {
wrapper = currentPIContext();
try {
if (wrapper != null) {
pushAction(wrapper);
}
} catch (Throwable ex) {
jtsLogger.i18NLogger.warn_context_genfail("ContextManager.current", ex);
throw new BAD_OPERATION();
}
}
return wrapper;
}
Aggregations