mirror of https://gitee.com/dromara/liteFlow
对某些sql插件中的log日志加上sqlParserVO.getSqlLogEnabled()判断
This commit is contained in:
parent
d4c5cf8fcc
commit
2d454115cf
|
@ -68,8 +68,9 @@ public class LiteFlowAutoLookUpJdbcConn implements LiteFlowDataSourceConnect {
|
|||
if (LiteFlowJdbcUtil.checkConnectionCanExecuteSql(dataSource.getConnection(), executeSql)) {
|
||||
// 找到数据源名称后,将其缓存起来,下次使用就不再寻找
|
||||
LiteFlowJdbcUtil.DataSourceBeanNameHolder.init(dataSourceName);
|
||||
|
||||
LOG.info("use dataSourceName[{}],has found liteflow config", dataSourceName);
|
||||
if (sqlParserVO.getSqlLogEnabled()) {
|
||||
LOG.info("use dataSourceName[{}],has found liteflow config", dataSourceName);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
LOG.info("check dataSourceName[{}],but not has liteflow config", dataSourceName);
|
||||
|
|
|
@ -157,47 +157,5 @@ public class LiteFlowJdbcUtil {
|
|||
public static boolean isNotInit() {
|
||||
return DATA_SOURCE_NAME == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动查找可用数据源
|
||||
*/
|
||||
public static Connection autoLookUpConn(SQLParserVO sqlParserVO) throws SQLException {
|
||||
Connection connection;
|
||||
Map<String, DataSource> dataSourceMap = ContextAwareHolder.loadContextAware().getBeansOfType(DataSource.class);
|
||||
if (DataSourceBeanNameHolder.isNotInit()) {
|
||||
synchronized (DataSourceBeanNameHolder.class) {
|
||||
if (DataSourceBeanNameHolder.isNotInit()) {
|
||||
String executeSql = buildCheckSql(sqlParserVO);
|
||||
// 遍历数据源,多数据源场景下,判断哪个数据源有 liteflow 配置
|
||||
for (Map.Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
|
||||
String dataSourceName = entry.getKey();
|
||||
DataSource dataSource = entry.getValue();
|
||||
|
||||
if (checkConnectionCanExecuteSql(dataSource.getConnection(), executeSql)) {
|
||||
// 找到数据源名称后,将其缓存起来,下次使用就不再寻找
|
||||
DataSourceBeanNameHolder.init(dataSourceName);
|
||||
if (sqlParserVO.getSqlLogEnabled()) {
|
||||
LOG.info("use dataSourceName[{}],has found liteflow config", dataSourceName);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
LOG.warn("check dataSourceName[{}],but not has liteflow config", dataSourceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DataSource dataSource = Optional.ofNullable(DataSourceBeanNameHolder.getDataSourceName())
|
||||
.map(dataSourceMap::get)
|
||||
.orElse(null);
|
||||
if (dataSource == null) {
|
||||
throw new ELSQLException("can not found liteflow config in dataSourceName " + dataSourceMap.keySet());
|
||||
}
|
||||
connection = dataSource.getConnection();
|
||||
if (connection == null) {
|
||||
throw new ELSQLException("can not found liteflow config in dataSourceName " + dataSourceMap.keySet());
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,4 +27,17 @@
|
|||
<artifactId>janino</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
Loading…
Reference in New Issue