Yanshuming1 commented on code in PR #2616:
URL: https://github.com/apache/hertzbeat/pull/2616#discussion_r1733740412


##########
manager/src/main/java/org/apache/hertzbeat/manager/service/impl/PluginServiceImpl.java:
##########
@@ -335,18 +428,30 @@ private List<URL> loadLibInPlugin(String pluginJarPath) {
                         out.flush();
                     }
                 }
+                if ((entry.getName().contains("define")) && 
(entry.getName().endsWith(".yml") || entry.getName().endsWith(".yaml"))) {
+                    try (InputStream ymlInputStream = 
jarFile.getInputStream(entry)) {
+                        List<ParamDefine> params = yaml.loadAs(ymlInputStream, 
List.class);
+                        PARAMS_Define_MAP.putIfAbsent(pluginMetadataId, 
params);
+                    }
+                }
             }
         }
         return libUrls;
     }
 
     @Override
-    public <T> void pluginExecute(Class<T> clazz, Consumer<T> execute) {
+    public <T> void pluginExecute(Class<T> clazz, Consumer<T> execute, 
BiConsumer<T, List<Configmap>> biConsumer) {
         for (URLClassLoader pluginClassLoader : pluginClassLoaders) {
             ServiceLoader<T> load = ServiceLoader.load(clazz, 
pluginClassLoader);
             for (T t : load) {
                 if (pluginIsEnable(t.getClass())) {
-                    execute.accept(t);
+                    Long pluginId = 
ITEM_TO_PLUGINMETADATAID_MAP.get(t.getClass().getName());
+                    List<Configmap> configmapList = PARAMS_MAP.get(pluginId);
+                    if (CollectionUtils.isEmpty(configmapList)) {
+                        execute.accept(t);
+                    } else {
+                        biConsumer.accept(t, configmapList);
+                    }

Review Comment:
   That is what is being done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to