You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/12/17 07:12:23 UTC

(camel) branch main updated: CAMEL-20245: camel-jbang - Log http summary when using supervised route controller.

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


The following commit(s) were added to refs/heads/main by this push:
     new 236c339b46c CAMEL-20245: camel-jbang - Log http summary when using supervised route controller.
236c339b46c is described below

commit 236c339b46c922fdddc550c63470741f48970294
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Dec 17 08:12:12 2023 +0100

    CAMEL-20245: camel-jbang - Log http summary when using supervised route controller.
---
 .../platform/http/main/MainHttpServer.java         | 45 +++++++++++++---------
 1 file changed, 26 insertions(+), 19 deletions(-)

diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
index 840eb824bd0..7a830d78bf0 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
@@ -261,8 +261,33 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
 
             private volatile Set<HttpEndpointModel> last;
 
+            private void logSummary() {
+                Set<HttpEndpointModel> endpoints = platformHttpComponent.getHttpEndpoints();
+                if (endpoints.isEmpty()) {
+                    return;
+                }
+
+                // log only if changed
+                if (last == null || last.size() != endpoints.size() || !last.containsAll(endpoints)) {
+                    LOG.info("HTTP endpoints summary");
+                    for (HttpEndpointModel u : endpoints) {
+                        String line = "http://0.0.0.0:" + (server != null ? server.getPort() : getPort()) + u.getUri();
+                        if (u.getVerbs() != null) {
+                            line += " (" + u.getVerbs() + ")";
+                        }
+                        LOG.info("    {}", line);
+                    }
+                }
+
+                // use a defensive copy of last known endpoints
+                last = new HashSet<>(endpoints);
+            }
+
             @Override
             public void onCamelContextStarted(CamelContext context, boolean alreadyStarted) {
+                if (alreadyStarted) {
+                    logSummary();
+                }
                 camelContext.getManagementStrategy().addEventNotifier(new SimpleEventNotifierSupport() {
 
                     @Override
@@ -282,25 +307,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
                             }
                         }
 
-                        Set<HttpEndpointModel> endpoints = platformHttpComponent.getHttpEndpoints();
-                        if (endpoints.isEmpty()) {
-                            return;
-                        }
-
-                        // log only if changed
-                        if (last == null || last.size() != endpoints.size() || !last.containsAll(endpoints)) {
-                            LOG.info("HTTP endpoints summary");
-                            for (HttpEndpointModel u : endpoints) {
-                                String line = "http://0.0.0.0:" + (server != null ? server.getPort() : getPort()) + u.getUri();
-                                if (u.getVerbs() != null) {
-                                    line += " (" + u.getVerbs() + ")";
-                                }
-                                LOG.info("    {}", line);
-                            }
-                        }
-
-                        // use a defensive copy of last known endpoints
-                        last = new HashSet<>(endpoints);
+                        logSummary();
                     }
                 });
             }