mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-30 06:37:36 +00:00
[Change] Core 为 FrameworkManager 添加对 'validatePluginDescriptor' 的具体实现, 以对 FrameworkDescriptor 进行检查;
[Change] FrameworkManager 覆盖 'validatePluginDescriptor' 方法, 补充对 FrameworkDescriptor 的检查;
This commit is contained in:
parent
a5f85227f2
commit
10b36e5f80
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package net.lamgc.cgj.bot.framework;
|
package net.lamgc.cgj.bot.framework;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import org.pf4j.*;
|
import org.pf4j.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -82,4 +83,26 @@ public class FrameworkManager extends JarPluginManager {
|
|||||||
protected PluginFactory createPluginFactory() {
|
protected PluginFactory createPluginFactory() {
|
||||||
return new FrameworkFactory(getPluginsRoot().getParent().resolve("frameworkData").toFile(), parentContext);
|
return new FrameworkFactory(getPluginsRoot().getParent().resolve("frameworkData").toFile(), parentContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void validatePluginDescriptor(PluginDescriptor descriptor) {
|
||||||
|
if (!(descriptor instanceof FrameworkDescriptor)) {
|
||||||
|
throw new PluginRuntimeException("Unsupported framework description specification");
|
||||||
|
}
|
||||||
|
super.validatePluginDescriptor(descriptor);
|
||||||
|
|
||||||
|
if (Strings.isNullOrEmpty(descriptor.getPluginClass())) {
|
||||||
|
throw new PluginRuntimeException("Field 'frameworkClass' cannot be empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform platform = ((FrameworkDescriptor) descriptor).getPlatform();
|
||||||
|
if (platform == null) {
|
||||||
|
throw new PluginRuntimeException("Field 'platform' cannot be empty");
|
||||||
|
} else if (Strings.isNullOrEmpty(platform.getPlatformIdentify())) {
|
||||||
|
throw new PluginRuntimeException("Field 'platform.platformIdentify' cannot be empty");
|
||||||
|
} else if (Strings.isNullOrEmpty(platform.getPlatformName())) {
|
||||||
|
throw new PluginRuntimeException("Field 'platform.platformName' cannot be empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user