【功能完善】IoT: 删除旧版 HTTP 插件,新增 HTTP 和 MQTT 插件,重构插件管理逻辑,优化代码结构,支持 EMQX 插件,更新相关配置文件。
This commit is contained in:
parent
d608c4b984
commit
a152f6d98f
Binary file not shown.
Binary file not shown.
|
@ -8,9 +8,9 @@
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modules>
|
<modules>
|
||||||
<module>yudao-module-iot-demo-plugin</module>
|
<module>yudao-module-iot-plugin-http</module>
|
||||||
<module>yudao-module-iot-http-plugin</module>
|
<module>yudao-module-iot-plugin-mqtt</module>
|
||||||
<module>yudao-module-iot-mqtt-plugin</module>
|
<module>yudao-module-iot-plugin-emqx</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
plugin.id=demo-plugin
|
|
||||||
plugin.class=cn.iocoder.yudao.module.iot.plugin.DemoPlugin
|
|
||||||
plugin.version=0.0.1
|
|
||||||
plugin.provider=ahh
|
|
||||||
plugin.dependencies=
|
|
||||||
plugin.description=demo-plugin
|
|
|
@ -1,77 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.iot.plugin;
|
|
||||||
|
|
||||||
import com.sun.net.httpserver.HttpServer;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.pf4j.Plugin;
|
|
||||||
import org.pf4j.PluginWrapper;
|
|
||||||
import org.pf4j.RuntimeMode;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 一个启动 HTTP 服务器的简单插件。
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class DemoPlugin extends Plugin {
|
|
||||||
|
|
||||||
private HttpServer server;
|
|
||||||
|
|
||||||
public DemoPlugin(PluginWrapper wrapper) {
|
|
||||||
super(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() {
|
|
||||||
log.info("Demo 插件启动");
|
|
||||||
// for testing the development mode
|
|
||||||
if (RuntimeMode.DEVELOPMENT.equals(wrapper.getRuntimeMode())) {
|
|
||||||
log.info("DemoPlugin in DEVELOPMENT mode");
|
|
||||||
}
|
|
||||||
startDemoServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop() {
|
|
||||||
log.info("Demo 插件停止");
|
|
||||||
stopDemoServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startDemoServer() {
|
|
||||||
try {
|
|
||||||
server = HttpServer.create(new InetSocketAddress(9081), 0);
|
|
||||||
server.createContext("/", exchange -> {
|
|
||||||
String response = "Hello from DemoPlugin";
|
|
||||||
exchange.sendResponseHeaders(200, response.getBytes().length);
|
|
||||||
OutputStream os = exchange.getResponseBody();
|
|
||||||
os.write(response.getBytes());
|
|
||||||
os.close();
|
|
||||||
});
|
|
||||||
server.setExecutor(null);
|
|
||||||
server.start();
|
|
||||||
log.info("HTTP 服务器启动成功,端口为 9081");
|
|
||||||
log.info("访问地址为 http://127.0.0.1:9081/");
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("HTTP 服务器启动失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stopDemoServer() {
|
|
||||||
if (server != null) {
|
|
||||||
server.stop(0);
|
|
||||||
log.info("HTTP 服务器停止成功");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Extension
|
|
||||||
// public static class WelcomeGreeting implements Greeting {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String getGreeting() {
|
|
||||||
// return "Welcome to DemoPlugin";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,81 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>yudao-module-iot-plugin</artifactId>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<version>2.2.0-snapshot</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>yudao-module-iot-http-plugin</artifactId>
|
|
||||||
<name>${project.artifactId}</name>
|
|
||||||
<version>2.2.0-snapshot</version>
|
|
||||||
<description>物联网 插件模块 - http 插件</description>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>2.4</version>
|
|
||||||
<configuration>
|
|
||||||
<archive>
|
|
||||||
<manifestEntries>
|
|
||||||
<Plugin-Id>${plugin.id}</Plugin-Id>
|
|
||||||
<Plugin-Class>${plugin.class}</Plugin-Class>
|
|
||||||
<Plugin-Version>${plugin.version}</Plugin-Version>
|
|
||||||
<Plugin-Provider>${plugin.provider}</Plugin-Provider>
|
|
||||||
<Plugin-Description>${plugin.description}</Plugin-Description>
|
|
||||||
<Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies>
|
|
||||||
</manifestEntries>
|
|
||||||
</archive>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<skip>true</skip>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.4.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
|
||||||
<shadedClassifierName>shaded</shadedClassifierName>
|
|
||||||
<transformers>
|
|
||||||
<transformer>
|
|
||||||
<mainClass>cn.iocoder.yudao.module.iot.HttpPluginSpringbootApplication</mainClass>
|
|
||||||
</transformer>
|
|
||||||
</transformers>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.pf4j</groupId>
|
|
||||||
<artifactId>pf4j-spring</artifactId>
|
|
||||||
<version>0.9.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.34</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<properties>
|
|
||||||
<plugin.class>cn.iocoder.yudao.module.iot.plugin.HttpVertxPlugin</plugin.class>
|
|
||||||
<plugin.version>0.0.1</plugin.version>
|
|
||||||
<plugin.id>http-plugin</plugin.id>
|
|
||||||
<plugin.description>http-plugin-0.0.1</plugin.description>
|
|
||||||
<plugin.provider>ahh</plugin.provider>
|
|
||||||
</properties>
|
|
||||||
</project>
|
|
|
@ -1,6 +0,0 @@
|
||||||
plugin.id=http-plugin
|
|
||||||
plugin.class=cn.iocoder.yudao.module.iot.plugin.HttpVertxPlugin
|
|
||||||
plugin.version=0.0.1
|
|
||||||
plugin.provider=ahh
|
|
||||||
plugin.dependencies=
|
|
||||||
plugin.description=http-plugin-0.0.1
|
|
|
@ -1,157 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="
|
|
||||||
http://maven.apache.org/POM/4.0.0
|
|
||||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>yudao-module-iot-plugin</artifactId>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<artifactId>yudao-module-iot-http-plugin</artifactId>
|
|
||||||
|
|
||||||
<name>${project.artifactId}</name>
|
|
||||||
<description>
|
|
||||||
物联网 插件模块 - http 插件
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<!-- 插件相关 -->
|
|
||||||
<plugin.id>http-plugin</plugin.id>
|
|
||||||
<plugin.class>cn.iocoder.yudao.module.iot.plugin.HttpVertxPlugin</plugin.class>
|
|
||||||
<plugin.version>0.0.1</plugin.version>
|
|
||||||
<plugin.provider>ahh</plugin.provider>
|
|
||||||
<plugin.description>http-plugin-0.0.1</plugin.description>
|
|
||||||
<plugin.dependencies/>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
|
||||||
<version>1.6</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>unzip jar file</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
<configuration>
|
|
||||||
<target>
|
|
||||||
<unzip src="target/${project.artifactId}-${project.version}.${project.packaging}"
|
|
||||||
dest="target/plugin-classes"/>
|
|
||||||
</target>
|
|
||||||
</configuration>
|
|
||||||
<goals>
|
|
||||||
<goal>run</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
|
||||||
<version>2.3</version>
|
|
||||||
<configuration>
|
|
||||||
<descriptors>
|
|
||||||
<descriptor>
|
|
||||||
src/main/assembly/assembly.xml
|
|
||||||
</descriptor>
|
|
||||||
</descriptors>
|
|
||||||
<appendAssemblyId>false</appendAssemblyId>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>make-assembly</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>attached</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>2.4</version>
|
|
||||||
<configuration>
|
|
||||||
<archive>
|
|
||||||
<manifestEntries>
|
|
||||||
<Plugin-Id>${plugin.id}</Plugin-Id>
|
|
||||||
<Plugin-Class>${plugin.class}</Plugin-Class>
|
|
||||||
<Plugin-Version>${plugin.version}</Plugin-Version>
|
|
||||||
<Plugin-Provider>${plugin.provider}</Plugin-Provider>
|
|
||||||
<Plugin-Description>${plugin.description}</Plugin-Description>
|
|
||||||
<Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies>
|
|
||||||
</manifestEntries>
|
|
||||||
</archive>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<skip>true</skip>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- <plugin>-->
|
|
||||||
<!-- <groupId>org.apache.maven.plugins</groupId>-->
|
|
||||||
<!-- <artifactId>maven-shade-plugin</artifactId>-->
|
|
||||||
<!-- <version>3.4.1</version>-->
|
|
||||||
<!-- <executions>-->
|
|
||||||
<!-- <execution>-->
|
|
||||||
<!-- <phase>package</phase>-->
|
|
||||||
<!-- <goals>-->
|
|
||||||
<!-- <goal>shade</goal>-->
|
|
||||||
<!-- </goals>-->
|
|
||||||
<!-- <configuration>-->
|
|
||||||
<!-- <shadedArtifactAttached>true</shadedArtifactAttached>-->
|
|
||||||
<!-- <shadedClassifierName>shaded</shadedClassifierName>-->
|
|
||||||
<!-- <transformers>-->
|
|
||||||
<!-- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">-->
|
|
||||||
<!-- <mainClass>cn.iocoder.yudao.module.iot.HttpPluginSpringbootApplication</mainClass>-->
|
|
||||||
<!-- </transformer>-->
|
|
||||||
<!-- </transformers>-->
|
|
||||||
<!-- </configuration>-->
|
|
||||||
<!-- </execution>-->
|
|
||||||
<!-- </executions>-->
|
|
||||||
<!-- </plugin>-->
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- 其他依赖项 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- PF4J Spring 集成 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.pf4j</groupId>
|
|
||||||
<artifactId>pf4j-spring</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- 项目依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-module-iot-api</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>${lombok.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- Vert.x Web -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.vertx</groupId>
|
|
||||||
<artifactId>vertx-web</artifactId>
|
|
||||||
<version>4.5.11</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,12 +0,0 @@
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
name: yudao-module-iot-http-plugin
|
|
||||||
|
|
||||||
# MQTT-RPC 配置
|
|
||||||
mqtt:
|
|
||||||
broker: tcp://chaojiniu.top:1883
|
|
||||||
username: haohao
|
|
||||||
password: ahh@123456
|
|
||||||
clientId: mqtt-rpc-client-${random.int}
|
|
||||||
requestTopic: rpc/request
|
|
||||||
responseTopicPrefix: rpc/response/
|
|
|
@ -1,31 +0,0 @@
|
||||||
<assembly>
|
|
||||||
<id>plugin</id>
|
|
||||||
<formats>
|
|
||||||
<format>zip</format>
|
|
||||||
</formats>
|
|
||||||
<includeBaseDirectory>false</includeBaseDirectory>
|
|
||||||
<dependencySets>
|
|
||||||
<dependencySet>
|
|
||||||
<useProjectArtifact>false</useProjectArtifact>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
<outputDirectory>lib</outputDirectory>
|
|
||||||
<includes>
|
|
||||||
<include>*:jar:*</include>
|
|
||||||
</includes>
|
|
||||||
</dependencySet>
|
|
||||||
</dependencySets>
|
|
||||||
<!--
|
|
||||||
<fileSets>
|
|
||||||
<fileSet>
|
|
||||||
<directory>target/classes</directory>
|
|
||||||
<outputDirectory>classes</outputDirectory>
|
|
||||||
</fileSet>
|
|
||||||
</fileSets>
|
|
||||||
-->
|
|
||||||
<fileSets>
|
|
||||||
<fileSet>
|
|
||||||
<directory>target/plugin-classes</directory>
|
|
||||||
<outputDirectory>classes</outputDirectory>
|
|
||||||
</fileSet>
|
|
||||||
</fileSets>
|
|
||||||
</assembly>
|
|
|
@ -1,6 +1,6 @@
|
||||||
plugin.id=emqx-plugin
|
plugin.id=plugin-emqx
|
||||||
plugin.class=cn.iocoder.yudao.module.iot.plugin.EmqxPlugin
|
plugin.class=cn.iocoder.yudao.module.iot.plugin.EmqxPlugin
|
||||||
plugin.version=0.0.1
|
plugin.version=1.0.0
|
||||||
plugin.provider=ahh
|
plugin.provider=ahh
|
||||||
plugin.dependencies=
|
plugin.dependencies=
|
||||||
plugin.description=emqx-plugin-0.0.1
|
plugin.description=plugin-emqx-1.0.0
|
|
@ -11,7 +11,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<artifactId>yudao-module-iot-emqx-plugin</artifactId>
|
<artifactId>yudao-module-iot-plugin-emqx</artifactId>
|
||||||
|
|
||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
<description>
|
<description>
|
|
@ -1,12 +1,11 @@
|
||||||
package cn.iocoder.yudao.module.iot.plugin;
|
package cn.iocoder.yudao.module.iot.plugin;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.iot.api.ServiceRegistry;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi;
|
import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.pf4j.Plugin;
|
import org.pf4j.Plugin;
|
||||||
import org.pf4j.PluginWrapper;
|
import org.pf4j.PluginWrapper;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
@ -14,8 +13,6 @@ import java.util.concurrent.Executors;
|
||||||
public class EmqxPlugin extends Plugin {
|
public class EmqxPlugin extends Plugin {
|
||||||
|
|
||||||
private ExecutorService executorService;
|
private ExecutorService executorService;
|
||||||
@Resource
|
|
||||||
private DeviceDataApi deviceDataApi;
|
|
||||||
|
|
||||||
public EmqxPlugin(PluginWrapper wrapper) {
|
public EmqxPlugin(PluginWrapper wrapper) {
|
||||||
super(wrapper);
|
super(wrapper);
|
||||||
|
@ -30,7 +27,7 @@ public class EmqxPlugin extends Plugin {
|
||||||
executorService = Executors.newSingleThreadExecutor();
|
executorService = Executors.newSingleThreadExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceDataApi = ServiceRegistry.getService(DeviceDataApi.class);
|
DeviceDataApi deviceDataApi = SpringUtil.getBean(DeviceDataApi.class);
|
||||||
if (deviceDataApi == null) {
|
if (deviceDataApi == null) {
|
||||||
log.error("未能从 ServiceRegistry 获取 DeviceDataApi 实例,请确保主程序已正确注册!");
|
log.error("未能从 ServiceRegistry 获取 DeviceDataApi 实例,请确保主程序已正确注册!");
|
||||||
return;
|
return;
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>yudao-module-iot-plugin</artifactId>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<version>2.2.0-snapshot</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>yudao-module-iot-plugin-http</artifactId>
|
||||||
|
<name>${project.artifactId}</name>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<description>物联网 插件模块 - http 插件</description>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<transformers>
|
||||||
|
<transformer>
|
||||||
|
<mainClass>com.example.HttpPluginSpringbootApplication</mainClass>
|
||||||
|
</transformer>
|
||||||
|
</transformers>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<properties>
|
||||||
|
<plugin.id>${project.artifactId}</plugin.id>
|
||||||
|
<plugin.description>${project.artifactId}-${project.version}</plugin.description>
|
||||||
|
<plugin.class>cn.iocoder.yudao.module.iot.config.HttpVertxPlugin</plugin.class>
|
||||||
|
<plugin.version>${project.version}</plugin.version>
|
||||||
|
<plugin.provider>yudao</plugin.provider>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
plugin.id=yudao-module-iot-plugin-http
|
||||||
|
plugin.class=cn.iocoder.yudao.module.iot.config.HttpVertxPlugin
|
||||||
|
plugin.version=1.0.0
|
||||||
|
plugin.provider=yudao
|
||||||
|
plugin.dependencies=
|
||||||
|
plugin.description=yudao-module-iot-plugin-http-1.0.0
|
|
@ -11,45 +11,27 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<artifactId>yudao-module-iot-demo-plugin</artifactId>
|
<artifactId>yudao-module-iot-plugin-http</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
|
||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
<description>
|
<description>
|
||||||
物联网 插件模块 - demo 插件
|
物联网 插件模块 - http 插件
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- 插件相关 -->
|
<!-- 插件相关 -->
|
||||||
<plugin.id>demo-plugin</plugin.id>
|
<plugin.id>${project.artifactId}</plugin.id>
|
||||||
<plugin.class>cn.iocoder.yudao.module.iot.plugin.DemoPlugin</plugin.class>
|
<plugin.class>cn.iocoder.yudao.module.iot.config.HttpVertxPlugin</plugin.class>
|
||||||
<plugin.version>0.0.1</plugin.version>
|
<plugin.version>${project.version}</plugin.version>
|
||||||
<plugin.provider>ahh</plugin.provider>
|
<plugin.provider>yudao</plugin.provider>
|
||||||
|
<plugin.description>${project.artifactId}-${project.version}</plugin.description>
|
||||||
<plugin.dependencies/>
|
<plugin.dependencies/>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<!-- DOESN'T WORK WITH MAVEN 3 (I defined the plugin metadata in properties section)
|
<!-- 插件模式 zip -->
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>properties-maven-plugin</artifactId>
|
|
||||||
<version>1.0-alpha-2</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>initialize</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>read-project-properties</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<files>
|
|
||||||
<file>plugin.properties</file>
|
|
||||||
</files>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
@ -60,7 +42,8 @@
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>
|
<target>
|
||||||
<unzip src="target/${project.artifactId}-${project.version}.${project.packaging}" dest="target/plugin-classes" />
|
<unzip src="target/${project.artifactId}-${project.version}.${project.packaging}"
|
||||||
|
dest="target/plugin-classes"/>
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
<goals>
|
<goals>
|
||||||
|
@ -92,6 +75,7 @@
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<!-- 插件模式 jar -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
@ -103,12 +87,30 @@
|
||||||
<Plugin-Class>${plugin.class}</Plugin-Class>
|
<Plugin-Class>${plugin.class}</Plugin-Class>
|
||||||
<Plugin-Version>${plugin.version}</Plugin-Version>
|
<Plugin-Version>${plugin.version}</Plugin-Version>
|
||||||
<Plugin-Provider>${plugin.provider}</Plugin-Provider>
|
<Plugin-Provider>${plugin.provider}</Plugin-Provider>
|
||||||
|
<Plugin-Description>${plugin.description}</Plugin-Description>
|
||||||
<Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies>
|
<Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies>
|
||||||
</manifestEntries>
|
</manifestEntries>
|
||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<!-- 独立模式 -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring.boot.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<classifier>-standalone</classifier>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
@ -122,15 +124,12 @@
|
||||||
<!-- 其他依赖项 -->
|
<!-- 其他依赖项 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
<version>${spring.boot.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- PF4J Spring 集成 -->
|
<!-- PF4J Spring 集成 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.pf4j</groupId>
|
<groupId>org.pf4j</groupId>
|
||||||
<artifactId>pf4j-spring</artifactId>
|
<artifactId>pf4j-spring</artifactId>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 项目依赖 -->
|
<!-- 项目依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -141,8 +140,11 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>${lombok.version}</version>
|
</dependency>
|
||||||
<scope>provided</scope>
|
<!-- Vert.x Web -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.vertx</groupId>
|
||||||
|
<artifactId>vertx-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -14,14 +14,7 @@
|
||||||
</includes>
|
</includes>
|
||||||
</dependencySet>
|
</dependencySet>
|
||||||
</dependencySets>
|
</dependencySets>
|
||||||
<!--
|
|
||||||
<fileSets>
|
|
||||||
<fileSet>
|
|
||||||
<directory>target/classes</directory>
|
|
||||||
<outputDirectory>classes</outputDirectory>
|
|
||||||
</fileSet>
|
|
||||||
</fileSets>
|
|
||||||
-->
|
|
||||||
<fileSets>
|
<fileSets>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>target/plugin-classes</directory>
|
<directory>target/plugin-classes</directory>
|
|
@ -1,7 +1,8 @@
|
||||||
package cn.iocoder.yudao.module.iot.plugin;
|
package cn.iocoder.yudao.module.iot.config;
|
||||||
|
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi;
|
import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi;
|
||||||
|
import cn.iocoder.yudao.module.iot.service.HttpVertxHandler;
|
||||||
import io.vertx.core.Vertx;
|
import io.vertx.core.Vertx;
|
||||||
import io.vertx.ext.web.Router;
|
import io.vertx.ext.web.Router;
|
||||||
import io.vertx.ext.web.handler.BodyHandler;
|
import io.vertx.ext.web.handler.BodyHandler;
|
||||||
|
@ -17,8 +18,6 @@ public class HttpVertxPlugin extends SpringPlugin {
|
||||||
private static final int PORT = 8092;
|
private static final int PORT = 8092;
|
||||||
private Vertx vertx;
|
private Vertx vertx;
|
||||||
|
|
||||||
private DeviceDataApi deviceDataApi;
|
|
||||||
|
|
||||||
public HttpVertxPlugin(PluginWrapper wrapper) {
|
public HttpVertxPlugin(PluginWrapper wrapper) {
|
||||||
super(wrapper);
|
super(wrapper);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +27,7 @@ public class HttpVertxPlugin extends SpringPlugin {
|
||||||
log.info("HttpVertxPlugin.start()");
|
log.info("HttpVertxPlugin.start()");
|
||||||
|
|
||||||
// 获取 DeviceDataApi 实例
|
// 获取 DeviceDataApi 实例
|
||||||
deviceDataApi = SpringUtil.getBean(DeviceDataApi.class);
|
DeviceDataApi deviceDataApi = SpringUtil.getBean(DeviceDataApi.class);
|
||||||
if (deviceDataApi == null) {
|
if (deviceDataApi == null) {
|
||||||
log.error("未能从 ServiceRegistry 获取 DeviceDataApi 实例,请确保主程序已正确注册!");
|
log.error("未能从 ServiceRegistry 获取 DeviceDataApi 实例,请确保主程序已正确注册!");
|
||||||
return;
|
return;
|
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.iot.config;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi;
|
import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi;
|
||||||
import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO;
|
import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.iot.plugin.HttpVertxPlugin;
|
|
||||||
import org.pf4j.DefaultPluginManager;
|
import org.pf4j.DefaultPluginManager;
|
||||||
import org.pf4j.PluginWrapper;
|
import org.pf4j.PluginWrapper;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
|
@ -1,4 +1,4 @@
|
||||||
package cn.iocoder.yudao.module.iot.plugin;
|
package cn.iocoder.yudao.module.iot.service;
|
||||||
|
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
|
@ -0,0 +1,3 @@
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: yudao-module-iot-plugin-http
|
|
@ -11,7 +11,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<artifactId>yudao-module-iot-mqtt-plugin</artifactId>
|
<artifactId>yudao-module-iot-plugin-mqtt</artifactId>
|
||||||
|
|
||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
<description>
|
<description>
|
Loading…
Reference in New Issue