Search in sources :

Example 1 with XAResourceRecoveryRegistry

use of org.jboss.tm.XAResourceRecoveryRegistry in project wildfly by wildfly.

the class EJBClientXidTransactionTestCase method beforeTestClass.

/**
 * Create and setup the remoting connection
 *
 * @throws Exception
 */
@BeforeClass
public static void beforeTestClass() throws Exception {
    // These system properties are required or else we end up picking up JTS transaction manager,
    // which is not what we want
    final JTAEnvironmentBean jtaEnvironmentBean = jtaPropertyManager.getJTAEnvironmentBean();
    jtaEnvironmentBean.setTransactionManagerClassName(TransactionManagerImple.class.getName());
    jtaEnvironmentBean.setTransactionSynchronizationRegistryClassName(TransactionSynchronizationRegistryImple.class.getName());
    final TransactionManager narayanaTm = jtaEnvironmentBean.getTransactionManager();
    final TransactionSynchronizationRegistry narayanaTsr = jtaEnvironmentBean.getTransactionSynchronizationRegistry();
    final XATerminator xat = new XATerminator();
    final JBossLocalTransactionProvider.Builder builder = JBossLocalTransactionProvider.builder();
    builder.setXATerminator(xat).setExtendedJBossXATerminator(xat);
    builder.setTransactionManager(narayanaTm);
    builder.setTransactionSynchronizationRegistry(narayanaTsr);
    builder.setXAResourceRecoveryRegistry(new XAResourceRecoveryRegistry() {

        @Override
        public void addXAResourceRecovery(XAResourceRecovery xaResourceRecovery) {
        }

        @Override
        public void removeXAResourceRecovery(XAResourceRecovery xaResourceRecovery) {
        }
    });
    builder.setXARecoveryLogDirRelativeToPath(new File("target").toPath());
    LocalTransactionContext.getContextManager().setGlobalDefault(new LocalTransactionContext(builder.build()));
    txManager = ContextTransactionManager.getInstance();
    txSyncRegistry = ContextTransactionSynchronizationRegistry.getInstance();
// setup the tx manager and tx sync registry
}
Also used : XATerminator(com.arjuna.ats.internal.jbossatx.jta.jca.XATerminator) JBossLocalTransactionProvider(org.wildfly.transaction.client.provider.jboss.JBossLocalTransactionProvider) XAResourceRecovery(org.jboss.tm.XAResourceRecovery) JTAEnvironmentBean(com.arjuna.ats.jta.common.JTAEnvironmentBean) LocalTransactionContext(org.wildfly.transaction.client.LocalTransactionContext) TransactionManagerImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple) TransactionSynchronizationRegistryImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple) ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) TransactionManager(javax.transaction.TransactionManager) TransactionSynchronizationRegistry(javax.transaction.TransactionSynchronizationRegistry) ContextTransactionSynchronizationRegistry(org.wildfly.transaction.client.ContextTransactionSynchronizationRegistry) XAResourceRecoveryRegistry(org.jboss.tm.XAResourceRecoveryRegistry) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 2 with XAResourceRecoveryRegistry

use of org.jboss.tm.XAResourceRecoveryRegistry in project wildfly by wildfly.

the class HTTPEJBClientXidTransactionTestCase method beforeTestClass.

/**
 * Create and setup the remoting connection
 *
 * @throws Exception
 */
