use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple 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.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class ObjStoreBrowserTest method testMBeanHeuristic.
/**
* Test that resources that generate heuristics are instrumented correctly
* @throws Exception
*/
@Test
public void testMBeanHeuristic() throws Exception {
// generates a heuristic on commit
FailureXAResource failureXAResource = new FailureXAResource(FailureXAResource.FailLocation.commit);
getHeuristicMBean(osb, new TransactionImple(), failureXAResource);
}
use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class ObjStoreBrowserTest method getHeuristic.
private HeuristicTestData getHeuristic() throws Exception {
// generates a heuristic on commit
FailureXAResource failureXAResource = new FailureXAResource(FailureXAResource.FailLocation.commit);
TransactionImple tx = new TransactionImple();
XAResourceRecordBeanMBean resourceBean = getHeuristicMBean(osb, tx, failureXAResource);
JTAActionBean txnMBean = getTransactionBean(osb, tx, true);
Set<ObjectName> participants;
String resourceBeanName;
String txnBeanName;
assertNotNull(txnMBean);
assertNotNull(resourceBean);
txnBeanName = String.format("jboss.jta:type=ObjectStore,itype=%s,uid=%s", txnMBean.type(), txnMBean.getId().replace(':', '_'));
resourceBeanName = String.format("%s,puid=%s", txnBeanName, resourceBean.getId().replace(':', '_'));
participants = JMXServer.getAgent().queryNames(resourceBeanName, null);
assertEquals(1, participants.size());
return new HeuristicTestData(tx, failureXAResource, txnMBean, resourceBean, participants.iterator().next(), txnBeanName, resourceBeanName);
}
use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class TransactionImpleUnitTest method testEnlist.
@Test
public void testEnlist() throws Exception {
ThreadActionData.purgeActions();
OTSImpleManager.current().contextManager().purgeActions();
TransactionImple tx = new TransactionImple();
tx.setRollbackOnly();
try {
tx.enlistResource(null);
fail();
} catch (final SystemException ex) {
}
try {
tx.enlistResource(new DummyXA(false));
fail();
} catch (final RollbackException ex) {
}
try {
tx.commit();
fail();
} catch (final RollbackException ex) {
}
try {
tx.enlistResource(new DummyXA(false));
fail();
} catch (final IllegalStateException ex) {
}
Control suspend = OTSImpleManager.current().suspend();
tx = new TransactionImple();
DummyXA res = new DummyXA(false);
tx.enlistResource(res);
tx.delistResource(res, XAResource.TMSUSPEND);
tx.enlistResource(res);
tx.commit();
}
use of com.arjuna.ats.internal.jta.transaction.jts.TransactionImple in project narayana by jbosstm.
the class TransactionImpleUnitTest method testDelist.
@Test
public void testDelist() throws Exception {
ThreadActionData.purgeActions();
OTSImpleManager.current().contextManager().purgeActions();
TransactionImple tx = new TransactionImple();
try {
tx.delistResource(null, XAResource.TMSUCCESS);
fail();
} catch (final SystemException ex) {
}
DummyXA xares = new DummyXA(false);
try {
assertFalse(tx.delistResource(xares, XAResource.TMSUCCESS));
} catch (final Throwable ex) {
fail();
}
tx.enlistResource(xares);
assertTrue(tx.delistResource(xares, XAResource.TMSUCCESS));
tx.commit();
try {
tx.delistResource(xares, XAResource.TMSUCCESS);
fail();
} catch (final IllegalStateException ex) {
}
}
Aggregations