SnifferConfigInitializer
initializes all configs in several way.
@@ -204,7 +206,7 @@ private static void overrideConfigBySystemProp() {
*
* @return the config file {@link InputStream}, or null if not needEnhance.
*/
- private static InputStreamReader loadConfig() throws AgentPackageNotFoundException, ConfigNotFoundException {
+ private static InputStreamReader loadConfig() throws AgentPackageNotFoundException, cn.hippo4j.common.conf.ConfigNotFoundException {
String specifiedConfigPath = System.getProperty(SPECIFIED_CONFIG_PATH);
File configFile = StringUtil.isEmpty(specifiedConfigPath) ? new File(
AgentPackagePath.getPath(), DEFAULT_CONFIG_FILE_NAME) : new File(specifiedConfigPath);
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/jvm/LoadedLibraryCollector.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/jvm/LoadedLibraryCollector.java
index f8a466a6c4..6bae20aa4e 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/jvm/LoadedLibraryCollector.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/jvm/LoadedLibraryCollector.java
@@ -17,9 +17,9 @@
package cn.hippo4j.agent.core.jvm;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
import cn.hippo4j.agent.core.util.CollectionUtil;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -28,13 +28,7 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
public class LoadedLibraryCollector {
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/AbstractClassEnhancePluginDefine.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/AbstractClassEnhancePluginDefine.java
index 41384b1ab6..82278a6a5f 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/AbstractClassEnhancePluginDefine.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/AbstractClassEnhancePluginDefine.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import cn.hippo4j.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import cn.hippo4j.agent.core.plugin.interceptor.StaticMethodsInterceptPoint;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/InstrumentDebuggingClass.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/InstrumentDebuggingClass.java
index e82258fb18..02a900ccd2 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/InstrumentDebuggingClass.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/InstrumentDebuggingClass.java
@@ -17,11 +17,11 @@
package cn.hippo4j.agent.core.plugin;
-import cn.hippo4j.agent.core.boot.AgentPackageNotFoundException;
import cn.hippo4j.agent.core.boot.AgentPackagePath;
-import cn.hippo4j.agent.core.conf.Config;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
+import cn.hippo4j.common.boot.AgentPackageNotFoundException;
+import cn.hippo4j.common.conf.Config;
import net.bytebuddy.dynamic.DynamicType;
import java.io.File;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginBootstrap.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginBootstrap.java
index 12dffe3914..f76fe19d83 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginBootstrap.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginBootstrap.java
@@ -17,10 +17,10 @@
package cn.hippo4j.agent.core.plugin;
-import cn.hippo4j.agent.core.boot.AgentPackageNotFoundException;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.loader.AgentClassLoader;
+import cn.hippo4j.common.boot.AgentPackageNotFoundException;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import java.net.URL;
import java.util.ArrayList;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginCfg.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginCfg.java
index 81e5027b8f..fe707c9ca0 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginCfg.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginCfg.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.exception.IllegalPluginDefineException;
import java.io.BufferedReader;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginResourcesResolver.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginResourcesResolver.java
index 06058a0b52..861995eeaf 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginResourcesResolver.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginResourcesResolver.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.loader.AgentClassLoader;
import java.io.IOException;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginSelector.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginSelector.java
index 8f336b36e2..4859909ee1 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginSelector.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/PluginSelector.java
@@ -20,9 +20,8 @@
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
-import cn.hippo4j.agent.core.conf.Config;
-import static cn.hippo4j.agent.core.conf.Config.Plugin.EXCLUDE_PLUGINS;
+import static cn.hippo4j.common.conf.Config.Plugin.EXCLUDE_PLUGINS;
/**
* Select some plugins in activated plugins
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bootstrap/BootstrapInstrumentBoost.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bootstrap/BootstrapInstrumentBoost.java
index 3260e439b5..7138ea8574 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bootstrap/BootstrapInstrumentBoost.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bootstrap/BootstrapInstrumentBoost.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.bootstrap;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.AbstractClassEnhancePluginDefine;
import cn.hippo4j.agent.core.plugin.ByteBuddyCoreClasses;
import cn.hippo4j.agent.core.plugin.InstrumentDebuggingClass;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bootstrap/BootstrapPluginLogBridge.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bootstrap/BootstrapPluginLogBridge.java
index 868b1c2c86..bdcbcfdc0f 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bootstrap/BootstrapPluginLogBridge.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bootstrap/BootstrapPluginLogBridge.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.bootstrap;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
/**
* The log bridge makes the ILog accessible inside bootstrap classloader, especially for internal interceptor.
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bytebuddy/CacheableTransformerDecorator.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bytebuddy/CacheableTransformerDecorator.java
index 8341772c23..f0ed68c6b7 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bytebuddy/CacheableTransformerDecorator.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/bytebuddy/CacheableTransformerDecorator.java
@@ -17,21 +17,18 @@
package cn.hippo4j.agent.core.plugin.bytebuddy;
-import cn.hippo4j.agent.core.boot.AgentPackageNotFoundException;
import cn.hippo4j.agent.core.boot.AgentPackagePath;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
import cn.hippo4j.agent.core.util.FileUtils;
import cn.hippo4j.agent.core.util.IOUtils;
+import cn.hippo4j.common.boot.AgentPackageNotFoundException;
+import cn.hippo4j.common.boot.ClassCacheMode;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.agent.builder.ResettableClassFileTransformer;
import net.bytebuddy.utility.RandomString;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
+import java.io.*;
import java.lang.instrument.IllegalClassFormatException;
import java.security.ProtectionDomain;
import java.util.Map;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java
index 70dddbadb2..8378aa35b1 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java
@@ -17,20 +17,16 @@
package cn.hippo4j.agent.core.plugin.interceptor.enhance;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.AbstractClassEnhancePluginDefine;
import cn.hippo4j.agent.core.plugin.EnhanceContext;
import cn.hippo4j.agent.core.plugin.PluginException;
import cn.hippo4j.agent.core.plugin.bootstrap.BootstrapInstrumentBoost;
-import cn.hippo4j.agent.core.plugin.interceptor.ConstructorInterceptPoint;
-import cn.hippo4j.agent.core.plugin.interceptor.DeclaredInstanceMethodsInterceptPoint;
-import cn.hippo4j.agent.core.plugin.interceptor.EnhanceException;
-import cn.hippo4j.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
-import cn.hippo4j.agent.core.plugin.interceptor.StaticMethodsInterceptPoint;
+import cn.hippo4j.agent.core.plugin.interceptor.*;
import cn.hippo4j.agent.core.plugin.interceptor.v2.InstanceMethodsInterceptV2Point;
import cn.hippo4j.agent.core.plugin.interceptor.v2.StaticMethodsInterceptV2Point;
import cn.hippo4j.agent.core.util.StringUtil;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/ConstructorInter.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/ConstructorInter.java
index d5b24c1d6c..7896eb22e0 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/ConstructorInter.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/ConstructorInter.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.interceptor.enhance;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.PluginException;
import cn.hippo4j.agent.core.plugin.loader.InterceptorInstanceLoader;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/InstMethodsInter.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/InstMethodsInter.java
index 489c54d3e2..1d5dd6c1c0 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/InstMethodsInter.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/InstMethodsInter.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.interceptor.enhance;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.PluginException;
import cn.hippo4j.agent.core.plugin.loader.InterceptorInstanceLoader;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/InstMethodsInterWithOverrideArgs.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/InstMethodsInterWithOverrideArgs.java
index 5febdb8310..57bc744442 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/InstMethodsInterWithOverrideArgs.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/InstMethodsInterWithOverrideArgs.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.interceptor.enhance;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.PluginException;
import cn.hippo4j.agent.core.plugin.loader.InterceptorInstanceLoader;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/StaticMethodsInter.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/StaticMethodsInter.java
index 3be9ccbab1..0a98c7de57 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/StaticMethodsInter.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/StaticMethodsInter.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.interceptor.enhance;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.loader.InterceptorInstanceLoader;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
import net.bytebuddy.implementation.bind.annotation.Origin;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/StaticMethodsInterWithOverrideArgs.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/StaticMethodsInterWithOverrideArgs.java
index 99f83a17b3..e7c11a7fb5 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/StaticMethodsInterWithOverrideArgs.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/StaticMethodsInterWithOverrideArgs.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.interceptor.enhance;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.loader.InterceptorInstanceLoader;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
import net.bytebuddy.implementation.bind.annotation.Morph;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/InstMethodsInterV2.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/InstMethodsInterV2.java
index 3967736a4f..eea316d00b 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/InstMethodsInterV2.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/InstMethodsInterV2.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.interceptor.enhance.v2;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.PluginException;
import cn.hippo4j.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import cn.hippo4j.agent.core.plugin.loader.InterceptorInstanceLoader;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/InstMethodsInterV2WithOverrideArgs.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/InstMethodsInterV2WithOverrideArgs.java
index f9cd51d609..9aaa9888ac 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/InstMethodsInterV2WithOverrideArgs.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/InstMethodsInterV2WithOverrideArgs.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.interceptor.enhance.v2;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.PluginException;
import cn.hippo4j.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import cn.hippo4j.agent.core.plugin.interceptor.enhance.OverrideCallable;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/StaticMethodsInterV2.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/StaticMethodsInterV2.java
index 9778577098..7bd4c2f184 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/StaticMethodsInterV2.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/StaticMethodsInterV2.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.interceptor.enhance.v2;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.loader.InterceptorInstanceLoader;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
import net.bytebuddy.implementation.bind.annotation.Origin;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/StaticMethodsInterV2WithOverrideArgs.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/StaticMethodsInterV2WithOverrideArgs.java
index 467af26a05..ca86bf2ec1 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/StaticMethodsInterV2WithOverrideArgs.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/interceptor/enhance/v2/StaticMethodsInterV2WithOverrideArgs.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.interceptor.enhance.v2;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.interceptor.enhance.OverrideCallable;
import cn.hippo4j.agent.core.plugin.loader.InterceptorInstanceLoader;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/jdk9module/JDK9ModuleExporter.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/jdk9module/JDK9ModuleExporter.java
index 1ff3514ee4..07c69b5485 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/jdk9module/JDK9ModuleExporter.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/jdk9module/JDK9ModuleExporter.java
@@ -17,8 +17,8 @@
package cn.hippo4j.agent.core.plugin.jdk9module;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.ByteBuddyCoreClasses;
import net.bytebuddy.agent.builder.AgentBuilder;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/loader/AgentClassLoader.java b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/loader/AgentClassLoader.java
index 3fec67cc41..d227ec7e17 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/loader/AgentClassLoader.java
+++ b/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/plugin/loader/AgentClassLoader.java
@@ -17,16 +17,16 @@
package cn.hippo4j.agent.core.plugin.loader;
-import cn.hippo4j.agent.core.boot.AgentPackageNotFoundException;
import cn.hippo4j.agent.core.boot.AgentPackagePath;
import cn.hippo4j.agent.core.boot.PluginConfig;
-import cn.hippo4j.agent.core.boot.SpringBootConfigNode;
import cn.hippo4j.agent.core.boot.SpringBootConfigInitializer;
-import cn.hippo4j.agent.core.conf.Config;
+import cn.hippo4j.agent.core.boot.SpringBootConfigNode;
import cn.hippo4j.agent.core.conf.SnifferConfigInitializer;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogManager;
import cn.hippo4j.agent.core.plugin.PluginBootstrap;
+import cn.hippo4j.common.boot.AgentPackageNotFoundException;
+import cn.hippo4j.common.conf.Config;
+import cn.hippo4j.common.logging.api.ILog;
+import cn.hippo4j.common.logging.api.LogManager;
import lombok.RequiredArgsConstructor;
import java.io.BufferedInputStream;
@@ -62,7 +62,7 @@ public class AgentClassLoader extends ClassLoader {
private static AgentClassLoader DEFAULT_LOADER;
private ListLogMessageHolder
is a {@link String} holder, in order to in-process propagation String across the
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/LogOutput.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/LogOutput.java
similarity index 95%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/LogOutput.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/LogOutput.java
index 2bf279a841..c8ba7bc269 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/LogOutput.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/LogOutput.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core;
+package cn.hippo4j.common.logging.core;
public enum LogOutput {
FILE, CONSOLE
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/Parser.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/Parser.java
similarity index 98%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/Parser.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/Parser.java
index 999b78f7ca..24cabc4a0c 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/Parser.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/Parser.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core;
+package cn.hippo4j.common.logging.core;
-import cn.hippo4j.agent.core.logging.core.converters.LiteralConverter;
+import cn.hippo4j.common.logging.core.converters.LiteralConverter;
import java.util.ArrayList;
import java.util.List;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/PatternLogResolver.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/PatternLogResolver.java
similarity index 85%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/PatternLogResolver.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/PatternLogResolver.java
index 075c2e01a2..0a761683a5 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/PatternLogResolver.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/PatternLogResolver.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core;
+package cn.hippo4j.common.logging.core;
-import cn.hippo4j.agent.core.conf.Config;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.logging.api.LogResolver;
+import cn.hippo4j.common.conf.Config;
+import cn.hippo4j.common.logging.api.LogResolver;
+import cn.hippo4j.common.logging.api.ILog;
public class PatternLogResolver implements LogResolver {
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/PatternLogger.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/PatternLogger.java
similarity index 94%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/PatternLogger.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/PatternLogger.java
index b9e4ef67d0..c713bb5abd 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/PatternLogger.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/PatternLogger.java
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core;
+package cn.hippo4j.common.logging.core;
-import cn.hippo4j.agent.core.logging.api.ILog;
-import cn.hippo4j.agent.core.util.StringUtil;
+import cn.hippo4j.common.toolkit.StringUtil;
/**
* A flexible Logger configurable with pattern string. This is default implementation of {@link ILog} This can parse a
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/ResolverType.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/ResolverType.java
similarity index 95%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/ResolverType.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/ResolverType.java
index 734d9294fc..774cb310ab 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/ResolverType.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/ResolverType.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core;
+package cn.hippo4j.common.logging.core;
public enum ResolverType {
JSON, PATTERN
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/SystemOutWriter.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/SystemOutWriter.java
similarity index 96%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/SystemOutWriter.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/SystemOutWriter.java
index e4cce11990..312d8fd2e0 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/SystemOutWriter.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/SystemOutWriter.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core;
+package cn.hippo4j.common.logging.core;
import java.io.PrintStream;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/WriterFactory.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/WriterFactory.java
similarity index 78%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/WriterFactory.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/WriterFactory.java
index 72f2ddeee4..4bf5331b1a 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/WriterFactory.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/WriterFactory.java
@@ -15,14 +15,13 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core;
+package cn.hippo4j.common.logging.core;
-import cn.hippo4j.agent.core.boot.AgentPackageNotFoundException;
-import cn.hippo4j.agent.core.boot.AgentPackagePath;
-import cn.hippo4j.agent.core.conf.Config;
-import cn.hippo4j.agent.core.conf.SnifferConfigInitializer;
-import cn.hippo4j.agent.core.plugin.PluginFinder;
-import cn.hippo4j.agent.core.util.StringUtil;
+import cn.hippo4j.common.boot.AgentPackageNotFoundException;
+import cn.hippo4j.common.boot.AgentPackagePath;
+import cn.hippo4j.common.conf.Config;
+import cn.hippo4j.common.conf.Constants;
+import cn.hippo4j.common.toolkit.StringUtil;
public class WriterFactory {
@@ -35,8 +34,7 @@ public static IWriter getLogWriter() {
if (WRITER != null) {
return WRITER;
}
- if (SnifferConfigInitializer.isInitCompleted()
- && PluginFinder.isPluginInitCompleted()
+ if (Constants.IS_INIT_COMPLETED
&& AgentPackagePath.isPathFound()) {
if (StringUtil.isEmpty(Config.Logging.DIR)) {
try {
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/AgentNameConverter.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/AgentNameConverter.java
similarity index 83%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/AgentNameConverter.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/AgentNameConverter.java
index 21090d2574..d6015b2179 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/AgentNameConverter.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/AgentNameConverter.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core.converters;
+package cn.hippo4j.common.logging.core.converters;
-import cn.hippo4j.agent.core.conf.Config;
-import cn.hippo4j.agent.core.logging.core.Converter;
-import cn.hippo4j.agent.core.logging.core.LogEvent;
+import cn.hippo4j.common.conf.Config;
+import cn.hippo4j.common.logging.core.Converter;
+import cn.hippo4j.common.logging.core.LogEvent;
public class AgentNameConverter implements Converter {
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/ClassConverter.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/ClassConverter.java
similarity index 87%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/ClassConverter.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/ClassConverter.java
index 5dc9951dbf..96dbcdc294 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/ClassConverter.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/ClassConverter.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core.converters;
+package cn.hippo4j.common.logging.core.converters;
-import cn.hippo4j.agent.core.logging.core.Converter;
-import cn.hippo4j.agent.core.logging.core.LogEvent;
+import cn.hippo4j.common.logging.core.Converter;
+import cn.hippo4j.common.logging.core.LogEvent;
/**
* Just return logEvent.getTargetClass().
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/DateConverter.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/DateConverter.java
similarity index 88%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/DateConverter.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/DateConverter.java
index e3a68067fb..f18da36b24 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/DateConverter.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/DateConverter.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core.converters;
+package cn.hippo4j.common.logging.core.converters;
-import cn.hippo4j.agent.core.logging.core.Converter;
-import cn.hippo4j.agent.core.logging.core.LogEvent;
+import cn.hippo4j.common.logging.core.Converter;
+import cn.hippo4j.common.logging.core.LogEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/LevelConverter.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/LevelConverter.java
similarity index 87%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/LevelConverter.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/LevelConverter.java
index 775c97ce78..ff818c18a7 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/LevelConverter.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/LevelConverter.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core.converters;
+package cn.hippo4j.common.logging.core.converters;
-import cn.hippo4j.agent.core.logging.core.Converter;
-import cn.hippo4j.agent.core.logging.core.LogEvent;
+import cn.hippo4j.common.logging.core.Converter;
+import cn.hippo4j.common.logging.core.LogEvent;
/**
* Just return logEvent.getLevel().name()
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/LiteralConverter.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/LiteralConverter.java
similarity index 88%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/LiteralConverter.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/LiteralConverter.java
index bd334955a9..58bb473442 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/LiteralConverter.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/LiteralConverter.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core.converters;
+package cn.hippo4j.common.logging.core.converters;
-import cn.hippo4j.agent.core.logging.core.Converter;
-import cn.hippo4j.agent.core.logging.core.LogEvent;
+import cn.hippo4j.common.logging.core.Converter;
+import cn.hippo4j.common.logging.core.LogEvent;
/**
* This Converter is used to return the literal.
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/MessageConverter.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/MessageConverter.java
similarity index 87%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/MessageConverter.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/MessageConverter.java
index a38cc3c7c7..fc15990fd9 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/MessageConverter.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/MessageConverter.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core.converters;
+package cn.hippo4j.common.logging.core.converters;
-import cn.hippo4j.agent.core.logging.core.Converter;
-import cn.hippo4j.agent.core.logging.core.LogEvent;
+import cn.hippo4j.common.logging.core.Converter;
+import cn.hippo4j.common.logging.core.LogEvent;
/**
* Just return the logEvent.getMessage()
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/ThreadConverter.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/ThreadConverter.java
similarity index 87%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/ThreadConverter.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/ThreadConverter.java
index 7bd6b16fdd..a22e16dfd1 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/ThreadConverter.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/ThreadConverter.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core.converters;
+package cn.hippo4j.common.logging.core.converters;
-import cn.hippo4j.agent.core.logging.core.Converter;
-import cn.hippo4j.agent.core.logging.core.LogEvent;
+import cn.hippo4j.common.logging.core.Converter;
+import cn.hippo4j.common.logging.core.LogEvent;
/**
* Just return the Thread.currentThread().getName()
diff --git a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/ThrowableConverter.java b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/ThrowableConverter.java
similarity index 88%
rename from agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/ThrowableConverter.java
rename to infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/ThrowableConverter.java
index 8d307f0ad8..3bab6e2b9c 100644
--- a/agent/hippo4j-agent-core/src/main/java/cn/hippo4j/agent/core/logging/core/converters/ThrowableConverter.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/logging/core/converters/ThrowableConverter.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package cn.hippo4j.agent.core.logging.core.converters;
+package cn.hippo4j.common.logging.core.converters;
-import cn.hippo4j.agent.core.conf.Constants;
-import cn.hippo4j.agent.core.logging.core.Converter;
-import cn.hippo4j.agent.core.logging.core.LogEvent;
+import cn.hippo4j.common.constant.Constants;
+import cn.hippo4j.common.logging.core.Converter;
+import cn.hippo4j.common.logging.core.LogEvent;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
diff --git a/infra/common/src/main/java/cn/hippo4j/common/toolkit/StringUtil.java b/infra/common/src/main/java/cn/hippo4j/common/toolkit/StringUtil.java
index 7c74e2cc3a..d85065068e 100644
--- a/infra/common/src/main/java/cn/hippo4j/common/toolkit/StringUtil.java
+++ b/infra/common/src/main/java/cn/hippo4j/common/toolkit/StringUtil.java
@@ -390,4 +390,69 @@ private static boolean containsText(CharSequence str) {
}
return false;
}
+
+ public static String join(final char delimiter, final String... strings) {
+ if (strings.length == 0) {
+ return null;
+ }
+ if (strings.length == 1) {
+ return strings[0];
+ }
+ int length = strings.length - 1;
+ for (final String s : strings) {
+ if (s == null) {
+ continue;
+ }
+ length += s.length();
+ }
+ final StringBuilder sb = new StringBuilder(length);
+ if (strings[0] != null) {
+ sb.append(strings[0]);
+ }
+ for (int i = 1; i < strings.length; ++i) {
+ if (!isEmpty(strings[i])) {
+ sb.append(delimiter).append(strings[i]);
+ } else {
+ sb.append(delimiter);
+ }
+ }
+ return sb.toString();
+ }
+
+ public static boolean substringMatch(CharSequence str, int index, CharSequence substring) {
+ if (index + substring.length() > str.length()) {
+ return false;
+ }
+ for (int i = 0; i < substring.length(); i++) {
+ if (str.charAt(index + i) != substring.charAt(i)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static String cut(String str, int threshold) {
+ if (isEmpty(str) || str.length() <= threshold) {
+ return str;
+ }
+ return str.substring(0, threshold);
+ }
+
+ public static String trim(final String str, final char ch) {
+ if (isEmpty(str)) {
+ return null;
+ }
+
+ final char[] chars = str.toCharArray();
+
+ int i = 0, j = chars.length - 1;
+ // noinspection StatementWithEmptyBody
+ for (; i < chars.length && chars[i] == ch; i++) {
+ }
+ // noinspection StatementWithEmptyBody
+ for (; j > 0 && chars[j] == ch; j--) {
+ }
+
+ return new String(chars, i, j - i + 1);
+ }
}
diff --git a/infra/common/src/main/java/cn/hippo4j/common/toolkit/agent/ConfigInitializer.java b/infra/common/src/main/java/cn/hippo4j/common/toolkit/agent/ConfigInitializer.java
new file mode 100644
index 0000000000..d1b250e9e9
--- /dev/null
+++ b/infra/common/src/main/java/cn/hippo4j/common/toolkit/agent/ConfigInitializer.java
@@ -0,0 +1,210 @@
+/*
+ * 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 cn.hippo4j.common.toolkit.agent;
+
+import cn.hippo4j.common.toolkit.StringUtil;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.*;
+
+/**
+ * Init a class's static fields by a {@link Properties}, including static fields and static inner classes.
+ *
+ */
+public class ConfigInitializer {
+
+ public static void initialize(Properties properties, Class> rootConfigType) throws IllegalAccessException {
+ initNextLevel(properties, rootConfigType, new ConfigDesc(), false);
+ }
+
+ public static void initialize(Properties properties, Class> rootConfigType, boolean isSpringProperties) throws IllegalAccessException {
+ initNextLevel(properties, rootConfigType, new ConfigDesc(), isSpringProperties);
+ }
+
+ private static void initNextLevel(Properties properties, Class> recentConfigType,
+ ConfigDesc parentDesc, boolean isSpringProperties) throws IllegalArgumentException, IllegalAccessException {
+ for (Field field : recentConfigType.getFields()) {
+ if (Modifier.isPublic(field.getModifiers()) && Modifier.isStatic(field.getModifiers())) {
+ String configKey = (parentDesc + "." + (isSpringProperties ? field.getName().replace("_", "-") : field.getName())).toLowerCase();
+ Class> type = field.getType();
+
+ if (type.equals(Map.class)) {
+ /*
+ * Map config format is, config_key[map_key]=map_value Such as plugin.opgroup.resttemplate.rule[abc]=/url/path
+ */
+ // Deduct two generic types of the map
+ ParameterizedType genericType = (ParameterizedType) field.getGenericType();
+ Type[] argumentTypes = genericType.getActualTypeArguments();
+
+ Type keyType = null;
+ Type valueType = null;
+ if (argumentTypes != null && argumentTypes.length == 2) {
+ // Get key type and value type of the map
+ keyType = argumentTypes[0];
+ valueType = argumentTypes[1];
+ }
+ Map map = (Map) field.get(null);
+ // Set the map from config key and properties
+ setForMapType(configKey, map, properties, keyType, valueType);
+ } else {
+ /*
+ * Others typical field type
+ */
+ String value = properties.getProperty(configKey);
+ // Convert the value into real type
+ final Length lengthDefine = field.getAnnotation(Length.class);
+ if (lengthDefine != null) {
+ if (value != null && value.length() > lengthDefine.value()) {
+ value = value.substring(0, lengthDefine.value());
+ }
+ }
+ Object convertedValue = convertToTypicalType(type, value);
+ if (convertedValue != null) {
+ field.set(null, convertedValue);
+ }
+ }
+ }
+ }
+ for (Class> innerConfiguration : recentConfigType.getClasses()) {
+ String simpleName = innerConfiguration.getSimpleName();
+ String description = isSpringProperties ? simpleName.replace("_", "-") : simpleName;
+ parentDesc.append(description);
+ initNextLevel(properties, innerConfiguration, parentDesc, isSpringProperties);
+ parentDesc.removeLastDesc();
+ }
+ }
+
+ /**
+ * Convert string value to typical type.
+ *
+ * @param type type to convert
+ * @param value string value to be converted
+ * @return converted value or null
+ */
+ private static Object convertToTypicalType(Type type, String value) {
+ if (value == null || type == null) {
+ return null;
+ }
+
+ Object result = null;
+ if (String.class.equals(type)) {
+ result = value;
+ } else if (int.class.equals(type) || Integer.class.equals(type)) {
+ result = Integer.valueOf(value);
+ } else if (long.class.equals(type) || Long.class.equals(type)) {
+ result = Long.valueOf(value);
+ } else if (boolean.class.equals(type) || Boolean.class.equals(type)) {
+ result = Boolean.valueOf(value);
+ } else if (float.class.equals(type) || Float.class.equals(type)) {
+ result = Float.valueOf(value);
+ } else if (double.class.equals(type) || Double.class.equals(type)) {
+ result = Double.valueOf(value);
+ } else if (List.class.equals(type)) {
+ result = convert2List(value);
+ } else if (type instanceof Class) {
+ Class> clazz = (Class>) type;
+ if (clazz.isEnum()) {
+ result = Enum.valueOf((Class