Search in sources :

Example 1 with UserTransactionRegistry

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);
}
Also used : ServerVMClientUserTransaction(org.jboss.tm.usertx.client.ServerVMClientUserTransaction) JTAEnvironmentBean(com.arjuna.ats.jta.common.JTAEnvironmentBean) UserTransactionRegistry(org.jboss.tm.usertx.UserTransactionRegistry) javax.transaction(javax.transaction)

Example 2 with UserTransactionRegistry

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();
                    }
                });
            }
        }
    });
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) UserTransactionRegistry(org.jboss.tm.usertx.UserTransactionRegistry) AssociationListener(org.wildfly.transaction.client.AssociationListener) AbstractTransaction(org.wildfly.transaction.client.AbstractTransaction)

Aggregations

UserTransactionRegistry (org.jboss.tm.usertx.UserTransactionRegistry)2 JTAEnvironmentBean (com.arjuna.ats.jta.common.JTAEnvironmentBean)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 javax.transaction (javax.transaction)1 ServerVMClientUserTransaction (org.jboss.tm.usertx.client.ServerVMClientUserTransaction)1 AbstractTransaction (org.wildfly.transaction.client.AbstractTransaction)1 AssociationListener (org.wildfly.transaction.client.AssociationListener)1