public abstract class AbstractDSFactory extends DSFactory
getDataSource(String)
时,工厂只需创建一次即可。dataSourceName, KEY_ALIAS_DRIVER, KEY_ALIAS_PASSWORD, KEY_ALIAS_URL, KEY_ALIAS_USER, KEY_CONN_PROPS
Constructor and Description |
---|
AbstractDSFactory(String dataSourceName,
Class<? extends DataSource> dataSourceClass,
Setting setting)
构造
|
Modifier and Type | Method and Description |
---|---|
void |
close(String group)
关闭对应数据源
|
protected abstract DataSource |
createDataSource(String jdbcUrl,
String driver,
String user,
String pass,
Setting poolSetting)
创建新的
DataSource |
void |
destroy()
销毁工厂类,关闭所有数据源
|
boolean |
equals(Object obj) |
DataSource |
getDataSource(String group)
获得分组对应数据源
|
Setting |
getSetting()
获取配置,用于自定义添加配置项
|
int |
hashCode() |
close, create, get, get, getDataSource, setCurrentDSFactory
public AbstractDSFactory(String dataSourceName, Class<? extends DataSource> dataSourceClass, Setting setting)
dataSourceName
- 数据源名称dataSourceClass
- 数据库连接池实现类,用于检测所提供的DataSource类是否存在,当传入的DataSource类不存在时抛出ClassNotFoundExceptionsetting
- 数据库连接配置,如果为null
,则读取全局自定义或默认配置public Setting getSetting()
public DataSource getDataSource(String group)
DSFactory
getDataSource
in class DSFactory
group
- 分组名protected abstract DataSource createDataSource(String jdbcUrl, String driver, String user, String pass, Setting poolSetting)
DataSource
jdbcUrl
- JDBC连接字符串driver
- 数据库驱动类名user
- 用户名pass
- 密码poolSetting
- 分组下的连接池配置文件DataSource
public void destroy()
DSFactory
Copyright © 2024. All rights reserved.