use of org.springframework.boot.jta.atomikos.AtomikosDataSourceBean in project spring-boot by spring-projects.
the class JtaAutoConfigurationTests method atomikosDataSourcePoolConfiguration.
@Test
public void atomikosDataSourcePoolConfiguration() {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "spring.jta.atomikos.datasource.minPoolSize:5", "spring.jta.atomikos.datasource.maxPoolSize:10");
this.context.register(JtaPropertiesConfiguration.class, AtomikosJtaConfiguration.class, PoolConfiguration.class);
this.context.refresh();
AtomikosDataSourceBean dataSource = this.context.getBean(AtomikosDataSourceBean.class);
assertThat(dataSource.getMinPoolSize()).isEqualTo(5);
assertThat(dataSource.getMaxPoolSize()).isEqualTo(10);
}
use of org.springframework.boot.jta.atomikos.AtomikosDataSourceBean in project dynamic_dataSource by tianliuzhen.
the class MyBatisConfig1 method oneDataSource.
// 配置第一个数据源
@Primary
@Bean(name = "oneDataSource")
public DataSource oneDataSource() {
// 这里datasource要使用阿里的支持XA的DruidXADataSource
DruidXADataSource datasource = new DruidXADataSource();
BeanUtils.copyProperties(oneDataSourceProperties, datasource);
AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
xaDataSource.setXaDataSource(datasource);
xaDataSource.setUniqueResourceName("oneDataSource");
return xaDataSource;
}
use of org.springframework.boot.jta.atomikos.AtomikosDataSourceBean in project dynamic_dataSource by tianliuzhen.
the class MyBatisConfig2 method twoDataSource.
@Bean(name = "twoDataSource")
public DataSource twoDataSource() {
DruidXADataSource datasource = new DruidXADataSource();
BeanUtils.copyProperties(twoDataSourceProperties, datasource);
AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
xaDataSource.setXaDataSource(datasource);
xaDataSource.setUniqueResourceName("twoDataSource");
return xaDataSource;
}
use of org.springframework.boot.jta.atomikos.AtomikosDataSourceBean in project citrus by Yiuman.
the class DynamicDataSourceAutoConfiguration method buildDruidXaDataSource.
/**
* 根据配置构建XA数据源
*
* @param resourceName 资源名,用于定义XA唯一资源
* @param properties 数据源配置
* @return XA数据源
*/
public DataSource buildDruidXaDataSource(String resourceName, DataSourceProperties properties) {
DruidXADataSource druidDataSource = new DruidXADataSource();
druidDataSource.setUrl(properties.getUrl());
druidDataSource.setUsername(properties.getUsername());
druidDataSource.setPassword(properties.getPassword());
druidDataSource.setDriverClassName(properties.getDriverClassName());
AtomikosDataSourceBean atomikosDataSourceBean = new AtomikosDataSourceBean();
atomikosDataSourceBean.setXaDataSource(druidDataSource);
atomikosDataSourceBean.setUniqueResourceName(String.format("%s$$%s", resourceName, UUID.randomUUID().toString().substring(0, 15)));
return atomikosDataSourceBean;
}
Aggregations