Commit a152f6d98fe7295f8abd6b7096b388f0ca3dee42
1 parent
d608c4b9
【功能完善】IoT: 删除旧版 HTTP 插件,新增 HTTP 和 MQTT 插件,重构插件管理逻辑,优化代码结构,支持 EMQX 插件,更新相关配置文件。
Showing
27 changed files
with
69 additions
and
397 deletions
plugins/yudao-module-iot-http-plugin-2.2.0-snapshot.jar deleted
No preview for this file type
plugins/yudao-module-iot-plugin-http-1.0.0.jar
0 → 100644
No preview for this file type
yudao-module-iot/yudao-module-iot-plugin/pom.xml
| ... | ... | @@ -8,9 +8,9 @@ |
| 8 | 8 | <version>${revision}</version> |
| 9 | 9 | </parent> |
| 10 | 10 | <modules> |
| 11 | - <module>yudao-module-iot-demo-plugin</module> | |
| 12 | - <module>yudao-module-iot-http-plugin</module> | |
| 13 | - <module>yudao-module-iot-mqtt-plugin</module> | |
| 11 | + <module>yudao-module-iot-plugin-http</module> | |
| 12 | + <module>yudao-module-iot-plugin-mqtt</module> | |
| 13 | + <module>yudao-module-iot-plugin-emqx</module> | |
| 14 | 14 | </modules> |
| 15 | 15 | |
| 16 | 16 | <modelVersion>4.0.0</modelVersion> | ... | ... |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-demo-plugin/plugin.properties deleted
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-demo-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/DemoPlugin.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.plugin; | |
| 2 | - | |
| 3 | -import com.sun.net.httpserver.HttpServer; | |
| 4 | -import lombok.extern.slf4j.Slf4j; | |
| 5 | -import org.pf4j.Plugin; | |
| 6 | -import org.pf4j.PluginWrapper; | |
| 7 | -import org.pf4j.RuntimeMode; | |
| 8 | - | |
| 9 | -import java.io.IOException; | |
| 10 | -import java.io.OutputStream; | |
| 11 | -import java.net.InetSocketAddress; | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * 一个启动 HTTP 服务器的简单插件。 | |
| 15 | - */ | |
| 16 | -@Slf4j | |
| 17 | -public class DemoPlugin extends Plugin { | |
| 18 | - | |
| 19 | - private HttpServer server; | |
| 20 | - | |
| 21 | - public DemoPlugin(PluginWrapper wrapper) { | |
| 22 | - super(wrapper); | |
| 23 | - } | |
| 24 | - | |
| 25 | - @Override | |
| 26 | - public void start() { | |
| 27 | - log.info("Demo 插件启动"); | |
| 28 | - // for testing the development mode | |
| 29 | - if (RuntimeMode.DEVELOPMENT.equals(wrapper.getRuntimeMode())) { | |
| 30 | - log.info("DemoPlugin in DEVELOPMENT mode"); | |
| 31 | - } | |
| 32 | - startDemoServer(); | |
| 33 | - } | |
| 34 | - | |
| 35 | - @Override | |
| 36 | - public void stop() { | |
| 37 | - log.info("Demo 插件停止"); | |
| 38 | - stopDemoServer(); | |
| 39 | - } | |
| 40 | - | |
| 41 | - private void startDemoServer() { | |
| 42 | - try { | |
| 43 | - server = HttpServer.create(new InetSocketAddress(9081), 0); | |
| 44 | - server.createContext("/", exchange -> { | |
| 45 | - String response = "Hello from DemoPlugin"; | |
| 46 | - exchange.sendResponseHeaders(200, response.getBytes().length); | |
| 47 | - OutputStream os = exchange.getResponseBody(); | |
| 48 | - os.write(response.getBytes()); | |
| 49 | - os.close(); | |
| 50 | - }); | |
| 51 | - server.setExecutor(null); | |
| 52 | - server.start(); | |
| 53 | - log.info("HTTP 服务器启动成功,端口为 9081"); | |
| 54 | - log.info("访问地址为 http://127.0.0.1:9081/"); | |
| 55 | - } catch (IOException e) { | |
| 56 | - log.error("HTTP 服务器启动失败", e); | |
| 57 | - } | |
| 58 | - } | |
| 59 | - | |
| 60 | - private void stopDemoServer() { | |
| 61 | - if (server != null) { | |
| 62 | - server.stop(0); | |
| 63 | - log.info("HTTP 服务器停止成功"); | |
| 64 | - } | |
| 65 | - } | |
| 66 | - | |
| 67 | -// @Extension | |
| 68 | -// public static class WelcomeGreeting implements Greeting { | |
| 69 | -// | |
| 70 | -// @Override | |
| 71 | -// public String getGreeting() { | |
| 72 | -// return "Welcome to DemoPlugin"; | |
| 73 | -// } | |
| 74 | -// | |
| 75 | -// } | |
| 76 | - | |
| 77 | -} | |
| 78 | 0 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/plugin.properties deleted
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/pom.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | -<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 3 | - xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation=" | |
| 4 | - http://maven.apache.org/POM/4.0.0 | |
| 5 | - http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 6 | - <parent> | |
| 7 | - <artifactId>yudao-module-iot-plugin</artifactId> | |
| 8 | - <groupId>cn.iocoder.boot</groupId> | |
| 9 | - <version>${revision}</version> | |
| 10 | - </parent> | |
| 11 | - <modelVersion>4.0.0</modelVersion> | |
| 12 | - <packaging>jar</packaging> | |
| 13 | - | |
| 14 | - <artifactId>yudao-module-iot-http-plugin</artifactId> | |
| 15 | - | |
| 16 | - <name>${project.artifactId}</name> | |
| 17 | - <description> | |
| 18 | - 物联网 插件模块 - http 插件 | |
| 19 | - </description> | |
| 20 | - | |
| 21 | - <properties> | |
| 22 | - <!-- 插件相关 --> | |
| 23 | - <plugin.id>http-plugin</plugin.id> | |
| 24 | - <plugin.class>cn.iocoder.yudao.module.iot.plugin.HttpVertxPlugin</plugin.class> | |
| 25 | - <plugin.version>0.0.1</plugin.version> | |
| 26 | - <plugin.provider>ahh</plugin.provider> | |
| 27 | - <plugin.description>http-plugin-0.0.1</plugin.description> | |
| 28 | - <plugin.dependencies/> | |
| 29 | - </properties> | |
| 30 | - | |
| 31 | - <build> | |
| 32 | - <plugins> | |
| 33 | - <plugin> | |
| 34 | - <groupId>org.apache.maven.plugins</groupId> | |
| 35 | - <artifactId>maven-antrun-plugin</artifactId> | |
| 36 | - <version>1.6</version> | |
| 37 | - <executions> | |
| 38 | - <execution> | |
| 39 | - <id>unzip jar file</id> | |
| 40 | - <phase>package</phase> | |
| 41 | - <configuration> | |
| 42 | - <target> | |
| 43 | - <unzip src="target/${project.artifactId}-${project.version}.${project.packaging}" | |
| 44 | - dest="target/plugin-classes"/> | |
| 45 | - </target> | |
| 46 | - </configuration> | |
| 47 | - <goals> | |
| 48 | - <goal>run</goal> | |
| 49 | - </goals> | |
| 50 | - </execution> | |
| 51 | - </executions> | |
| 52 | - </plugin> | |
| 53 | - | |
| 54 | - <plugin> | |
| 55 | - <artifactId>maven-assembly-plugin</artifactId> | |
| 56 | - <version>2.3</version> | |
| 57 | - <configuration> | |
| 58 | - <descriptors> | |
| 59 | - <descriptor> | |
| 60 | - src/main/assembly/assembly.xml | |
| 61 | - </descriptor> | |
| 62 | - </descriptors> | |
| 63 | - <appendAssemblyId>false</appendAssemblyId> | |
| 64 | - </configuration> | |
| 65 | - <executions> | |
| 66 | - <execution> | |
| 67 | - <id>make-assembly</id> | |
| 68 | - <phase>package</phase> | |
| 69 | - <goals> | |
| 70 | - <goal>attached</goal> | |
| 71 | - </goals> | |
| 72 | - </execution> | |
| 73 | - </executions> | |
| 74 | - </plugin> | |
| 75 | - | |
| 76 | - <plugin> | |
| 77 | - <groupId>org.apache.maven.plugins</groupId> | |
| 78 | - <artifactId>maven-jar-plugin</artifactId> | |
| 79 | - <version>2.4</version> | |
| 80 | - <configuration> | |
| 81 | - <archive> | |
| 82 | - <manifestEntries> | |
| 83 | - <Plugin-Id>${plugin.id}</Plugin-Id> | |
| 84 | - <Plugin-Class>${plugin.class}</Plugin-Class> | |
| 85 | - <Plugin-Version>${plugin.version}</Plugin-Version> | |
| 86 | - <Plugin-Provider>${plugin.provider}</Plugin-Provider> | |
| 87 | - <Plugin-Description>${plugin.description}</Plugin-Description> | |
| 88 | - <Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies> | |
| 89 | - </manifestEntries> | |
| 90 | - </archive> | |
| 91 | - </configuration> | |
| 92 | - </plugin> | |
| 93 | - | |
| 94 | - <plugin> | |
| 95 | - <artifactId>maven-deploy-plugin</artifactId> | |
| 96 | - <configuration> | |
| 97 | - <skip>true</skip> | |
| 98 | - </configuration> | |
| 99 | - </plugin> | |
| 100 | - | |
| 101 | - <!-- <plugin>--> | |
| 102 | - <!-- <groupId>org.apache.maven.plugins</groupId>--> | |
| 103 | - <!-- <artifactId>maven-shade-plugin</artifactId>--> | |
| 104 | - <!-- <version>3.4.1</version>--> | |
| 105 | - <!-- <executions>--> | |
| 106 | - <!-- <execution>--> | |
| 107 | - <!-- <phase>package</phase>--> | |
| 108 | - <!-- <goals>--> | |
| 109 | - <!-- <goal>shade</goal>--> | |
| 110 | - <!-- </goals>--> | |
| 111 | - <!-- <configuration>--> | |
| 112 | - <!-- <shadedArtifactAttached>true</shadedArtifactAttached>--> | |
| 113 | - <!-- <shadedClassifierName>shaded</shadedClassifierName>--> | |
| 114 | - <!-- <transformers>--> | |
| 115 | - <!-- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">--> | |
| 116 | - <!-- <mainClass>cn.iocoder.yudao.module.iot.HttpPluginSpringbootApplication</mainClass>--> | |
| 117 | - <!-- </transformer>--> | |
| 118 | - <!-- </transformers>--> | |
| 119 | - <!-- </configuration>--> | |
| 120 | - <!-- </execution>--> | |
| 121 | - <!-- </executions>--> | |
| 122 | - <!-- </plugin>--> | |
| 123 | - </plugins> | |
| 124 | - </build> | |
| 125 | - | |
| 126 | - <dependencies> | |
| 127 | - <!-- 其他依赖项 --> | |
| 128 | - <dependency> | |
| 129 | - <groupId>org.springframework.boot</groupId> | |
| 130 | - <artifactId>spring-boot-starter</artifactId> | |
| 131 | - </dependency> | |
| 132 | - <!-- PF4J Spring 集成 --> | |
| 133 | - <dependency> | |
| 134 | - <groupId>org.pf4j</groupId> | |
| 135 | - <artifactId>pf4j-spring</artifactId> | |
| 136 | - <scope>provided</scope> | |
| 137 | - </dependency> | |
| 138 | - <!-- 项目依赖 --> | |
| 139 | - <dependency> | |
| 140 | - <groupId>cn.iocoder.boot</groupId> | |
| 141 | - <artifactId>yudao-module-iot-api</artifactId> | |
| 142 | - <version>${revision}</version> | |
| 143 | - </dependency> | |
| 144 | - <dependency> | |
| 145 | - <groupId>org.projectlombok</groupId> | |
| 146 | - <artifactId>lombok</artifactId> | |
| 147 | - <version>${lombok.version}</version> | |
| 148 | - <scope>provided</scope> | |
| 149 | - </dependency> | |
| 150 | - <!-- Vert.x Web --> | |
| 151 | - <dependency> | |
| 152 | - <groupId>io.vertx</groupId> | |
| 153 | - <artifactId>vertx-web</artifactId> | |
| 154 | - <version>4.5.11</version> | |
| 155 | - </dependency> | |
| 156 | - </dependencies> | |
| 157 | -</project> | |
| 158 | 0 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/resources/application.yml deleted
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-mqtt-plugin/src/main/assembly/assembly.xml deleted
| 1 | -<assembly> | |
| 2 | - <id>plugin</id> | |
| 3 | - <formats> | |
| 4 | - <format>zip</format> | |
| 5 | - </formats> | |
| 6 | - <includeBaseDirectory>false</includeBaseDirectory> | |
| 7 | - <dependencySets> | |
| 8 | - <dependencySet> | |
| 9 | - <useProjectArtifact>false</useProjectArtifact> | |
| 10 | - <scope>runtime</scope> | |
| 11 | - <outputDirectory>lib</outputDirectory> | |
| 12 | - <includes> | |
| 13 | - <include>*:jar:*</include> | |
| 14 | - </includes> | |
| 15 | - </dependencySet> | |
| 16 | - </dependencySets> | |
| 17 | - <!-- | |
| 18 | - <fileSets> | |
| 19 | - <fileSet> | |
| 20 | - <directory>target/classes</directory> | |
| 21 | - <outputDirectory>classes</outputDirectory> | |
| 22 | - </fileSet> | |
| 23 | - </fileSets> | |
| 24 | - --> | |
| 25 | - <fileSets> | |
| 26 | - <fileSet> | |
| 27 | - <directory>target/plugin-classes</directory> | |
| 28 | - <outputDirectory>classes</outputDirectory> | |
| 29 | - </fileSet> | |
| 30 | - </fileSets> | |
| 31 | -</assembly> |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-emqx-plugin/plugin.properties renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-emqx/plugin.properties
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-emqx-plugin/pom.xml renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-emqx/pom.xml
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-demo-plugin/src/main/assembly/assembly.xml renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-emqx/src/main/assembly/assembly.xml
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-emqx-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/EmqxPlugin.java renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-emqx/src/main/java/cn/iocoder/yudao/module/iot/plugin/EmqxPlugin.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.plugin; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.iot.api.ServiceRegistry; | |
| 3 | +import cn.hutool.extra.spring.SpringUtil; | |
| 4 | 4 | import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; |
| 5 | 5 | import lombok.extern.slf4j.Slf4j; |
| 6 | 6 | import org.pf4j.Plugin; |
| 7 | 7 | import org.pf4j.PluginWrapper; |
| 8 | 8 | |
| 9 | -import javax.annotation.Resource; | |
| 10 | 9 | import java.util.concurrent.ExecutorService; |
| 11 | 10 | import java.util.concurrent.Executors; |
| 12 | 11 | |
| ... | ... | @@ -14,8 +13,6 @@ import java.util.concurrent.Executors; |
| 14 | 13 | public class EmqxPlugin extends Plugin { |
| 15 | 14 | |
| 16 | 15 | private ExecutorService executorService; |
| 17 | - @Resource | |
| 18 | - private DeviceDataApi deviceDataApi; | |
| 19 | 16 | |
| 20 | 17 | public EmqxPlugin(PluginWrapper wrapper) { |
| 21 | 18 | super(wrapper); |
| ... | ... | @@ -30,7 +27,7 @@ public class EmqxPlugin extends Plugin { |
| 30 | 27 | executorService = Executors.newSingleThreadExecutor(); |
| 31 | 28 | } |
| 32 | 29 | |
| 33 | - deviceDataApi = ServiceRegistry.getService(DeviceDataApi.class); | |
| 30 | + DeviceDataApi deviceDataApi = SpringUtil.getBean(DeviceDataApi.class); | |
| 34 | 31 | if (deviceDataApi == null) { |
| 35 | 32 | log.error("未能从 ServiceRegistry 获取 DeviceDataApi 实例,请确保主程序已正确注册!"); |
| 36 | 33 | return; | ... | ... |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/dependency-reduced-pom.xml renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/dependency-reduced-pom.xml
| ... | ... | @@ -6,37 +6,15 @@ |
| 6 | 6 | <version>2.2.0-snapshot</version> |
| 7 | 7 | </parent> |
| 8 | 8 | <modelVersion>4.0.0</modelVersion> |
| 9 | - <artifactId>yudao-module-iot-http-plugin</artifactId> | |
| 9 | + <artifactId>yudao-module-iot-plugin-http</artifactId> | |
| 10 | 10 | <name>${project.artifactId}</name> |
| 11 | - <version>2.2.0-snapshot</version> | |
| 11 | + <version>1.0.0</version> | |
| 12 | 12 | <description>物联网 插件模块 - http 插件</description> |
| 13 | 13 | <build> |
| 14 | 14 | <plugins> |
| 15 | 15 | <plugin> |
| 16 | - <artifactId>maven-jar-plugin</artifactId> | |
| 17 | - <version>2.4</version> | |
| 18 | - <configuration> | |
| 19 | - <archive> | |
| 20 | - <manifestEntries> | |
| 21 | - <Plugin-Id>${plugin.id}</Plugin-Id> | |
| 22 | - <Plugin-Class>${plugin.class}</Plugin-Class> | |
| 23 | - <Plugin-Version>${plugin.version}</Plugin-Version> | |
| 24 | - <Plugin-Provider>${plugin.provider}</Plugin-Provider> | |
| 25 | - <Plugin-Description>${plugin.description}</Plugin-Description> | |
| 26 | - <Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies> | |
| 27 | - </manifestEntries> | |
| 28 | - </archive> | |
| 29 | - </configuration> | |
| 30 | - </plugin> | |
| 31 | - <plugin> | |
| 32 | - <artifactId>maven-deploy-plugin</artifactId> | |
| 33 | - <configuration> | |
| 34 | - <skip>true</skip> | |
| 35 | - </configuration> | |
| 36 | - </plugin> | |
| 37 | - <plugin> | |
| 38 | 16 | <artifactId>maven-shade-plugin</artifactId> |
| 39 | - <version>3.4.1</version> | |
| 17 | + <version>3.2.4</version> | |
| 40 | 18 | <executions> |
| 41 | 19 | <execution> |
| 42 | 20 | <phase>package</phase> |
| ... | ... | @@ -44,11 +22,9 @@ |
| 44 | 22 | <goal>shade</goal> |
| 45 | 23 | </goals> |
| 46 | 24 | <configuration> |
| 47 | - <shadedArtifactAttached>true</shadedArtifactAttached> | |
| 48 | - <shadedClassifierName>shaded</shadedClassifierName> | |
| 49 | 25 | <transformers> |
| 50 | 26 | <transformer> |
| 51 | - <mainClass>cn.iocoder.yudao.module.iot.HttpPluginSpringbootApplication</mainClass> | |
| 27 | + <mainClass>com.example.HttpPluginSpringbootApplication</mainClass> | |
| 52 | 28 | </transformer> |
| 53 | 29 | </transformers> |
| 54 | 30 | </configuration> |
| ... | ... | @@ -57,25 +33,11 @@ |
| 57 | 33 | </plugin> |
| 58 | 34 | </plugins> |
| 59 | 35 | </build> |
| 60 | - <dependencies> | |
| 61 | - <dependency> | |
| 62 | - <groupId>org.pf4j</groupId> | |
| 63 | - <artifactId>pf4j-spring</artifactId> | |
| 64 | - <version>0.9.0</version> | |
| 65 | - <scope>provided</scope> | |
| 66 | - </dependency> | |
| 67 | - <dependency> | |
| 68 | - <groupId>org.projectlombok</groupId> | |
| 69 | - <artifactId>lombok</artifactId> | |
| 70 | - <version>1.18.34</version> | |
| 71 | - <scope>provided</scope> | |
| 72 | - </dependency> | |
| 73 | - </dependencies> | |
| 74 | 36 | <properties> |
| 75 | - <plugin.class>cn.iocoder.yudao.module.iot.plugin.HttpVertxPlugin</plugin.class> | |
| 76 | - <plugin.version>0.0.1</plugin.version> | |
| 77 | - <plugin.id>http-plugin</plugin.id> | |
| 78 | - <plugin.description>http-plugin-0.0.1</plugin.description> | |
| 79 | - <plugin.provider>ahh</plugin.provider> | |
| 37 | + <plugin.id>${project.artifactId}</plugin.id> | |
| 38 | + <plugin.description>${project.artifactId}-${project.version}</plugin.description> | |
| 39 | + <plugin.class>cn.iocoder.yudao.module.iot.config.HttpVertxPlugin</plugin.class> | |
| 40 | + <plugin.version>${project.version}</plugin.version> | |
| 41 | + <plugin.provider>yudao</plugin.provider> | |
| 80 | 42 | </properties> |
| 81 | 43 | </project> | ... | ... |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/plugin.properties
0 → 100644
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-demo-plugin/pom.xml renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/pom.xml
| ... | ... | @@ -11,45 +11,27 @@ |
| 11 | 11 | <modelVersion>4.0.0</modelVersion> |
| 12 | 12 | <packaging>jar</packaging> |
| 13 | 13 | |
| 14 | - <artifactId>yudao-module-iot-demo-plugin</artifactId> | |
| 14 | + <artifactId>yudao-module-iot-plugin-http</artifactId> | |
| 15 | + <version>1.0.0</version> | |
| 15 | 16 | |
| 16 | 17 | <name>${project.artifactId}</name> |
| 17 | 18 | <description> |
| 18 | - 物联网 插件模块 - demo 插件 | |
| 19 | + 物联网 插件模块 - http 插件 | |
| 19 | 20 | </description> |
| 20 | 21 | |
| 21 | 22 | <properties> |
| 22 | 23 | <!-- 插件相关 --> |
| 23 | - <plugin.id>demo-plugin</plugin.id> | |
| 24 | - <plugin.class>cn.iocoder.yudao.module.iot.plugin.DemoPlugin</plugin.class> | |
| 25 | - <plugin.version>0.0.1</plugin.version> | |
| 26 | - <plugin.provider>ahh</plugin.provider> | |
| 24 | + <plugin.id>${project.artifactId}</plugin.id> | |
| 25 | + <plugin.class>cn.iocoder.yudao.module.iot.config.HttpVertxPlugin</plugin.class> | |
| 26 | + <plugin.version>${project.version}</plugin.version> | |
| 27 | + <plugin.provider>yudao</plugin.provider> | |
| 28 | + <plugin.description>${project.artifactId}-${project.version}</plugin.description> | |
| 27 | 29 | <plugin.dependencies/> |
| 28 | 30 | </properties> |
| 29 | 31 | |
| 30 | 32 | <build> |
| 31 | 33 | <plugins> |
| 32 | - <!-- DOESN'T WORK WITH MAVEN 3 (I defined the plugin metadata in properties section) | |
| 33 | - <plugin> | |
| 34 | - <groupId>org.codehaus.mojo</groupId> | |
| 35 | - <artifactId>properties-maven-plugin</artifactId> | |
| 36 | - <version>1.0-alpha-2</version> | |
| 37 | - <executions> | |
| 38 | - <execution> | |
| 39 | - <phase>initialize</phase> | |
| 40 | - <goals> | |
| 41 | - <goal>read-project-properties</goal> | |
| 42 | - </goals> | |
| 43 | - <configuration> | |
| 44 | - <files> | |
| 45 | - <file>plugin.properties</file> | |
| 46 | - </files> | |
| 47 | - </configuration> | |
| 48 | - </execution> | |
| 49 | - </executions> | |
| 50 | - </plugin> | |
| 51 | - --> | |
| 52 | - | |
| 34 | + <!-- 插件模式 zip --> | |
| 53 | 35 | <plugin> |
| 54 | 36 | <groupId>org.apache.maven.plugins</groupId> |
| 55 | 37 | <artifactId>maven-antrun-plugin</artifactId> |
| ... | ... | @@ -60,7 +42,8 @@ |
| 60 | 42 | <phase>package</phase> |
| 61 | 43 | <configuration> |
| 62 | 44 | <target> |
| 63 | - <unzip src="target/${project.artifactId}-${project.version}.${project.packaging}" dest="target/plugin-classes" /> | |
| 45 | + <unzip src="target/${project.artifactId}-${project.version}.${project.packaging}" | |
| 46 | + dest="target/plugin-classes"/> | |
| 64 | 47 | </target> |
| 65 | 48 | </configuration> |
| 66 | 49 | <goals> |
| ... | ... | @@ -92,6 +75,7 @@ |
| 92 | 75 | </executions> |
| 93 | 76 | </plugin> |
| 94 | 77 | |
| 78 | + <!-- 插件模式 jar --> | |
| 95 | 79 | <plugin> |
| 96 | 80 | <groupId>org.apache.maven.plugins</groupId> |
| 97 | 81 | <artifactId>maven-jar-plugin</artifactId> |
| ... | ... | @@ -103,12 +87,30 @@ |
| 103 | 87 | <Plugin-Class>${plugin.class}</Plugin-Class> |
| 104 | 88 | <Plugin-Version>${plugin.version}</Plugin-Version> |
| 105 | 89 | <Plugin-Provider>${plugin.provider}</Plugin-Provider> |
| 90 | + <Plugin-Description>${plugin.description}</Plugin-Description> | |
| 106 | 91 | <Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies> |
| 107 | 92 | </manifestEntries> |
| 108 | 93 | </archive> |
| 109 | 94 | </configuration> |
| 110 | 95 | </plugin> |
| 111 | 96 | |
| 97 | + <!-- 独立模式 --> | |
| 98 | + <plugin> | |
| 99 | + <groupId>org.springframework.boot</groupId> | |
| 100 | + <artifactId>spring-boot-maven-plugin</artifactId> | |
| 101 | + <version>${spring.boot.version}</version> | |
| 102 | + <executions> | |
| 103 | + <execution> | |
| 104 | + <goals> | |
| 105 | + <goal>repackage</goal> | |
| 106 | + </goals> | |
| 107 | + <configuration> | |
| 108 | + <classifier>-standalone</classifier> | |
| 109 | + </configuration> | |
| 110 | + </execution> | |
| 111 | + </executions> | |
| 112 | + </plugin> | |
| 113 | + | |
| 112 | 114 | <plugin> |
| 113 | 115 | <artifactId>maven-deploy-plugin</artifactId> |
| 114 | 116 | <configuration> |
| ... | ... | @@ -122,15 +124,12 @@ |
| 122 | 124 | <!-- 其他依赖项 --> |
| 123 | 125 | <dependency> |
| 124 | 126 | <groupId>org.springframework.boot</groupId> |
| 125 | - <artifactId>spring-boot-starter-web</artifactId> | |
| 126 | - <version>${spring.boot.version}</version> | |
| 127 | - <scope>provided</scope> | |
| 127 | + <artifactId>spring-boot-starter</artifactId> | |
| 128 | 128 | </dependency> |
| 129 | 129 | <!-- PF4J Spring 集成 --> |
| 130 | 130 | <dependency> |
| 131 | 131 | <groupId>org.pf4j</groupId> |
| 132 | 132 | <artifactId>pf4j-spring</artifactId> |
| 133 | - <scope>provided</scope> | |
| 134 | 133 | </dependency> |
| 135 | 134 | <!-- 项目依赖 --> |
| 136 | 135 | <dependency> |
| ... | ... | @@ -141,8 +140,11 @@ |
| 141 | 140 | <dependency> |
| 142 | 141 | <groupId>org.projectlombok</groupId> |
| 143 | 142 | <artifactId>lombok</artifactId> |
| 144 | - <version>${lombok.version}</version> | |
| 145 | - <scope>provided</scope> | |
| 143 | + </dependency> | |
| 144 | + <!-- Vert.x Web --> | |
| 145 | + <dependency> | |
| 146 | + <groupId>io.vertx</groupId> | |
| 147 | + <artifactId>vertx-web</artifactId> | |
| 146 | 148 | </dependency> |
| 147 | 149 | </dependencies> |
| 148 | 150 | </project> |
| 149 | 151 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/assembly/assembly.xml renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/assembly/assembly.xml
| ... | ... | @@ -14,14 +14,7 @@ |
| 14 | 14 | </includes> |
| 15 | 15 | </dependencySet> |
| 16 | 16 | </dependencySets> |
| 17 | - <!-- | |
| 18 | - <fileSets> | |
| 19 | - <fileSet> | |
| 20 | - <directory>target/classes</directory> | |
| 21 | - <outputDirectory>classes</outputDirectory> | |
| 22 | - </fileSet> | |
| 23 | - </fileSets> | |
| 24 | - --> | |
| 17 | + | |
| 25 | 18 | <fileSets> |
| 26 | 19 | <fileSet> |
| 27 | 20 | <directory>target/plugin-classes</directory> | ... | ... |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/java/cn/iocoder/yudao/module/iot/HttpPluginSpringbootApplication.java renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/HttpPluginSpringbootApplication.java
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/HttpVertxPlugin.java renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/config/HttpVertxPlugin.java
| 1 | -package cn.iocoder.yudao.module.iot.plugin; | |
| 1 | +package cn.iocoder.yudao.module.iot.config; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.extra.spring.SpringUtil; |
| 4 | 4 | import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; |
| 5 | +import cn.iocoder.yudao.module.iot.service.HttpVertxHandler; | |
| 5 | 6 | import io.vertx.core.Vertx; |
| 6 | 7 | import io.vertx.ext.web.Router; |
| 7 | 8 | import io.vertx.ext.web.handler.BodyHandler; |
| ... | ... | @@ -17,8 +18,6 @@ public class HttpVertxPlugin extends SpringPlugin { |
| 17 | 18 | private static final int PORT = 8092; |
| 18 | 19 | private Vertx vertx; |
| 19 | 20 | |
| 20 | - private DeviceDataApi deviceDataApi; | |
| 21 | - | |
| 22 | 21 | public HttpVertxPlugin(PluginWrapper wrapper) { |
| 23 | 22 | super(wrapper); |
| 24 | 23 | } |
| ... | ... | @@ -28,7 +27,7 @@ public class HttpVertxPlugin extends SpringPlugin { |
| 28 | 27 | log.info("HttpVertxPlugin.start()"); |
| 29 | 28 | |
| 30 | 29 | // 获取 DeviceDataApi 实例 |
| 31 | - deviceDataApi = SpringUtil.getBean(DeviceDataApi.class); | |
| 30 | + DeviceDataApi deviceDataApi = SpringUtil.getBean(DeviceDataApi.class); | |
| 32 | 31 | if (deviceDataApi == null) { |
| 33 | 32 | log.error("未能从 ServiceRegistry 获取 DeviceDataApi 实例,请确保主程序已正确注册!"); |
| 34 | 33 | return; | ... | ... |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/java/cn/iocoder/yudao/module/iot/config/TestConfiguration.java renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/config/TestConfiguration.java
| ... | ... | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.iot.config; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; |
| 4 | 4 | import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO; |
| 5 | -import cn.iocoder.yudao.module.iot.plugin.HttpVertxPlugin; | |
| 6 | 5 | import org.pf4j.DefaultPluginManager; |
| 7 | 6 | import org.pf4j.PluginWrapper; |
| 8 | 7 | import org.springframework.context.annotation.Bean; | ... | ... |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/HttpVertxHandler.java renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/service/HttpVertxHandler.java
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/resources/application.yml
0 → 100644
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-mqtt-plugin/plugin.properties renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-mqtt/plugin.properties
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-mqtt-plugin/pom.xml renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-mqtt/pom.xml
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-emqx-plugin/src/main/assembly/assembly.xml renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-mqtt/src/main/assembly/assembly.xml
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-mqtt-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/MqttPlugin.java renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-mqtt/src/main/java/cn/iocoder/yudao/module/iot/plugin/MqttPlugin.java
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-mqtt-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/MqttServerExtension.java renamed to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-mqtt/src/main/java/cn/iocoder/yudao/module/iot/plugin/MqttServerExtension.java