use of com.baomidou.dynamic.datasource.enums.SeataMode in project dynamic-datasource-spring-boot-starter by baomidou.
the class AbstractDataSourceCreator method wrapDataSource.
private DataSource wrapDataSource(DataSource dataSource, DataSourceProperty dataSourceProperty) {
String name = dataSourceProperty.getPoolName();
DataSource targetDataSource = dataSource;
Boolean enabledP6spy = properties.getP6spy() && dataSourceProperty.getP6spy();
if (enabledP6spy) {
targetDataSource = new P6DataSource(dataSource);
log.debug("dynamic-datasource [{}] wrap p6spy plugin", name);
}
Boolean enabledSeata = properties.getSeata() && dataSourceProperty.getSeata();
SeataMode seataMode = properties.getSeataMode();
if (enabledSeata) {
if (SeataMode.XA == seataMode) {
targetDataSource = new DataSourceProxyXA(targetDataSource);
} else {
targetDataSource = new DataSourceProxy(targetDataSource);
}
log.debug("dynamic-datasource [{}] wrap seata plugin transaction mode ", name);
}
return new ItemDataSource(name, dataSource, targetDataSource, enabledP6spy, enabledSeata, seataMode);
}
Aggregations