mirror of
https://github.com/Geniusay/ChopperBot.git
synced 2026-06-01 03:20:10 +08:00
插件开机启动,热插拔,api接口全部完成
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
package org.example.constpool;
|
||||
|
||||
import org.example.cache.FileCache;
|
||||
import org.example.exception.FileCacheException;
|
||||
import org.example.pojo.configfile.ModuleSrcConfigFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
|
||||
@@ -2,9 +2,8 @@ package org.example.init;
|
||||
|
||||
import org.example.bean.ConfigFile;
|
||||
import org.example.plugin.CommonPlugin;
|
||||
import org.example.plugin.Plugin;
|
||||
import org.example.plugin.annotation.Plugin;
|
||||
import org.example.util.ConfigFileUtil;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
@@ -3,11 +3,10 @@ package org.example.init;
|
||||
import org.example.cache.FileCacheManager;
|
||||
import org.example.cache.FileCacheManagerInstance;
|
||||
import org.example.constpool.ConstPool;
|
||||
import org.example.constpool.ModuleName;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.log.ChopperLogFactory;
|
||||
import org.example.log.LoggerType;
|
||||
import org.example.plugin.CommonPlugin;
|
||||
import org.example.plugin.Plugin;
|
||||
import org.example.plugin.annotation.Plugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,7 +15,7 @@ import java.util.List;
|
||||
* @date 2023/04/26 02:09
|
||||
**/
|
||||
|
||||
@Plugin(moduleName = ConstPool.FILE,
|
||||
@Plugin(moduleName = ModuleName.FILE,
|
||||
pluginName = PluginName.FILE_CACHE_PLUGIN,
|
||||
needPlugin = {},
|
||||
pluginClass= FileCacheManager.class )
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package org.example.init.module;
|
||||
|
||||
import org.example.constpool.ConstPool;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.init.FileCacheManagerInitMachine;
|
||||
import org.example.constpool.ModuleName;
|
||||
import org.example.init.ModuleInitMachine;
|
||||
import org.example.log.ChopperLogFactory;
|
||||
import org.example.log.LoggerType;
|
||||
import org.example.plugin.Plugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
@@ -18,7 +14,7 @@ import java.util.List;
|
||||
public class FileModuleInitMachine extends ModuleInitMachine {
|
||||
|
||||
public FileModuleInitMachine() {
|
||||
super(ConstPool.FILE, ChopperLogFactory.getLogger(LoggerType.File));
|
||||
super(ModuleName.FILE, ChopperLogFactory.getLogger(LoggerType.File));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ import java.util.Map;
|
||||
**/
|
||||
|
||||
|
||||
public class ModuleSrcConfigFile extends ConfigFile<Map<String, Object>> {
|
||||
public class ChopperBotConfigFile extends ConfigFile<Map<String, Object>> {
|
||||
|
||||
private static final String filePath = "./config/";
|
||||
|
||||
private static final String fileName = "chopperBotConfig.json";
|
||||
|
||||
public ModuleSrcConfigFile() {
|
||||
super( "ChopperBot", PluginName.MODULE_CONFIG_PLUGIN,List.of(),true,filePath, fileName,
|
||||
public ChopperBotConfigFile() {
|
||||
super( "ChopperBot", PluginName.CHOPPER_BOT_CONFIG_PLUGIN,List.of(),true,filePath, fileName,
|
||||
Map.of("src",Map.of( ConstPool.ACCOUNT, "./config/"+ConstPool.ACCOUNT,
|
||||
ConstPool.SECTION, "./config/"+ConstPool.SECTION,
|
||||
ConstPool.BARRAGE, "./config/"+ConstPool.BARRAGE,
|
||||
@@ -30,7 +30,7 @@ public class ModuleSrcConfigFile extends ConfigFile<Map<String, Object>> {
|
||||
ConstPool.SECTION_WORK, "./config/"+ConstPool.SECTION_WORK,
|
||||
ConstPool.HOT, "./config/"+ConstPool.HOT,
|
||||
ConstPool.PUBLISH, "./config/"+ConstPool.PUBLISH),
|
||||
"plugin",Map.of()), FileType.CHOPPER_BOT);
|
||||
"pluginStart",Map.of()), FileType.CHOPPER_BOT);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.example.cache;
|
||||
|
||||
import org.example.constpool.GlobalFileCache;
|
||||
import org.example.pojo.Student;
|
||||
import org.example.pojo.configfile.ModuleSrcConfigFile;
|
||||
import org.example.pojo.configfile.ChopperBotConfigFile;
|
||||
import org.example.exception.FileCacheException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -35,8 +35,8 @@ public class FileCacheTest {
|
||||
|
||||
@Test
|
||||
public void TestFileCache() throws FileCacheException, InterruptedException {
|
||||
ModuleSrcConfigFile moduleSrcConfigFile = new ModuleSrcConfigFile();
|
||||
FileCache fileCache = new FileCache(moduleSrcConfigFile);
|
||||
ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
|
||||
FileCache fileCache = new FileCache(chopperBotConfigFile);
|
||||
|
||||
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
|
||||
manager.start();
|
||||
@@ -45,8 +45,8 @@ public class FileCacheTest {
|
||||
|
||||
@Test
|
||||
public void TestFileCacheManager() throws FileCacheException, InterruptedException {
|
||||
ModuleSrcConfigFile moduleSrcConfigFile = new ModuleSrcConfigFile();
|
||||
FileCache fileCache = new FileCache(moduleSrcConfigFile);
|
||||
ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
|
||||
FileCache fileCache = new FileCache(chopperBotConfigFile);
|
||||
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
|
||||
manager.start();
|
||||
Thread.sleep(500000);
|
||||
@@ -54,8 +54,8 @@ public class FileCacheTest {
|
||||
|
||||
@Test
|
||||
public void TestGet() throws FileCacheException, InterruptedException {
|
||||
ModuleSrcConfigFile moduleSrcConfigFile = new ModuleSrcConfigFile();
|
||||
FileCache fileCache = new FileCache(moduleSrcConfigFile);
|
||||
ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
|
||||
FileCache fileCache = new FileCache(chopperBotConfigFile);
|
||||
|
||||
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
|
||||
manager.start();
|
||||
@@ -101,8 +101,8 @@ public class FileCacheTest {
|
||||
|
||||
@Test
|
||||
public void TestArrayAdd() throws InterruptedException, FileCacheException {
|
||||
ModuleSrcConfigFile moduleSrcConfigFile = new ModuleSrcConfigFile();
|
||||
FileCache fileCache = new FileCache(moduleSrcConfigFile);
|
||||
ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
|
||||
FileCache fileCache = new FileCache(chopperBotConfigFile);
|
||||
|
||||
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
|
||||
manager.start();
|
||||
|
||||
Reference in New Issue
Block a user