use of com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple in project narayana by jbosstm.
the class OTSImpleManager method init.
private static final synchronized void init() {
if (_current == null) {
if (OTSImpleManager._theFactory == null) {
/*
* Only check once, when the factory is first created.
*/
int resolver = Services.CONFIGURATION_FILE;
boolean requireTransactionManager = false;
if (jtsPropertyManager.getJTSEnvironmentBean().isTransactionManager()) {
requireTransactionManager = true;
String resolveMechanism = opPropertyManager.getOrbPortabilityEnvironmentBean().getResolveService();
if (resolveMechanism.compareTo("NAME_SERVICE") == 0)
resolver = Services.NAME_SERVICE;
else {
if (resolveMechanism.compareTo("BIND_CONNECT") == 0)
resolver = Services.BIND_CONNECT;
}
}
if (requireTransactionManager) {
try {
if (resolver != Services.BIND_CONNECT) {
String[] params = new String[1];
params[0] = Services.otsKind;
org.omg.CORBA.Object obj = ORBManager.getServices().getService(Services.transactionService, params, resolver);
params = null;
OTSImpleManager._theFactoryRef = org.omg.CosTransactions.TransactionFactoryHelper.narrow(obj);
} else {
}
if (OTSImpleManager._theFactoryRef == null)
throw new BAD_PARAM();
} catch (InvalidName e1) {
jtsLogger.i18NLogger.warn_otsserverfailed(e1);
throw new FatalError(e1.toString(), e1);
} catch (BAD_PARAM ex1) {
jtsLogger.i18NLogger.warn_otsserverfailed(ex1);
throw new FatalError(ex1.toString(), ex1);
} catch (IOException e2) {
jtsLogger.i18NLogger.warn_otsservererror(e2);
throw new FatalError(e2.toString(), e2);
} catch (SystemException e3) {
jtsLogger.i18NLogger.warn_otsservererror(e3);
throw new FatalError(e3.toString(), e3);
} catch (UserException e4) {
jtsLogger.i18NLogger.warn_otsservererror(e4);
throw new FatalError(e4.toString(), e4);
}
} else {
/* force to be local */
OTSImpleManager._theFactory = new TransactionFactoryImple();
}
}
if (OTSImpleManager._current == null) {
try {
OTSImpleManager._current = new CurrentImple();
OTSImpleManager._currentRef = OTSImpleManager._current;
} catch (Exception e) {
OTSImpleManager._current = null;
throw new com.arjuna.ats.arjuna.exceptions.FatalError("OTSImpleManager.current: " + e.toString(), e);
}
}
}
}
use of com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple in project narayana by jbosstm.
the class FactoryListUnitTest method test.
@SuppressWarnings("static-access")
@Test
public void test() throws Exception {
FactoryList factory = new FactoryList();
factory.removeDefault();
try {
assertNull(factory.recreate(null, FactoryList.DEFAULT_ID));
fail();
} catch (final INVALID_TRANSACTION ex) {
} catch (final Throwable ex) {
fail();
}
FactoryList.remove(Arjuna.restrictedXID());
TransactionFactoryImple imple = new TransactionFactoryImple("test");
ControlImple tx = imple.createLocal(1000);
PropagationContext ctx = tx.get_coordinator().get_txcontext();
Control cont = FactoryList.recreate(ctx, Arjuna.XID());
assertTrue(Utility.getUid(cont).equals(tx.get_uid()));
}
use of com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple in project narayana by jbosstm.
the class ServerControlWrapperUnitTest method testEquality.
@Test
public void testEquality() throws Exception {
TransactionFactoryImple imple = new TransactionFactoryImple("test");
ControlImple tx = imple.createLocal(1000);
ServerControlWrapper wrap1 = new ServerControlWrapper(tx);
ServerControlWrapper wrap2 = new ServerControlWrapper(tx.getControl());
assertTrue(wrap1.get_uid().equals(wrap2.get_uid()));
wrap1 = new ServerControlWrapper(tx.getControl(), tx);
wrap2 = new ServerControlWrapper(tx.getControl(), tx.get_uid());
assertTrue(wrap1.get_uid().equals(wrap2.get_uid()));
}
use of com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple in project narayana by jbosstm.
the class ServerFactoryUnitTest method test.
@Test
public void test() throws Exception {
TransactionFactoryImple factory = new TransactionFactoryImple("test");
ControlImple tx = factory.createLocal(1000);
Uid u = new Uid();
ServerControl server = ServerFactory.create_transaction(u, null, null, tx.get_coordinator(), tx.get_terminator(), 1000);
try {
ServerFactory.getCurrentStatus(new Uid("", false));
Assert.fail();
} catch (final Throwable ex) {
}
Assert.assertEquals(ServerFactory.getStatus(tx.get_uid()), org.omg.CosTransactions.Status.StatusActive);
}
use of com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple in project narayana by jbosstm.
the class FactoryContactItemUnitTest method test.
@Test
public void test() throws Exception {
TransactionFactoryImple factory = new TransactionFactoryImple("test");
assertTrue(FactoryContactItem.createAndSave(ArjunaFactoryHelper.narrow(factory.getReference())));
FactoryContactItem item = FactoryContactItem.recreate(com.arjuna.ats.arjuna.utils.Utility.getProcessUid());
assertTrue(item != null);
assertTrue(item.getFactory() != null);
item.markAsAlive();
assertTrue(item.getAliveTime() != null);
item.markAsDead();
assertTrue(item.getCreationTime() != null);
assertTrue(item.getUid() != Uid.nullUid());
}
Aggregations