use of com.arjuna.ats.internal.jts.orbspecific.ControlImple in project narayana by jbosstm.
the class JTSInterpositionSynchronizationTest method test.
@Test
public void test() throws Exception {
InterpositionCreator creator = new InterpositionCreator();
jtaPropertyManager.getJTAEnvironmentBean().setTransactionManagerClassName(com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple.class.getName());
jtaPropertyManager.getJTAEnvironmentBean().setUserTransactionClassName(com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple.class.getName());
jtsPropertyManager.getJTSEnvironmentBean().setSupportInterposedSynchronization(true);
javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
tm.setTransactionTimeout(1000000);
tm.begin();
TransactionImple transaction = (TransactionImple) tm.getTransaction();
transaction.enlistResource(new XAResource() {
@Override
public int prepare(Xid arg0) throws XAException {
prepareCalled = true;
beforeCompletionCalledFirst = beforeCompletionCalled;
return 0;
}
@Override
public void commit(Xid arg0, boolean arg1) throws XAException {
}
@Override
public void end(Xid arg0, int arg1) throws XAException {
}
@Override
public void forget(Xid arg0) throws XAException {
}
@Override
public int getTransactionTimeout() throws XAException {
return 0;
}
@Override
public boolean isSameRM(XAResource arg0) throws XAException {
return false;
}
@Override
public Xid[] recover(int arg0) throws XAException {
return null;
}
@Override
public void rollback(Xid arg0) throws XAException {
}
@Override
public boolean setTransactionTimeout(int arg0) throws XAException {
return false;
}
@Override
public void start(Xid arg0, int arg1) throws XAException {
}
});
ControlWrapper controlWrapper = transaction.getControlWrapper();
Uid get_uid = transaction.get_uid();
ControlImple cont = controlWrapper.getImple();
ArjunaTransactionImple tx = cont.getImplHandle();
CurrentImple current = OTSImpleManager.current();
Control get_control = current.get_control();
PropagationContext ctx = cont.get_coordinator().get_txcontext();
ControlImple recreateLocal = creator.recreateLocal(ctx);
assertTrue(recreateLocal != null);
Control recreate = creator.recreate(ctx);
assertTrue(recreate != null);
Object remove = ControlImple.allControls.remove(get_uid);
ServerControl sc = new ServerControl(get_uid, get_control, null, cont.get_coordinator(), cont.get_terminator());
ControlImple.allControls.put(get_uid, remove);
ServerTopLevelAction serverTopLevelAction = new ServerTopLevelAction(sc);
sc.getImplHandle().register_synchronization(new ManagedSynchronizationImple(new Synchronization() {
@Override
public void beforeCompletion() {
beforeCompletionCalled = true;
}
@Override
public void afterCompletion(int status) {
afterCompletionCalled = true;
}
}).getSynchronization());
transaction.commit();
assertTrue(prepareCalled == true);
assertTrue(beforeCompletionCalled);
assertTrue(afterCompletionCalled);
assertTrue(beforeCompletionCalledFirst == jtsPropertyManager.getJTSEnvironmentBean().isSupportInterposedSynchronization());
}
use of com.arjuna.ats.internal.jts.orbspecific.ControlImple in project narayana by jbosstm.
the class FactoryList method recreateLocal.
public static ControlImple recreateLocal(PropagationContext ctx, int formatID) throws SystemException {
ControlImple toReturn = null;
if (ctx == null)
throw new INVALID_TRANSACTION();
FactoryElement ptr = find(formatID);
if (ptr != null) {
toReturn = ptr.recreateLocal(ctx);
}
return toReturn;
}
use of com.arjuna.ats.internal.jts.orbspecific.ControlImple in project narayana by jbosstm.
the class ServerFactory method create_transaction.
public static ServerControl create_transaction(Uid u, Control parentControl, ArjunaTransactionImple parentImpl, Coordinator realCoord, Terminator realTerm, int time_out) {
ServerControl tranControl = new ServerControl(u, parentControl, parentImpl, realCoord, realTerm);
if ((time_out != 0) && (parentImpl == null)) {
TransactionReaper reaper = TransactionReaper.transactionReaper();
reaper.insert(new ServerControlWrapper((ControlImple) tranControl), time_out);
}
return tranControl;
}
use of com.arjuna.ats.internal.jts.orbspecific.ControlImple in project narayana by jbosstm.
the class Interposition method setupHierarchy.
/*
* Assume that all actions in the imported hierarchy are of the same
* type, i.e., all JBoss transactions.
*
* Because of the way garbage collection works in the ORB we have to
* run an explicit garbage collection phase for finished hierarchies.
*/
public synchronized ControlImple setupHierarchy(PropagationContext context) throws SystemException {
ControlImple controlPtr = null;
Uid theUid = null;
ServerTopLevelAction proxyAction = null;
if (context.parents.length == 0)
theUid = Utility.otidToUid(context.current.otid);
else
theUid = Utility.otidToUid(context.parents[context.parents.length - 1].otid);
proxyAction = present(theUid);
if (proxyAction == null) {
/*
* Create a new proxyAction element and return the
* "current" transaction.
*/
controlPtr = createHierarchy(context, theUid);
} else {
/*
* Check hierarchy of existing element.
*/
controlPtr = checkHierarchy(proxyAction, context);
proxyAction = null;
}
return controlPtr;
}
use of com.arjuna.ats.internal.jts.orbspecific.ControlImple 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