@BeforeClass
public static void beforeTestClass() throws Exception {
    // These system properties are required or else we end up picking up JTS transaction manager,
    // which is not what we want
    final JTAEnvironmentBean jtaEnvironmentBean = jtaPropertyManager.getJTAEnvironmentBean();
    jtaEnvironmentBean.setTransactionManagerClassName(TransactionManagerImple.class.getName());
    jtaEnvironmentBean.setTransactionSynchronizationRegistryClassName(TransactionSynchronizationRegistryImple.class.getName());
    final TransactionManager narayanaTm = jtaEnvironmentBean.getTransactionManager();
    final TransactionSynchronizationRegistry narayanaTsr = jtaEnvironmentBean.getTransactionSynchronizationRegistry();
    final XATerminator xat = new XATerminator();
    final JBossLocalTransactionProvider.Builder builder = JBossLocalTransactionProvider.builder();
    builder.setXATerminator(xat).setExtendedJBossXATerminator(xat);
    builder.setTransactionManager(narayanaTm);
    builder.setTransactionSynchronizationRegistry(narayanaTsr);
    builder.setXAResourceRecoveryRegistry(new XAResourceRecoveryRegistry() {

        @Override
        public void addXAResourceRecovery(XAResourceRecovery xaResourceRecovery) {
        }

        @Override
        public void removeXAResourceRecovery(XAResourceRecovery xaResourceRecovery) {
        }
    });
    builder.setXARecoveryLogDirRelativeToPath(new File("target").toPath());
    LocalTransactionContext.getContextManager().setGlobalDefault(new LocalTransactionContext(builder.build()));
    txManager = ContextTransactionManager.getInstance();
    txSyncRegistry = ContextTransactionSynchronizationRegistry.getInstance();
    // setup the tx manager and tx sync registry
    AuthenticationConfiguration config = AuthenticationConfiguration.EMPTY.useName("user1").usePassword("password1");
    AuthenticationContext context = AuthenticationContext.empty().with(MatchRule.ALL, config);
    old = AuthenticationContext.captureCurrent();
    AuthenticationContext.getContextManager().setGlobalDefault(context);
}
Also used : AuthenticationConfiguration(org.wildfly.security.auth.client.AuthenticationConfiguration) XATerminator(com.arjuna.ats.internal.jbossatx.jta.jca.XATerminator) JBossLocalTransactionProvider(org.wildfly.transaction.client.provider.jboss.JBossLocalTransactionProvider) AuthenticationContext(org.wildfly.security.auth.client.AuthenticationContext) XAResourceRecovery(org.jboss.tm.XAResourceRecovery) JTAEnvironmentBean(com.arjuna.ats.jta.common.JTAEnvironmentBean) LocalTransactionContext(org.wildfly.transaction.client.LocalTransactionContext) TransactionManagerImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple) TransactionSynchronizationRegistryImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple) ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) TransactionManager(javax.transaction.TransactionManager) TransactionSynchronizationRegistry(javax.transaction.TransactionSynchronizationRegistry) ContextTransactionSynchronizationRegistry(org.wildfly.transaction.client.ContextTransactionSynchronizationRegistry) XAResourceRecoveryRegistry(org.jboss.tm.XAResourceRecoveryRegistry) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 3 with XAResourceRecoveryRegistry

use of org.jboss.tm.XAResourceRecoveryRegistry in project wildfly by wildfly.

the class WildFlyRecoveryRegistry method getXAResourceRecoveryRegistry.

private static XAResourceRecoveryRegistry getXAResourceRecoveryRegistry() {
    // This parsing isn't 100% ideal as it's somewhat 'internal' knowledge of the relationship between
    // capability names and service names. But at this point that relationship really needs to become
    // a contract anyway
    ServiceName serviceName = ServiceNameFactory.parseServiceName(MessagingServices.TRANSACTION_XA_RESOURCE_RECOVERY_REGISTRY_CAPABILITY);
    @SuppressWarnings("unchecked") ServiceController<XAResourceRecoveryRegistry> service = (ServiceController<XAResourceRecoveryRegistry>) container.getService(serviceName);
    return service == null ? null : service.getValue();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) XAResourceRecoveryRegistry(org.jboss.tm.XAResourceRecoveryRegistry) ServiceController(org.jboss.msc.service.ServiceController)

Example 4 with XAResourceRecoveryRegistry

use of org.jboss.tm.XAResourceRecoveryRegistry in project wildfly by wildfly.

the class TestWildFlyTSR method test.

