@Bean @ConditionalOnMissingBean(XAConnectionFactoryWrapper.class) public NarayanaXAConnectionFactoryWrapper xaConnectionFactoryWrapper( TransactionManager transactionManager, NarayanaRecoveryManagerBean narayanaRecoveryManagerBean, NarayanaProperties narayanaProperties) { return new NarayanaXAConnectionFactoryWrapper(transactionManager, narayanaRecoveryManagerBean, narayanaProperties); }
@Primary @Bean(name = { "jmsConnectionFactory", "xaJmsConnectionFactory" }) public ConnectionFactory jmsConnectionFactory(ListableBeanFactory beanFactory, HornetQProperties properties, XAConnectionFactoryWrapper wrapper) throws Exception { return wrapper.wrapConnectionFactory( new HornetQConnectionFactoryFactory(beanFactory, properties) .createConnectionFactory( SpringBootHornetQXAConnectionFactory.class)); }
@Primary @Bean(name = { "jmsConnectionFactory", "xaJmsConnectionFactory" }) public ConnectionFactory jmsConnectionFactory(ListableBeanFactory beanFactory, ArtemisProperties properties, XAConnectionFactoryWrapper wrapper) throws Exception { return wrapper.wrapConnectionFactory( new ArtemisConnectionFactoryFactory(beanFactory, properties) .createConnectionFactory(ActiveMQXAConnectionFactory.class)); }
@Primary @Bean(name = { "jmsConnectionFactory", "xaJmsConnectionFactory" }) public ConnectionFactory jmsConnectionFactory(ActiveMQProperties properties, XAConnectionFactoryWrapper wrapper) throws Exception { ActiveMQXAConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory( properties).createConnectionFactory(ActiveMQXAConnectionFactory.class); return wrapper.wrapConnectionFactory(connectionFactory); }
@Test public void disableJtaSupport() { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.jta.enabled:false"); this.context.register(JtaAutoConfiguration.class); this.context.refresh(); assertThat(this.context.getBeansOfType(JtaTransactionManager.class)).isEmpty(); assertThat(this.context.getBeansOfType(XADataSourceWrapper.class)).isEmpty(); assertThat(this.context.getBeansOfType(XAConnectionFactoryWrapper.class)) .isEmpty(); }
@Test public void atomikosSanityCheck() throws Exception { this.context = new AnnotationConfigApplicationContext(JtaProperties.class, AtomikosJtaConfiguration.class); this.context.getBean(AtomikosProperties.class); this.context.getBean(UserTransactionService.class); this.context.getBean(UserTransactionManager.class); this.context.getBean(UserTransaction.class); this.context.getBean(XADataSourceWrapper.class); this.context.getBean(XAConnectionFactoryWrapper.class); this.context.getBean(AtomikosDependsOnBeanFactoryPostProcessor.class); this.context.getBean(JtaTransactionManager.class); }
@Test public void bitronixSanityCheck() throws Exception { this.context = new AnnotationConfigApplicationContext(JtaProperties.class, BitronixJtaConfiguration.class); this.context.getBean(bitronix.tm.Configuration.class); this.context.getBean(TransactionManager.class); this.context.getBean(XADataSourceWrapper.class); this.context.getBean(XAConnectionFactoryWrapper.class); this.context.getBean(BitronixDependentBeanFactoryPostProcessor.class); this.context.getBean(JtaTransactionManager.class); }
@Bean public ConnectionFactory pooledConnectionFactory( XAConnectionFactoryWrapper wrapper) throws Exception { XAConnectionFactory connectionFactory = mock(XAConnectionFactory.class); XAConnection connection = mock(XAConnection.class); XASession session = mock(XASession.class); TemporaryQueue queue = mock(TemporaryQueue.class); XAResource resource = mock(XAResource.class); given(connectionFactory.createXAConnection()).willReturn(connection); given(connection.createXASession()).willReturn(session); given(session.createTemporaryQueue()).willReturn(queue); given(session.getXAResource()).willReturn(resource); return wrapper.wrapConnectionFactory(connectionFactory); }
@Primary @Bean(name = { "jmsConnectionFactory", "xaJmsConnectionFactory" }) public ConnectionFactory jmsConnectionFactory(ListableBeanFactory beanFactory, HornetQProperties properties, XAConnectionFactoryWrapper wrapper) throws Exception { return wrapper.wrapConnectionFactory( new HornetQConnectionFactoryFactory(beanFactory, properties) .createConnectionFactory(HornetQXAConnectionFactory.class)); }
@Test public void disableJtaSupport() { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.jta.enabled:false"); this.context.register(JtaAutoConfiguration.class); this.context.refresh(); assertEquals(0, this.context.getBeansOfType(JtaTransactionManager.class).size()); assertEquals(0, this.context.getBeansOfType(XADataSourceWrapper.class).size()); assertEquals(0, this.context.getBeansOfType(XAConnectionFactoryWrapper.class).size()); }
@Bean @ConditionalOnMissingBean(XAConnectionFactoryWrapper.class) public AtomikosXAConnectionFactoryWrapper xaConnectionFactoryWrapper() { return new AtomikosXAConnectionFactoryWrapper(); }
@Bean @ConditionalOnMissingBean(XAConnectionFactoryWrapper.class) public BitronixXAConnectionFactoryWrapper xaConnectionFactoryWrapper() { return new BitronixXAConnectionFactoryWrapper(); }