public class DynamicDataSource
extends org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource
| Constructor and Description |
|---|
DynamicDataSource() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addDataSource(String key,
DataSource dataSource)
动态增加数据源
|
void |
afterPropertiesSet()
在获取key的集合,目的只是为了添加一些告警日志
|
boolean |
containsKey(String key)
判断指定DataSrouce当前是否存在
|
protected Object |
determineCurrentLookupKey()
AbstractRoutingDataSource
抽象类实现方法,
即获取当前线程数据源的key
|
DataSource |
getDefaultDataSource()
获取默认数据源
|
static DynamicDataSource |
getInstance()
单例方法
|
void |
setTargetDataSources(Map<Object,Object> map) |
determineTargetDataSource, getConnection, getConnection, isWrapperFor, resolveSpecifiedDataSource, resolveSpecifiedLookupKey, setDataSourceLookup, setDefaultTargetDataSource, setLenientFallback, unwrappublic static DynamicDataSource getInstance()
public static void addDataSource(String key, DataSource dataSource)
key - 数据源keydataSource - 数据源信息public void setTargetDataSources(Map<Object,Object> map)
setTargetDataSources in class org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSourceprotected Object determineCurrentLookupKey()
determineCurrentLookupKey in class org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSourcepublic void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanafterPropertiesSet in class org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSourcepublic boolean containsKey(String key)
key - 数据源keypublic DataSource getDefaultDataSource()
Copyright © 2020. All rights reserved.