mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-07-01 12:57:26 +00:00
[Fix] Core, Framework-API 将 Framework 中 'initial()' 的调用转移到 FrameworkFactory 中, 以解决类初始化问题;
[Change] Framework 移除 'initial()' 的调用, 以修复类初始化过程中的一些隐式问题(如因父类尚未初始化完成, 导致子类成员变量尚未初始化, 出现 NPE 的问题); [Change] FrameworkFactory 将 Framework 的初始化转移到此, 以修复类初始化过程中的一些隐式问题(如上);
This commit is contained in:
@ -19,7 +19,6 @@ package net.lamgc.cgj.bot.framework;
|
||||
|
||||
import org.pf4j.Plugin;
|
||||
import org.pf4j.PluginDescriptor;
|
||||
import org.pf4j.PluginState;
|
||||
import org.pf4j.PluginWrapper;
|
||||
|
||||
import java.io.File;
|
||||
@ -46,18 +45,12 @@ public abstract class Framework extends Plugin {
|
||||
throw new IllegalStateException("Invalid description object");
|
||||
}
|
||||
this.dataFolder = dataFolder;
|
||||
try {
|
||||
initial();
|
||||
} catch (Throwable e) {
|
||||
wrapper.setFailedException(e);
|
||||
wrapper.setPluginState(PluginState.FAILED);
|
||||
log.error("An exception occurred while initializing the framework", e);
|
||||
throw new IllegalStateException("An exception occurred while initializing the framework", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行初始化操作.
|
||||
* <p> 警告: 请不要在初始化过程中调用 {@link org.pf4j.PluginManager}
|
||||
* 的任何插件管理方法, 这将会导致加载错误.
|
||||
*/
|
||||
protected abstract void initial();
|
||||
|
||||
|
Reference in New Issue
Block a user