# hexagon **Repository Path**: itranlin/hexagon ## Basic Information - **Project Name**: hexagon - **Description**: 基于SpringBoot的插件管理框架 - **Primary Language**: Unknown - **License**: AGPL-3.0 - **Default Branch**: dev-1.0.1 - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-10-19 - **Last Updated**: 2024-10-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## USE ### 环境准备: 1. JDK 17 2. Maven ### 主程序 1. 依赖 ```xml com.itranlin.hexagon hexagon-adapter-springboot3-starter 1.0.0 ``` 2. 启动 jvm 参数: --add-opens java.base/java.lang=ALL-UNNAMED ### 插件管理服务 1. 依赖 ```xml com.itranlin.hexagon hexagon-plugin-manager 1.0.0 ``` ### 插件 1. 依赖 ```xml com.itranlin.hexagon hexagon-plugin-depend 1.0.0 ``` 2. 配置插件Build ```xml com.itranlin.hexagon hexagon-plugin-builder-maven-plugin 1.0.0 builder ``` ## 核心 API ```java public interface HexagonAppContext { /** * 获取当前所有的插件 id */ List getAllPluginId(); /** * 预加载, 只读取元信息. */ Plugin preInstall(File file); /** * 安装插件 */ Plugin install(File file) throws Throwable; /** * 卸载插件 */ void uninstall(String pluginId) throws Exception; /** * 获取多个扩展点的插件实例 */

List

get(String tag); /** * 获取单个插件实例. */

Optional

get(String tag, String pluginId); } ``` ## 插件核心配置 springboot 配置项(application.yml支持): ```yaml com: itranlin: hexagon: master: path: 'plugins' auto-delete: true work-dir: "plugins_work" url-replace: true base-package: "com.itranlin.hexagon" ``` ## 插件配置 1. plugin-meta.properties ```properties # 插件 boot class plugin.boot.class=com.itranlin.open.hexagon.example.empty.Boot # code 名 不能为空 plugin.domain=example.plugin.empty # 描述 plugin.desc=this a plugin a empty demo # 版本 plugin.version=1.0.0 # 扩展 plugin.ext=null ``` 2. extension.properties 扩展点映射 ```properties com.itranlin.hexagonexample.extend.DemoService=com.itranlin.hexagonexample.plugin.DemoServiceImpl ``` ## 进阶 1. 插件回调 - 参考 [HexagonPluginManagerCallbackDefaultImpl.java](hexagon-core/hexagon-container/src/main/java/com/itranlin/hexagon/core/impl/HexagonPluginManagerCallbackDefaultImpl.java)