mirror of
https://github.com/Geniusay/ChopperBot.git
synced 2026-05-23 04:39:41 +08:00
今日更新内容:
1,InitPluginRegister 增加了插件管理和插件注册,提供了插件依赖接口,每个插件初始化的时候会检查依赖插件是否完备,构成依赖启动 2,添加了一个系统守护线程池,就是一个线程池,待拓展和优化,负责运行一些单例线程独立运行的插件
This commit is contained in:
@@ -259,7 +259,6 @@ public class FileCache <T extends ConfigFile>{
|
||||
String dir = getFullFilePath();
|
||||
configFile.onlyUpdateTime(take);
|
||||
File file = JsonFileUtil.writeJsonFile(dir, take);
|
||||
logger.debug("正在写入{}新版本",dir);
|
||||
return Objects.isNull(file);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ public abstract class ConfigInitMachine<T extends ConfigFile> extends CommonInit
|
||||
|
||||
private String filePath;
|
||||
|
||||
public ConfigInitMachine(T configFile, Logger logger) {
|
||||
super(logger);
|
||||
public ConfigInitMachine(String pluginName,T configFile, Logger logger) {
|
||||
super(logger,pluginName);
|
||||
this.configFile = configFile;
|
||||
filePath = Paths.get(configFile.getFilePath(), configFile.getFileName()).toString();
|
||||
}
|
||||
@@ -32,7 +32,11 @@ public abstract class ConfigInitMachine<T extends ConfigFile> extends CommonInit
|
||||
|
||||
@Override
|
||||
public boolean init() {
|
||||
return ConfigFileUtil.createConfigFile(filePath,configFile,logger,this.getClass().getName());
|
||||
if (ConfigFileUtil.createConfigFile(filePath,configFile,logger,pluginName)) {
|
||||
registerPlugin();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.example.init;
|
||||
|
||||
import org.example.cache.FileCacheManagerInstance;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.log.ChopperLogFactory;
|
||||
import org.example.log.LoggerType;
|
||||
|
||||
@@ -11,13 +12,14 @@ import org.example.log.LoggerType;
|
||||
public class FileCacheManagerInit extends CommonInitMachine{
|
||||
|
||||
public FileCacheManagerInit() {
|
||||
super( ChopperLogFactory.getLogger(LoggerType.File));
|
||||
super(ChopperLogFactory.getLogger(LoggerType.File), PluginName.FILE_CACHE_PLUGIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init() {
|
||||
try {
|
||||
FileCacheManagerInstance.getInstance().start();
|
||||
registerPlugin();
|
||||
return success();
|
||||
}catch (Exception e){
|
||||
return fail(e.getMessage());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.example.init;
|
||||
|
||||
import org.example.constpool.ConstPool;
|
||||
import org.example.log.ChopperLogFactory;
|
||||
import org.example.log.LoggerType;
|
||||
|
||||
@@ -15,7 +16,7 @@ public class FileModuleInitMachine extends ModuleInitMachine{
|
||||
super(List.of(
|
||||
new ModuleSrcConfigFileInit(),
|
||||
new FileCacheManagerInit()
|
||||
), "FileModule", ChopperLogFactory.getLogger(LoggerType.File));
|
||||
), ConstPool.FILE, ChopperLogFactory.getLogger(LoggerType.File));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.example.init;
|
||||
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.log.ChopperLogFactory;
|
||||
import org.example.log.LoggerType;
|
||||
import org.example.pojo.configfile.ModuleSrcConfigFile;
|
||||
@@ -21,7 +22,8 @@ public class ModuleSrcConfigFileInit extends CommonInitMachine {
|
||||
ModuleSrcConfigFile moduleSrcConfigFile;
|
||||
|
||||
public ModuleSrcConfigFileInit() {
|
||||
super( ChopperLogFactory.getLogger(LoggerType.File));
|
||||
super( ChopperLogFactory.getLogger(LoggerType.File),
|
||||
PluginName.MODULE_CONFIG_PLUGIN);
|
||||
moduleSrcConfigFile = new ModuleSrcConfigFile();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user