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 44dc451636b camel-core - Source location should preserve scheme in
Java DSL
44dc451636b is described below
commit 44dc451636b97d94db57ae6a63046e3ec289de2d
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Sep 16 10:52:54 2022 +0200
camel-core - Source location should preserve scheme in Java DSL
---
.../apache/camel/model/ProcessorDefinition.java | 11 +++++----
.../camel/model/ProcessorDefinitionHelper.java | 27 +++++++++++++++++++++-
.../commands/process/CamelProcessorStatus.java | 4 ----
3 files changed, 32 insertions(+), 10 deletions(-)
diff --git
a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index 1a820d47651..71a1f96d043 100644
---
a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++
b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -177,11 +177,6 @@ public abstract class ProcessorDefinition<Type extends
ProcessorDefinition<Type>
}
}
}
- if (context != null && (context.isSourceLocationEnabled() ||
context.isDebugging() || context.isTracing())) {
- // we want to capture source location:line for every output
- Resource resource = this instanceof ResourceAware ?
((ResourceAware) this).getResource() : null;
- ProcessorDefinitionHelper.prepareSourceLocation(resource, output);
- }
// inject context
CamelContextAware.trySetCamelContext(output, context);
@@ -210,6 +205,12 @@ public abstract class ProcessorDefinition<Type extends
ProcessorDefinition<Type>
output.setParent(this);
configureChild(output);
getOutputs().add(output);
+
+ if (context != null && (context.isSourceLocationEnabled() ||
context.isDebugging() || context.isTracing())) {
+ // we want to capture source location:line for every output
+ Resource resource = this instanceof ResourceAware ?
((ResourceAware) this).getResource() : null;
+ ProcessorDefinitionHelper.prepareSourceLocation(resource, output);
+ }
}
public void clearOutput() {
diff --git
a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
index 24aff77ee90..2395618db79 100644
---
a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
+++
b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
@@ -24,6 +24,7 @@ import java.util.Set;
import org.apache.camel.NamedNode;
import org.apache.camel.spi.Resource;
+import org.apache.camel.support.ResourceHelper;
import org.apache.camel.util.FileUtil;
/**
@@ -402,7 +403,17 @@ public final class ProcessorDefinitionHelper {
// when we are no longer in model/RouteBuilder, we have
found the location:line-number
node.setLineNumber(e.getLineNumber());
if (node.getLocation() == null) {
- String name = e.getClassName();
+ String name = e.getFileName();
+ if (name == null) {
+ name = e.getClassName();
+ }
+ // find out what scheme for location as it can be
file, classpath etc
+ if (!ResourceHelper.hasScheme(name)) {
+ String scheme =
findParentSourceLocationScheme(node);
+ if (scheme != null) {
+ name = scheme + name;
+ }
+ }
node.setLocation(name);
}
return;
@@ -427,4 +438,18 @@ public final class ProcessorDefinitionHelper {
return level;
}
+ /**
+ * Finds the source location scheme from the parent nodes.
+ */
+ public static String findParentSourceLocationScheme(NamedNode node) {
+ while (node != null && node.getParent() != null) {
+ String location = node.getLocation();
+ if (ResourceHelper.hasScheme(location)) {
+ return ResourceHelper.getScheme(location);
+ }
+ node = node.getParent();
+ }
+ return null;
+ }
+
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelProcessorStatus.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelProcessorStatus.java
index 2bd2adde44e..46a31caeb88 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelProcessorStatus.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelProcessorStatus.java
@@ -216,10 +216,6 @@ public class CamelProcessorStatus extends
ProcessBaseCommand {
} else {
answer = r.processorId != null ? r.processorId : r.routeId;
}
- if (r.processorId != null) {
- String pad = StringHelper.padString(r.level, 1);
- answer = pad + answer;
- }
return answer;
}