diff --git a/LICENSE b/LICENSE
index 261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64..7fd89d0cd9f6534504279ae8b6bace45eb517f10 100644
--- a/LICENSE
+++ b/LICENSE
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright [yyyy] [name of copyright owner]
+ Copyright [2019-2022] [starBlues]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/README.md b/README.md
index c9ca3a728a03680b12fc2827366c218ed3deceae..b7c06b894456f599f8090ec56b522844fa79a7a0 100644
--- a/README.md
+++ b/README.md
@@ -1,53 +1,29 @@
# SpringBoot Plugin Development Framework
-### Introduce
-This framework can develop plugins for extension projects on the `SpringBoot` project,
-and can define extension functions such as interface, static file and `Mybatis-xml` separately in the plugin module.
-
-### Core
-- Based on `Pf4j` development.
-- Plugin configuration plug in SpringBoot project.
-- Plugin development can be carried out on springboot with strong expansibility.
-Different plugins can be developed for different projects and different plugin jar packages can be deployed.
-- You can specify whether to enable or disable plugins through the configuration file, and you can specify the order in which plugins are started.
-- It supports uploading plugins and plugin configuration files to the server, and dynamically deploying and updating plugins without restarting the main program.
-- It supports viewing plugin operation status and plugin installation location.
-- Without restarting the main program, dynamically install, uninstall, enable, stop, backup and delete plugins through the interface.
-- On the plugin application module, `spring annotations` can be used to define components for dependency injection.
-- Supports the development of `Http-Restful` interfaces in plugins
-- Support to define persistence layer access and other requirements separately in the plugin.
-- You can follow the plugin interface provided by the main program to develop any extended functions.
-- It supports annotation for any business scenario extension, and uses defined coordinates for scenario hit.
-- Plugin can customize independent configuration files according to the production and development environment. Currently only `YML files` are supported.
-- It supports user-defined extension development interface, and users can extend additional functions on the reserved interface.
-- Supports method calls between plugins.
-- Supporting plugin http interface documentation: `Swagger`、`SpringDoc`。
-- The plugin supports custom development of the 'Spring-MVC interceptor`.
-- The plugin supports 'Spring-Aop'.
-
-### Expansion pack
-#### `SpringBoot-Mybatis` Expansion
-
-1. Supports customizing the `mapper` interface, `mapper XML` and the corresponding entity `Bean` in the plugin
-2. Support integration `Mybatis`、`Mybatis-Plus`、`Tk-Mybatis`
-3. Supports independent configuration of `DataSources` in plugin
-
-- See details: [SpringBoot Mybatis Expansion](http://www.starblues.cn/extension-doc/Mybatis%E6%89%A9%E5%B1%95.html)
-
-#### `Static resource access` Extension
-
-1. Supports accessing static resources in plugins through HTTP
-2. Support `Thymeleaf` template engine for interface plugin development
+- A new `3.0.0' version is available, a framework for dynamically extending the system.
-- See details: [Static Resource Access Extension](http://www.starblues.cn/extension-doc/%E9%9D%99%E6%80%81%E8%B5%84%E6%BA%90%E8%AE%BF%E9%97%AE%E6%89%A9%E5%B1%95.html)
-
-#### `Plugin Log` Extension
-
-1. The plugin can independently configure the integrated `logback` log
-2. The plugin can independently configure the integrated `log4j2` log
-
-- See details: [Plugin Log Extension](http://www.starblues.cn/extension-doc/Log%E6%89%A9%E5%B1%95.html)
-- Thank for [sousouki](https://gitee.com/caoshx_sousouki) development
+### Introduce
+The framework can be developed in the `SpringBoot` project plugin, plugin can be used in exactly the same way as `SpringBoot`. Using this framework you can achieve the following requirements:
+
+- In the plugin, you can develop as a mini `spring-boot` project, which is easy to use.
+- The extension of various function points in the system in plugin, for flexible system expansion, no longer need to use branches to deliver different requirements of the project.
+- Various frameworks and their various `spring-boot-XXX-starter` can be integrated in plugin.
+- Independent dependencies can now be defined in plugin, not in the main program.
+- Can perfectly solve the plugin package and plugin package, plugin package and the main program because of the same framework of different versions of the conflict problem. Individual plugin can define different versions of the framework for the same dependency.
+- Without the need to restart the main program, you can freely realize the dynamic installation and deployment of the plugin package, to dynamically expand the function of the system.
+- Plugin can also integrate microservice modules independently of the main program.
+- And so on, you can imagine what pressing needs and extensions this framework brings to you.
+### Features
+1. It simplifies the integration steps of the framework and makes it easier to get started.
+2. Plugin development is closer to `spring-boot` native development.
+3. Package plugin with `Maven` to support independent package compilation of plugins. Current support:
+- Dev packaging: Package the plugin as a development environment plugin (packaged only once).
+- Prod packaging: Package plug-ins into a `jar`, `zip`, `folder`, etc.
+4. Plugin support two modes of operation:
+- Plugin mode: As a plugin, it is bootloaded by the main program.
+- Autonomous boot mode: Starts as a separate `SpringBoot` project。
+5. Self-developed class loader, support plugin definition of a variety of dependent 'jar' packages.
+6. Various frameworks and their various `spring-boot-XXX-starter` can be integrated in plugins, such as integration: `mybatis`、`mybatis-plus`、`spring-jpa` etc.
### Environment
1. jdk1.8+d
@@ -60,7 +36,7 @@ Different plugins can be developed for different projects and different plugin j
### Doc
-- [http://www.starblues.cn/](http://www.starblues.cn/)
+- [https://www.yuque.com/starblues/iuyk4y/ypurcw](https://www.yuque.com/starblues/iuyk4y/ypurcw)
### Derivative products
#### Background management system with front and rear plugin function
@@ -74,9 +50,4 @@ Different plugins can be developed for different projects and different plugin j
### Contact
QQ: 859570617(**After you like the framework, you can enter the group. Please note the Gitee/GitHub nickname before entering the group**)
-### Framework maintenance
-**Welcome all development enthusiasts to participate in the maintenance and extension development of the framework**
-
-See for extended development documents: - [springboot-plugin-framework Extended](http://www.starblues.cn/extension-doc/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%89%A9%E5%B1%95.html)
-
diff --git a/README_zh.md b/README_zh.md
index b5bb0192a5f4dcea7739c8f5025fde87f3d41408..7b14600a2608a4fb2278163715df4ae49e67d42a 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -1,51 +1,43 @@
# springboot插件式开发框架
-### 介绍
-此框架可在`SpringBoot`项目上开发出用于扩展项目的插件,可在插件模块中单独定义接口、静态文件、`Mybatis-xml`等扩展功能。
-
-### 核心功能
-- 基于`Pf4j`开发。
-- 插件配置式插拔于`SpringBoot`项目。
-- 在`SpringBoot`上可以进行插件式开发, 扩展性极强, 可以针对不同项目开发不同插件, 进行不同插件`jar`包的部署。
-- 可通过配置文件指定要启用或者禁用插件, 可以指定启动插件顺序。
-- 支持上传插件和插件配置文件到服务器, 并且无需重启主程序, 动态部署插件、更新插件。
-- 支持查看插件运行状态, 查看插件安装位置。
-- 无需重启主程序, 通过接口动态的安装插件、卸载插件、启用插件、停止插件、备份插件、删除插件。
-- 在插件应用模块上可以使用`Spring`注解定义组件, 进行依赖注入。
-- 支持在插件中开发`Http-Restful`接口。
-- 支持在插件中单独定义持久层访问等需求。
-- 可以遵循主程序提供的插件接口开发任意扩展功能。
-- 支持注解进行任意业务场景扩展, 并使用定义的坐标进行场景命中。
-- 插件可以根据生产和开发环境自定义独立的配置文件。目前只支持yml文件。
-- 支持自定义扩展开发接口, 使用者可以在预留接口上扩展额外功能。
-- 支持插件之间的方法调用。
-- 支持插件`Http`接口文档: `Swagger`、`SpringDoc`。
-- 插件支持`拦截器`的定制开发。
-- 插件对`Spring-Aop`进行支持。
-
-### 扩展包功能
-#### `SpringBoot-Mybatis`扩展包
-
-1. 支持在插件中自定义`Mapper`接口、`Mapper xml` 以及对应的实体`bean`
-2. 支持集成`Mybatis`、`Mybatis-Plus`、`Tk-Mybatis`
-3. 支持可在插件中独立配置数据源
-
-- 详见 [插件SpringBoot Mybatis扩展](http://www.starblues.cn/extension-doc/Mybatis%E6%89%A9%E5%B1%95.html)
-
-#### 静态资源访问扩展包
-
-1. 支持通过http访问插件中静态资源
-2. 支持`Thymeleaf`模板引擎进行界面插件式开发
+- 全新`3.0.0`版本上线啦,为动态扩展系统而生的框架。
-- 详见 [插件静态资源访问扩展](http://www.starblues.cn/extension-doc/%E9%9D%99%E6%80%81%E8%B5%84%E6%BA%90%E8%AE%BF%E9%97%AE%E6%89%A9%E5%B1%95.html)
+### 背景
+在当下后端市场,还是以`SpringBoot`为核心框架进行系统开发,本框架可以在`SpringBoot`系统上进行插件式的开发,将插件当做一个`mini`版本的`SpringBoot`进行系统扩展开发,可以解决如下痛点:
+1. 在`To-B`系统场景中,不同甲方会有不同的需求,在不打分支和改动系统核心代码的前提下,可以在插件中进行扩展开发特定功能,不同甲方使用不同插件,完美解决非核心系统的扩展功能开发。
+2. 在`To-C`系统场景中,可以在主程序通过定义`java-interface`,在插件中做不同实现,来达到动态扩展系统功能。
+3. 在开发中,由于引入了不同版本的依赖,导致系统无法运行,本框架可以完美解决在不同插件中定义不同版本的依赖,从底层进行隔离,以解决引入不同版本依赖冲突的问题。比如可以解决同一个程序同时连接`mysql-5`和`mysql-8`版本数据库。
+4. 在开发中,不同插件依赖不同框架的功能,可以按需引入。比如在插件A引入连接`mysql`、在插件B引入连接`elasticsearch`、在插件C引入连接`oracle`。
+5. 在插件中,可以任意集成不同的非`web`类型的`springboot-xx-starter`,然后将不同插件功能组装起来,以达到一个统一对外提供服务的完整系统,实现系统组装化、插拔化开发。
+6. 在不重启主程序的前提下,对插件进行动态的安装、卸载。
-#### 插件日志扩展包
-
-1. 插件可自主配置集成`logback`日志
-2. 插件可自主配置集成`log4j2`日志
-
-- 详见 [插件静态资源访问扩展](http://www.starblues.cn/extension-doc/Log%E6%89%A9%E5%B1%95.html)
-- 感谢 [sousouki](https://gitee.com/caoshx_sousouki) 的开发提供
+### 介绍
+该框架可以在`SpringBoot`项目上开发出插件功能,在插件中可以和`SpringBoot`使用方式一模一样。使用了本框架您可以实现如下需求:
+
+- 在插件中,您可以当成一个微型的`Spring-Boot`项目来开发,简单易用。
+- 在插件中扩展出系统各种功能点,用于系统灵活扩展,再也不用使用分支来交付不同需求的项目了。
+- 在插件中可以集成各种框架及其各种`spring-boot-xxx-starter`。
+- 在插件中可以定义独立依赖包了,再也不用在主程序中定义依赖包了。
+- 可以完美解决插件包与插件包、插件包与主程序因为同一框架的不同版本冲突问题了。各个插件可以定义同一依赖的不同版本框架。
+- 无需重启主程序,可以自由实现插件包的动态安装部署,来动态扩展系统的功能。
+- 插件也可以不依赖主程序独立集成微服务模块。
+- 您可以丰富想象该框架给您带来哪些迫切的需求和扩展。
+
+### 特性
+1. 简化了框架的集成步骤,更容易上手。
+2. 插件开发更加贴近`spring-boot`原生开发。
+3. 使用`Maven`打包插件,支持对插件的自主打包编译。目前支持:
+
+ 开发打包:将插件打包成开发环境下的插件(仅需打包一次)。
+
+ 生产打包:将插件打包成一个`jar`、`zip`、`文件夹`等。
+4. 插件支持两种运行模式
+
+ 插件模式: 作为一个插件,由主程序引导加载。
+
+ 自主启动模式:单独作为一个`SpringBoot`项目来启动。
+5. 自主的开发的类加载器,支持插件定义各种的依赖`jar`包。
+6. 在插件中可以集成各种框架及其各种`spring-boot-xxx-starter`,比如集成`mybatis`、`mybatis-plus`、`spring-jpa`等。
### 运行环境
1. jdk1.8+
@@ -58,7 +50,7 @@
### 文档地址
-- [http://www.starblues.cn/](http://www.starblues.cn/)
+- [https://www.yuque.com/starblues/springboot-plugin-framework-v3.0.0](https://www.yuque.com/starblues/springboot-plugin-framework-v3.0.0)
### 衍生产品
#### 携带前后端插件功能的后台管理系统
@@ -70,11 +62,4 @@
- [springboot-plugin-framework 功能测试+案例](https://gitee.com/starblues/springboot-plugin-framework-example)
### QQ交流群
-859570617(**点赞框架后可进群, 进群前请备注gitee昵称**)
-
-### 框架维护
-**欢迎各位开发爱好者参与到框架的维护和扩展开发当中**
-
-扩展开发文档见: - [springboot-plugin-framework 扩展功能](http://www.starblues.cn/extension-doc/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%89%A9%E5%B1%95.html)
-
-
+859570617(**点赞框架后可进群, 进群前请备注gitee昵称**)
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c4167139218a22121f9c3863683b944bf626531b..4847d111bc7296a71288fe4cc467b8cd5b75f303 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,17 +4,154 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
+
+ org.sonatype.oss
+ oss-parent
+ 7
+
+
com.gitee.starblues
- springboot-plugin-framework-parent
+ spring-brick-parent
pom
- 2.4.6-RELEASE
-
- spring boot 插件开发集成包
+ 3.0.0
- springboot-plugin-framework
- springboot-plugin-framework-extension
+ spring-brick-common
+ spring-brick-loader
+ spring-brick
+ spring-brick-bootstrap
+ spring-brick-maven-packager
-
+
+
+ 1.8
+ UTF-8
+ 3.8.1
+
+ 3.1.0
+ 3.1.0
+ 3.1.0
+ 1.6
+
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ https://gitee.com/starblues/springboot-plugin-framework-parent
+ scm:https://gitee.com/starblues/springboot-plugin-framework-parent.git
+ scm:https://gitee.com/starblues/springboot-plugin-framework-parent.git
+ 1.0
+
+
+
+
+ sonatype-nexus-snapshots
+ oss Snapshots Repository
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
+ sonatype-nexus-staging
+ oss Staging Repository
+ https://oss.sonatype.org/service/local/staging/deploy/maven2/
+
+
+
+
+
+ StarBlues
+ starblues@foxmail.com
+ https://gitee.com/starblues/
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+ ${java.version}
+ ${java.version}
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ ${maven-source-plugin.version}
+
+
+ package
+
+ jar-no-fork
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ ${maven-javadoc-plugin.version}
+
+ ${plugin.skip}
+
+
+
+ package
+
+ jar
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ ${maven-gpg-plugin.version}
+
+ ${plugin.skip}
+
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+
+
+
+
+
+
+
+
+ dev
+
+ true
+
+
+ true
+
+
+
+
+ release
+
+ false
+
+
+
+
\ No newline at end of file
diff --git a/spring-brick-bootstrap/pom.xml b/spring-brick-bootstrap/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..45d8b2eae1672249fe32db34623a6f63f4327cd0
--- /dev/null
+++ b/spring-brick-bootstrap/pom.xml
@@ -0,0 +1,88 @@
+
+
+ 4.0.0
+
+
+ spring-brick-parent
+ com.gitee.starblues
+ 3.0.0
+
+
+ spring-brick-bootstrap
+ jar
+
+ 插件引导模块
+
+
+ 1.8
+ UTF-8
+ 3.8.1
+
+ 3.0.0
+
+ 1.9.6
+ 1.7.7
+ 2.11.3
+
+ 2.5.6
+ 5.3.2
+ 4.0.1
+ 1.6.5
+
+
+
+
+ org.aspectj
+ aspectjweaver
+ ${aspectj.version}
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+ com.gitee.starblues
+ spring-brick
+ ${project.version}
+ provided
+ true
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
+
+ org.springframework.boot
+ spring-boot
+ ${spring-boot.version}
+ provided
+ true
+
+
+ org.springframework
+ spring-webmvc
+ ${spring.version}
+ provided
+ true
+
+
+ org.springdoc
+ springdoc-openapi-common
+ ${springdoc.version}
+ provided
+ true
+
+
+ javax.servlet
+ javax.servlet-api
+ ${javax.servlet-api.version}
+ provided
+ true
+
+
+
+
\ No newline at end of file
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ConfigureMainPluginEnvironment.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ConfigureMainPluginEnvironment.java
new file mode 100644
index 0000000000000000000000000000000000000000..c2e0080564535f9d08d943077d88ce6882844b22
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ConfigureMainPluginEnvironment.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap;
+
+import com.gitee.starblues.bootstrap.annotation.OneselfConfig;
+import com.gitee.starblues.bootstrap.processor.ProcessorContext;
+import com.gitee.starblues.bootstrap.utils.AnnotationUtils;
+import com.gitee.starblues.utils.ObjectUtils;
+import com.gitee.starblues.utils.ResourceUtils;
+import org.springframework.boot.env.PropertiesPropertySourceLoader;
+import org.springframework.boot.env.PropertySourceLoader;
+import org.springframework.boot.env.YamlPropertySourceLoader;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.PropertySource;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+import org.springframework.util.ClassUtils;
+
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+
+/**
+ * 插件环境配置
+ * @author starBlues
+ * @version 3.0.0
+ */
+class ConfigureMainPluginEnvironment {
+
+ private final ProcessorContext processorContext;
+ private final List propertySourceLoaders;
+
+ ConfigureMainPluginEnvironment(ProcessorContext processorContext) {
+ this.processorContext = processorContext;
+
+ this.propertySourceLoaders = new ArrayList<>(2);
+ this.propertySourceLoaders.add(new YamlPropertySourceLoader());
+ this.propertySourceLoaders.add(new PropertiesPropertySourceLoader());
+ }
+
+ void configureEnvironment(ConfigurableEnvironment environment, String[] args) {
+ SpringPluginBootstrap springPluginBootstrap = processorContext.getSpringPluginBootstrap();
+ OneselfConfig oneselfConfig = AnnotationUtils.findAnnotation(springPluginBootstrap.getClass(),
+ OneselfConfig.class);
+ if(oneselfConfig == null){
+ return;
+ }
+ String[] mainConfigFileName = oneselfConfig.mainConfigFileName();
+ if(mainConfigFileName.length == 0){
+ return;
+ }
+ for (String fileName : mainConfigFileName) {
+ load(environment, fileName);
+ }
+ }
+
+
+ private void load(ConfigurableEnvironment environment, String fileName){
+ String fileSuffix = ResourceUtils.getFileSuffix(fileName);
+ if(ObjectUtils.isEmpty(fileSuffix)){
+ return;
+ }
+ PropertySourceLoader sourceLoader = null;
+ for (PropertySourceLoader propertySourceLoader : propertySourceLoaders) {
+ String[] fileExtensions = propertySourceLoader.getFileExtensions();
+ for (String fileExtension : fileExtensions) {
+ if(fileSuffix.equalsIgnoreCase(fileExtension)){
+ sourceLoader = propertySourceLoader;
+ break;
+ }
+ }
+ }
+ if(sourceLoader == null){
+ return;
+ }
+ URL url = Objects.requireNonNull(ClassUtils.getDefaultClassLoader()).getResource(fileName);
+ if(url == null){
+ return;
+ }
+ try {
+ Path path = Paths.get(url.toURI());
+ Resource resource = new FileSystemResource(path);
+ List> propertySources = sourceLoader.load(fileName, resource);
+ for (PropertySource> propertySource : propertySources) {
+ environment.getPropertySources().addFirst(propertySource);
+ }
+ } catch (Exception e){
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ConfigurePluginEnvironment.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ConfigurePluginEnvironment.java
new file mode 100644
index 0000000000000000000000000000000000000000..c159c6e9b470648b34f8885e72c18d9f2c539328
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ConfigurePluginEnvironment.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap;
+
+import com.gitee.starblues.bootstrap.processor.ProcessorContext;
+import com.gitee.starblues.core.descriptor.InsidePluginDescriptor;
+import com.gitee.starblues.integration.AutoIntegrationConfiguration;
+import com.gitee.starblues.utils.Assert;
+import com.gitee.starblues.utils.FilesUtils;
+import com.gitee.starblues.utils.ObjectUtils;
+import com.gitee.starblues.utils.PluginFileUtils;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.MapPropertySource;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 插件环境配置
+ * @author starBlues
+ * @version 3.0.0
+ */
+class ConfigurePluginEnvironment {
+
+ private final static String PLUGIN_PROPERTY_NAME = "pluginPropertySources";
+
+ private final static String SPRING_CONFIG_NAME = "spring.config.name";
+ private final static String SPRING_CONFIG_LOCATION = "spring.config.location";
+
+ private final static String SPRING_JMX_UNIQUE_NAMES = "spring.jmx.unique-names";
+ private final static String SPRING_ADMIN_JMX_NAME = "spring.application.admin.jmx-name";
+ private final static String SPRING_ADMIN_JMX_VALUE = "org.springframework.boot:type=Admin,name=";
+
+ public static final String REGISTER_SHUTDOWN_HOOK_PROPERTY = "logging.register-shutdown-hook";
+ public static final String MBEAN_DOMAIN_PROPERTY_NAME = "spring.liveBeansView.mbeanDomain";
+
+ private final ProcessorContext processorContext;
+ private final InsidePluginDescriptor pluginDescriptor;
+
+ ConfigurePluginEnvironment(ProcessorContext processorContext) {
+ this.processorContext = Assert.isNotNull(processorContext, "processorContext 不能为空");
+ this.pluginDescriptor = Assert.isNotNull(processorContext.getPluginDescriptor(),
+ "pluginDescriptor 不能为空");
+ }
+
+ void configureEnvironment(ConfigurableEnvironment environment, String[] args) {
+ Map env = new HashMap<>();
+ String pluginId = pluginDescriptor.getPluginId();
+ String configFileName = pluginDescriptor.getConfigFileName();
+ if(!ObjectUtils.isEmpty(configFileName)){
+ env.put(SPRING_CONFIG_NAME, PluginFileUtils.getFileName(configFileName));
+ }
+ String configFileLocation = pluginDescriptor.getConfigFileLocation();
+ if(!ObjectUtils.isEmpty(configFileLocation)){
+ env.put(SPRING_CONFIG_LOCATION, getConfigFileLocation(configFileLocation));
+ }
+ env.put(AutoIntegrationConfiguration.ENABLE_STARTER_KEY, false);
+ env.put(SPRING_JMX_UNIQUE_NAMES, true);
+ env.put(SPRING_ADMIN_JMX_NAME, SPRING_ADMIN_JMX_VALUE + pluginId);
+ env.put(REGISTER_SHUTDOWN_HOOK_PROPERTY, false);
+ env.put(MBEAN_DOMAIN_PROPERTY_NAME, pluginId);
+ environment.getPropertySources().addFirst(new MapPropertySource(PLUGIN_PROPERTY_NAME, env));
+
+ if(processorContext.runMode() == ProcessorContext.RunMode.ONESELF){
+ ConfigureMainPluginEnvironment configureMainPluginEnvironment =
+ new ConfigureMainPluginEnvironment(processorContext);
+ configureMainPluginEnvironment.configureEnvironment(environment, args);
+ }
+ }
+
+ private String getConfigFileLocation(String configFileLocation){
+ String s = FilesUtils.resolveRelativePath(new File("").getAbsolutePath(), configFileLocation);
+ if(s.endsWith("/") || s.endsWith(File.separator)){
+ return s;
+ } else {
+ return s + File.separator;
+ }
+ }
+
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/DefaultSpringPluginHook.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/DefaultSpringPluginHook.java
new file mode 100644
index 0000000000000000000000000000000000000000..7e47ff442de99e8e45e2ca9ae8d38b443e44cbf8
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/DefaultSpringPluginHook.java
@@ -0,0 +1,124 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap;
+
+import com.gitee.starblues.bootstrap.processor.ProcessorContext;
+import com.gitee.starblues.bootstrap.processor.SpringPluginProcessor;
+import com.gitee.starblues.bootstrap.processor.web.thymeleaf.PluginThymeleafProcessor;
+import com.gitee.starblues.bootstrap.realize.PluginCloseListener;
+import com.gitee.starblues.bootstrap.realize.StopValidator;
+import com.gitee.starblues.bootstrap.utils.DestroyUtils;
+import com.gitee.starblues.bootstrap.utils.SpringBeanUtils;
+import com.gitee.starblues.core.exception.PluginProhibitStopException;
+import com.gitee.starblues.spring.ApplicationContext;
+import com.gitee.starblues.spring.ApplicationContextProxy;
+import com.gitee.starblues.spring.SpringPluginHook;
+import com.gitee.starblues.spring.WebConfig;
+import com.gitee.starblues.spring.web.thymeleaf.ThymeleafConfig;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.support.SpringFactoriesLoader;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 默认的插件钩子器
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class DefaultSpringPluginHook implements SpringPluginHook {
+
+ private final SpringPluginProcessor pluginProcessor;
+ private final ProcessorContext processorContext;
+ private final StopValidator stopValidator;
+
+ public DefaultSpringPluginHook(SpringPluginProcessor pluginProcessor,
+ ProcessorContext processorContext) {
+ this.pluginProcessor = pluginProcessor;
+ this.processorContext = processorContext;
+ this.stopValidator = SpringBeanUtils.getExistBean(processorContext.getApplicationContext(),
+ StopValidator.class);
+ }
+
+ /**
+ * 先校验是否可卸载
+ */
+ @Override
+ public void stopVerify() {
+ if(stopValidator == null){
+ return;
+ }
+ try {
+ StopValidator.Result result = stopValidator.verify();
+ if(result != null && !result.isVerify()){
+ throw new PluginProhibitStopException(processorContext.getPluginDescriptor(),
+ result.getMessage());
+ }
+ } catch (Exception e){
+ throw new PluginProhibitStopException(processorContext.getPluginDescriptor(),
+ e.getMessage());
+ }
+ }
+
+
+ @Override
+ public void close() throws Exception{
+ try {
+ GenericApplicationContext applicationContext = processorContext.getApplicationContext();
+ callPluginCloseListener(applicationContext);
+ pluginProcessor.close(processorContext);
+ if(applicationContext != null){
+ applicationContext.close();
+ }
+ processorContext.clearRegistryInfo();
+ DestroyUtils.destroyAll(null, SpringFactoriesLoader.class, "cache", Map.class);
+ } catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public ApplicationContext getApplicationContext() {
+ return new ApplicationContextProxy(processorContext.getApplicationContext().getBeanFactory());
+ }
+
+ @Override
+ public WebConfig getWebConfig() {
+ return processorContext.getWebConfig();
+ }
+
+ @Override
+ public ThymeleafConfig getThymeleafConfig() {
+ return processorContext.getRegistryInfo(PluginThymeleafProcessor.CONFIG_KEY);
+ }
+
+ private void callPluginCloseListener(GenericApplicationContext applicationContext){
+ List pluginCloseListeners = SpringBeanUtils.getBeans(
+ applicationContext, PluginCloseListener.class);
+ if(pluginCloseListeners.isEmpty()){
+ return;
+ }
+ for (PluginCloseListener pluginCloseListener : pluginCloseListeners) {
+ try {
+ pluginCloseListener.close(processorContext.getPluginDescriptor());
+ } catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptyMainApplicationContext.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptyMainApplicationContext.java
new file mode 100644
index 0000000000000000000000000000000000000000..53a55368e9971b990a1ed3c039d4ede5e69f721f
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptyMainApplicationContext.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap;
+
+import com.gitee.starblues.spring.MainApplicationContext;
+import com.gitee.starblues.spring.SpringBeanFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.core.ResolvableType;
+
+import java.lang.annotation.Annotation;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 空的MainApplicationContext实现
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class EmptyMainApplicationContext implements MainApplicationContext {
+
+ private final SpringBeanFactory springBeanFactory = new EmptySpringBeanFactory();
+
+ @Override
+ public SpringBeanFactory getSpringBeanFactory() {
+ return springBeanFactory;
+ }
+
+ @Override
+ public void close() throws Exception {
+
+ }
+
+ @Override
+ public Map> getConfigurableEnvironment() {
+ return Collections.emptyMap();
+ }
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptySpringBeanFactory.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptySpringBeanFactory.java
new file mode 100644
index 0000000000000000000000000000000000000000..b784bd5503633f70836893593d9e9ce8a399a855
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptySpringBeanFactory.java
@@ -0,0 +1,178 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap;
+
+import com.gitee.starblues.spring.SpringBeanFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.core.ResolvableType;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+
+/**
+ * 空的 SpringBeanFactory 实现
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class EmptySpringBeanFactory implements SpringBeanFactory {
+ @Override
+ public boolean containsBeanDefinition(String beanName) {
+ return false;
+ }
+
+ @Override
+ public int getBeanDefinitionCount() {
+ return 0;
+ }
+
+ @Override
+ public String[] getBeanDefinitionNames() {
+ return new String[0];
+ }
+
+ @Override
+ public ObjectProvider getBeanProvider(Class requiredType, boolean allowEagerInit) {
+ return null;
+ }
+
+ @Override
+ public ObjectProvider getBeanProvider(ResolvableType requiredType, boolean allowEagerInit) {
+ return null;
+ }
+
+ @Override
+ public String[] getBeanNamesForType(ResolvableType type) {
+ return new String[0];
+ }
+
+ @Override
+ public String[] getBeanNamesForType(ResolvableType type, boolean includeNonSingletons, boolean allowEagerInit) {
+ return new String[0];
+ }
+
+ @Override
+ public String[] getBeanNamesForType(Class> type) {
+ return new String[0];
+ }
+
+ @Override
+ public String[] getBeanNamesForType(Class> type, boolean includeNonSingletons, boolean allowEagerInit) {
+ return new String[0];
+ }
+
+ @Override
+ public Map getBeansOfType(Class type) throws BeansException {
+ return null;
+ }
+
+ @Override
+ public Map getBeansOfType(Class type, boolean includeNonSingletons, boolean allowEagerInit) throws BeansException {
+ return null;
+ }
+
+ @Override
+ public String[] getBeanNamesForAnnotation(Class extends Annotation> annotationType) {
+ return new String[0];
+ }
+
+ @Override
+ public Map getBeansWithAnnotation(Class extends Annotation> annotationType) throws BeansException {
+ return null;
+ }
+
+ @Override
+ public A findAnnotationOnBean(String beanName, Class annotationType) throws NoSuchBeanDefinitionException {
+ return null;
+ }
+
+ @Override
+ public Object getBean(String name) throws BeansException {
+ return null;
+ }
+
+ @Override
+ public T getBean(String name, Class requiredType) throws BeansException {
+ return null;
+ }
+
+ @Override
+ public Object getBean(String name, Object... args) throws BeansException {
+ return null;
+ }
+
+ @Override
+ public T getBean(Class requiredType) throws BeansException {
+ return null;
+ }
+
+ @Override
+ public T getBean(Class requiredType, Object... args) throws BeansException {
+ return null;
+ }
+
+ @Override
+ public ObjectProvider getBeanProvider(Class requiredType) {
+ return null;
+ }
+
+ @Override
+ public ObjectProvider getBeanProvider(ResolvableType requiredType) {
+ return null;
+ }
+
+ @Override
+ public boolean containsBean(String name) {
+ return false;
+ }
+
+ @Override
+ public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
+ return false;
+ }
+
+ @Override
+ public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
+ return false;
+ }
+
+ @Override
+ public boolean isTypeMatch(String name, ResolvableType typeToMatch) throws NoSuchBeanDefinitionException {
+ return false;
+ }
+
+ @Override
+ public boolean isTypeMatch(String name, Class> typeToMatch) throws NoSuchBeanDefinitionException {
+ return false;
+ }
+
+ @Override
+ public Class> getType(String name) throws NoSuchBeanDefinitionException {
+ return null;
+ }
+
+ @Override
+ public Class> getType(String name, boolean allowFactoryBeanInit) throws NoSuchBeanDefinitionException {
+ return null;
+ }
+
+ @Override
+ public String[] getAliases(String name) {
+ return new String[0];
+ }
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginApplicationContext.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginApplicationContext.java
new file mode 100644
index 0000000000000000000000000000000000000000..2ed37d010bff52beae6cdfe2b5745d590b5a3e35
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginApplicationContext.java
@@ -0,0 +1,60 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap;
+
+import com.gitee.starblues.bootstrap.processor.ProcessorContext;
+import com.gitee.starblues.core.descriptor.PluginDescriptor;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * 插件ApplicationContext实现
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class PluginApplicationContext extends AnnotationConfigApplicationContext {
+
+ private final PluginDescriptor pluginDescriptor;
+
+ public PluginApplicationContext(DefaultListableBeanFactory beanFactory,
+ ProcessorContext processorContext) {
+ super(beanFactory);
+ setResourceLoader(processorContext.getResourceLoader());
+ this.pluginDescriptor = processorContext.getPluginDescriptor();
+ }
+
+ @Override
+ public void registerShutdownHook() {
+ // 忽略
+ }
+
+ @Override
+ public String getApplicationName() {
+ return pluginDescriptor.getPluginId();
+ }
+
+ @Override
+ public void refresh() throws BeansException, IllegalStateException {
+ super.refresh();
+ }
+
+ @Override
+ public void close() {
+ super.close();
+ }
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginListableBeanFactory.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginListableBeanFactory.java
new file mode 100644
index 0000000000000000000000000000000000000000..fda812953dfe96df79455ce6c412c62db5e3777f
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginListableBeanFactory.java
@@ -0,0 +1,100 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap;
+
+import com.gitee.starblues.bootstrap.utils.DestroyUtils;
+import com.gitee.starblues.spring.MainApplicationContext;
+import com.gitee.starblues.spring.SpringBeanFactory;
+import com.gitee.starblues.utils.ObjectUtils;
+import com.gitee.starblues.utils.ReflectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.TypeConverter;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.DependencyDescriptor;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.lang.Nullable;
+
+import java.util.Set;
+
+/**
+ * 插件BeanFactory实现
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class PluginListableBeanFactory extends DefaultListableBeanFactory {
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ private final MainApplicationContext applicationContext;
+
+ public PluginListableBeanFactory(MainApplicationContext applicationContext) {
+ this.applicationContext = applicationContext;
+ }
+
+ @Override
+ public Object resolveDependency(DependencyDescriptor descriptor,
+ @Nullable String requestingBeanName,
+ @Nullable Set autowiredBeanNames,
+ @Nullable TypeConverter typeConverter) throws BeansException {
+
+ try {
+ return super.resolveDependency(descriptor, requestingBeanName, autowiredBeanNames, typeConverter);
+ } catch (BeansException e){
+ return resolveDependencyFromMain(descriptor);
+ }
+ }
+
+ private Object resolveDependencyFromMain(DependencyDescriptor descriptor){
+ String dependencyName = descriptor.getDependencyName();
+ SpringBeanFactory springBeanFactory = applicationContext.getSpringBeanFactory();
+ if(!ObjectUtils.isEmpty(dependencyName) && springBeanFactory.containsBean(dependencyName)){
+ return springBeanFactory.getBean(dependencyName);
+ } else {
+ try {
+ return springBeanFactory.getBean(descriptor.getDependencyType());
+ } catch (Exception e){
+ throw new NoSuchBeanDefinitionException(descriptor.getDependencyType());
+ }
+ }
+ }
+
+ @Override
+ public void destroySingletons() {
+ String[] beanDefinitionNames = getBeanDefinitionNames();
+ for (String beanDefinitionName : beanDefinitionNames) {
+ destroyBean(beanDefinitionName);
+ }
+ super.destroySingletons();
+ destroyAll();
+ }
+
+ private void destroyAll(){
+ ReflectionUtils.findField(this.getClass(), field -> {
+ field.setAccessible(true);
+ try {
+ Object o = field.get(this);
+ DestroyUtils.destroyAll(o);
+ } catch (IllegalAccessException e) {
+ // 忽略
+ }
+ return false;
+ });
+ }
+
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginOneselfInteractive.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginOneselfInteractive.java
new file mode 100644
index 0000000000000000000000000000000000000000..dfd07faeeb4f2456ea7d0db2b670b93d27474ced
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginOneselfInteractive.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap;
+
+import com.gitee.starblues.common.PackageStructure;
+import com.gitee.starblues.core.descriptor.DevPluginDescriptorLoader;
+import com.gitee.starblues.core.descriptor.InsidePluginDescriptor;
+import com.gitee.starblues.core.descriptor.PluginDescriptorLoader;
+import com.gitee.starblues.core.launcher.plugin.PluginInteractive;
+import com.gitee.starblues.integration.AutoIntegrationConfiguration;
+import com.gitee.starblues.integration.IntegrationConfiguration;
+import com.gitee.starblues.spring.MainApplicationContext;
+import com.gitee.starblues.spring.extract.DefaultOpExtractFactory;
+import com.gitee.starblues.spring.extract.OpExtractFactory;
+import com.gitee.starblues.spring.invoke.DefaultInvokeSupperCache;
+import com.gitee.starblues.spring.invoke.InvokeSupperCache;
+import com.gitee.starblues.utils.FilesUtils;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * 插件自己的Interactive
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class PluginOneselfInteractive implements PluginInteractive {
+
+ private final InsidePluginDescriptor pluginDescriptor;
+ private final MainApplicationContext mainApplicationContext;
+ private final IntegrationConfiguration configuration;
+ private final InvokeSupperCache invokeSupperCache;
+ private final OpExtractFactory opExtractFactory;
+
+ public PluginOneselfInteractive(){
+ this.pluginDescriptor = createPluginDescriptor();
+ this.mainApplicationContext = new EmptyMainApplicationContext();
+ this.configuration = new AutoIntegrationConfiguration();
+ this.invokeSupperCache = new DefaultInvokeSupperCache();
+ this.opExtractFactory = new DefaultOpExtractFactory();
+ }
+
+ @Override
+ public InsidePluginDescriptor getPluginDescriptor() {
+ return pluginDescriptor;
+ }
+
+ @Override
+ public MainApplicationContext getMainApplicationContext() {
+ return mainApplicationContext;
+ }
+
+ @Override
+ public IntegrationConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ public InvokeSupperCache getInvokeSupperCache() {
+ return invokeSupperCache;
+ }
+
+ @Override
+ public OpExtractFactory getOpExtractFactory() {
+ return opExtractFactory;
+ }
+
+ private InsidePluginDescriptor createPluginDescriptor(){
+ try (PluginDescriptorLoader pluginDescriptorLoader = new DevPluginDescriptorLoader()){
+ Path classesPath = Paths.get(this.getClass().getResource("/").toURI()).getParent();
+ String metaInf = FilesUtils.joiningFilePath(classesPath.toString(), PackageStructure.META_INF_NAME);
+ InsidePluginDescriptor pluginDescriptor = pluginDescriptorLoader.load(Paths.get(metaInf));
+ if(pluginDescriptor == null){
+ throw new RuntimeException("没有发现插件信息, 请使用框架提供的Maven插件器对插件进行编译!");
+ }
+ return pluginDescriptor;
+ } catch (Exception e){
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginSpringApplication.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginSpringApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..c46e5f620dc5cd40e42cca43844a988b117df61f
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginSpringApplication.java
@@ -0,0 +1,120 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap;
+
+import com.gitee.starblues.bootstrap.processor.ProcessorContext;
+import com.gitee.starblues.bootstrap.processor.SpringPluginProcessor;
+import com.gitee.starblues.spring.ApplicationContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.boot.Banner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.StandardEnvironment;
+import org.springframework.core.io.ResourceLoader;
+
+/**
+ * 插件SpringApplication实现
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class PluginSpringApplication extends SpringApplication {
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ private final ProcessorContext.RunMode runMode;
+
+ private final SpringPluginProcessor pluginProcessor;
+ private final ProcessorContext processorContext;
+
+ private final GenericApplicationContext applicationContext;
+
+ private final DefaultListableBeanFactory beanFactory;
+ private final ResourceLoader resourceLoader;
+ private final ConfigurePluginEnvironment configurePluginEnvironment;
+
+ public PluginSpringApplication(SpringPluginProcessor pluginProcessor,
+ ProcessorContext processorContext,
+ Class>... primarySources) {
+ super(primarySources);
+ this.runMode = processorContext.runMode();
+ this.pluginProcessor = pluginProcessor;
+ this.processorContext = processorContext;
+ this.resourceLoader = processorContext.getResourceLoader();
+ this.beanFactory = new PluginListableBeanFactory(processorContext.getMainApplicationContext());
+ this.configurePluginEnvironment = new ConfigurePluginEnvironment(processorContext);
+ this.applicationContext = getApplicationContext();
+ setDefaultPluginConfig();
+ }
+
+ protected GenericApplicationContext getApplicationContext(){
+ if(runMode == ProcessorContext.RunMode.ONESELF){
+ return (GenericApplicationContext) super.createApplicationContext();
+ } else {
+ return new PluginApplicationContext(beanFactory, processorContext);
+ }
+ }
+
+ public void setDefaultPluginConfig(){
+ if(runMode == ProcessorContext.RunMode.PLUGIN){
+ setResourceLoader(resourceLoader);
+ setBannerMode(Banner.Mode.OFF);
+ setEnvironment(new StandardEnvironment());
+ setWebApplicationType(WebApplicationType.NONE);
+ setRegisterShutdownHook(false);
+ setLogStartupInfo(false);
+ }
+ }
+
+ @Override
+ protected void configureEnvironment(ConfigurableEnvironment environment, String[] args) {
+ super.configureEnvironment(environment, args);
+ configurePluginEnvironment.configureEnvironment(environment, args);
+ }
+
+ @Override
+ protected ConfigurableApplicationContext createApplicationContext() {
+ return this.applicationContext;
+ }
+
+ @Override
+ public ConfigurableApplicationContext run(String... args) {
+ try {
+ processorContext.setApplicationContext(this.applicationContext);
+ pluginProcessor.initialize(processorContext);
+ return super.run(args);
+ } catch (Exception e) {
+ pluginProcessor.failure(processorContext);
+ logger.error("启动插件[{}]失败. {}",
+ processorContext.getPluginDescriptor().getPluginId(),
+ e.getMessage(), e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ protected void refresh(ConfigurableApplicationContext applicationContext) {
+ pluginProcessor.refreshBefore(processorContext);
+ super.refresh(applicationContext);
+ pluginProcessor.refreshAfter(processorContext);
+ }
+
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/SpringPluginBootstrap.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/SpringPluginBootstrap.java
new file mode 100644
index 0000000000000000000000000000000000000000..b54de8b32a9287fa8f8fda930b130ff5e066d585
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/SpringPluginBootstrap.java
@@ -0,0 +1,99 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap;
+
+import com.gitee.starblues.bootstrap.processor.ComposeSpringPluginProcessor;
+import com.gitee.starblues.bootstrap.processor.DefaultProcessorContext;
+import com.gitee.starblues.bootstrap.processor.ProcessorContext;
+import com.gitee.starblues.bootstrap.processor.SpringPluginProcessor;
+import com.gitee.starblues.core.launcher.plugin.PluginInteractive;
+import com.gitee.starblues.spring.SpringPluginHook;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 插件引导抽象类。插件入口需集成本抽象类
+ * @author starBlues
+ * @version 3.0.0
+ */
+public abstract class SpringPluginBootstrap {
+
+ private ProcessorContext.RunMode runMode = ProcessorContext.RunMode.ONESELF;
+
+ private volatile PluginInteractive pluginInteractive;
+
+ private final List customPluginProcessors = new ArrayList<>();
+
+ public final SpringPluginHook run(String[] args){
+ return run(this.getClass(), args);
+ }
+
+ public final SpringPluginHook run(Class> primarySources, String[] args){
+ return run(new Class[]{ primarySources }, args);
+ }
+
+ public final SpringPluginHook run(Class>[] primarySources, String[] args){
+ return start(primarySources, args);
+ }
+
+ private SpringPluginHook start(Class>[] primarySources, String[] args){
+ createPluginInteractive();
+ addCustomSpringPluginProcessor();
+ SpringPluginProcessor pluginProcessor = new ComposeSpringPluginProcessor(runMode, customPluginProcessors);
+ ProcessorContext processorContext = new DefaultProcessorContext(
+ runMode, this, pluginInteractive, this.getClass()
+ );
+ PluginSpringApplication springApplication = new PluginSpringApplication(
+ pluginProcessor,
+ processorContext,
+ primarySources);
+ springApplication.run(args);
+ return new DefaultSpringPluginHook(pluginProcessor, processorContext);
+ }
+
+ public final SpringPluginBootstrap setPluginInteractive(PluginInteractive pluginInteractive) {
+ this.pluginInteractive = pluginInteractive;
+ this.runMode = ProcessorContext.RunMode.PLUGIN;
+ return this;
+ }
+
+ public final SpringPluginBootstrap addSpringPluginProcessor(SpringPluginProcessor springPluginProcessor){
+ if(springPluginProcessor != null){
+ customPluginProcessors.add(springPluginProcessor);
+ }
+ return this;
+ }
+
+ protected final void createPluginInteractive(){
+ if(pluginInteractive != null){
+ return;
+ }
+ createPluginInteractiveOfOneself();
+ }
+
+ protected final void createPluginInteractiveOfOneself(){
+ this.pluginInteractive = new PluginOneselfInteractive();
+ }
+
+
+ /**
+ * 子类自定义插件 SpringPluginProcessor
+ */
+ protected void addCustomSpringPluginProcessor(){}
+
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/DisablePluginWeb.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/DisablePluginWeb.java
new file mode 100644
index 0000000000000000000000000000000000000000..9a4fba0dab474e6ae6ec8c4fd319ee53d5bb9de8
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/DisablePluginWeb.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * 禁用web环境. 如果该注解加入到入口类上, 表示当前插件禁用web的功能。
+ * 包括:controller注册、拦截器注册、web静态资源访问、thymeleaf模板引擎
+ * @author starBlues
+ * @version 3.0.0
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface DisablePluginWeb {
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/OneselfConfig.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/OneselfConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..1af29cd5fb749b474a9191dea2c819a852bff514
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/OneselfConfig.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * 插件自主运行配置
+ * @author starBlues
+ * @version 3.0.0
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface OneselfConfig {
+
+ /**
+ * 主程序配置文件名称
+ * @return String[]
+ */
+ String[] mainConfigFileName() default {};
+
+
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ComposeSpringPluginProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ComposeSpringPluginProcessor.java
new file mode 100644
index 0000000000000000000000000000000000000000..05d48476a050b42a822b4235f3971118812427c9
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ComposeSpringPluginProcessor.java
@@ -0,0 +1,186 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.processor;
+
+import com.gitee.starblues.bootstrap.SpringPluginBootstrap;
+import com.gitee.starblues.bootstrap.annotation.DisablePluginWeb;
+import com.gitee.starblues.bootstrap.processor.web.PluginControllerProcessor;
+import com.gitee.starblues.bootstrap.processor.web.PluginInterceptorsProcessor;
+import com.gitee.starblues.bootstrap.processor.web.PluginSpringDocControllerProcessor;
+import com.gitee.starblues.bootstrap.processor.web.PluginStaticResourceProcessor;
+import com.gitee.starblues.bootstrap.processor.web.thymeleaf.PluginThymeleafProcessor;
+import com.gitee.starblues.bootstrap.utils.AnnotationUtils;
+import com.gitee.starblues.bootstrap.utils.ProcessorUtils;
+import com.gitee.starblues.utils.OrderUtils;
+import com.gitee.starblues.utils.ObjectUtils;
+import com.gitee.starblues.utils.OrderPriority;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 组合的处理器
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class ComposeSpringPluginProcessor implements SpringPluginProcessor {
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ private final ProcessorContext.RunMode runMode;
+
+ private List processors;
+
+ public ComposeSpringPluginProcessor(ProcessorContext.RunMode runMode) {
+ this(runMode, null);
+ }
+
+ public ComposeSpringPluginProcessor(ProcessorContext.RunMode runMode, List processors) {
+ this.runMode = runMode;
+ if(!ObjectUtils.isEmpty(processors)){
+ this.processors = processors;
+ } else {
+ this.processors = new ArrayList<>();
+ }
+ }
+
+ public void addSpringPluginProcessor(SpringPluginProcessor springPluginProcessor){
+ if(springPluginProcessor != null){
+ this.processors.add(springPluginProcessor);
+ }
+ }
+
+ @Override
+ public void initialize(ProcessorContext context) throws ProcessorException {
+ List processors = new ArrayList<>();
+ addDefaultProcessors(context, processors);
+ addDefaultWebEnvProcessors(context, processors);
+ processors.addAll(this.processors);
+ this.processors = processors.stream()
+ .filter(p->{
+ ProcessorContext.RunMode runMode = p.runMode();
+ return runMode == ProcessorContext.RunMode.ALL || runMode == this.runMode;
+ })
+ .sorted(OrderUtils.orderPriority(SpringPluginProcessor::order))
+ .collect(Collectors.toList());
+ for (SpringPluginProcessor processor : this.processors) {
+ try {
+ processor.initialize(context);
+ } catch (Throwable e){
+ processException(processor, "initialize", e, true);
+ }
+ }
+ }
+
+ @Override
+ public void refreshBefore(ProcessorContext context) throws ProcessorException {
+ for (SpringPluginProcessor processor : processors) {
+ try {
+ processor.refreshBefore(context);
+ } catch (Throwable e){
+ processException(processor, "refreshBefore", e, true);
+ }
+ }
+ }
+
+ @Override
+ public void refreshAfter(ProcessorContext context) throws ProcessorException {
+ for (SpringPluginProcessor processor : processors) {
+ try {
+ processor.refreshAfter(context);
+ } catch (Throwable e){
+ processException(processor, "refreshAfter", e, true);
+ }
+ }
+ }
+
+ @Override
+ public void failure(ProcessorContext context) throws ProcessorException {
+ for (SpringPluginProcessor processor : processors) {
+ try {
+ processor.failure(context);
+ } catch (Throwable e){
+ processException(processor, "failure", e, false);
+ }
+ }
+ }
+
+ @Override
+ public void close(ProcessorContext context) throws ProcessorException {
+ for (SpringPluginProcessor processor : processors) {
+ try {
+ processor.close(context);
+ } catch (Throwable e){
+ processException(processor, "close", e, false);
+ }
+ }
+ }
+
+ @Override
+ public OrderPriority order() {
+ return OrderPriority.getHighPriority();
+ }
+
+ @Override
+ public ProcessorContext.RunMode runMode() {
+ return ProcessorContext.RunMode.ALL;
+ }
+
+ /**
+ * 获取默认的处理者
+ * @param context ProcessorContext
+ * @param processors 处理者容器集合
+ */
+ protected void addDefaultProcessors(ProcessorContext context, List processors){
+ processors.add(new FrameDefineBeanProcessor());
+ processors.add(new ExtractBeanProcessor());
+ processors.add(new InvokeOtherPluginProcessor());
+ }
+
+ /**
+ * 添加默认web环境处理者
+ * @param context ProcessorContext
+ * @param processors 处理者容器集合
+ */
+ protected void addDefaultWebEnvProcessors(ProcessorContext context, List processors){
+ SpringPluginBootstrap springPluginBootstrap = context.getSpringPluginBootstrap();
+ DisablePluginWeb disablePluginWeb = AnnotationUtils.findAnnotation(springPluginBootstrap.getClass(),
+ DisablePluginWeb.class);
+ if(disablePluginWeb != null){
+ return;
+ }
+ context.getWebConfig().setEnable(true);
+ processors.add(new PluginControllerProcessor());
+ processors.add(new PluginInterceptorsProcessor());
+ processors.add(new PluginStaticResourceProcessor());
+ processors.add(new PluginThymeleafProcessor());
+ ProcessorUtils.add(processors, PluginSpringDocControllerProcessor::new);
+ }
+
+ private void processException(SpringPluginProcessor processor, String executeType,
+ Throwable e, boolean isThrow) throws ProcessorException{
+ String error = "Processor[" + processor.getClass().getName() + "] execute[" + executeType + "] failure : "
+ + e.getMessage();
+ logger.error(error, e);
+ if(isThrow){
+ throw new ProcessorException(error, e);
+ }
+ }
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/DefaultProcessorContext.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/DefaultProcessorContext.java
new file mode 100644
index 0000000000000000000000000000000000000000..d9d85e090eb25c0a030e640999f5ca7725d55996
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/DefaultProcessorContext.java
@@ -0,0 +1,138 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.processor;
+
+import com.gitee.starblues.bootstrap.SpringPluginBootstrap;
+import com.gitee.starblues.core.descriptor.InsidePluginDescriptor;
+import com.gitee.starblues.core.launcher.plugin.CacheRegistryInfo;
+import com.gitee.starblues.core.launcher.plugin.PluginInteractive;
+import com.gitee.starblues.integration.IntegrationConfiguration;
+import com.gitee.starblues.spring.MainApplicationContext;
+import com.gitee.starblues.spring.SpringBeanFactory;
+import com.gitee.starblues.spring.WebConfig;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.DefaultResourceLoader;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.util.ClassUtils;
+
+/**
+ * 默认的处理者上下文
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class DefaultProcessorContext extends CacheRegistryInfo implements ProcessorContext{
+
+ private final RunMode runMode;
+
+ private final SpringPluginBootstrap springPluginBootstrap;
+ private final PluginInteractive pluginInteractive;
+ private final Class extends SpringPluginBootstrap> runnerClass;
+ private final MainApplicationContext mainApplicationContext;
+ private final ClassLoader classLoader;
+ private final ResourceLoader resourceLoader;
+
+ private final IntegrationConfiguration configuration;
+ private final WebConfig webConfig;
+
+ private GenericApplicationContext applicationContext;
+
+ public DefaultProcessorContext(RunMode runMode, SpringPluginBootstrap springPluginBootstrap,
+ PluginInteractive pluginInteractive, Class extends SpringPluginBootstrap> runnerClass) {
+ this.runMode = runMode;
+ this.springPluginBootstrap = springPluginBootstrap;
+ this.pluginInteractive = pluginInteractive;
+ this.runnerClass = runnerClass;
+ this.classLoader = getPluginClassLoader();
+ this.resourceLoader = new DefaultResourceLoader(this.classLoader);
+ this.mainApplicationContext = pluginInteractive.getMainApplicationContext();
+ this.configuration = pluginInteractive.getConfiguration();
+ this.webConfig = new WebConfig();
+ }
+
+ @Override
+ public RunMode runMode() {
+ return runMode;
+ }
+
+ @Override
+ public SpringPluginBootstrap getSpringPluginBootstrap() {
+ return springPluginBootstrap;
+ }
+
+ @Override
+ public InsidePluginDescriptor getPluginDescriptor() {
+ return pluginInteractive.getPluginDescriptor();
+ }
+
+ @Override
+ public Class extends SpringPluginBootstrap> getRunnerClass() {
+ return runnerClass;
+ }
+
+ @Override
+ public PluginInteractive getPluginInteractive() {
+ return pluginInteractive;
+ }
+
+ @Override
+ public MainApplicationContext getMainApplicationContext() {
+ return mainApplicationContext;
+ }
+
+ @Override
+ public SpringBeanFactory getMainBeanFactory() {
+ return mainApplicationContext.getSpringBeanFactory();
+ }
+
+ @Override
+ public IntegrationConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ public GenericApplicationContext getApplicationContext() {
+ if(applicationContext == null){
+ return null;
+ }
+ return applicationContext;
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ @Override
+ public ResourceLoader getResourceLoader() {
+ return resourceLoader;
+ }
+
+ @Override
+ public WebConfig getWebConfig() {
+ return webConfig;
+ }
+
+ @Override
+ public void setApplicationContext(GenericApplicationContext applicationContext) {
+ this.applicationContext = applicationContext;
+ }
+
+
+ protected ClassLoader getPluginClassLoader(){
+ return ClassUtils.getDefaultClassLoader();
+ }
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ExtractBeanProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ExtractBeanProcessor.java
new file mode 100644
index 0000000000000000000000000000000000000000..0ed867c6488db5c29e1d8e6e1494e01ff11f2695
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ExtractBeanProcessor.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.processor;
+
+import com.gitee.starblues.annotation.Extract;
+import com.gitee.starblues.bootstrap.processor.ProcessorContext;
+import com.gitee.starblues.bootstrap.processor.ProcessorException;
+import com.gitee.starblues.bootstrap.processor.SpringPluginProcessor;
+import com.gitee.starblues.spring.extract.OpExtractFactory;
+import com.gitee.starblues.utils.ObjectUtils;
+import org.springframework.context.support.GenericApplicationContext;
+
+import java.util.Map;
+
+/**
+ * Extract 扩展Bean注册处理者
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class ExtractBeanProcessor implements SpringPluginProcessor {
+
+ @Override
+ public void refreshAfter(ProcessorContext context) throws ProcessorException {
+ GenericApplicationContext applicationContext = context.getApplicationContext();
+ Map extractMap = applicationContext.getBeansWithAnnotation(Extract.class);
+ if(ObjectUtils.isEmpty(extractMap)){
+ return;
+ }
+ String pluginId = context.getPluginDescriptor().getPluginId();
+ OpExtractFactory opExtractFactory = context.getPluginInteractive().getOpExtractFactory();
+ for (Object extract : extractMap.values()) {
+ opExtractFactory.add(pluginId, extract);
+ }
+ }
+
+ @Override
+ public void close(ProcessorContext context) throws ProcessorException {
+ OpExtractFactory opExtractFactory = context.getPluginInteractive().getOpExtractFactory();
+ String pluginId = context.getPluginDescriptor().getPluginId();
+ opExtractFactory.remove(pluginId);
+ }
+
+ @Override
+ public ProcessorContext.RunMode runMode() {
+ return ProcessorContext.RunMode.ALL;
+ }
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/FrameDefineBeanProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/FrameDefineBeanProcessor.java
new file mode 100644
index 0000000000000000000000000000000000000000..56fcb6af01916a9de51eaf1c8c57d56230c3229a
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/FrameDefineBeanProcessor.java
@@ -0,0 +1,60 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.processor;
+
+
+import com.gitee.starblues.bootstrap.realize.DefaultMainEnvironmentProvider;
+import com.gitee.starblues.bootstrap.realize.EmptyMainEnvironmentProvider;
+import com.gitee.starblues.bootstrap.realize.MainEnvironmentProvider;
+import com.gitee.starblues.core.descriptor.InsidePluginDescriptor;
+import com.gitee.starblues.integration.AutoIntegrationConfiguration;
+import com.gitee.starblues.integration.ExtendPointConfiguration;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.context.support.GenericApplicationContext;
+
+/**
+ * 框架内置bean注册
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class FrameDefineBeanProcessor implements SpringPluginProcessor {
+
+ @Override
+ public void refreshBefore(ProcessorContext context) throws ProcessorException {
+ GenericApplicationContext applicationContext = context.getApplicationContext();
+ InsidePluginDescriptor pluginDescriptor = context.getPluginDescriptor();
+ ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
+ beanFactory.registerSingleton("pluginDescriptor", pluginDescriptor.toPluginDescriptor());
+ beanFactory.registerSingleton("mainApplicationContext", context.getMainApplicationContext());
+
+ MainEnvironmentProvider mainEnvironmentProvider = null;
+ if(context.runMode() == ProcessorContext.RunMode.ONESELF){
+ beanFactory.registerSingleton("integrationConfiguration", new AutoIntegrationConfiguration());
+ applicationContext.registerBean(ExtendPointConfiguration.class);
+ mainEnvironmentProvider = new EmptyMainEnvironmentProvider();
+ } else {
+ mainEnvironmentProvider = new DefaultMainEnvironmentProvider(context.getMainApplicationContext());
+ }
+ beanFactory.registerSingleton("mainEnvironmentProvider", mainEnvironmentProvider);
+ }
+
+ @Override
+ public ProcessorContext.RunMode runMode() {
+ return ProcessorContext.RunMode.ALL;
+ }
+
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/InvokeOtherPluginProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/InvokeOtherPluginProcessor.java
new file mode 100644
index 0000000000000000000000000000000000000000..6c12254fb5e464637b8ae4b1cf1ffdfcfb3b3726
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/InvokeOtherPluginProcessor.java
@@ -0,0 +1,126 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.processor;
+
+import com.gitee.starblues.annotation.Caller;
+import com.gitee.starblues.annotation.Supplier;
+import com.gitee.starblues.bootstrap.processor.invoke.InvokeBeanFactory;
+import com.gitee.starblues.bootstrap.processor.scanner.PluginClassPathBeanDefinitionScanner;
+import com.gitee.starblues.spring.ApplicationContext;
+import com.gitee.starblues.spring.ApplicationContextProxy;
+import com.gitee.starblues.spring.invoke.InvokeSupperCache;
+import com.gitee.starblues.spring.invoke.SupperCache;
+import com.gitee.starblues.utils.ObjectUtils;
+import com.gitee.starblues.utils.ScanUtils;
+import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.GenericBeanDefinition;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.annotation.AnnotationUtils;
+import org.springframework.core.type.filter.AnnotationTypeFilter;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 反射调用其他插件的处理者
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class InvokeOtherPluginProcessor implements SpringPluginProcessor {
+
+ @Override
+ public void refreshBefore(ProcessorContext context) throws ProcessorException {
+ InvokeCallerBeanDefinitionScanner scanner = new InvokeCallerBeanDefinitionScanner(context);
+ scanner.doScan(ScanUtils.getScanBasePackages(context.getRunnerClass()));
+ }
+
+ @Override
+ public void refreshAfter(ProcessorContext context) throws ProcessorException {
+ GenericApplicationContext applicationContext = context.getApplicationContext();
+ Map supplierBeans = applicationContext.getBeansWithAnnotation(Supplier.class);
+ String pluginId = context.getPluginDescriptor().getPluginId();
+ ApplicationContext applicationContextReflection = new ApplicationContextProxy(applicationContext);
+ InvokeSupperCache invokeSupperCache = context.getPluginInteractive().getInvokeSupperCache();
+ supplierBeans.forEach((k,v)->{
+ Supplier supplier = AnnotationUtils.findAnnotation(v.getClass(), Supplier.class);
+ String supperKey = k;
+ if(supplier != null && !ObjectUtils.isEmpty(supplier.value())){
+ supperKey = supplier.value();
+ }
+ invokeSupperCache.add(pluginId, new SupperCache(supperKey, k, applicationContextReflection));
+ });
+ }
+
+ @Override
+ public ProcessorContext.RunMode runMode() {
+ return ProcessorContext.RunMode.ALL;
+ }
+
+
+ private static class InvokeCallerBeanDefinitionScanner extends PluginClassPathBeanDefinitionScanner {
+
+ private final ProcessorContext context;
+
+ public InvokeCallerBeanDefinitionScanner(ProcessorContext context) {
+ super(context, false);
+ setResourceLoader(context.getResourceLoader());
+ this.context = context;
+ addIncludeFilter(new AnnotationTypeFilter(Caller.class));
+ addExcludeFilter((metadataReader, metadataReaderFactory) -> {
+ String className = metadataReader.getClassMetadata().getClassName();
+ return className.endsWith("package-info");
+ });
+ }
+
+
+ @Override
+ protected Set doScan(String... basePackages) {
+ Set holders = super.doScan(basePackages);
+ ClassLoader pluginClassLoader = context.getClassLoader();
+ InvokeSupperCache invokeSupperCache = context.getPluginInteractive().getInvokeSupperCache();
+ for (BeanDefinitionHolder holder : holders) {
+ AbstractBeanDefinition definition = (AbstractBeanDefinition) holder.getBeanDefinition();
+ try {
+ Class> aClass = pluginClassLoader.loadClass(definition.getBeanClassName());
+ Caller caller = AnnotationUtils.findAnnotation(aClass, Caller.class);
+ if(caller == null){
+ continue;
+ }
+ // 是调用方
+ definition.getPropertyValues().add("callerAnnotation", caller);
+ definition.getPropertyValues().add("callerInterface", aClass);
+ definition.getPropertyValues().add("invokeSupperCache", invokeSupperCache);
+ definition.setBeanClass(InvokeBeanFactory.class);
+ definition.setAutowireMode(GenericBeanDefinition.AUTOWIRE_BY_TYPE);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return holders;
+ }
+
+ @Override
+ protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
+ return beanDefinition.getMetadata().isInterface() && beanDefinition.getMetadata().isIndependent();
+ }
+
+ }
+
+
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorContext.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorContext.java
new file mode 100644
index 0000000000000000000000000000000000000000..db4c125427aa79507918a11895fa75cf05606bd0
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorContext.java
@@ -0,0 +1,138 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.processor;
+
+
+import com.gitee.starblues.bootstrap.SpringPluginBootstrap;
+import com.gitee.starblues.core.descriptor.InsidePluginDescriptor;
+import com.gitee.starblues.core.launcher.plugin.PluginInteractive;
+import com.gitee.starblues.core.launcher.plugin.RegistryInfo;
+import com.gitee.starblues.integration.IntegrationConfiguration;
+import com.gitee.starblues.spring.MainApplicationContext;
+import com.gitee.starblues.spring.SpringBeanFactory;
+import com.gitee.starblues.spring.WebConfig;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ResourceLoader;
+
+/**
+ * 处理者上下文
+ * @author starBlues
+ * @version 3.0.0
+ */
+public interface ProcessorContext extends RegistryInfo {
+
+ /**
+ * 当前运行模式
+ * @return RunMode
+ */
+ RunMode runMode();
+
+ /**
+ * 得到入口类对象-SpringPluginBootstrap
+ * @return SpringPluginBootstrap
+ */
+ SpringPluginBootstrap getSpringPluginBootstrap();
+
+ /**
+ * 得到插件信息 PluginDescriptor
+ * @return PluginDescriptor
+ */
+ InsidePluginDescriptor getPluginDescriptor();
+
+ /**
+ * 得到启动的class类
+ * @return Class
+ */
+ Class extends SpringPluginBootstrap> getRunnerClass();
+
+ /**
+ * 得到 PluginInteractive
+ * @return PluginInteractive
+ */
+ PluginInteractive getPluginInteractive();
+
+ /**
+ * 得到主程序的 ApplicationContext
+ * @return MainApplicationContext
+ */
+ MainApplicationContext getMainApplicationContext();
+
+ /**
+ * 得到主程序的 SpringBeanFactory
+ * @return SpringBeanFactory
+ */
+ SpringBeanFactory getMainBeanFactory();
+
+ /**
+ * 得到当前框架的集成配置
+ * @return IntegrationConfiguration
+ */
+ IntegrationConfiguration getConfiguration();
+
+
+ /**
+ * 得到当前插件的 ApplicationContext
+ * @return GenericApplicationContext
+ */
+ GenericApplicationContext getApplicationContext();
+
+ /**
+ * 得到当前插件的 ClassLoader
+ * @return ClassLoader
+ */
+ ClassLoader getClassLoader();
+
+ /**
+ * 得到插件的资源loader
+ * @return ResourceLoader
+ */
+ ResourceLoader getResourceLoader();
+
+ /**
+ * 获取 WebConfig
+ * @return WebConfig
+ */
+ WebConfig getWebConfig();
+
+ /**
+ * set 当前插件的 ApplicationContext
+ * @param applicationContext GenericApplicationContext
+ */
+ void setApplicationContext(GenericApplicationContext applicationContext);
+
+ /**
+ * 运行模式
+ */
+ enum RunMode{
+ /**
+ * 全部运行
+ */
+ ALL,
+
+ /**
+ * 插件环境运行
+ */
+ PLUGIN,
+
+ /**
+ * 插件独立运行
+ */
+ ONESELF
+ }
+
+
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorException.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorException.java
new file mode 100644
index 0000000000000000000000000000000000000000..c0f6306af7593b8a8517b05dae30dafbe40fa49d
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorException.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.processor;
+
+/**
+ * 处理者异常
+ * @author starBlues
+ * @version 3.0.0
+ */
+public class ProcessorException extends RuntimeException{
+
+ public ProcessorException() {
+ super();
+ }
+
+ public ProcessorException(String message) {
+ super(message);
+ }
+
+ public ProcessorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ProcessorException(Throwable cause) {
+ super(cause);
+ }
+
+ protected ProcessorException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/SpringPluginProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/SpringPluginProcessor.java
new file mode 100644
index 0000000000000000000000000000000000000000..5b959466a634992bf46841e763802787994b284e
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/SpringPluginProcessor.java
@@ -0,0 +1,90 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.processor;
+
+import com.gitee.starblues.utils.Order;
+import com.gitee.starblues.utils.OrderPriority;
+
+/**
+ * spring plugin 处理器
+ * @author starBlues
+ * @version 3.0.0
+ */
+public interface SpringPluginProcessor extends Order {
+
+ /**
+ * 初始化时
+ * @param context ProcessorContext
+ * @throws ProcessorException 处理异常
+ */
+ default void initialize(ProcessorContext context) throws ProcessorException{
+
+ }
+
+ /**
+ * 刷新上下文前
+ * @param context ProcessorContext
+ * @throws ProcessorException 处理异常
+ */
+ default void refreshBefore(ProcessorContext context) throws ProcessorException{
+
+ }
+
+ /**
+ * 刷新上下文后
+ * @param context ProcessorContext
+ * @throws ProcessorException 处理异常
+ */
+ default void refreshAfter(ProcessorContext context) throws ProcessorException{
+
+ }
+
+ /**
+ * 启动失败
+ * @param context ProcessorContext
+ * @throws ProcessorException 处理异常
+ */
+ default void failure(ProcessorContext context) throws ProcessorException{
+
+ }
+
+ /**
+ * 关闭容器时
+ * @param context ProcessorContext
+ * @throws ProcessorException 处理异常
+ */
+ default void close(ProcessorContext context) throws ProcessorException{
+
+ }
+
+ /**
+ * 执行顺序
+ * @return OrderPriority
+ */
+ @Override
+ default OrderPriority order(){
+ return OrderPriority.getLowPriority();
+ }
+
+ /**
+ * 处理器运行模式
+ * @return RunMode
+ */
+ ProcessorContext.RunMode runMode();
+
+
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegister.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegister.java
new file mode 100644
index 0000000000000000000000000000000000000000..7d3454aede3b78cf7e0c9797a9ddb7b05f0e56ac
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegister.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.processor.interceptor;
+
+/**
+ * 插件拦截器注册者
+ * @author starBlues
+ * @version 3.0.0
+ */
+public interface PluginInterceptorRegister {
+
+ /**
+ * 拦截器注册者
+ * @param registry 注册对象
+ */
+ void registry(PluginInterceptorRegistry registry);
+
+
+}
diff --git a/springboot-plugin-framework/src/main/java/com/gitee/starblues/factory/process/pipe/interceptor/PluginInterceptorRegistration.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistration.java
similarity index 81%
rename from springboot-plugin-framework/src/main/java/com/gitee/starblues/factory/process/pipe/interceptor/PluginInterceptorRegistration.java
rename to spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistration.java
index ee8647e093c567c707082f2ca6341f6e3236eb09..668ab01a7a0409e7cc1d8f28e061329c52d34105 100644
--- a/springboot-plugin-framework/src/main/java/com/gitee/starblues/factory/process/pipe/interceptor/PluginInterceptorRegistration.java
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistration.java
@@ -1,7 +1,23 @@
-package com.gitee.starblues.factory.process.pipe.interceptor;
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.processor.interceptor;
-import com.gitee.starblues.utils.CommonUtils;
-import org.pf4j.util.StringUtils;
+import com.gitee.starblues.utils.ObjectUtils;
+import com.gitee.starblues.utils.UrlUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.PathMatcher;
import org.springframework.web.servlet.HandlerInterceptor;
@@ -15,7 +31,7 @@ import java.util.List;
/**
* 插件拦截器注册的信息
* @author starBlues
- * @version 2.4.1
+ * @version 3.0.0
*/
public class PluginInterceptorRegistration {
@@ -68,10 +84,10 @@ public class PluginInterceptorRegistration {
}
// 局部的
for (String pattern : patterns) {
- if(StringUtils.isNullOrEmpty(pattern)){
+ if(ObjectUtils.isEmpty(pattern)){
continue;
}
- this.includePatterns.add(CommonUtils.joiningPath(pluginRestApiPrefix, pattern));
+ this.includePatterns.add(UrlUtils.joiningUrlPath(pluginRestApiPrefix, pattern));
}
return this;
}
@@ -86,10 +102,10 @@ public class PluginInterceptorRegistration {
this.excludePatterns.addAll(Arrays.asList(patterns));
}
for (String pattern : patterns) {
- if(StringUtils.isNullOrEmpty(pattern)){
+ if(ObjectUtils.isEmpty(pattern)){
continue;
}
- this.excludePatterns.add(CommonUtils.joiningPath(pluginRestApiPrefix, pattern));
+ this.excludePatterns.add(UrlUtils.joiningUrlPath(pluginRestApiPrefix, pattern));
}
return this;
}
@@ -137,7 +153,7 @@ public class PluginInterceptorRegistration {
protected Object getInterceptor() {
if(type == PluginInterceptorRegistry.Type.PLUGIN){
if(this.includePatterns.isEmpty()){
- this.includePatterns.add(CommonUtils.joiningPath(pluginRestApiPrefix, "/**"));
+ this.includePatterns.add(UrlUtils.joiningUrlPath(pluginRestApiPrefix, "/**"));
}
}
if (this.includePatterns.isEmpty() && this.excludePatterns.isEmpty()) {
diff --git a/springboot-plugin-framework/src/main/java/com/gitee/starblues/factory/process/pipe/interceptor/PluginInterceptorRegistry.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistry.java
similarity index 82%
rename from springboot-plugin-framework/src/main/java/com/gitee/starblues/factory/process/pipe/interceptor/PluginInterceptorRegistry.java
rename to spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistry.java
index f95ecc8476f834a1cb6623e1de465437c4fe3721..817bce85e2359741b59af3869eee4b5d91eba4b3 100644
--- a/springboot-plugin-framework/src/main/java/com/gitee/starblues/factory/process/pipe/interceptor/PluginInterceptorRegistry.java
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistry.java
@@ -1,4 +1,20 @@
-package com.gitee.starblues.factory.process.pipe.interceptor;
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.starblues.bootstrap.processor.interceptor;
import org.springframework.core.OrderComparator;
import org.springframework.core.Ordered;
@@ -15,7 +31,7 @@ import java.util.stream.Collectors;
/**
* 插件拦截器添加者
* @author starBlues
- * @version 2.4.1
+ * @version 3.0.0
*/
public class PluginInterceptorRegistry {
@@ -68,6 +84,15 @@ public class PluginInterceptorRegistry {
.collect(Collectors.toList());
}
+ private static final Comparator