use of cn.hutool.setting.SettingRuntimeException in project hutool by looly.
the class BasicSetting method autoLoad.
/**
* 在配置文件变更时自动加载
*
* @param autoReload 是否自动加载
*/
public void autoLoad(boolean autoReload) {
if (autoReload) {
if (null != this.watchMonitor) {
this.watchMonitor.close();
}
try {
watchMonitor = WatchMonitor.create(this.settingUrl, StandardWatchEventKinds.ENTRY_MODIFY);
watchMonitor.setWatcher(new SimpleWatcher() {
@Override
public void onModify(WatchEvent<?> event, Path currentPath) {
load();
}
}).start();
} catch (Exception e) {
throw new SettingRuntimeException(e, "Setting auto load not support url: [{}]", this.settingUrl);
}
StaticLog.debug("Auto load for [{}] listenning...", this.settingUrl);
} else {
IoUtil.close(this.watchMonitor);
this.watchMonitor = null;
}
}
use of cn.hutool.setting.SettingRuntimeException in project hutool by looly.
the class Props method autoLoad.
/**
* 在配置文件变更时自动加载
*
* @param autoReload 是否自动加载
*/
public void autoLoad(boolean autoReload) {
if (autoReload) {
if (null != this.watchMonitor) {
this.watchMonitor.close();
try {
watchMonitor = WatchMonitor.create(Paths.get(this.propertiesFileUrl.toURI()));
watchMonitor.setWatcher(new SimpleWatcher() {
@Override
public void onModify(WatchEvent<?> event, Path currentPath) {
load();
}
}).start();
} catch (Exception e) {
throw new SettingRuntimeException(e, "Setting auto load not support url: [{}]", this.propertiesFileUrl);
}
}
} else {
IoUtil.close(this.watchMonitor);
this.watchMonitor = null;
}
}
Aggregations