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,9 +8,9 @@ | ||
| 8 | <version>${revision}</version> | 8 | <version>${revision}</version> |
| 9 | </parent> | 9 | </parent> |
| 10 | <modules> | 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 | </modules> | 14 | </modules> |
| 15 | 15 | ||
| 16 | <modelVersion>4.0.0</modelVersion> | 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 | \ No newline at end of file | 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 | \ No newline at end of file | 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
| 1 | -plugin.id=emqx-plugin | 1 | +plugin.id=plugin-emqx |
| 2 | plugin.class=cn.iocoder.yudao.module.iot.plugin.EmqxPlugin | 2 | plugin.class=cn.iocoder.yudao.module.iot.plugin.EmqxPlugin |
| 3 | -plugin.version=0.0.1 | 3 | +plugin.version=1.0.0 |
| 4 | plugin.provider=ahh | 4 | plugin.provider=ahh |
| 5 | plugin.dependencies= | 5 | plugin.dependencies= |
| 6 | -plugin.description=emqx-plugin-0.0.1 | 6 | +plugin.description=plugin-emqx-1.0.0 |
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
| @@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
| 11 | <modelVersion>4.0.0</modelVersion> | 11 | <modelVersion>4.0.0</modelVersion> |
| 12 | <packaging>jar</packaging> | 12 | <packaging>jar</packaging> |
| 13 | 13 | ||
| 14 | - <artifactId>yudao-module-iot-emqx-plugin</artifactId> | 14 | + <artifactId>yudao-module-iot-plugin-emqx</artifactId> |
| 15 | 15 | ||
| 16 | <name>${project.artifactId}</name> | 16 | <name>${project.artifactId}</name> |
| 17 | <description> | 17 | <description> |
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 | package cn.iocoder.yudao.module.iot.plugin; | 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 | import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; | 4 | import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; |
| 5 | import lombok.extern.slf4j.Slf4j; | 5 | import lombok.extern.slf4j.Slf4j; |
| 6 | import org.pf4j.Plugin; | 6 | import org.pf4j.Plugin; |
| 7 | import org.pf4j.PluginWrapper; | 7 | import org.pf4j.PluginWrapper; |
| 8 | 8 | ||
| 9 | -import javax.annotation.Resource; | ||
| 10 | import java.util.concurrent.ExecutorService; | 9 | import java.util.concurrent.ExecutorService; |
| 11 | import java.util.concurrent.Executors; | 10 | import java.util.concurrent.Executors; |
| 12 | 11 | ||
| @@ -14,8 +13,6 @@ import java.util.concurrent.Executors; | @@ -14,8 +13,6 @@ import java.util.concurrent.Executors; | ||
| 14 | public class EmqxPlugin extends Plugin { | 13 | public class EmqxPlugin extends Plugin { |
| 15 | 14 | ||
| 16 | private ExecutorService executorService; | 15 | private ExecutorService executorService; |
| 17 | - @Resource | ||
| 18 | - private DeviceDataApi deviceDataApi; | ||
| 19 | 16 | ||
| 20 | public EmqxPlugin(PluginWrapper wrapper) { | 17 | public EmqxPlugin(PluginWrapper wrapper) { |
| 21 | super(wrapper); | 18 | super(wrapper); |
| @@ -30,7 +27,7 @@ public class EmqxPlugin extends Plugin { | @@ -30,7 +27,7 @@ public class EmqxPlugin extends Plugin { | ||
| 30 | executorService = Executors.newSingleThreadExecutor(); | 27 | executorService = Executors.newSingleThreadExecutor(); |
| 31 | } | 28 | } |
| 32 | 29 | ||
| 33 | - deviceDataApi = ServiceRegistry.getService(DeviceDataApi.class); | 30 | + DeviceDataApi deviceDataApi = SpringUtil.getBean(DeviceDataApi.class); |
| 34 | if (deviceDataApi == null) { | 31 | if (deviceDataApi == null) { |
| 35 | log.error("未能从 ServiceRegistry 获取 DeviceDataApi 实例,请确保主程序已正确注册!"); | 32 | log.error("未能从 ServiceRegistry 获取 DeviceDataApi 实例,请确保主程序已正确注册!"); |
| 36 | return; | 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,37 +6,15 @@ | ||
| 6 | <version>2.2.0-snapshot</version> | 6 | <version>2.2.0-snapshot</version> |
| 7 | </parent> | 7 | </parent> |
| 8 | <modelVersion>4.0.0</modelVersion> | 8 | <modelVersion>4.0.0</modelVersion> |
| 9 | - <artifactId>yudao-module-iot-http-plugin</artifactId> | 9 | + <artifactId>yudao-module-iot-plugin-http</artifactId> |
| 10 | <name>${project.artifactId}</name> | 10 | <name>${project.artifactId}</name> |
| 11 | - <version>2.2.0-snapshot</version> | 11 | + <version>1.0.0</version> |
| 12 | <description>物联网 插件模块 - http 插件</description> | 12 | <description>物联网 插件模块 - http 插件</description> |
| 13 | <build> | 13 | <build> |
| 14 | <plugins> | 14 | <plugins> |
| 15 | <plugin> | 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 | <artifactId>maven-shade-plugin</artifactId> | 16 | <artifactId>maven-shade-plugin</artifactId> |
| 39 | - <version>3.4.1</version> | 17 | + <version>3.2.4</version> |
| 40 | <executions> | 18 | <executions> |
| 41 | <execution> | 19 | <execution> |
| 42 | <phase>package</phase> | 20 | <phase>package</phase> |
| @@ -44,11 +22,9 @@ | @@ -44,11 +22,9 @@ | ||
| 44 | <goal>shade</goal> | 22 | <goal>shade</goal> |
| 45 | </goals> | 23 | </goals> |
| 46 | <configuration> | 24 | <configuration> |
| 47 | - <shadedArtifactAttached>true</shadedArtifactAttached> | ||
| 48 | - <shadedClassifierName>shaded</shadedClassifierName> | ||
| 49 | <transformers> | 25 | <transformers> |
| 50 | <transformer> | 26 | <transformer> |
| 51 | - <mainClass>cn.iocoder.yudao.module.iot.HttpPluginSpringbootApplication</mainClass> | 27 | + <mainClass>com.example.HttpPluginSpringbootApplication</mainClass> |
| 52 | </transformer> | 28 | </transformer> |
| 53 | </transformers> | 29 | </transformers> |
| 54 | </configuration> | 30 | </configuration> |
| @@ -57,25 +33,11 @@ | @@ -57,25 +33,11 @@ | ||
| 57 | </plugin> | 33 | </plugin> |
| 58 | </plugins> | 34 | </plugins> |
| 59 | </build> | 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 | <properties> | 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 | </properties> | 42 | </properties> |
| 81 | </project> | 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,45 +11,27 @@ | ||
| 11 | <modelVersion>4.0.0</modelVersion> | 11 | <modelVersion>4.0.0</modelVersion> |
| 12 | <packaging>jar</packaging> | 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 | <name>${project.artifactId}</name> | 17 | <name>${project.artifactId}</name> |
| 17 | <description> | 18 | <description> |
| 18 | - 物联网 插件模块 - demo 插件 | 19 | + 物联网 插件模块 - http 插件 |
| 19 | </description> | 20 | </description> |
| 20 | 21 | ||
| 21 | <properties> | 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 | <plugin.dependencies/> | 29 | <plugin.dependencies/> |
| 28 | </properties> | 30 | </properties> |
| 29 | 31 | ||
| 30 | <build> | 32 | <build> |
| 31 | <plugins> | 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 | <plugin> | 35 | <plugin> |
| 54 | <groupId>org.apache.maven.plugins</groupId> | 36 | <groupId>org.apache.maven.plugins</groupId> |
| 55 | <artifactId>maven-antrun-plugin</artifactId> | 37 | <artifactId>maven-antrun-plugin</artifactId> |
| @@ -60,7 +42,8 @@ | @@ -60,7 +42,8 @@ | ||
| 60 | <phase>package</phase> | 42 | <phase>package</phase> |
| 61 | <configuration> | 43 | <configuration> |
| 62 | <target> | 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 | </target> | 47 | </target> |
| 65 | </configuration> | 48 | </configuration> |
| 66 | <goals> | 49 | <goals> |
| @@ -92,6 +75,7 @@ | @@ -92,6 +75,7 @@ | ||
| 92 | </executions> | 75 | </executions> |
| 93 | </plugin> | 76 | </plugin> |
| 94 | 77 | ||
| 78 | + <!-- 插件模式 jar --> | ||
| 95 | <plugin> | 79 | <plugin> |
| 96 | <groupId>org.apache.maven.plugins</groupId> | 80 | <groupId>org.apache.maven.plugins</groupId> |
| 97 | <artifactId>maven-jar-plugin</artifactId> | 81 | <artifactId>maven-jar-plugin</artifactId> |
| @@ -103,12 +87,30 @@ | @@ -103,12 +87,30 @@ | ||
| 103 | <Plugin-Class>${plugin.class}</Plugin-Class> | 87 | <Plugin-Class>${plugin.class}</Plugin-Class> |
| 104 | <Plugin-Version>${plugin.version}</Plugin-Version> | 88 | <Plugin-Version>${plugin.version}</Plugin-Version> |
| 105 | <Plugin-Provider>${plugin.provider}</Plugin-Provider> | 89 | <Plugin-Provider>${plugin.provider}</Plugin-Provider> |
| 90 | + <Plugin-Description>${plugin.description}</Plugin-Description> | ||
| 106 | <Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies> | 91 | <Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies> |
| 107 | </manifestEntries> | 92 | </manifestEntries> |
| 108 | </archive> | 93 | </archive> |
| 109 | </configuration> | 94 | </configuration> |
| 110 | </plugin> | 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 | <plugin> | 114 | <plugin> |
| 113 | <artifactId>maven-deploy-plugin</artifactId> | 115 | <artifactId>maven-deploy-plugin</artifactId> |
| 114 | <configuration> | 116 | <configuration> |
| @@ -122,15 +124,12 @@ | @@ -122,15 +124,12 @@ | ||
| 122 | <!-- 其他依赖项 --> | 124 | <!-- 其他依赖项 --> |
| 123 | <dependency> | 125 | <dependency> |
| 124 | <groupId>org.springframework.boot</groupId> | 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 | </dependency> | 128 | </dependency> |
| 129 | <!-- PF4J Spring 集成 --> | 129 | <!-- PF4J Spring 集成 --> |
| 130 | <dependency> | 130 | <dependency> |
| 131 | <groupId>org.pf4j</groupId> | 131 | <groupId>org.pf4j</groupId> |
| 132 | <artifactId>pf4j-spring</artifactId> | 132 | <artifactId>pf4j-spring</artifactId> |
| 133 | - <scope>provided</scope> | ||
| 134 | </dependency> | 133 | </dependency> |
| 135 | <!-- 项目依赖 --> | 134 | <!-- 项目依赖 --> |
| 136 | <dependency> | 135 | <dependency> |
| @@ -141,8 +140,11 @@ | @@ -141,8 +140,11 @@ | ||
| 141 | <dependency> | 140 | <dependency> |
| 142 | <groupId>org.projectlombok</groupId> | 141 | <groupId>org.projectlombok</groupId> |
| 143 | <artifactId>lombok</artifactId> | 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 | </dependency> | 148 | </dependency> |
| 147 | </dependencies> | 149 | </dependencies> |
| 148 | </project> | 150 | </project> |
| 149 | \ No newline at end of file | 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 +14,7 @@ | ||
| 14 | </includes> | 14 | </includes> |
| 15 | </dependencySet> | 15 | </dependencySet> |
| 16 | </dependencySets> | 16 | </dependencySets> |
| 17 | - <!-- | ||
| 18 | - <fileSets> | ||
| 19 | - <fileSet> | ||
| 20 | - <directory>target/classes</directory> | ||
| 21 | - <outputDirectory>classes</outputDirectory> | ||
| 22 | - </fileSet> | ||
| 23 | - </fileSets> | ||
| 24 | - --> | 17 | + |
| 25 | <fileSets> | 18 | <fileSets> |
| 26 | <fileSet> | 19 | <fileSet> |
| 27 | <directory>target/plugin-classes</directory> | 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 | import cn.hutool.extra.spring.SpringUtil; | 3 | import cn.hutool.extra.spring.SpringUtil; |
| 4 | import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; | 4 | import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; |
| 5 | +import cn.iocoder.yudao.module.iot.service.HttpVertxHandler; | ||
| 5 | import io.vertx.core.Vertx; | 6 | import io.vertx.core.Vertx; |
| 6 | import io.vertx.ext.web.Router; | 7 | import io.vertx.ext.web.Router; |
| 7 | import io.vertx.ext.web.handler.BodyHandler; | 8 | import io.vertx.ext.web.handler.BodyHandler; |
| @@ -17,8 +18,6 @@ public class HttpVertxPlugin extends SpringPlugin { | @@ -17,8 +18,6 @@ public class HttpVertxPlugin extends SpringPlugin { | ||
| 17 | private static final int PORT = 8092; | 18 | private static final int PORT = 8092; |
| 18 | private Vertx vertx; | 19 | private Vertx vertx; |
| 19 | 20 | ||
| 20 | - private DeviceDataApi deviceDataApi; | ||
| 21 | - | ||
| 22 | public HttpVertxPlugin(PluginWrapper wrapper) { | 21 | public HttpVertxPlugin(PluginWrapper wrapper) { |
| 23 | super(wrapper); | 22 | super(wrapper); |
| 24 | } | 23 | } |
| @@ -28,7 +27,7 @@ public class HttpVertxPlugin extends SpringPlugin { | @@ -28,7 +27,7 @@ public class HttpVertxPlugin extends SpringPlugin { | ||
| 28 | log.info("HttpVertxPlugin.start()"); | 27 | log.info("HttpVertxPlugin.start()"); |
| 29 | 28 | ||
| 30 | // 获取 DeviceDataApi 实例 | 29 | // 获取 DeviceDataApi 实例 |
| 31 | - deviceDataApi = SpringUtil.getBean(DeviceDataApi.class); | 30 | + DeviceDataApi deviceDataApi = SpringUtil.getBean(DeviceDataApi.class); |
| 32 | if (deviceDataApi == null) { | 31 | if (deviceDataApi == null) { |
| 33 | log.error("未能从 ServiceRegistry 获取 DeviceDataApi 实例,请确保主程序已正确注册!"); | 32 | log.error("未能从 ServiceRegistry 获取 DeviceDataApi 实例,请确保主程序已正确注册!"); |
| 34 | return; | 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,7 +2,6 @@ package cn.iocoder.yudao.module.iot.config; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; | 3 | import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; |
| 4 | import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO; | 4 | import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO; |
| 5 | -import cn.iocoder.yudao.module.iot.plugin.HttpVertxPlugin; | ||
| 6 | import org.pf4j.DefaultPluginManager; | 5 | import org.pf4j.DefaultPluginManager; |
| 7 | import org.pf4j.PluginWrapper; | 6 | import org.pf4j.PluginWrapper; |
| 8 | import org.springframework.context.annotation.Bean; | 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
| @@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
| 11 | <modelVersion>4.0.0</modelVersion> | 11 | <modelVersion>4.0.0</modelVersion> |
| 12 | <packaging>jar</packaging> | 12 | <packaging>jar</packaging> |
| 13 | 13 | ||
| 14 | - <artifactId>yudao-module-iot-mqtt-plugin</artifactId> | 14 | + <artifactId>yudao-module-iot-plugin-mqtt</artifactId> |
| 15 | 15 | ||
| 16 | <name>${project.artifactId}</name> | 16 | <name>${project.artifactId}</name> |
| 17 | <description> | 17 | <description> |
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