This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8f8ff424f1b2de2eef97985136253ebf353fd09a
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Sat Oct 12 22:55:38 2024 +0200

    CAMEL-21338: camel-core - Add boot startup time in INFO logging so it show 
the total time incl boot camel-jbang/camel-main/camel-spring-boot that may take 
some time also.
---
 .../camel/impl/engine/AbstractCamelContext.java    |  2 +-
 .../org/apache/camel/main/BaseMainSupport.java     | 34 +++++++++++++---------
 .../src/main/java/org/apache/camel/main/Main.java  |  2 --
 .../java/org/apache/camel/main/MainSupport.java    |  2 --
 4 files changed, 22 insertions(+), 18 deletions(-)

diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index a874ef3a18b..4bca692a410 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -2749,7 +2749,7 @@ public abstract class AbstractCamelContext extends 
BaseService
                 }
             }
             String msg = String.format("Apache Camel %s (%s) started in %s 
(build:%s init:%s start:%s", getVersion(),
-                        camelContextExtension.getName(), total, built, init, 
start);
+                    camelContextExtension.getName(), total, built, init, 
start);
             if (boot != null) {
                 msg += " boot:" + boot;
             }
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java 
b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index 161ca88c86f..0f06523176f 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -739,19 +739,25 @@ public abstract class BaseMainSupport extends BaseService 
{
         // ensure camel context is build
         camelContext.build();
 
-        for (MainListener listener : listeners) {
-            listener.beforeInitialize(this);
-        }
-
-        // allow doing custom configuration before camel is started
-        for (MainListener listener : listeners) {
-            listener.beforeConfigure(this);
-        }
-
         // we want to capture startup events for import tasks during main 
bootstrap
         StartupStepRecorder recorder = 
camelContext.getCamelContextExtension().getStartupStepRecorder();
         StartupStep step;
 
+        if (!listeners.isEmpty()) {
+            step = recorder.beginStep(BaseMainSupport.class, 
"beforeInitialize", "MainListener");
+            for (MainListener listener : listeners) {
+                listener.beforeInitialize(this);
+            }
+            recorder.endStep(step);
+
+            // allow doing custom configuration before camel is started
+            step = recorder.beginStep(BaseMainSupport.class, 
"beforeConfigure", "MainListener");
+            for (MainListener listener : listeners) {
+                listener.beforeConfigure(this);
+            }
+            recorder.endStep(step);
+        }
+
         if (standalone) {
             step = recorder.beginStep(BaseMainSupport.class, "autoconfigure", 
"Auto Configure");
             autoconfigure(camelContext);
@@ -774,11 +780,13 @@ public abstract class BaseMainSupport extends BaseService 
{
         postProcessCamelRegistry(camelContext, mainConfigurationProperties);
 
         // allow doing custom configuration before camel is started
-        step = recorder.beginStep(BaseMainSupport.class, "afterConfigure", 
"MainListener");
-        for (MainListener listener : listeners) {
-            listener.afterConfigure(this);
+        if (!listeners.isEmpty()) {
+            step = recorder.beginStep(BaseMainSupport.class, "afterConfigure", 
"MainListener");
+            for (MainListener listener : listeners) {
+                listener.afterConfigure(this);
+            }
+            recorder.endStep(step);
         }
-        recorder.endStep(step);
 
         // we want to log the property placeholder summary after routes has 
been started,
         // but before camel context logs that it has been started, so we need 
to use an event listener
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/Main.java 
b/core/camel-main/src/main/java/org/apache/camel/main/Main.java
index bdab0232182..fbdf88d436a 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/Main.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/Main.java
@@ -20,9 +20,7 @@ import java.util.Map;
 
 import org.apache.camel.CamelConfiguration;
 import org.apache.camel.CamelContext;
-import org.apache.camel.ContextEvents;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.clock.EventClock;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.spi.Registry;
 
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java 
b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
index fd508d6c75b..ffb89845d66 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
@@ -24,11 +24,9 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.ContextEvents;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.clock.Clock;
-import org.apache.camel.clock.ContextClock;
 import org.apache.camel.spi.EventNotifier;
 import org.apache.camel.support.ResetableClock;
 import org.apache.camel.support.service.ServiceHelper;
-import org.apache.camel.util.StopWatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Reply via email to