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 2022/01/05 10:06:52 UTC

[camel] branch main updated (92103eb -> a712344)

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

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


    from 92103eb  CAMEL-17429: removed JDK 8 profile on the base pom
     new 1b7f2cb  CAMEL-17417: camel-core - Route stack trace to include source file:line
     new 8a398c3  Polished method call toString
     new a712344  CAMEL-17420: camel-core - Add flag to turn on|off source loc:line

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/cdi/xml/CamelContextFactoryBean.java     | 12 ++++++++
 .../org/apache/camel/spring/xml/camelContext.json  |  1 +
 .../camel/spring/xml/CamelContextFactoryBean.java  | 19 ++++++++++++
 .../java/org/apache/camel/ExtendedExchange.java    | 12 ++++++++
 .../src/main/java/org/apache/camel/Route.java      |  5 ++++
 .../camel/impl/engine/CamelInternalProcessor.java  |  5 ++++
 .../org/apache/camel/impl/engine/DefaultRoute.java |  8 +++++
 .../docs/modules/eips/pages/message-history.adoc   | 35 ++++++++++++++++++++++
 .../camel/model/language/MethodCallExpression.java | 17 +++++++++--
 .../core/xml/AbstractCamelContextFactoryBean.java  |  5 ++++
 .../org/apache/camel/support/AbstractExchange.java | 11 +++++++
 .../org/apache/camel/support/MessageHelper.java    | 25 +++++++++++-----
 .../ROOT/pages/camel-3x-upgrade-guide-3_15.adoc    | 13 ++++++++
 13 files changed, 158 insertions(+), 10 deletions(-)

[camel] 01/03: CAMEL-17417: camel-core - Route stack trace to include source file:line

Posted by da...@apache.org.
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 1b7f2cb7356b7769e0623298269ada3876da9eea
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 5 09:56:49 2022 +0100

    CAMEL-17417: camel-core - Route stack trace to include source file:line
---
 .../java/org/apache/camel/ExtendedExchange.java    | 12 +++++++++++
 .../src/main/java/org/apache/camel/Route.java      |  5 +++++
 .../camel/impl/engine/CamelInternalProcessor.java  |  5 +++++
 .../org/apache/camel/impl/engine/DefaultRoute.java |  8 +++++++
 .../org/apache/camel/support/AbstractExchange.java | 11 ++++++++++
 .../org/apache/camel/support/MessageHelper.java    | 25 +++++++++++++++-------
 .../ROOT/pages/camel-3x-upgrade-guide-3_15.adoc    | 13 +++++++++++
 7 files changed, 71 insertions(+), 8 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/ExtendedExchange.java b/core/camel-api/src/main/java/org/apache/camel/ExtendedExchange.java
