Commit ce4912304388f6dd4b38cdd1718b90019aa7578b
1 parent
290fcd94
【功能修改】IoT:更新问候语打印方法,返回问候语数量;删除不再使用的插件控制器和配置类
Showing
5 changed files
with
6 additions
and
76 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininfo/Greetings.java
| @@ -30,11 +30,12 @@ public class Greetings { | @@ -30,11 +30,12 @@ public class Greetings { | ||
| 30 | @Autowired | 30 | @Autowired |
| 31 | private List<Greeting> greetings; | 31 | private List<Greeting> greetings; |
| 32 | 32 | ||
| 33 | - public void printGreetings() { | 33 | + public Integer printGreetings() { |
| 34 | System.out.printf("找到扩展点的 %d 个扩展 '%s'%n", greetings.size(), Greeting.class.getName()); | 34 | System.out.printf("找到扩展点的 %d 个扩展 '%s'%n", greetings.size(), Greeting.class.getName()); |
| 35 | for (Greeting greeting : greetings) { | 35 | for (Greeting greeting : greetings) { |
| 36 | System.out.println(">>> " + greeting.getGreeting()); | 36 | System.out.println(">>> " + greeting.getGreeting()); |
| 37 | } | 37 | } |
| 38 | + return greetings.size(); | ||
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | -} | 41 | -} |
| 42 | +} | ||
| 41 | \ No newline at end of file | 43 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininfo/PluginController.java
| @@ -123,12 +123,12 @@ public class PluginController { | @@ -123,12 +123,12 @@ public class PluginController { | ||
| 123 | /** | 123 | /** |
| 124 | * 打印问候语 | 124 | * 打印问候语 |
| 125 | * | 125 | * |
| 126 | - * @return 1 | 126 | + * @return 问候语数量 |
| 127 | */ | 127 | */ |
| 128 | @PermitAll | 128 | @PermitAll |
| 129 | @GetMapping("/printGreetings") | 129 | @GetMapping("/printGreetings") |
| 130 | public ResponseEntity<Integer> printGreetings() { | 130 | public ResponseEntity<Integer> printGreetings() { |
| 131 | - greetings.printGreetings(); | ||
| 132 | - return ResponseEntity.ok(1); | 131 | + Integer count = greetings.printGreetings(); |
| 132 | + return ResponseEntity.ok(count); | ||
| 133 | } | 133 | } |
| 134 | } | 134 | } |
yudao-module-iot/yudao-module-iot-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/IoTHttpPluginController.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.plugin; | ||
| 2 | - | ||
| 3 | - | ||
| 4 | -import org.pf4j.Extension; | ||
| 5 | -import org.pf4j.ExtensionPoint; | ||
| 6 | -import org.springframework.web.bind.annotation.*; | ||
| 7 | - | ||
| 8 | -@RestController | ||
| 9 | -@RequestMapping("/iot/plugin-demo") | ||
| 10 | -@Extension | ||
| 11 | -public class IoTHttpPluginController implements ExtensionPoint { | ||
| 12 | - | ||
| 13 | - @GetMapping("/greet") | ||
| 14 | - public String greet() { | ||
| 15 | - return "Hello from MyPlugin!"; | ||
| 16 | - } | ||
| 17 | - | ||
| 18 | - @PostMapping("/message") | ||
| 19 | - public void receiveMessage(@RequestBody String message) { | ||
| 20 | - System.out.println("Received message: " + message); | ||
| 21 | - } | ||
| 22 | -} |
yudao-module-iot/yudao-module-iot-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/IoTPlugin.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.plugin; | ||
| 2 | - | ||
| 3 | -import org.pf4j.PluginWrapper; | ||
| 4 | -import org.pf4j.spring.SpringPlugin; | ||
| 5 | -import org.springframework.context.ApplicationContext; | ||
| 6 | -import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
| 7 | - | ||
| 8 | -public class IoTPlugin extends SpringPlugin { | ||
| 9 | - public IoTPlugin(PluginWrapper wrapper) { | ||
| 10 | - super(wrapper); | ||
| 11 | - } | ||
| 12 | - | ||
| 13 | - @Override | ||
| 14 | - public void start() { | ||
| 15 | - System.out.println("IoTPlugin 启动"); | ||
| 16 | - } | ||
| 17 | - | ||
| 18 | - @Override | ||
| 19 | - public void stop() { | ||
| 20 | - System.out.println("IoTPlugin 停止"); | ||
| 21 | - super.stop(); // to close applicationContext | ||
| 22 | - } | ||
| 23 | - | ||
| 24 | - @Override | ||
| 25 | - protected ApplicationContext createApplicationContext() { | ||
| 26 | - AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); | ||
| 27 | - applicationContext.setClassLoader(getWrapper().getPluginClassLoader()); | ||
| 28 | - applicationContext.register(IoTHttpPluginController.class); // 注册 IoTPluginConfig | ||
| 29 | - applicationContext.refresh(); | ||
| 30 | - System.out.println("IoTPlugin 加载完成"); | ||
| 31 | - return applicationContext; | ||
| 32 | - } | ||
| 33 | -} |
yudao-module-iot/yudao-module-iot-plugin/src/main/java/cn/iocoder/yudao/module/iot/plugin/IotPluginConfig.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.plugin; | ||
| 2 | - | ||
| 3 | -import org.springframework.context.annotation.ComponentScan; | ||
| 4 | -import org.springframework.context.annotation.Configuration; | ||
| 5 | -import org.springframework.boot.web.server.WebServerFactoryCustomizer; | ||
| 6 | -import org.springframework.boot.web.server.ConfigurableWebServerFactory; | ||
| 7 | -import org.springframework.context.annotation.Bean; | ||
| 8 | - | ||
| 9 | -@Configuration | ||
| 10 | -public class IoTPluginConfig { | ||
| 11 | - | ||
| 12 | - @Bean | ||
| 13 | - public IoTHttpPluginController ioTHttpPluginController() { | ||
| 14 | - return new IoTHttpPluginController(); | ||
| 15 | - } | ||
| 16 | -} |