yyt
2024-06-26 0cceb649e1dc443c2a91d26d81eacb0867c96db3
提交 | 用户 | 时间
0cceb6 1 package com.jcdm.framework.datasource;
Y 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 }