对某些sql插件中的log日志加上sqlParserVO.getSqlLogEnabled()判断

This commit is contained in:
everywhere.z 2025-02-23 17:58:24 +08:00
parent d4c5cf8fcc
commit 2d454115cf
3 changed files with 16 additions and 44 deletions

View File

@ -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);

View File

@ -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;
}
}
}

View File

@ -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>