From 91b817a9ecd1b22d2ea1ee5e0aa1a17f4b2bbd43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=89=E6=B5=A9=E6=B5=A9?= <1036606149@qq.com>
Date: Mon, 16 Dec 2024 22:25:01 +0800
Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=E3=80=91IoT=EF=BC=9A=E5=88=A0=E9=99=A4=20WelcomePlugin?=
=?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=20HttpPlugin=20=E4=BB=A5=E6=94=AF?=
=?UTF-8?q?=E6=8C=81=20HTTP=20=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
yudao-module-iot/pom.xml | 2 +-
.../yudao-module-iot-plugin-api/pom.xml | 4 +-
.../yudao-module-iot-plugin/plugin.properties | 5 -
.../yudao-module-iot-plugin/pom.xml | 149 ++---------------
.../module/iot/plugin/WelcomePlugin.java | 58 -------
.../plugin.properties | 5 +
.../yudao-module-iot-http-plugin/pom.xml | 156 ++++++++++++++++++
.../src/main/assembly/assembly.xml | 0
.../yudao/module/iot/plugin/HttpPlugin.java | 79 +++++++++
9 files changed, 253 insertions(+), 205 deletions(-)
delete mode 100644 yudao-module-iot/yudao-module-iot-plugin/plugin.properties
delete mode 100644 yudao-module-iot/yudao-module-iot-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/WelcomePlugin.java
create mode 100644 yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/plugin.properties
create mode 100644 yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/pom.xml
rename yudao-module-iot/yudao-module-iot-plugin/{ => yudao-module-iot-http-plugin}/src/main/assembly/assembly.xml (100%)
create mode 100644 yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/HttpPlugin.java
diff --git a/yudao-module-iot/pom.xml b/yudao-module-iot/pom.xml
index d47d3c7f64..ecfefab64d 100644
--- a/yudao-module-iot/pom.xml
+++ b/yudao-module-iot/pom.xml
@@ -10,8 +10,8 @@
yudao-module-iot-api
yudao-module-iot-biz
- yudao-module-iot-plugin
yudao-module-iot-plugin-api
+ yudao-module-iot-plugin
4.0.0
diff --git a/yudao-module-iot/yudao-module-iot-plugin-api/pom.xml b/yudao-module-iot/yudao-module-iot-plugin-api/pom.xml
index e04e818deb..6d5eb765b1 100644
--- a/yudao-module-iot/yudao-module-iot-plugin-api/pom.xml
+++ b/yudao-module-iot/yudao-module-iot-plugin-api/pom.xml
@@ -1,6 +1,6 @@
-
4.0.0
cn.iocoder.boot
diff --git a/yudao-module-iot/yudao-module-iot-plugin/plugin.properties b/yudao-module-iot/yudao-module-iot-plugin/plugin.properties
deleted file mode 100644
index bbfe3185c6..0000000000
--- a/yudao-module-iot/yudao-module-iot-plugin/plugin.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-plugin.id=iot-plugin-hppt
-plugin.class=cn.iocoder.yudao.module.iot.plugin.WelcomePlugin
-plugin.version=0.0.1
-plugin.provider=ahh
-plugin.dependencies=
diff --git a/yudao-module-iot/yudao-module-iot-plugin/pom.xml b/yudao-module-iot/yudao-module-iot-plugin/pom.xml
index 52e58d57b4..8ec68638f3 100644
--- a/yudao-module-iot/yudao-module-iot-plugin/pom.xml
+++ b/yudao-module-iot/yudao-module-iot-plugin/pom.xml
@@ -1,149 +1,20 @@
+ 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">
4.0.0
cn.iocoder.boot
yudao-module-iot-plugin
0.0.1
- jar
+ pom
+
+
+ yudao-module-iot-http-plugin
+
${project.artifactId}
- 物联网 模块 - 插件
+
+ 物联网模块 - 插件模块
+
-
-
- iot-plugin-http
- cn.iocoder.yudao.module.iot.plugin.WelcomePlugin
- 0.0.1
- ahh
-
-
-
- 17
- ${java.version}
- ${java.version}
- 1.6
- 2.3
- 2.4
- 0.9.0
-
- 3.3.1
- UTF-8
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
- ${spring.boot.version}
- provided
-
-
-
- org.pf4j
- pf4j-spring
- ${pf4j-spring.version}
- provided
-
-
-
- cn.iocoder.boot
- yudao-module-iot-plugin-api
- ${project.version}
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-antrun-plugin
- ${maven-antrun-plugin.version}
-
-
- unzip jar file
- package
-
-
-
-
-
-
- run
-
-
-
-
-
-
- maven-assembly-plugin
- ${maven-assembly-plugin.version}
-
-
-
- src/main/assembly/assembly.xml
-
-
- false
-
-
-
- make-assembly
- package
-
- attached
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- ${maven-jar-plugin.version}
-
-
-
- ${plugin.id}
- ${plugin.class}
- ${plugin.version}
- ${plugin.provider}
- ${plugin.dependencies}
-
-
-
-
-
-
- maven-deploy-plugin
-
- true
-
-
-
-
\ No newline at end of file
diff --git a/yudao-module-iot/yudao-module-iot-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/WelcomePlugin.java b/yudao-module-iot/yudao-module-iot-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/WelcomePlugin.java
deleted file mode 100644
index 5c53cf8a86..0000000000
--- a/yudao-module-iot/yudao-module-iot-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/WelcomePlugin.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012-present the original author or authors.
- *
- * 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 cn.iocoder.yudao.module.iot.plugin;
-
-import cn.iocoder.yudao.module.iot.api.Greeting;
-import org.apache.commons.lang.StringUtils;
-import org.pf4j.Extension;
-import org.pf4j.Plugin;
-import org.pf4j.PluginWrapper;
-import org.pf4j.RuntimeMode;
-
-/**
- * 打招呼 测试用例
- */
-public class WelcomePlugin extends Plugin {
-
- public WelcomePlugin(PluginWrapper wrapper) {
- super(wrapper);
- }
-
- @Override
- public void start() {
- System.out.println("WelcomePlugin.start()");
- // for testing the development mode
- if (RuntimeMode.DEVELOPMENT.equals(wrapper.getRuntimeMode())) {
- System.out.println(StringUtils.upperCase("WelcomePlugin"));
- }
- }
-
- @Override
- public void stop() {
- System.out.println("WelcomePlugin.stop()");
- }
-
- @Extension
- public static class WelcomeGreeting implements Greeting {
-
- @Override
- public String getGreeting() {
- return "Welcome to PF4J";
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/plugin.properties b/yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/plugin.properties
new file mode 100644
index 0000000000..694c97ba5f
--- /dev/null
+++ b/yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/plugin.properties
@@ -0,0 +1,5 @@
+plugin.id=http-plugin
+plugin.class=cn.iocoder.yudao.module.iot.plugin.HttpPlugin
+plugin.version=0.0.1
+plugin.provider=ahh
+plugin.dependencies=
diff --git a/yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/pom.xml b/yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/pom.xml
new file mode 100644
index 0000000000..eccf47febd
--- /dev/null
+++ b/yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/pom.xml
@@ -0,0 +1,156 @@
+
+
+ 4.0.0
+ cn.iocoder.boot
+ yudao-module-iot-http-plugin
+ 0.0.1
+ jar
+
+ ${project.artifactId}
+ 物联网 模块 - http 插件
+
+
+
+ http-plugin
+ cn.iocoder.yudao.module.iot.plugin.HttpPlugin
+ 0.0.1
+ ahh
+
+
+
+ 17
+ ${java.version}
+ ${java.version}
+ 1.6
+ 2.3
+ 2.4
+ 0.9.0
+
+ 1.18.34
+ 3.3.1
+ UTF-8
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ ${spring.boot.version}
+ provided
+
+
+
+ org.pf4j
+ pf4j-spring
+ ${pf4j-spring.version}
+ provided
+
+
+
+ cn.iocoder.boot
+ yudao-module-iot-plugin-api
+ ${project.version}
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ ${maven-antrun-plugin.version}
+
+
+ unzip jar file
+ package
+
+
+
+
+
+
+ run
+
+
+
+
+
+
+ maven-assembly-plugin
+ ${maven-assembly-plugin.version}
+
+
+
+ src/main/assembly/assembly.xml
+
+
+ false
+
+
+
+ make-assembly
+ package
+
+ attached
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ ${maven-jar-plugin.version}
+
+
+
+ ${plugin.id}
+ ${plugin.class}
+ ${plugin.version}
+ ${plugin.provider}
+ ${plugin.dependencies}
+
+
+
+
+
+
+ maven-deploy-plugin
+
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/yudao-module-iot/yudao-module-iot-plugin/src/main/assembly/assembly.xml b/yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/assembly/assembly.xml
similarity index 100%
rename from yudao-module-iot/yudao-module-iot-plugin/src/main/assembly/assembly.xml
rename to yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/assembly/assembly.xml
diff --git a/yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/HttpPlugin.java b/yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/HttpPlugin.java
new file mode 100644
index 0000000000..32926be452
--- /dev/null
+++ b/yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-http-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/HttpPlugin.java
@@ -0,0 +1,79 @@
+package cn.iocoder.yudao.module.iot.plugin;
+
+import cn.iocoder.yudao.module.iot.api.Greeting;
+import com.sun.net.httpserver.HttpServer;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.pf4j.Extension;
+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 HttpPlugin extends Plugin {
+
+ private HttpServer server;
+
+ public HttpPlugin(PluginWrapper wrapper) {
+ super(wrapper);
+ }
+
+ @Override
+ public void start() {
+ log.info("HttpPlugin.start()");
+ // for testing the development mode
+ if (RuntimeMode.DEVELOPMENT.equals(wrapper.getRuntimeMode())) {
+ log.info("HttpPlugin in DEVELOPMENT mode");
+ }
+ startHttpServer();
+ }
+
+ @Override
+ public void stop() {
+ log.info("HttpPlugin.stop()");
+ stopHttpServer();
+ }
+
+ private void startHttpServer() {
+ try {
+ server = HttpServer.create(new InetSocketAddress(9081), 0);
+ server.createContext("/", exchange -> {
+ String response = "Welcome to PF4J HTTP Server";
+ exchange.sendResponseHeaders(200, response.getBytes().length);
+ OutputStream os = exchange.getResponseBody();
+ os.write(response.getBytes());
+ os.close();
+ });
+ server.setExecutor(null);
+ server.start();
+ log.info("HTTP server started on port 9081");
+ } catch (IOException e) {
+ log.error("Error starting HTTP server", e);
+ }
+ }
+
+ private void stopHttpServer() {
+ if (server != null) {
+ server.stop(0);
+ log.info("HTTP server stopped");
+ }
+ }
+
+ @Extension
+ public static class WelcomeGreeting implements Greeting {
+
+ @Override
+ public String getGreeting() {
+ return "Welcome to PF4J";
+ }
+
+ }
+
+}
\ No newline at end of file