use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class CurrentImple method get_transaction_name.
public String get_transaction_name() throws SystemException {
ControlWrapper currentAction = _theManager.current();
String ch = ((currentAction == null) ? "null" : currentAction.get_transaction_name());
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("CurrentImple::get_transaction_name - returning " + ch);
}
return ch;
}
use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class CurrentImple method suspend.
/*
* Problem: there is a general problem with the Orb and memory management.
* If this method, say, is invoked remotely then we must duplicate the
* reference before returning it since the Orb will call release on the
* return value once it has been sent to the caller. However, in the local
* case, if we call duplicate then there is nothing to call release and we
* get memory leaks!
*
* Also assume that BasicAction's notion of current is the same as
* CurrentImple's, if the action is local.
*
*/
/**
* The spec. states that after suspend we should have a null transaction
* context, but is hazy as to what to do if we are nested. We shall assume
* that the control returned is for the current transaction and that we
* suspend the entire transaction hierarchy. Given the returned control, we
* can always regenerate the hierarchy later if required by resume.
*/
public org.omg.CosTransactions.Control suspend() throws SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("CurrentImple::suspend ()");
}
ControlWrapper actPtr = _theManager.popAction();
if (actPtr == null) {
ThreadAssociationControl.updateAssociation(null, TX_SUSPENDED);
return null;
} else {
ThreadAssociationControl.updateAssociation(actPtr, TX_SUSPENDED);
/*
* Purge the remaining controls from the thread context. If the
* controls are remote and proxies then we delete them here, since
* we must recreate them next time we want to use them anyway.
*/
_theManager.purgeActions();
if (actPtr.isLocal())
return actPtr.getImple().getControl();
else
return actPtr.getControl();
}
}
use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class CurrentImple method get_control.
public org.omg.CosTransactions.Control get_control() throws SystemException {
ControlWrapper theControl = _theManager.current();
if (theControl == null)
return null;
if (true) {
try {
return theControl.get_control();
} catch (Unavailable e) {
return null;
}
} else {
Coordinator coord = null;
try {
coord = theControl.get_coordinator();
} catch (Unavailable e) {
coord = null;
throw new UNKNOWN(ExceptionCodes.UNAVAILABLE_COORDINATOR, CompletionStatus.COMPLETED_NO);
} catch (SystemException sysEx) {
coord = null;
throw sysEx;
}
org.omg.CosTransactions.Control proxyControl = TransactionFactoryImple.createPropagatedControl(coord);
coord = null;
theControl = null;
return proxyControl;
}
}
use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class CurrentImple method suspendWrapper.
public ControlWrapper suspendWrapper() throws SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("CurrentImple::suspendWrapper ()");
}
ControlWrapper actPtr = _theManager.popAction();
if (actPtr == null) {
ThreadAssociationControl.updateAssociation(null, TX_SUSPENDED);
return null;
} else {
ThreadAssociationControl.updateAssociation(actPtr, TX_SUSPENDED);
/*
* Purge the remaining controls from the thread context. If the
* controls are remote and proxies then we delete them here, since
* we must recreate them next time we want to use them anyway.
*/
_theManager.purgeActions();
return actPtr;
}
}
use of com.arjuna.ats.internal.jts.ControlWrapper in project narayana by jbosstm.
the class ArjunaTransactionImple method doAfterCompletion.
protected void doAfterCompletion(org.omg.CosTransactions.Status myStatus) throws SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::doAfterCompletion for " + get_uid());
}
if (myStatus == Status.StatusActive) {
jtsLogger.i18NLogger.warn_orbspecific_coordinator_txrun("ArjunaTransactionImple.doAfterCompletion");
return;
}
boolean problem = false;
SystemException exp = null;
if (_synchs != null) {
ControlWrapper cw = null;
boolean doSuspend = false;
try {
// cw = OTSImpleManager.systemCurrent().getControlWrapper();
cw = OTSImpleManager.current().getControlWrapper();
if ((cw == null) || (!controlHandle.equals(cw.getImple()))) {
// OTSImpleManager.systemCurrent().resumeImple(controlHandle);
OTSImpleManager.current().resumeImple(controlHandle);
doSuspend = true;
}
} catch (Exception ex) {
/*
* It should still be OK to make the call without a context
* because a Synchronization can only be associated with a
* single transaction.
*/
problem = true;
}
/*
* Regardless of failures, we must tell all synchronizations what
* happened.
*/
// afterCompletions should run in reverse order compared to beforeCompletions
Stack stack = new Stack();
Iterator iterator = _synchs.iterator();
while (iterator.hasNext()) {
stack.push(iterator.next());
}
iterator = stack.iterator();
/*
* Regardless of failures, we must tell all synchronizations what
* happened.
*/
while (!stack.isEmpty()) {
SynchronizationRecord value = (SynchronizationRecord) stack.pop();
Synchronization c = value.contents();
try {
c.after_completion(myStatus);
} catch (SystemException e) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple.doAfterCompletion - caught exception " + e);
}
problem = true;
if (exp == null)
exp = e;
}
}
if (doSuspend) {
try {
if (cw != null)
OTSImpleManager.current().resumeWrapper(cw);
else
OTSImpleManager.current().suspend();
} catch (Exception ex) {
}
}
_synchs = null;
}
boolean superProblem = !super.afterCompletion(myStatus == Status.StatusCommitted ? ActionStatus.COMMITTED : ActionStatus.ABORTED);
if (problem || superProblem) {
if (exp != null)
throw exp;
else
throw new UNKNOWN(ExceptionCodes.SYNCHRONIZATION_EXCEPTION, CompletionStatus.COMPLETED_NO);
}
}
Aggregations