public class DaoFactory extends Object implements org.springframework.beans.factory.InitializingBean
Created by wuwenbin on 2017/1/2.
| 限定符和类型 | 字段和说明 |
|---|---|
AncestorDao |
defaultDao
default dao
before using it,define @Autowired DaoFactory daoFactory is necessary
using method:daFactory.defaultDao.xxxxxx() to execute it
|
AncestorDao |
dynamicDao
this default value is equals to defaultDao
use this param commonly,it is enough
|
| 构造器和说明 |
|---|
DaoFactory() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
afterPropertiesSet()
init some values
|
void |
determineTargetDao()
根据当前线程中的变量来确定切换的dynamicDao
|
AncestorDao |
getAncestorDaoByKey(String key)
transfer dao by key you set just now
|
void |
setDataSourceMap(Map<String,DataSourceX> dataSourceMap) |
void |
setDefaultDao(DataSourceX dataSourceX)
线程同步即可,此方法是不会再程序运行中调用,初始化即调用
|
public AncestorDao defaultDao
before using it,define @Autowired DaoFactory daoFactory is necessary using method:daFactory.defaultDao.xxxxxx() to execute it
public AncestorDao dynamicDao
public void setDataSourceMap(Map<String,DataSourceX> dataSourceMap)
public void setDefaultDao(DataSourceX dataSourceX)
dataSourceX - public void determineTargetDao()
throws DataSourceKeyNotExistException
public void afterPropertiesSet()
throws Exception
afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBeanExceptionpublic AncestorDao getAncestorDaoByKey(String key) throws DataSourceKeyNotExistException
#key - the key of dataSource you setAncestorDaoDataSourceKeyNotExistExceptionCopyright © 2019. All rights reserved.