|
| 1 | +# FIT插件启动顺序说明 |
| 2 | + |
| 3 | +## 概述 |
| 4 | + |
| 5 | +本文档记录了 FIT Framework 内置插件的启动顺序。FIT 内置插件共定义了 **22 个**,其中: |
| 6 | + |
| 7 | +- **20 个**会自动输出到 `build/plugins/` 目录 |
| 8 | +- **2 个**不在 `build/plugins/` 目录中(需单独配置) |
| 9 | + |
| 10 | +所有 FIT 插件均配置为 **category=SYSTEM, level=4**。 |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## 启动顺序说明 |
| 15 | + |
| 16 | +### 整体启动阶段 |
| 17 | + |
| 18 | +``` |
| 19 | +FIT 框架插件启动顺序 |
| 20 | +│ |
| 21 | +├─ 阶段1: SYSTEM 插件启动 |
| 22 | +│ │ |
| 23 | +│ └─ Level 4 (20个自动输出 + 2个可选) |
| 24 | +│ └─ FIT 内置插件 |
| 25 | +│ |
| 26 | +└─ 阶段2: USER 插件启动 |
| 27 | +``` |
| 28 | + |
| 29 | +**FIT 内置插件均配置为 SYSTEM Level 4,为应用层插件提供基础服务。** |
| 30 | + |
| 31 | +### 启动规则 |
| 32 | + |
| 33 | +- **category=SYSTEM (id=1) 的插件先于 USER (id=2) 插件加载** |
| 34 | +- **相同 category 内,level 数值越小,启动优先级越高** |
| 35 | +- **相同 category 和 level 的插件,加载顺序不确定** |
| 36 | + |
| 37 | +**默认值**: |
| 38 | +- 未指定 category 时,默认为 **category=USER** |
| 39 | +- 未指定 level 时,默认为 **level=4** |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## 自动添加的FIT插件 |
| 44 | + |
| 45 | +这 20 个插件会在构建时自动复制到 `build/plugins/` 目录(插件均配置为 category=SYSTEM, level=4): |
| 46 | + |
| 47 | +| 序号 | 插件名称 | 说明 | |
| 48 | +|----|---------------------------------------|-------------------| |
| 49 | +| 1 | `fit-actuator` | 监控端点 | |
| 50 | +| 2 | `fit-client-http` | HTTP 客户端 | |
| 51 | +| 3 | `fit-dynamic-plugin-directory` | 动态插件目录 | |
| 52 | +| 4 | `fit-heartbeat-client` | 心跳客户端 | |
| 53 | +| 5 | `fit-http-client-okhttp` | OkHttp 客户端 | |
| 54 | +| 6 | `fit-http-handler-registry` | HTTP 处理器注册 | |
| 55 | +| 7 | `fit-http-openapi3-swagger` | OpenAPI 3/Swagger | |
| 56 | +| 8 | `fit-http-server-netty` | Netty HTTP 服务器 | |
| 57 | +| 9 | `fit-logger` | 日志组件 | |
| 58 | +| 10 | `fit-message-serializer-cbor` | CBOR 序列化 | |
| 59 | +| 11 | `fit-message-serializer-json-jackson` | Jackson JSON 序列化 | |
| 60 | +| 12 | `fit-security-simple` | 简单安全 | |
| 61 | +| 13 | `fit-server-http` | HTTP 服务器 | |
| 62 | +| 14 | `fit-service-coordination-locator` | 服务定位 | |
| 63 | +| 15 | `fit-service-coordination-simple` | 简单服务协调 | |
| 64 | +| 16 | `fit-service-discovery` | 服务发现 | |
| 65 | +| 17 | `fit-service-registry` | 服务注册 | |
| 66 | +| 18 | `fit-validation-hibernate-jakarta` | Jakarta 验证 | |
| 67 | +| 19 | `fit-validation-hibernate-javax` | Javax 验证 | |
| 68 | +| 20 | `fit-value-fastjson` | Fastjson 支持 | |
| 69 | + |
| 70 | +**注意**: 表格中的序号仅用于标识,不代表实际加载顺序。相同 category 和 level 的插件之间的加载顺序是不确定的。 |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## 需要手动添加的插件 |
| 75 | + |
| 76 | +以下插件在源码中定义,但**不会自动输出**到 `build/plugins/` 目录,需要手动添加(插件均配置为 category=SYSTEM, level=4): |
| 77 | + |
| 78 | +### 1. fit-dynamic-plugin-mvn |
| 79 | + |
| 80 | +| 属性 | 值 | |
| 81 | +|----------|-----------------------------------------------------------------| |
| 82 | +| **插件名** | fit-dynamic-plugin-mvn | |
| 83 | +| **源码路径** | `framework/fit/java/fit-builtin/plugins/fit-dynamic-plugin-mvn` | |
| 84 | +| **说明** | Maven 动态插件加载器 | |
| 85 | +| **用途** | 从 Maven 仓库动态加载插件 | |
| 86 | + |
| 87 | +### 2. fit-service-coordination-nacos |
| 88 | + |
| 89 | +| 属性 | 值 | |
| 90 | +|----------|-------------------------------------------------------------------------| |
| 91 | +| **插件名** | fit-service-coordination-nacos | |
| 92 | +| **源码路径** | `framework/fit/java/fit-builtin/plugins/fit-service-coordination-nacos` | |
| 93 | +| **说明** | Nacos 服务协调实现 | |
| 94 | +| **用途** | 使用 Nacos 进行服务注册和发现 | |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## 插件功能分类 |
| 99 | + |
| 100 | +虽然所有 FIT 插件都在 Level 4 启动,但它们提供不同类别的功能: |
| 101 | + |
| 102 | +### HTTP 服务相关(7个) |
| 103 | + |
| 104 | +- `fit-client-http` - HTTP 客户端接口 |
| 105 | +- `fit-http-client-okhttp` - OkHttp 客户端实现 |
| 106 | +- `fit-http-handler-registry` - HTTP 处理器注册 |
| 107 | +- `fit-http-openapi3-swagger` - OpenAPI 3 和 Swagger UI |
| 108 | +- `fit-http-server-netty` - Netty HTTP 服务器实现 |
| 109 | +- `fit-server-http` - HTTP 服务器接口 |
| 110 | +- `fit-heartbeat-client` - 心跳客户端 |
| 111 | + |
| 112 | +### 序列化相关(3个) |
| 113 | + |
| 114 | +- `fit-message-serializer-cbor` - CBOR 格式序列化 |
| 115 | +- `fit-message-serializer-json-jackson` - JSON 格式序列化(Jackson) |
| 116 | +- `fit-value-fastjson` - Fastjson 值支持 |
| 117 | + |
| 118 | +### 服务协调相关(5个,其中1个可选) |
| 119 | + |
| 120 | +- `fit-service-coordination-locator` - 服务定位器 |
| 121 | +- `fit-service-coordination-simple` - 简单服务协调实现(默认) |
| 122 | +- `fit-service-coordination-nacos` - Nacos 服务协调实现(可选,不在 build/plugins) |
| 123 | +- `fit-service-discovery` - 服务发现 |
| 124 | +- `fit-service-registry` - 服务注册 |
| 125 | + |
| 126 | +### 验证和安全(3个) |
| 127 | + |
| 128 | +- `fit-validation-hibernate-jakarta` - Jakarta Bean Validation |
| 129 | +- `fit-validation-hibernate-javax` - Javax Bean Validation |
| 130 | +- `fit-security-simple` - 简单安全实现 |
| 131 | + |
| 132 | +### 动态插件加载(2个,其中1个可选) |
| 133 | + |
| 134 | +- `fit-dynamic-plugin-directory` - 从目录加载插件(默认) |
| 135 | +- `fit-dynamic-plugin-mvn` - 从 Maven 仓库加载插件(可选,不在 build/plugins) |
| 136 | + |
| 137 | +### 其他(2个) |
| 138 | + |
| 139 | +- `fit-actuator` - 应用监控端点 |
| 140 | +- `fit-logger` - 日志组件 |
| 141 | + |
| 142 | +--- |
| 143 | + |
| 144 | +## 源代码位置 |
| 145 | + |
| 146 | +所有 FIT 内置插件的源码位于:`framework/fit/java/fit-builtin/plugins/` |
| 147 | + |
| 148 | +``` |
| 149 | +framework/fit/java/fit-builtin/plugins/ |
| 150 | +├── pom.xml # 父 POM,统一配置 level=4 |
| 151 | +│ |
| 152 | +├── fit-actuator/ |
| 153 | +├── fit-client-http/ |
| 154 | +├── fit-dynamic-plugin-directory/ |
| 155 | +├── fit-dynamic-plugin-mvn/ # 不会自动输出到build/plugins |
| 156 | +├── fit-heartbeat-client/ |
| 157 | +├── fit-http-client-okhttp/ |
| 158 | +├── fit-http-handler-registry/ |
| 159 | +├── fit-http-openapi3-swagger/ |
| 160 | +├── fit-http-server-netty/ |
| 161 | +├── fit-logger/ |
| 162 | +├── fit-message-serializer-cbor/ |
| 163 | +├── fit-message-serializer-json-jackson/ |
| 164 | +├── fit-security-simple/ |
| 165 | +├── fit-server-http/ |
| 166 | +├── fit-service-coordination-locator/ |
| 167 | +├── fit-service-coordination-simple/ |
| 168 | +├── fit-service-coordination-nacos/ # 不会自动输出到build/plugins |
| 169 | +├── fit-service-discovery/ |
| 170 | +├── fit-service-registry/ |
| 171 | +├── fit-validation-hibernate-jakarta/ |
| 172 | +├── fit-validation-hibernate-javax/ |
| 173 | +└── fit-value-fastjson/ |
| 174 | +``` |
| 175 | + |
| 176 | +### 父 POM 配置 |
| 177 | + |
| 178 | +所有 FIT 内置插件继承自 `fit-builtin/plugins/pom.xml`,该文件统一配置了: |
| 179 | + |
| 180 | +```xml |
| 181 | + |
| 182 | +<build> |
| 183 | + <plugins> |
| 184 | + <plugin> |
| 185 | + <groupId>org.fitframework</groupId> |
| 186 | + <artifactId>fit-build-maven-plugin</artifactId> |
| 187 | + <configuration> |
| 188 | + <category>system</category> |
| 189 | + <level>4</level> <!-- 所有子插件继承此配置 --> |
| 190 | + </configuration> |
| 191 | + <executions> |
| 192 | + <execution> |
| 193 | + <id>build-plugin</id> |
| 194 | + <goals> |
| 195 | + <goal>build-plugin</goal> |
| 196 | + </goals> |
| 197 | + </execution> |
| 198 | + <execution> |
| 199 | + <id>package-plugin</id> |
| 200 | + <goals> |
| 201 | + <goal>package-plugin</goal> |
| 202 | + </goals> |
| 203 | + </execution> |
| 204 | + </executions> |
| 205 | + </plugin> |
| 206 | + </plugins> |
| 207 | +</build> |
| 208 | +``` |
0 commit comments