use of org.jboss.tm.usertx.UserTransactionRegistry in project narayana by jbosstm.
the class SPIUnitTest method initJTS.
public static void initJTS() throws Exception {
initORB();
JTAEnvironmentBean jtaEnvironmentBean = jtaPropertyManager.getJTAEnvironmentBean();
jtaEnvironmentBean.setTransactionManagerClassName(com.arjuna.ats.jbossatx.jts.TransactionManagerDelegate.class.getName());
JNDIManager.bindJTATransactionManagerImplementation(initialContext);
jtaEnvironmentBean.setTransactionSynchronizationRegistryClassName(com.arjuna.ats.internal.jta.transaction.jts.TransactionSynchronizationRegistryImple.class.getName());
JNDIManager.bindJTATransactionSynchronizationRegistryImplementation(initialContext);
final com.arjuna.ats.jbossatx.jts.TransactionManagerService service = new com.arjuna.ats.jbossatx.jts.TransactionManagerService();
final ServerVMClientUserTransaction userTransaction = new ServerVMClientUserTransaction(service.getTransactionManager());
jtaEnvironmentBean.setUserTransaction(userTransaction);
JNDIManager.bindJTAUserTransactionImplementation(initialContext);
UserTransactionRegistry userTransactionRegistry = new UserTransactionRegistry();
userTransactionRegistry.addProvider(userTransaction);
}
use of org.jboss.tm.usertx.UserTransactionRegistry in project wildfly by wildfly.
the class TransactionManagerService method start.
public void start(final StartContext context) throws StartException {
final UserTransactionRegistry registry = registryInjector.getValue();
LocalTransactionContext.getCurrent().registerCreationListener((txn, createdBy) -> {
if (createdBy == CreationListener.CreatedBy.USER_TRANSACTION) {
if (WildFlySecurityManager.isChecking()) {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
txn.registerAssociationListener(new AssociationListener() {
private final AtomicBoolean first = new AtomicBoolean();
public void associationChanged(final AbstractTransaction t, final boolean a) {
if (a && first.compareAndSet(false, true))
registry.userTransactionStarted();
}
});
return null;
});
} else {
txn.registerAssociationListener(new AssociationListener() {
private final AtomicBoolean first = new AtomicBoolean();
public void associationChanged(final AbstractTransaction t, final boolean a) {
if (a && first.compareAndSet(false, true))
registry.userTransactionStarted();
}
});
}
}
});
}
Aggregations