This is an automated email from the ASF dual-hosted git repository. pcongiusti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit b19a5f690b920b0936f00f560c6be6b82dec48f8 Author: Pasquale Congiusti <pasquale.congiu...@gmail.com> AuthorDate: Thu Apr 24 11:06:50 2025 +0200 chore(main): remove summary As we have now at least 2 different port, the summary is wrong as it uses information coming from the platform component instead of router. --- .../main/camel-main-configuration-metadata.json | 42 +++++------ .../platform/http/main/MainHttpServer.java | 86 ---------------------- .../platform/http/main/ManagementHttpServer.java | 86 ---------------------- 3 files changed, 21 insertions(+), 193 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json index 760a8ac8c24..266f6b75d8a 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json @@ -4,7 +4,7 @@ { "name": "camel.startupcondition", "description": "Camel Startup Condition configurations", "sourceType": "org.apache.camel.main.StartupConditionConfigurationProperties" }, { "name": "camel.routecontroller", "description": "Camel Route Controller configurations", "sourceType": "org.apache.camel.main.RouteControllerConfigurationProperties" }, { "name": "camel.server", "description": "Camel Embedded HTTP Server (only for standalone; not Spring Boot or Quarkus) configurations", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties" }, - { "name": "camel.management.server", "description": "Camel Embedded HTTP management Server (only for standalone; not Spring Boot or Quarkus) configurations", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties" }, + { "name": "camel.management", "description": "Camel Embedded HTTP management Server (only for standalone; not Spring Boot or Quarkus) configurations", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties" }, { "name": "camel.debug", "description": "Camel Debugger configurations", "sourceType": "org.apache.camel.main.DebuggerConfigurationProperties" }, { "name": "camel.trace", "description": "Camel Tracer configurations", "sourceType": "org.apache.camel.main.TracerConfigurationProperties" }, { "name": "camel.ssl", "description": "Camel SSL configurations", "sourceType": "org.apache.camel.main.SSLConfigurationProperties" }, @@ -190,26 +190,26 @@ { "name": "camel.lra.enabled", "description": "To enable Saga LRA", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": false }, { "name": "camel.lra.localParticipantContextPath", "description": "The context-path for the local participant. Is default \/lra-participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/lra-participant" }, { "name": "camel.lra.localParticipantUrl", "description": "The URL for the local participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, - { "name": "camel.management.server.authenticationEnabled", "description": "Whether to enable HTTP authentication for embedded server (for standalone applications; not Spring Boot or Quarkus).", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, - { "name": "camel.management.server.authenticationPath", "description": "Set HTTP url path of embedded server that is protected by authentication configuration.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, - { "name": "camel.management.server.basicPropertiesFile", "description": "Name of the file that contains basic authentication info for Vert.x file auth provider.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, - { "name": "camel.management.server.devConsoleEnabled", "description": "Whether to enable developer console (not intended for production use). Dev console must also be enabled on CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code camelContext.setDevConsole(true); If enabled then you can access a basic developer console on context-path: \/q\/dev.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", [...] - { "name": "camel.management.server.enabled", "description": "Whether embedded HTTP server is enabled. By default, the server is not enabled.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, - { "name": "camel.management.server.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/q\/health (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, - { "name": "camel.management.server.healthPath", "description": "The path endpoint used to expose the health status", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/health" }, - { "name": "camel.management.server.host", "description": "Hostname to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.0.0" }, - { "name": "camel.management.server.infoEnabled", "description": "Whether to enable info console. If enabled then you can see some basic Camel information at \/q\/info", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, - { "name": "camel.management.server.jolokiaEnabled", "description": "Whether to enable jolokia. If enabled then you can access jolokia api on context-path: \/q\/jolokia", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, - { "name": "camel.management.server.jolokiaPath", "description": "The path endpoint used to expose the jolokia data.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/jolokia" }, - { "name": "camel.management.server.jwtKeystorePassword", "description": "Password from the keystore used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, - { "name": "camel.management.server.jwtKeystorePath", "description": "Path to the keystore file used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, - { "name": "camel.management.server.jwtKeystoreType", "description": "Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.).", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, - { "name": "camel.management.server.maxBodySize", "description": "Maximum HTTP body size the embedded HTTP server can accept.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "java.lang.Long" }, - { "name": "camel.management.server.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/q\/metrics (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, - { "name": "camel.management.server.path", "description": "Context-path to use for embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" }, - { "name": "camel.management.server.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 9876 }, - { "name": "camel.management.server.sendEnabled", "description": "Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to Camel endpoint URIs via HTTP.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, - { "name": "camel.management.server.useGlobalSslContextParameters", "description": "Whether to use global SSL configuration for securing the embedded HTTP server.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.management.authenticationEnabled", "description": "Whether to enable HTTP authentication for embedded server (for standalone applications; not Spring Boot or Quarkus).", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.management.authenticationPath", "description": "Set HTTP url path of embedded server that is protected by authentication configuration.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, + { "name": "camel.management.basicPropertiesFile", "description": "Name of the file that contains basic authentication info for Vert.x file auth provider.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, + { "name": "camel.management.devConsoleEnabled", "description": "Whether to enable developer console (not intended for production use). Dev console must also be enabled on CamelContext. For example by setting camel.context.dev-console=true in application.properties, or via code camelContext.setDevConsole(true); If enabled then you can access a basic developer console on context-path: \/q\/dev.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": [...] + { "name": "camel.management.enabled", "description": "Whether embedded HTTP server is enabled. By default, the server is not enabled.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.management.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/q\/health (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.management.healthPath", "description": "The path endpoint used to expose the health status", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/health" }, + { "name": "camel.management.host", "description": "Hostname to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.0.0" }, + { "name": "camel.management.infoEnabled", "description": "Whether to enable info console. If enabled then you can see some basic Camel information at \/q\/info", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.management.jolokiaEnabled", "description": "Whether to enable jolokia. If enabled then you can access jolokia api on context-path: \/q\/jolokia", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.management.jolokiaPath", "description": "The path endpoint used to expose the jolokia data.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/observe\/jolokia" }, + { "name": "camel.management.jwtKeystorePassword", "description": "Password from the keystore used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, + { "name": "camel.management.jwtKeystorePath", "description": "Path to the keystore file used for JWT tokens validation.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, + { "name": "camel.management.jwtKeystoreType", "description": "Type of the keystore used for JWT tokens validation (jks, pkcs12, etc.).", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, + { "name": "camel.management.maxBodySize", "description": "Maximum HTTP body size the embedded HTTP server can accept.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "java.lang.Long" }, + { "name": "camel.management.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/q\/metrics (default)", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.management.path", "description": "Context-path to use for embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" }, + { "name": "camel.management.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 9876 }, + { "name": "camel.management.sendEnabled", "description": "Whether to enable sending messages to Camel via HTTP. This makes it possible to use Camel to send messages to Camel endpoint URIs via HTTP.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.management.useGlobalSslContextParameters", "description": "Whether to use global SSL configuration for securing the embedded HTTP server.", "sourceType": "org.apache.camel.main.HttpManagementServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.metrics.baseEndpointURIExchangeEventNotifier", "description": "Whether to use static or dynamic values for Endpoint Name tags in captured metrics. By default, static values are used. When using dynamic tags, then a dynamic to (toD) can compute many different endpoint URIs that, can lead to many tags as the URI is dynamic, so use this with care if setting this option to false.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", " [...] { "name": "camel.metrics.binders", "description": "Additional Micrometer binders to include such as jvm-memory, processor, jvm-thread, and so forth. Multiple binders can be separated by comma. The following binders currently is available from Micrometer: class-loader, commons-object-pool2, file-descriptor, hystrix-metrics-binder, jvm-compilation, jvm-gc, jvm-heap-pressure, jvm-info, jvm-memory, jvm-thread, log4j2, logback, processor, uptime", "sourceType": "org.apache.camel.main.Metr [...] { "name": "camel.metrics.clearOnReload", "description": "Clear the captured metrics data when Camel is reloading routes such as when using Camel JBang.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, 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 abbd0f92f23..6e5531741c2 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 @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -55,13 +54,11 @@ import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.NoSuchEndpointException; import org.apache.camel.ProducerTemplate; -import org.apache.camel.StartupListener; import org.apache.camel.StaticService; import org.apache.camel.api.management.ManagedAttribute; import org.apache.camel.api.management.ManagedCamelContext; import org.apache.camel.api.management.ManagedResource; import org.apache.camel.api.management.mbean.ManagedCamelContextMBean; -import org.apache.camel.component.platform.http.HttpEndpointModel; import org.apache.camel.component.platform.http.PlatformHttpComponent; import org.apache.camel.component.platform.http.plugin.JolokiaPlatformHttpPlugin; import org.apache.camel.component.platform.http.spi.PlatformHttpPluginRegistry; @@ -74,7 +71,6 @@ import org.apache.camel.health.HealthCheck; import org.apache.camel.health.HealthCheckHelper; import org.apache.camel.health.HealthCheckRegistry; import org.apache.camel.http.base.HttpProtocolHeaderFilterStrategy; -import org.apache.camel.spi.CamelEvent; import org.apache.camel.spi.HeaderFilterStrategy; import org.apache.camel.spi.PackageScanResourceResolver; import org.apache.camel.spi.ReloadStrategy; @@ -87,7 +83,6 @@ import org.apache.camel.support.LoggerHelper; import org.apache.camel.support.MessageHelper; import org.apache.camel.support.PluginHelper; import org.apache.camel.support.ResolverHelper; -import org.apache.camel.support.SimpleEventNotifierSupport; import org.apache.camel.support.jsse.SSLContextParameters; import org.apache.camel.support.service.ServiceHelper; import org.apache.camel.support.service.ServiceSupport; @@ -456,7 +451,6 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware, platformHttpComponent = camelContext.getComponent("platform-http", PlatformHttpComponent.class); setupConsoles(); - setupStartupSummary(); } @Override @@ -499,86 +493,6 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware, // metrics will be setup in camel-micrometer-prometheus } - protected void setupStartupSummary() throws Exception { - camelContext.addStartupListener(new StartupListener() { - - 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"); - int longestEndpoint = 0; - for (HttpEndpointModel u : endpoints) { - String endpoint = getEndpoint(u); - if (endpoint.length() > longestEndpoint) { - longestEndpoint = endpoint.length(); - } - } - - int spacing = 3; - String formatTemplate = "%-" + (longestEndpoint + spacing) + "s %-8s %s"; - for (HttpEndpointModel u : endpoints) { - String endpoint = getEndpoint(u); - String formattedVerbs = ""; - if (u.getVerbs() != null) { - formattedVerbs = "(" + u.getVerbs() + ")"; - } - String formattedMediaTypes = ""; - if (u.getConsumes() != null || u.getProduces() != null) { - formattedMediaTypes = String.format("(%s%s%s)", - u.getConsumes() != null ? "accept:" + u.getConsumes() : "", - u.getProduces() != null && u.getConsumes() != null ? " " : "", - u.getProduces() != null ? "produce:" + u.getProduces() : ""); - } - LOG.info(" {}", String.format(formatTemplate, endpoint, formattedVerbs, formattedMediaTypes)); - } - } - - // use a defensive copy of last known endpoints - last = new HashSet<>(endpoints); - } - - private String getEndpoint(HttpEndpointModel httpEndpointModel) { - return "http://0.0.0.0:" + (server != null ? server.getPort() : getPort()) + httpEndpointModel.getUri(); - } - - @Override - public void onCamelContextStarted(CamelContext context, boolean alreadyStarted) { - if (alreadyStarted) { - logSummary(); - } - camelContext.getManagementStrategy().addEventNotifier(new SimpleEventNotifierSupport() { - - @Override - public boolean isEnabled(CamelEvent event) { - return event instanceof CamelEvent.CamelContextStartedEvent - || event instanceof CamelEvent.RouteReloadedEvent; - } - - @Override - public void notify(CamelEvent event) { - // when reloading then there may be more routes in the same batch, so we only want - // to log the summary at the end - if (event instanceof CamelEvent.RouteReloadedEvent) { - CamelEvent.RouteReloadedEvent re = (CamelEvent.RouteReloadedEvent) event; - if (re.getIndex() < re.getTotal()) { - return; - } - } - - logSummary(); - } - }); - } - }); - } - protected void setupStatic() { String path = staticContextPath; if (!path.endsWith("*")) { diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java index 40ca9fe36ac..c96c05f638c 100644 --- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java +++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/ManagementHttpServer.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -47,13 +46,11 @@ import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.NoSuchEndpointException; import org.apache.camel.ProducerTemplate; -import org.apache.camel.StartupListener; import org.apache.camel.StaticService; import org.apache.camel.api.management.ManagedAttribute; import org.apache.camel.api.management.ManagedCamelContext; import org.apache.camel.api.management.ManagedResource; import org.apache.camel.api.management.mbean.ManagedCamelContextMBean; -import org.apache.camel.component.platform.http.HttpEndpointModel; import org.apache.camel.component.platform.http.PlatformHttpComponent; import org.apache.camel.component.platform.http.plugin.JolokiaPlatformHttpPlugin; import org.apache.camel.component.platform.http.spi.PlatformHttpPluginRegistry; @@ -66,7 +63,6 @@ import org.apache.camel.health.HealthCheck; import org.apache.camel.health.HealthCheckHelper; import org.apache.camel.health.HealthCheckRegistry; import org.apache.camel.http.base.HttpProtocolHeaderFilterStrategy; -import org.apache.camel.spi.CamelEvent; import org.apache.camel.spi.HeaderFilterStrategy; import org.apache.camel.spi.ReloadStrategy; import org.apache.camel.support.CamelContextHelper; @@ -74,7 +70,6 @@ import org.apache.camel.support.EndpointHelper; import org.apache.camel.support.ExceptionHelper; import org.apache.camel.support.MessageHelper; import org.apache.camel.support.ResolverHelper; -import org.apache.camel.support.SimpleEventNotifierSupport; import org.apache.camel.support.jsse.SSLContextParameters; import org.apache.camel.support.service.ServiceHelper; import org.apache.camel.support.service.ServiceSupport; @@ -353,7 +348,6 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext platformHttpComponent = camelContext.getComponent("platform-http", PlatformHttpComponent.class); setupConsoles(); - setupStartupSummary(); } @Override @@ -384,86 +378,6 @@ public class ManagementHttpServer extends ServiceSupport implements CamelContext // metrics will be setup in camel-micrometer-prometheus } - protected void setupStartupSummary() throws Exception { - camelContext.addStartupListener(new StartupListener() { - - 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"); - int longestEndpoint = 0; - for (HttpEndpointModel u : endpoints) { - String endpoint = getEndpoint(u); - if (endpoint.length() > longestEndpoint) { - longestEndpoint = endpoint.length(); - } - } - - int spacing = 3; - String formatTemplate = "%-" + (longestEndpoint + spacing) + "s %-8s %s"; - for (HttpEndpointModel u : endpoints) { - String endpoint = getEndpoint(u); - String formattedVerbs = ""; - if (u.getVerbs() != null) { - formattedVerbs = "(" + u.getVerbs() + ")"; - } - String formattedMediaTypes = ""; - if (u.getConsumes() != null || u.getProduces() != null) { - formattedMediaTypes = String.format("(%s%s%s)", - u.getConsumes() != null ? "accept:" + u.getConsumes() : "", - u.getProduces() != null && u.getConsumes() != null ? " " : "", - u.getProduces() != null ? "produce:" + u.getProduces() : ""); - } - LOG.info(" {}", String.format(formatTemplate, endpoint, formattedVerbs, formattedMediaTypes)); - } - } - - // use a defensive copy of last known endpoints - last = new HashSet<>(endpoints); - } - - private String getEndpoint(HttpEndpointModel httpEndpointModel) { - return "http://0.0.0.0:" + (server != null ? server.getPort() : getPort()) + httpEndpointModel.getUri(); - } - - @Override - public void onCamelContextStarted(CamelContext context, boolean alreadyStarted) { - if (alreadyStarted) { - logSummary(); - } - camelContext.getManagementStrategy().addEventNotifier(new SimpleEventNotifierSupport() { - - @Override - public boolean isEnabled(CamelEvent event) { - return event instanceof CamelEvent.CamelContextStartedEvent - || event instanceof CamelEvent.RouteReloadedEvent; - } - - @Override - public void notify(CamelEvent event) { - // when reloading then there may be more routes in the same batch, so we only want - // to log the summary at the end - if (event instanceof CamelEvent.RouteReloadedEvent) { - CamelEvent.RouteReloadedEvent re = (CamelEvent.RouteReloadedEvent) event; - if (re.getIndex() < re.getTotal()) { - return; - } - } - - logSummary(); - } - }); - } - }); - } - protected void setupInfo() { final Route info = router.route("/q/info"); info.method(HttpMethod.GET);