diff --git a/joylive-core/joylive-core-framework/src/main/java/com/jd/live/agent/core/bootstrap/Bootstrap.java b/joylive-core/joylive-core-framework/src/main/java/com/jd/live/agent/core/bootstrap/Bootstrap.java index ce6a46922..7c242795e 100644 --- a/joylive-core/joylive-core-framework/src/main/java/com/jd/live/agent/core/bootstrap/Bootstrap.java +++ b/joylive-core/joylive-core-framework/src/main/java/com/jd/live/agent/core/bootstrap/Bootstrap.java @@ -36,6 +36,7 @@ import com.jd.live.agent.core.event.Subscription; import com.jd.live.agent.core.exception.ParseException; import com.jd.live.agent.core.extension.ExtensibleDesc; +import com.jd.live.agent.core.extension.ExtensionDesc; import com.jd.live.agent.core.extension.ExtensionEvent.EventType; import com.jd.live.agent.core.extension.ExtensionManager; import com.jd.live.agent.core.extension.condition.ConditionManager; @@ -197,7 +198,7 @@ public class Bootstrap implements AgentLifecycle { /** * Manages extensions to the agent. */ - private ExtensionManager extensionManager; + private JExtensionManager extensionManager; /** * Supplies bytecode for instrumentation. @@ -276,6 +277,7 @@ public void install() { commandManager = createCommandManager(); subscriptions = createSubscriptions(); subscribe(); + printExtensions(); serviceManager.start().join(); // TODO In AgentMain mode, it is necessary to enhance the registry first to obtain the service strategy, and then enhance the routing plugin if (pluginManager.install(dynamic)) { @@ -373,6 +375,24 @@ public void addReadyHook(Callable callable, ClassLoader classLoader) { } } + private void printExtensions() { + StringBuilder builder = new StringBuilder(); + extensionManager.forEach(extensible -> { + builder.delete(0, builder.length()); + builder.append(extensible.getName().getClazz().getName()).append(": "); + Iterable> extensionDescs = extensible.getExtensionDescs(); + int i = 0; + for (ExtensionDesc extensionDesc : extensionDescs) { + if (i++ > 0) { + builder.append(", "); + } + builder.append(extensionDesc.getName().getName()); + } + logger.info("Load extensions " + builder); + }); + + } + /** * Creates an {@link AgentPath} instance using environment variables. * This includes paths for the agent's root, log, and output directories. @@ -551,7 +571,7 @@ private ConditionMatcher createConditionMatcher() { DEPEND_ON_LOADER.negate()); } - private ExtensionManager createExtensionManager() { + private JExtensionManager createExtensionManager() { return new JExtensionManager(conditionMatcher); } diff --git a/joylive-core/joylive-core-framework/src/main/java/com/jd/live/agent/core/extension/jplug/JExtensionManager.java b/joylive-core/joylive-core-framework/src/main/java/com/jd/live/agent/core/extension/jplug/JExtensionManager.java index f090603ef..562bb94e6 100644 --- a/joylive-core/joylive-core-framework/src/main/java/com/jd/live/agent/core/extension/jplug/JExtensionManager.java +++ b/joylive-core/joylive-core-framework/src/main/java/com/jd/live/agent/core/extension/jplug/JExtensionManager.java @@ -15,8 +15,6 @@ */ package com.jd.live.agent.core.extension.jplug; -import com.jd.live.agent.bootstrap.logger.Logger; -import com.jd.live.agent.bootstrap.logger.LoggerFactory; import com.jd.live.agent.core.extension.*; import com.jd.live.agent.core.extension.ExtensionEvent.EventType; import com.jd.live.agent.core.extension.annotation.Extensible; @@ -27,6 +25,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.function.Consumer; /** * JExtensionManager @@ -36,8 +35,6 @@ */ public class JExtensionManager implements ExtensionManager { - private static final Logger logger = LoggerFactory.getLogger(JExtensionManager.class); - private final ConditionMatcher matcher; private final Map, ExtensibleDesc> extensibles = new ConcurrentHashMap<>(); @@ -157,9 +154,6 @@ public ExtensibleDesc loadExtensible(Class extensible, ExtensionLoader // Sort Comparator> c = ExtensionDesc.AscendingComparator.INSTANCE; extensionDescList.sort(c); - if (logger.isInfoEnabled()) { - logger.info("Load extensible {} success", name); - } // No need to cache objects in the loading method return new JExtensible<>(name, extensionDescList); } @@ -204,4 +198,10 @@ public void removeListener(ExtensionListener listener) { listeners.remove(listener); } } + + public void forEach(Consumer> consumer) { + if (consumer != null) { + extensibles.values().forEach(consumer); + } + } }