use of com.arjuna.ArjunaOTS.UidCoordinator in project narayana by jbosstm.
the class ArjunaTransactionImple method is_same_transaction.
public boolean is_same_transaction(Coordinator tc) throws SystemException {
if (tc == null)
return false;
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::is_same_transaction comparing hash codes: < " + tc.hash_transaction() + ", " + hash_transaction() + " >");
}
if (tc.hash_transaction() != hash_transaction())
return false;
boolean result = false;
try {
UidCoordinator ptr = com.arjuna.ArjunaOTS.UidCoordinatorHelper.narrow(tc);
if (ptr != null) {
/*
* Must be an Arjuna coordinator.
*/
String myUid = uid();
String compareUid = ptr.uid();
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::is_same_transaction comparing uids < " + compareUid + ", " + myUid + " >");
}
if (myUid.compareTo(compareUid) == 0)
result = true;
myUid = null;
compareUid = null;
ptr = null;
} else
throw new BAD_PARAM();
} catch (SystemException e) {
/*
* Narrow failed, so can't be an Arjuna Uid. Therefore, the answer
* must be false.
*/
}
return result;
}
use of com.arjuna.ArjunaOTS.UidCoordinator in project narayana by jbosstm.
the class TransactionFactoryImple method createProxy.
public static Control createProxy(Coordinator coordinator, Terminator terminator, Control parentControl) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("TransactionFactoryImple::createProxy ( " + coordinator + ", " + terminator + ", " + parentControl + " )");
}
/*
* Different from the C++ version in that we can cache proxy
* implementations and reuse them, since we rely upon the Java garbage
* collection facility to remove them when all outstanding references
* have gone.
*/
/*
* If not an Arjuna UidCoordinator then we may have a memory leak since
* there is no way to remove this control.
*/
UidCoordinator uidCoord = Helper.getUidCoordinator(coordinator);
Uid theUid = null;
if (uidCoord != null) {
try {
theUid = Helper.getUid(uidCoord);
if (ServerControl.allServerControls != null) {
synchronized (ServerControl.allServerControls) {
ControlImple c = (ControlImple) ServerControl.allServerControls.get(theUid);
if (c != null)
return c.getControl();
}
}
} catch (Exception e) {
/*
* Not a JBoss transaction, so allocate any Uid.
*/
theUid = new Uid();
}
uidCoord = null;
} else
theUid = new Uid();
ControlImple proxy = new ControlImple(coordinator, terminator, parentControl, theUid);
return proxy.getControl();
}
use of com.arjuna.ArjunaOTS.UidCoordinator in project narayana by jbosstm.
the class Helper method localAction.
/**
* Given a Control_ptr determine if this is a reference to a local
* action, and if so return the raw BasicAction pointer.
*/
public static final BasicAction localAction(org.omg.CosTransactions.Control control) {
if (control == null)
return null;
if (control instanceof ControlImple) {
try {
ControlImple c = (ControlImple) control;
return (BasicAction) c.getImplHandle();
} catch (Exception e) {
}
}
try {
UidCoordinator coord = Helper.getUidCoordinator(control);
if (coord != null) {
Uid u = Helper.getUid(coord);
coord = null;
return ActionManager.manager().get(u);
} else
throw new BAD_PARAM();
} catch (Exception e) {
/*
* Can't be an Arjuna action, so ignore.
*/
}
return null;
}
Aggregations