index 7b50a63..ce49eb3 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ExtendedExchange.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ExtendedExchange.java
@@ -105,6 +105,18 @@ public interface ExtendedExchange extends Exchange {
     String getHistoryNodeLabel();
 
     /**
+     * Gets the history node source:line-number where the node is located in the source code (the current processor that
+     * will process the exchange).
+     */
+    String getHistoryNodeSource();
+
+    /**
+     * Sets the history node source:line-number where the node is located in the source code (the current processor that
+     * will process the exchange).
+     */
+    void setHistoryNodeSource(String historyNodeSource);
+
+    /**
      * Sets whether the exchange is routed in a transaction.
      */
     void setTransacted(boolean transacted);
diff --git a/core/camel-api/src/main/java/org/apache/camel/Route.java b/core/camel-api/src/main/java/org/apache/camel/Route.java
index 0d4d3ff..a575690 100644
--- a/core/camel-api/src/main/java/org/apache/camel/Route.java
+++ b/core/camel-api/src/main/java/org/apache/camel/Route.java
@@ -142,6 +142,11 @@ public interface Route extends RuntimeConfiguration {
     Resource getSourceResource();
 
     /**
+     * The source:line-number where the route input is located in the source code
+     */
+    String getSourceLocation();
+
+    /**
      * Gets the camel context
      *
      * @return the camel context
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
index f84bea7..d723ee1 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
@@ -59,6 +59,7 @@ import org.apache.camel.spi.UnitOfWorkFactory;
 import org.apache.camel.spi.annotations.EagerClassloaded;
 import org.apache.camel.support.CamelContextHelper;
 import org.apache.camel.support.ExchangeHelper;
+import org.apache.camel.support.LoggerHelper;
 import org.apache.camel.support.MessageHelper;
 import org.apache.camel.support.OrderedComparator;
 import org.apache.camel.support.SynchronizationAdapter;
@@ -867,10 +868,12 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor implements In
 
         private final String id;
         private final String label;
+        private final String source;
 
         public NodeHistoryAdvice(NamedNode definition) {
             this.id = definition.getId();
             this.label = definition.getLabel();
+            this.source = LoggerHelper.getLineNumberLoggerName(definition);
         }
 
         @Override
@@ -878,6 +881,7 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor implements In
             ExtendedExchange ee = (ExtendedExchange) exchange;
             ee.setHistoryNodeId(id);
             ee.setHistoryNodeLabel(label);
+            ee.setHistoryNodeSource(source);
             return null;
         }
 
@@ -886,6 +890,7 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor implements In
             ExtendedExchange ee = (ExtendedExchange) exchange;
             ee.setHistoryNodeId(null);
             ee.setHistoryNodeLabel(null);
+            ee.setHistoryNodeSource(null);
         }
 
         @Override
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java
index 377c1a5..49f2a62 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoute.java
@@ -48,6 +48,7 @@ import org.apache.camel.spi.RouteController;
 import org.apache.camel.spi.RouteError;
 import org.apache.camel.spi.RouteIdAware;
 import org.apache.camel.spi.RoutePolicy;
+import org.apache.camel.support.LoggerHelper;
 import org.apache.camel.support.PatternHelper;
 import org.apache.camel.support.service.ServiceHelper;
 import org.apache.camel.support.service.ServiceSupport;
@@ -68,6 +69,7 @@ public class DefaultRoute extends ServiceSupport implements Route {
     private final String routeId;
     private final String routeDescription;
     private final Resource sourceResource;
+    private final String sourceLocation;
     private final List<Processor> eventDrivenProcessors = new ArrayList<>();
     private final List<InterceptStrategy> interceptStrategies = new ArrayList<>(0);
     private ManagementInterceptStrategy managementInterceptStrategy;
@@ -109,6 +111,7 @@ public class DefaultRoute extends ServiceSupport implements Route {
         this.routeDescription = routeDescription;
         this.endpoint = endpoint;
         this.sourceResource = resource;
+        this.sourceLocation = LoggerHelper.getLineNumberLoggerName(route);
     }
 
     @Override
@@ -176,6 +179,11 @@ public class DefaultRoute extends ServiceSupport implements Route {
     }
 
     @Override
+    public String getSourceLocation() {
+        return sourceLocation;
+    }
+
+    @Override
     public void initializeServices() throws Exception {
         // gather all the services for this route
         gatherServices(services);
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java b/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java
index 55b0b9a..03cf3f1 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java
@@ -75,6 +75,7 @@ class AbstractExchange implements ExtendedExchange {
     Boolean externalRedelivered;
     String historyNodeId;
     String historyNodeLabel;
+    String historyNodeSource;
     boolean transacted;
     boolean routeStop;
     boolean rollbackOnly;
@@ -798,6 +799,16 @@ class AbstractExchange implements ExtendedExchange {
     }
 
     @Override
+    public String getHistoryNodeSource() {
+        return historyNodeSource;
+    }
+
+    @Override
+    public void setHistoryNodeSource(String historyNodeSource) {
+        this.historyNodeSource = historyNodeSource;
+    }
+
+    @Override
     public boolean isNotifyEvent() {
         return notifyEvent;
     }
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
index 29ff2cf..fd98a0f 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
@@ -31,6 +31,7 @@ import org.apache.camel.ExchangePropertyKey;
 import org.apache.camel.ExtendedExchange;
 import org.apache.camel.Message;
 import org.apache.camel.MessageHistory;
+import org.apache.camel.Route;
 import org.apache.camel.StreamCache;
 import org.apache.camel.WrappedFile;
 import org.apache.camel.spi.ExchangeFormatter;
@@ -48,8 +49,8 @@ import org.slf4j.Logger;
 @EagerClassloaded
 public final class MessageHelper {
 
-    private static final String MESSAGE_HISTORY_HEADER = "%-20s %-20s %-80s %-12s";
-    private static final String MESSAGE_HISTORY_OUTPUT = "[%-18.18s] [%-18.18s] [%-78.78s] [%10.10s]";
+    private static final String MESSAGE_HISTORY_HEADER = "%-30s %-20s %-20s %-50s %-12s";
+    private static final String MESSAGE_HISTORY_OUTPUT = "%-30.30s %-20.20s %-20.20s %-50.50s %12.12s";
 
     /**
      * Utility classes should not have a public constructor.
@@ -568,22 +569,25 @@ public final class MessageHelper {
         sb.append(
                 "---------------------------------------------------------------------------------------------------------------------------------------\n");
         String goMessageHistoryHeader = exchange.getContext().getGlobalOption(Exchange.MESSAGE_HISTORY_HEADER_FORMAT);
-        sb.append(String.format(goMessageHistoryHeader == null ? MESSAGE_HISTORY_HEADER : goMessageHistoryHeader, "RouteId",
-                "ProcessorId", "Processor", "Elapsed (ms)"));
+        sb.append(String.format(goMessageHistoryHeader == null ? MESSAGE_HISTORY_HEADER : goMessageHistoryHeader,
+                "Location", "RouteId", "ProcessorId", "Processor", "Elapsed (ms)"));
         sb.append("\n");
 
         // add incoming origin of message on the top
         String routeId = exchange.getFromRouteId();
+        Route route = exchange.getContext().getRoute(routeId);
+        String loc = route != null ? route.getSourceLocation() : "";
         String id = routeId;
         String label = "";
         if (exchange.getFromEndpoint() != null) {
-            label = "from[" + URISupport.sanitizeUri(exchange.getFromEndpoint().getEndpointUri() + "]");
+            label = "from[" + URISupport.sanitizeUri(StringHelper.limitLength(exchange.getFromEndpoint().getEndpointUri(), 100))
+                    + "]";
         }
         long elapsed = new StopWatch(exchange.getCreated()).taken();
 
         String goMessageHistoryOutput = exchange.getContext().getGlobalOption(Exchange.MESSAGE_HISTORY_OUTPUT_FORMAT);
         goMessageHistoryOutput = goMessageHistoryOutput == null ? MESSAGE_HISTORY_OUTPUT : goMessageHistoryOutput;
-        sb.append(String.format(goMessageHistoryOutput, routeId, id, label, elapsed));
+        sb.append(String.format(goMessageHistoryOutput, loc, routeId, id, label, elapsed));
         sb.append("\n");
 
         if (list == null || list.isEmpty()) {
@@ -592,6 +596,7 @@ public final class MessageHelper {
             id = exchange.adapt(ExtendedExchange.class).getHistoryNodeId();
             if (id != null) {
                 // compute route id
+                loc = exchange.adapt(ExtendedExchange.class).getHistoryNodeSource();
                 String rid = ExchangeHelper.getAtRouteId(exchange);
                 if (rid != null) {
                     routeId = rid;
@@ -608,12 +613,16 @@ public final class MessageHelper {
                 // we do not have elapsed time
                 elapsed = 0;
                 sb.append("\t...\n");
-                sb.append(String.format(goMessageHistoryOutput, routeId, id, label, elapsed));
+                sb.append(String.format(goMessageHistoryOutput, loc, routeId, id, label, elapsed));
                 sb.append("\n");
             }
         } else {
             for (MessageHistory history : list) {
                 // and then each history
+                loc = LoggerHelper.getLineNumberLoggerName(history.getNode());
+                if (loc == null) {
+                    loc = "";
+                }
                 routeId = history.getRouteId() != null ? history.getRouteId() : "";
                 id = history.getNode().getId();
                 // we need to avoid leak the sensible information here
@@ -626,7 +635,7 @@ public final class MessageHelper {
                 label = URISupport.sanitizeUri(StringHelper.limitLength(history.getNode().getLabel(), 100));
                 elapsed = history.getElapsed();
 
-                sb.append(String.format(goMessageHistoryOutput, routeId, id, label, elapsed));
+                sb.append(String.format(goMessageHistoryOutput, loc, routeId, id, label, elapsed));
                 sb.append("\n");
             }
         }
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_15.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_15.adoc
index 92dab96..456c909 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_15.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_15.adoc
@@ -20,6 +20,19 @@ Added `getScheme` method to `org.apache.camel.spi.Resource`.
 
 Removed the deprecated `Classic` value from `startupSummaryLevel` enums.
 
+==== Message History
+
+The message history output now includes a source column, which refers to the Java class/XML file
+from the DSL the message was at the given time. (line precise error reporting).
+
+This means there is now 5 columns and the defaults are:
+```
+MESSAGE_HISTORY_HEADER = "%-30s %-20s %-20s %-50s %-12s";
+MESSAGE_HISTORY_OUTPUT = "%-30.30s %-20.20s %-20.20s %-50.50s %12.12s";
+```
+
+If you are using custom sizes then you need to adjust from 4 to 5 columns.
+
 === camel-endpointdsl
 
 The Endpoint DSL is now more type-safe, where previously an option would be declared as `Object` type,

[camel] 03/03: CAMEL-17420: camel-core - Add flag to turn on|off source loc:line

Posted by da...@apache.org.
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 a712344a3f87ab7038e0a1f8e69da870a16fdc81
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 5 11:04:57 2022 +0100

    CAMEL-17420: camel-core - Add flag to turn on|off source loc:line
---
 .../camel/cdi/xml/CamelContextFactoryBean.java     | 12 ++++++++
 .../org/apache/camel/spring/xml/camelContext.json  |  1 +
 .../camel/spring/xml/CamelContextFactoryBean.java  | 19 ++++++++++++
 .../docs/modules/eips/pages/message-history.adoc   | 35 ++++++++++++++++++++++
 .../core/xml/AbstractCamelContextFactoryBean.java  |  5 ++++
 5 files changed, 72 insertions(+)

diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
index dc4b15d..bf00408 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
@@ -101,6 +101,9 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Def
     private String messageHistory;
 
     @XmlAttribute
+    private String sourceLocationEnabled;
+
+    @XmlAttribute
     private String logMask;
 
     @XmlAttribute
@@ -731,6 +734,15 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Def
     }
 
     @Override
+    public String getSourceLocationEnabled() {
+        return sourceLocationEnabled;
+    }
+
+    public void setSourceLocationEnabled(String sourceLocationEnabled) {
+        this.sourceLocationEnabled = sourceLocationEnabled;
+    }
+
+    @Override
     public String getLogMask() {
         return logMask;
     }
diff --git a/components/camel-spring-xml/src/generated/resources/org/apache/camel/spring/xml/camelContext.json b/components/camel-spring-xml/src/generated/resources/org/apache/camel/spring/xml/camelContext.json
index cf721b1..a97c077 100644
--- a/components/camel-spring-xml/src/generated/resources/org/apache/camel/spring/xml/camelContext.json
+++ b/components/camel-spring-xml/src/generated/resources/org/apache/camel/spring/xml/camelContext.json
@@ -19,6 +19,7 @@
     "tracePattern": { "kind": "attribute", "displayName": "Trace Pattern", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Tracing pattern to match which node EIPs to trace. For example to match all To EIP nodes, use to. The pattern matches by node and route id's Multiple patterns can be separated by comma." },
     "debug": { "kind": "attribute", "displayName": "Debug", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets whether debugging is enabled or not. To use debugging then this must be enabled on startup to be installed in the CamelContext." },
     "messageHistory": { "kind": "attribute", "displayName": "Message History", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "false", "description": "Sets whether message history is enabled or not." },
+    "sourceLocationEnabled": { "kind": "attribute", "displayName": "Source Location Enabled", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "false", "description": "Whether to capture precise source location:line-number for all EIPs in Camel routes. Enabling this will impact parsing Java based routes (also Groovy, Kotlin, etc.) on startup as this uses JDK StackTraceElement to calculate the lo [...]
     "logMask": { "kind": "attribute", "displayName": "Log Mask", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "false", "description": "Sets whether security mask for Logging is enabled or not." },
     "logExhaustedMessageBody": { "kind": "attribute", "displayName": "Log Exhausted Message Body", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets whether to log exhausted message body with message history." },
     "streamCache": { "kind": "attribute", "displayName": "Stream Cache", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets whether stream caching is enabled or not." },
diff --git a/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/CamelContextFactoryBean.java b/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/CamelContextFactoryBean.java
index 4bf106f..7b23921 100644
--- a/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/CamelContextFactoryBean.java
+++ b/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/CamelContextFactoryBean.java
@@ -124,6 +124,9 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
     private String messageHistory;
     @XmlAttribute
     @Metadata(defaultValue = "false")
+    private String sourceLocationEnabled;
+    @XmlAttribute
+    @Metadata(defaultValue = "false")
     private String logMask;
     @XmlAttribute
     private String logExhaustedMessageBody;
@@ -858,6 +861,22 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
     }
 
     @Override
+    public String getSourceLocationEnabled() {
+        return sourceLocationEnabled;
+    }
+
+    /**
+     * Whether to capture precise source location:line-number for all EIPs in Camel routes.
+     *
+     * Enabling this will impact parsing Java based routes (also Groovy, Kotlin, etc.) on startup as this uses JDK
+     * StackTraceElement to calculate the location from the Camel route, which comes with a performance cost. This only
+     * impact startup, not the performance of the routes at runtime.
+     */
+    public void setSourceLocationEnabled(String sourceLocationEnabled) {
+        this.sourceLocationEnabled = sourceLocationEnabled;
+    }
+
+    @Override
     public String getLogMask() {
         return logMask;
     }
diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/message-history.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/message-history.adoc
index 88cc170..802c50e 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/message-history.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/message-history.adoc
@@ -92,6 +92,41 @@ And in XML:
 </route>
 ----
 
+=== Enabling source location information
+
+Camel is capable of gathering precise source file:line-number for each EIPs in the routes.
+When enabled, then the message history will output this information in the route stack-trace.
+
+To enable source location:
+
+[source,java]
+----
+camelContext.setSourceLocationEnabled(true);
+----
+
+Or in XML
+
+[source,xml]
+----
+<camelContext sourceLocationEnabled="true">
+
+</camelContext>
+----
+
+Or when using Spring Boot or Quarkus, you can enable this in the configuration file:
+
+[source,properties]
+----
+camel.springboot.source-location-enabled = true
+----
+
+And in Quarkus:
+
+[source,properties]
+----
+camel.quarkus.source-location-enabled = true
+----
+
 == Route stack-trace in exceptions logged by error handler
 
 If Message History is enabled, then Camel will include this information,
diff --git a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index 07661d1..47652f4 100644
--- a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -976,6 +976,8 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
 
     public abstract String getMessageHistory();
 
+    public abstract String getSourceLocationEnabled();
+
     public abstract String getLogMask();
 
     public abstract String getLogExhaustedMessageBody();
@@ -1120,6 +1122,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
         if (getMessageHistory() != null) {
             context.setMessageHistory(CamelContextHelper.parseBoolean(context, getMessageHistory()));
         }
+        if (getSourceLocationEnabled() != null) {
+            context.setSourceLocationEnabled(CamelContextHelper.parseBoolean(context, getSourceLocationEnabled()));
+        }
         if (getLogMask() != null) {
             context.setLogMask(CamelContextHelper.parseBoolean(context, getLogMask()));
         }

[camel] 02/03: Polished method call toString

Posted by da...@apache.org.
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 8a398c3355d692a2e528f99561b0b53f830699f2
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 5 10:10:27 2022 +0100

    Polished method call toString
---
 .../camel/model/language/MethodCallExpression.java      | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/language/MethodCallExpression.java b/core/camel-core-model/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
index d2c7876..62ed6aa 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
@@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StringHelper;
 
 /**
  * Calls a Java bean method.
@@ -183,8 +184,20 @@ public class MethodCallExpression extends ExpressionDefinition {
 
     @Override
     public String toString() {
-        boolean isRef = ref != null;
-        return "bean[" + (isRef ? "ref:" : "") + beanName() + (method != null ? " method:" + method : "") + "]";
+        String name = null;
+        if (ref != null) {
+            name = "ref:" + ref;
+        } else if (beanTypeName != null) {
+            // we just want the simple name
+            name = StringHelper.afterLast(beanTypeName, ".", beanTypeName);
+        } else if (beanType != null) {
+            name = beanType.getSimpleName();
+        } else if (instance != null) {
+            name = instance.getClass().getSimpleName();
+        } else {
+            name = getExpression();
+        }
+        return "bean[" + name + (method != null ? " method:" + method : "") + "]";
     }
 
 }