cn.schoolwow.quickdao.module.initial.flow.database.CheckDataSourceFlow Maven / Gradle / Ivy
package cn.schoolwow.quickdao.module.initial.flow.database;
import cn.schoolwow.quickdao.domain.QuickDAOConfig;
import cn.schoolwow.quickdao.domain.provider.DatabaseProvider;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import com.zaxxer.hikari.HikariDataSource;
import javax.sql.DataSource;
import java.util.List;
public class CheckDataSourceFlow implements BusinessFlow {
@Override
public void executeBusinessFlow(FlowContext flowContext) throws Exception {
List databaseProviderList = (List) flowContext.checkData("databaseProviderList");
QuickDAOConfig quickDAOConfig = (QuickDAOConfig) flowContext.checkData("quickDAOConfig");
String jdbcUrl = (String) flowContext.checkData("jdbcUrl");
for (DatabaseProvider databaseProvider : databaseProviderList) {
if (jdbcUrl.contains("jdbc:" + databaseProvider.name())) {
quickDAOConfig.databaseContext.databaseProvider = databaseProvider;
break;
}
}
if (null == quickDAOConfig.databaseContext.databaseProvider) {
throw new IllegalArgumentException("不支持的数据库类型!jdbcUrl:" + jdbcUrl);
}
flowContext.putTemporaryData("databaseType", quickDAOConfig.databaseContext.databaseProvider.getDatabaseType());
}
@Override
public String name() {
return "检查数据库连接池";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy