@Bean @ConditionalOnMissingBean(XADataSourceWrapper.class) public XADataSourceWrapper xaDataSourceWrapper( NarayanaRecoveryManagerBean narayanaRecoveryManagerBean, NarayanaProperties narayanaProperties) { return new NarayanaXADataSourceWrapper(narayanaRecoveryManagerBean, narayanaProperties); }
@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); }
@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 @OrchestratorPersistenceUnit @Primary public DataSource dataSource(XADataSourceWrapper wrapper) throws Exception { XADataSource xaDataSource = createXaDataSource(orchestratorDataSourceProperties()); return wrapper.wrapDataSource(xaDataSource); }
@Bean @ConditionalOnMissingBean(XADataSourceWrapper.class) public AtomikosXADataSourceWrapper xaDataSourceWrapper() { return new AtomikosXADataSourceWrapper(); }
@Bean @ConditionalOnMissingBean(XADataSourceWrapper.class) public BitronixXADataSourceWrapper xaDataSourceWrapper() { return new BitronixXADataSourceWrapper(); }
@Bean public DataSource pooledDataSource(XADataSourceWrapper wrapper) throws Exception { XADataSource dataSource = mock(XADataSource.class); return wrapper.wrapDataSource(dataSource); }
@Bean @WorkflowPersistenceUnit public DataSource workflowDataSource(XADataSourceWrapper wrapper) throws Exception { XADataSource xaDataSource = createXaDataSource(workflowDataSourceProperties()); return wrapper.wrapDataSource(xaDataSource); }