mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 01:28:24 +08:00
fix: 修复 druid 数据源的某些场景下,数据加密无法使用的问题
This commit is contained in:
parent
6eadba4e77
commit
725b3efcd0
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.mybatisflex.core.datasource;
|
||||
|
||||
import com.mybatisflex.core.exception.FlexExceptions;
|
||||
import com.mybatisflex.core.util.ClassUtil;
|
||||
import org.apache.ibatis.logging.LogFactory;
|
||||
|
||||
@ -42,6 +43,8 @@ public class DataSourceManager {
|
||||
return;
|
||||
}
|
||||
|
||||
restartDataSource(dataSource);
|
||||
|
||||
for (DataSourceProperty property : DataSourceProperty.values()) {
|
||||
Method getterMethod = ClassUtil.getAnyMethod(dataSource.getClass(), property.getGetterMethods());
|
||||
if (getterMethod != null) {
|
||||
@ -57,6 +60,18 @@ public class DataSourceManager {
|
||||
}
|
||||
}
|
||||
|
||||
static void restartDataSource(DataSource dataSource) {
|
||||
Method restartMethod = ClassUtil.getFirstMethod(ClassUtil.getUsefulClass(dataSource.getClass())
|
||||
, method -> "restart".equals(method.getName()));
|
||||
if (restartMethod != null) {
|
||||
try {
|
||||
restartMethod.invoke(dataSource);
|
||||
} catch (Exception e) {
|
||||
throw FlexExceptions.wrap(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static String invokeMethod(Method method, Object object, Object... params) {
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user