diff --git a/ContentGrabbingJi-core/src/main/java/net/lamgc/cgj/bot/framework/FrameworkManager.java b/ContentGrabbingJi-core/src/main/java/net/lamgc/cgj/bot/framework/FrameworkManager.java index 553ff46..8175fe3 100644 --- a/ContentGrabbingJi-core/src/main/java/net/lamgc/cgj/bot/framework/FrameworkManager.java +++ b/ContentGrabbingJi-core/src/main/java/net/lamgc/cgj/bot/framework/FrameworkManager.java @@ -40,6 +40,13 @@ public class FrameworkManager extends JarPluginManager { setSystemVersion(systemVersion); } + @Override + protected PluginLoader createPluginLoader() { + return new CompoundPluginLoader() + .add(new DevelopmentPluginLoader(this), this::isDevelopment) + .add(new JarFrameworkLoader(this), this::isNotDevelopment); + } + @Override protected PluginDescriptorFinder createPluginDescriptorFinder() { return new JsonFrameworkDescriptorFinder(); diff --git a/ContentGrabbingJi-core/src/main/java/net/lamgc/cgj/bot/framework/JarFrameworkLoader.java b/ContentGrabbingJi-core/src/main/java/net/lamgc/cgj/bot/framework/JarFrameworkLoader.java new file mode 100644 index 0000000..733efaa --- /dev/null +++ b/ContentGrabbingJi-core/src/main/java/net/lamgc/cgj/bot/framework/JarFrameworkLoader.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2020 LamGC + * + * ContentGrabbingJi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * ContentGrabbingJi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package net.lamgc.cgj.bot.framework; + +import org.pf4j.*; + +import java.nio.file.Path; + +/** + * + * @author LamGC + */ +public class JarFrameworkLoader extends JarPluginLoader { + + public JarFrameworkLoader(PluginManager pluginManager) { + super(pluginManager); + } + + @Override + public ClassLoader loadPlugin(Path pluginPath, PluginDescriptor pluginDescriptor) { + PluginClassLoader pluginClassLoader = + new PluginClassLoader(pluginManager, pluginDescriptor, + getClass().getClassLoader(), ClassLoadingStrategy.ADP); + pluginClassLoader.addFile(pluginPath.toFile()); + + return pluginClassLoader; + } +}