提交 | 用户 | 时间
|
1ac2bc
|
1 |
package cn.stylefeng.guns.base.db.factory; |
懒 |
2 |
|
|
3 |
import cn.stylefeng.roses.core.config.properties.DruidProperties; |
|
4 |
import com.atomikos.jdbc.AtomikosDataSourceBean; |
|
5 |
import com.atomikos.jdbc.AtomikosSQLException; |
|
6 |
|
|
7 |
import java.util.Properties; |
|
8 |
|
|
9 |
/** |
|
10 |
* AtomikosDataSourceBean数据源工厂 |
|
11 |
* |
|
12 |
* @author fengshuonan |
|
13 |
* @Date 2019/11/19 18:22 |
|
14 |
*/ |
|
15 |
public class AtomikosFactory { |
|
16 |
|
|
17 |
public static AtomikosDataSourceBean create(String dataSourceName, DruidProperties druidProperties) { |
|
18 |
AtomikosDataSourceBean atomikosDataSourceBean = new AtomikosDataSourceBean(); |
|
19 |
atomikosDataSourceBean.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource"); |
|
20 |
atomikosDataSourceBean.setUniqueResourceName(dataSourceName); |
|
21 |
atomikosDataSourceBean.setMaxPoolSize(100); |
|
22 |
atomikosDataSourceBean.setBorrowConnectionTimeout(60); |
|
23 |
atomikosDataSourceBean.setMinPoolSize(0); |
|
24 |
|
|
25 |
Properties properties = druidProperties.createProperties(); |
|
26 |
atomikosDataSourceBean.setXaProperties(properties); |
|
27 |
|
|
28 |
try { |
|
29 |
atomikosDataSourceBean.init(); |
|
30 |
} catch (AtomikosSQLException e) { |
|
31 |
e.printStackTrace(); |
|
32 |
} |
|
33 |
|
|
34 |
return atomikosDataSourceBean; |
|
35 |
} |
|
36 |
|
|
37 |
} |