jonyangx commented on code in PR #2917:
URL: 
https://github.com/apache/incubator-eventmesh/pull/2917#discussion_r1068767967


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/ConfigService.java:
##########
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.eventmesh.common.config;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.Objects;
+import java.util.Properties;
+
+import org.assertj.core.util.Strings;
+
+import lombok.Getter;
+
+
+public class ConfigService {
+
+    private static final ConfigService INSTANCE = new ConfigService();
+
+    /**
+     * Unified configuration Properties corresponding to eventmesh.properties
+     */
+    private Properties properties = new Properties();
+
+    @Getter
+    private String rootPath;
+
+    private final ConfigMonitorService configMonitorService = new 
ConfigMonitorService();
+
+    private String configPath;
+
+
+    public static ConfigService getInstance() {
+        return INSTANCE;
+    }
+
+    public ConfigService() {
+    }
+
+    public ConfigService setConfigPath(String configPath) {
+        this.configPath = configPath;
+        return this;
+    }
+
+    public void setRootConfig(String path) throws Exception {
+        ConfigInfo configInfo = new ConfigInfo();
+        rootPath = path;
+        configInfo.setPath(rootPath);
+        properties = this.getConfig(configInfo);
+    }
+
+    public Properties getRootConfig() {
+        return this.properties;
+    }
+
+    public <T> T getConfig(Class<?> clazz) {
+        Config[] configArray = clazz.getAnnotationsByType(Config.class);
+        if (configArray.length == 0) {
+            try {
+                return this.getConfig(ConfigInfo.builder()
+                        .clazz(clazz)
+                        .hump(ConfigInfo.HUMP_SPOT)
+                        .build());
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+        Config config = configArray[0];
+        try {
+            // todo Complete all attributes
+            ConfigInfo configInfo = new ConfigInfo();
+            configInfo.setClazz(clazz);
+            configInfo.setPath(config.path());
+            configInfo.setHump(config.hump());
+            configInfo.setPrefix(config.prefix());
+            configInfo.setMonitor(config.monitor());
+
+            return this.getConfig(configInfo);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void getConfig(Object object) throws IllegalAccessException, 
NoSuchFieldException, IOException {

Review Comment:
   suggest rename the method name,it is unclear or confusing with public <T> T 
getConfig(Class<?> clazz) method.  @eight-nines 



-- 
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