use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple 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.CurrentImple 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.CurrentImple in project narayana by jbosstm.
the class InterpositionThreadSetup method setup.
public void setup() {
/*
* Simply getting (or trying to get) the current tx control
* will ensure that this thread is initialised properly. We
* have to do this because in a POA implementation the receiving
* thread may not be the same one which does the work, so we
* cannot do thread association at the interceptor level. We must
* do it when the invoked method actually gets called.
*/
CurrentImple curr = OTSImpleManager.current();
/*
* Probably separate the underlying work out so that we can
* call that directly. No real harm at present since the hard
* work represents most of the overhead and has to be done
* anyway.
*/
curr.contextManager().associate();
}
use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class ContextThreadSetup method setup.
public void setup() {
/*
* Simply getting (or trying to get) the current tx control
* will ensure that this thread is initialised properly. We
* have to do this because in a POA implementation the receiving
* thread may not be the same one which does the work, so we
* cannot do thread association at the interceptor level. We must
* do it when the invoked method actually gets called.
*/
CurrentImple curr = OTSImpleManager.current();
/*
* Probably separate the underlying work out so that we can
* call that directly. No real harm at present since the hard
* work represents most of the overhead and has to be done
* anyway.
*/
curr.contextManager().associate();
}
use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class ContextThreadSetup method setup.
public void setup() {
/*
* Simply getting (or trying to get) the current tx control
* will ensure that this thread is initialised properly. We
* have to do this because in a POA implementation the receiving
* thread may not be the same one which does the work, so we
* cannot do thread association at the interceptor level. We must
* do it when the invoked method actually gets called.
*/
CurrentImple curr = OTSImpleManager.current();
/*
* Probably separate the underlying work out so that we can
* call that directly. No real harm at present since the hard
* work represents most of the overhead and has to be done
* anyway.
*/
curr.contextManager().associate();
}
Aggregations