@Test
public void test() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException {
    jtaPropertyManager.getJTAEnvironmentBean().setTransactionManagerClassName("com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple");
    arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreDir(System.getProperty("ObjectStoreEnvironmentBean.objectStoreDir"));
    final TransactionSynchronizationRegistry tsr = new TransactionSynchronizationRegistryWrapper();
    final JBossLocalTransactionProvider.Builder builder = JBossLocalTransactionProvider.builder();
    builder.setTransactionManager(com.arjuna.ats.jta.TransactionManager.transactionManager());
    builder.setExtendedJBossXATerminator(new XATerminatorImple());
    builder.setXAResourceRecoveryRegistry(new XAResourceRecoveryRegistry() {

        @Override
        public void addXAResourceRecovery(XAResourceRecovery xaResourceRecovery) {
        }

        @Override
        public void removeXAResourceRecovery(XAResourceRecovery xaResourceRecovery) {
        }
    });
    LocalTransactionContext.getContextManager().setGlobalDefault(new LocalTransactionContext(builder.build()));
    TransactionManager transactionManager = ContextTransactionManager.getInstance();
    transactionManager.begin();
    tsr.registerInterposedSynchronization(new Synchronization() {

        @Override
        public void beforeCompletion() {
            tsr.registerInterposedSynchronization(new Synchronization() {

                @Override
                public void beforeCompletion() {
                    innerSyncCalled = true;
                }

                @Override
                public void afterCompletion(int status) {
                }
            });
        }

        @Override
        public void afterCompletion(int status) {
        }
    });
    transactionManager.commit();
    assertTrue(innerSyncCalled);
}
Also used : JBossLocalTransactionProvider(org.wildfly.transaction.client.provider.jboss.JBossLocalTransactionProvider) TransactionSynchronizationRegistry(javax.transaction.TransactionSynchronizationRegistry) XAResourceRecovery(org.jboss.tm.XAResourceRecovery) ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) TransactionManager(javax.transaction.TransactionManager) XATerminatorImple(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple) XAResourceRecoveryRegistry(org.jboss.tm.XAResourceRecoveryRegistry) LocalTransactionContext(org.wildfly.transaction.client.LocalTransactionContext) Synchronization(javax.transaction.Synchronization) TransactionSynchronizationRegistryWrapper(org.jboss.as.txn.service.internal.tsr.TransactionSynchronizationRegistryWrapper) Test(org.junit.Test)

Aggregations

XAResourceRecoveryRegistry (org.jboss.tm.XAResourceRecoveryRegistry)4 TransactionManager (javax.transaction.TransactionManager)3 TransactionSynchronizationRegistry (javax.transaction.TransactionSynchronizationRegistry)3 XAResourceRecovery (org.jboss.tm.XAResourceRecovery)3 ContextTransactionManager (org.wildfly.transaction.client.ContextTransactionManager)3 LocalTransactionContext (org.wildfly.transaction.client.LocalTransactionContext)3 JBossLocalTransactionProvider (org.wildfly.transaction.client.provider.jboss.JBossLocalTransactionProvider)3 XATerminator (com.arjuna.ats.internal.jbossatx.jta.jca.XATerminator)2 TransactionManagerImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple)2 TransactionSynchronizationRegistryImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)2 JTAEnvironmentBean (com.arjuna.ats.jta.common.JTAEnvironmentBean)2 File (java.io.File)2 BeforeClass (org.junit.BeforeClass)2 ContextTransactionSynchronizationRegistry (org.wildfly.transaction.client.ContextTransactionSynchronizationRegistry)2 XATerminatorImple (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple)1 Synchronization (javax.transaction.Synchronization)1 TransactionSynchronizationRegistryWrapper (org.jboss.as.txn.service.internal.tsr.TransactionSynchronizationRegistryWrapper)1 ServiceController (org.jboss.msc.service.ServiceController)1 ServiceName (org.jboss.msc.service.ServiceName)1 Test (org.junit.Test)1