simple druid config

This commit is contained in:
huayanYu 2023-10-23 21:58:54 +08:00
parent 15d7447d55
commit 5107fd54dd
2 changed files with 10 additions and 12 deletions

View File

@ -102,20 +102,20 @@ public final class DruidConfigUtil {
* @param c 当前配置
*/
public static void setValue(DruidDataSource dataSource, String field, DruidConfig c) {
PropertyDescriptor descriptor = DATASOURCE_DESCRIPTOR_MAP.get(field);
if (descriptor == null) {
log.warn("druid current not support [" + field + " ]");
return;
}
Method writeMethod = descriptor.getWriteMethod();
if (writeMethod == null) {
log.warn("druid current could not set [" + field + " ]");
return;
}
try {
Method configReadMethod = CONFIG_DESCRIPTOR_MAP.get(field).getReadMethod();
Object value = configReadMethod.invoke(c);
if (value != null) {
PropertyDescriptor descriptor = DATASOURCE_DESCRIPTOR_MAP.get(field);
if (descriptor == null) {
log.warn("druid current not support [" + field + " ]");
return;
}
Method writeMethod = descriptor.getWriteMethod();
if (writeMethod == null) {
log.warn("druid current could not set [" + field + " ]");
return;
}
writeMethod.invoke(dataSource, value);
}
} catch (Exception e) {

View File

@ -75,8 +75,6 @@ public class DruidDataSourceCreator implements DataSourceCreator {
PARAMS.add("socketTimeout");
}
// @Autowired(required = false)
// private ApplicationContext applicationContext;
private DruidConfig gConfig;
/**