mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 11:58:01 +08:00
调整
This commit is contained in:
parent
b479c3ed96
commit
e3b84abf47
@ -12,6 +12,8 @@
|
||||
6. 新增WebSSH 管理功能
|
||||
7. 【Server】用户新增邮箱和钉钉群webhook 属性
|
||||
8. 【Server】监控报警通知改为联系人
|
||||
9. 【Server】引人netty插件(感谢@夜空中最亮的星)
|
||||
10. 支持docker 容器运行(感谢@24k)
|
||||
|
||||
### 解决BUG、优化功能
|
||||
|
||||
|
@ -25,11 +25,6 @@ import java.nio.charset.Charset;
|
||||
*/
|
||||
public class JpomApplication extends ApplicationBuilder {
|
||||
|
||||
static {
|
||||
// 初始化插件
|
||||
PluginFactory.init();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -68,6 +63,8 @@ public class JpomApplication extends ApplicationBuilder {
|
||||
addInterceptor(PluginFeatureInterceptor.class);
|
||||
//
|
||||
addApplicationEventClient(new JpomApplicationEvent());
|
||||
// 添加初始化监听
|
||||
this.application().addInitializers(new PluginFactory());
|
||||
}
|
||||
|
||||
private void checkEvent(String[] args) throws Exception {
|
||||
|
@ -1,5 +1,16 @@
|
||||
package cn.keepbx.plugin;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.JarClassLoader;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||
import cn.keepbx.jpom.model.system.JpomManifest;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -9,7 +20,7 @@ import java.util.List;
|
||||
* @author bwcx_jzy
|
||||
* @date 2019/8/13
|
||||
*/
|
||||
public class PluginFactory {
|
||||
public class PluginFactory implements ApplicationContextInitializer {
|
||||
|
||||
private static final List<FeatureCallback> FEATURE_CALLBACKS = new ArrayList<>();
|
||||
|
||||
@ -29,7 +40,40 @@ public class PluginFactory {
|
||||
/**
|
||||
* 正式环境添加依赖
|
||||
*/
|
||||
public static void init() {
|
||||
private static void init() {
|
||||
if (JpomManifest.getInstance().isDebug()) {
|
||||
return;
|
||||
}
|
||||
File runPath = JpomManifest.getRunPath().getParentFile();
|
||||
File plugin = FileUtil.file(runPath, "plugin");
|
||||
if (!plugin.exists() || plugin.isFile()) {
|
||||
return;
|
||||
}
|
||||
File[] files = plugin.listFiles(File::isDirectory);
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
for (File file : files) {
|
||||
File lib = FileUtil.file(file, "lib");
|
||||
if (!lib.exists() || lib.isFile()) {
|
||||
continue;
|
||||
}
|
||||
File[] listFiles = lib.listFiles((dir, name) -> StrUtil.endWith(name, ".jar", true));
|
||||
if (listFiles == null || listFiles.length <= 0) {
|
||||
continue;
|
||||
}
|
||||
addPlugin(file.getName(), lib);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addPlugin(String pluginName, File file) {
|
||||
DefaultSystemLog.LOG().info("加载:{}插件", pluginName);
|
||||
ClassLoader contextClassLoader = ClassLoaderUtil.getClassLoader();
|
||||
JarClassLoader.loadJar((URLClassLoader) contextClassLoader, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user