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
}
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);
}
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();
}
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);
}
Aggregations