mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-29 22:27:33 +00:00
[Fix] Core 修复因 PluginClassLoader 默认类加载策略错误导致类重复加载;
[Add] JarFrameworkLoader 添加一个调整了类加载策略的 Loader 构造器; [Fix] FrameworkManager 注册 JarFrameworkLoader 以解决类加载策略错误导致的类重复加载问题;
This commit is contained in:
parent
3f353cbfa3
commit
02bbab8e6d
@ -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();
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user