春风项目四线(合箱线、总装线)
wujian
2024-01-19 717bf861cecf28eacc3cb1488f1b6acae3fee4cb
提交 | 用户 | 时间
fd2207 1 package com.jcdm.framework.datasource;
2
3 import java.util.Map;
4 import javax.sql.DataSource;
5 import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
6
7 /**
8  * 动态数据源
9  * 
10  * @author jc
11  */
12 public class DynamicDataSource extends AbstractRoutingDataSource
13 {
14     public DynamicDataSource(DataSource defaultTargetDataSource, Map<Object, Object> targetDataSources)
15     {
16         super.setDefaultTargetDataSource(defaultTargetDataSource);
17         super.setTargetDataSources(targetDataSources);
18         super.afterPropertiesSet();
19     }
20
21     @Override
22     protected Object determineCurrentLookupKey()
23     {
24         return DynamicDataSourceContextHolder.getDataSourceType();
25     }
26 }