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 8b1b055b680d CAMEL-23004: camel-jbang - Transform route should better 
support Java DSL with inlined expressions
8b1b055b680d is described below

commit 8b1b055b680d67f8a03f1a96e9d67cee0d6d7fae
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Feb 14 10:06:27 2026 +0100

    CAMEL-23004: camel-jbang - Transform route should better support Java DSL 
with inlined expressions
---
 .../modules/eips/pages/dead-letter-channel.adoc    | 14 ++--
 .../main/docs/modules/eips/pages/delay-eip.adoc    | 39 +++++++++
 .../java/org/apache/camel/yaml/io/YamlWriter.java  |  2 +-
 .../java/org/apache/camel/main/KameletMain.java    |  3 +
 .../apache/camel/main/stub/BeanStubReifier.java    | 66 ++++++++++++++++
 .../camel/dsl/yaml/validator/CamelYamlParser.java  |  3 +
 .../camel/dsl/yaml/validator/stub/StubReifier.java | 92 ++++++++++++++++++++++
 7 files changed, 211 insertions(+), 8 deletions(-)

diff --git 
a/core/camel-core-engine/src/main/docs/modules/eips/pages/dead-letter-channel.adoc
 
b/core/camel-core-engine/src/main/docs/modules/eips/pages/dead-letter-channel.adoc
index 539376911794..898361571fe1 100644
--- 
a/core/camel-core-engine/src/main/docs/modules/eips/pages/dead-letter-channel.adoc
+++ 
b/core/camel-core-engine/src/main/docs/modules/eips/pages/dead-letter-channel.adoc
@@ -25,7 +25,7 @@ The Dead Letter Channel is similar to the default error 
handler, but with the fo
 == Using Dead Letter Error Handler
 
 When using the dead letter channel error handler, you must configure the dead 
letter queue as an endpoint, so the handler knows where to move the failed 
messages.
-This is done a bit differently in the Java DSL and XML DSL.
+This is done a bit differently in the Java DSL and Spring XML DSL.
 
 For example, here’s how to log the message at `ERROR` level:
 
@@ -73,7 +73,7 @@ individual routes used another error handler.
 
 NOTE: The DSLs is planned to be improved in the near future to have a unified
 way of configuring error handling across all DSLs with 
xref:manual::route-configuration.adoc[Route Configuration].
-When fully implemented, then configuring error handler in Java and XML DSL 
would be much more similar than currently.
+When fully implemented, then configuring error handler in Java and Spring XML 
DSL would be much more similar than currently.
 
 === Redelivery
 
@@ -154,7 +154,7 @@ errorHandler(deadLetterChannel("jms:queue:dead")
     .maximumRedeliveries(3).redeliveryDelay(5000));
 ----
 
-XML::
+Spring XML::
 +
 [source,xml]
 ----
@@ -212,7 +212,7 @@ errorHandler(deadLetterChannel("jms:queue:dead")
    .useOriginalMessage().maximumRedeliveries(5).redeliveryDelay(5000);
 ----
 
-XML::
+Spring XML::
 +
 And in XML, you set `useOriginalMessage=true` on the `<errorHandler>` as shown:
 +
@@ -259,7 +259,7 @@ errorHandler(deadLetterChannel("jms:queue:dead")
   .onRedeliver(new MyOnRedeliveryProcessor());
 ----
 
-XML::
+Spring XML::
 +
 And in XML DSL, you specify a bean id via `onRedeliveryRef` on the 
`<errorHandler>` as shown:
 +
@@ -309,7 +309,7 @@ Java::
 errorHandler(deadLetterChannel("jms:dead").onPrepareFailure(new 
MyPrepareProcessor()));
 ----
 
-XML::
+Spring XML::
 +
 Configuring this from Spring XML is done with the `onPrepareFailureRef` to 
refer to the processor as a `<bean>` as shown:
 +
@@ -355,7 +355,7 @@ Java::
 errorHandler(deadLetterChannel("jms:dead").onExceptionOccurred(new 
OnErrorLogger()));
 ----
 
-XML::
+Spring XML::
 +
 Configuring this from Spring XML is done with the `onExceptionOccurredRef` to 
refer to the processor as a `<bean>` as shown:
 +
diff --git 
a/core/camel-core-engine/src/main/docs/modules/eips/pages/delay-eip.adoc 
b/core/camel-core-engine/src/main/docs/modules/eips/pages/delay-eip.adoc
index 506693696ae9..48da16a6131b 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/delay-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/delay-eip.adoc
@@ -125,6 +125,10 @@ YAML::
 You can also call a xref:languages:bean-language.adoc[Bean Method] to compute 
the
 delayed value from Java code:
 
+[tabs]
+====
+Java::
++
 [source,java]
 ----
 from("activemq:foo")
@@ -132,6 +136,41 @@ from("activemq:foo")
   .to("activemq:bar");
 ----
 
+XML::
++
+[source,xml]
+----
+<route>
+    <from uri="activemq:foo"/>
+    <delay>
+        <method ref="someBean" method="computeDelay"/>
+    </delay>
+    <to uri="activemq:bar"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: activemq
+      parameters:
+        destinationName: foo
+      steps:
+        - delay:
+            expression:
+              method:
+                ref: someBean
+                method: computeDelay
+        - to:
+            uri: activemq
+            parameters:
+              destinationName: bar
+----
+====
+
 Then the bean would look something like this:
 
 [source,java]
diff --git 
a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java 
b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java
index 42442edb8f26..28a8083e4887 100644
--- a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java
+++ b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java
@@ -360,7 +360,7 @@ public class YamlWriter extends ServiceSupport implements 
CamelContextAware {
                     node.addExpression(eipNode);
                 } else {
                     node.addProperty(key, v);
-                    if ("expression".equals(key)) {
+                    if ("expression".equals(key) || node.isExpression()) {
                         node.addProperty("language", model.getName());
                     }
                 }
diff --git 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
index a1f4bbb760f9..2bc2320fb646 100644
--- 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
+++ 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
@@ -79,6 +79,7 @@ import org.apache.camel.main.download.TransactedDownloader;
 import org.apache.camel.main.download.TypeConverterLoaderDownloadListener;
 import org.apache.camel.main.injection.AnnotationDependencyInjection;
 import org.apache.camel.main.reload.OpenApiGeneratorReloadStrategy;
+import org.apache.camel.main.stub.BeanStubReifier;
 import org.apache.camel.main.util.ClipboardReloadStrategy;
 import org.apache.camel.main.util.ExtraClassesClassLoader;
 import org.apache.camel.main.util.ExtraFilesClassLoader;
@@ -490,6 +491,8 @@ public class KameletMain extends MainCommandLineSupport {
             // turn off inlining routes
             configure().rest().withInlineRoutes(false);
             blueprintXmlBeansHandler.setTransform(true);
+            // stub beans
+            BeanStubReifier.registerStubBeanReifiers();
         }
         if (silent) {
             // silent should not include http server
diff --git 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/stub/BeanStubReifier.java
 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/stub/BeanStubReifier.java
new file mode 100644
index 000000000000..b8935aacb2b4
--- /dev/null
+++ 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/stub/BeanStubReifier.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.main.stub;
+
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.builder.PredicateBuilder;
+import org.apache.camel.model.BeanDefinition;
+import org.apache.camel.model.language.MethodCallExpression;
+import org.apache.camel.processor.DisabledProcessor;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.reifier.language.ExpressionReifier;
+
+public class BeanStubReifier {
+
+    private BeanStubReifier() {
+    }
+
+    public static void registerStubBeanReifiers() {
+        ExpressionReifier.registerReifier(MethodCallExpression.class, 
(camelContext, expressionDefinition) -> {
+            if (expressionDefinition instanceof MethodCallExpression) {
+                return new ExpressionReifier<>(camelContext, 
expressionDefinition) {
+                    @Override
+                    public Expression createExpression() {
+                        return ExpressionBuilder.constantExpression(null);
+                    }
+
+                    @Override
+                    public Predicate createPredicate() {
+                        return PredicateBuilder.constant(true);
+                    }
+                };
+            }
+            return null;
+        });
+        ProcessorReifier.registerReifier(BeanDefinition.class,
+                (route, processorDefinition) -> {
+                    if (processorDefinition instanceof BeanDefinition bd) {
+                        return new ProcessorReifier<>(route, bd) {
+                            @Override
+                            public Processor createProcessor() throws 
Exception {
+                                return new DisabledProcessor();
+                            }
+                        };
+                    }
+                    return null;
+                });
+    }
+
+}
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/CamelYamlParser.java
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/CamelYamlParser.java
index be7b3a4f725b..9ebca9b460b1 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/CamelYamlParser.java
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/CamelYamlParser.java
@@ -28,6 +28,7 @@ import org.apache.camel.dsl.yaml.YamlRoutesBuilderLoader;
 import org.apache.camel.dsl.yaml.validator.stub.StubBeanRepository;
 import org.apache.camel.dsl.yaml.validator.stub.StubDataFormat;
 import org.apache.camel.dsl.yaml.validator.stub.StubLanguage;
+import org.apache.camel.dsl.yaml.validator.stub.StubReifier;
 import org.apache.camel.dsl.yaml.validator.stub.StubTransformer;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.spi.ComponentResolver;
@@ -64,6 +65,8 @@ public class CamelYamlParser {
                     (name, context) -> new StubTransformer());
             camelContext.start();
 
+            StubReifier.registerStubReifiers();
+
             YamlRoutesBuilderLoader loader = new YamlRoutesBuilderLoader();
             loader.setCamelContext(camelContext);
             loader.start();
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/stub/StubReifier.java
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/stub/StubReifier.java
new file mode 100644
index 000000000000..e8ebc1d50fbe
--- /dev/null
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/stub/StubReifier.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.yaml.validator.stub;
+
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.builder.PredicateBuilder;
+import org.apache.camel.model.BeanDefinition;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.SagaDefinition;
+import org.apache.camel.model.language.MethodCallExpression;
+import org.apache.camel.processor.DisabledProcessor;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.reifier.language.ExpressionReifier;
+
+public class StubReifier {
+
+    private StubReifier() {
+    }
+
+    public static void registerStubReifiers() {
+        ExpressionReifier.registerReifier(MethodCallExpression.class, 
(camelContext, expressionDefinition) -> {
+            if (expressionDefinition instanceof MethodCallExpression) {
+                return new ExpressionReifier<>(camelContext, 
expressionDefinition) {
+                    @Override
+                    public Expression createExpression() {
+                        return ExpressionBuilder.constantExpression(null);
+                    }
+
+                    @Override
+                    public Predicate createPredicate() {
+                        return PredicateBuilder.constant(true);
+                    }
+                };
+            }
+            return null;
+        });
+        ProcessorReifier.registerReifier(BeanDefinition.class,
+                (route, processorDefinition) -> {
+                    if (processorDefinition instanceof BeanDefinition bd) {
+                        return new ProcessorReifier<>(route, bd) {
+                            @Override
+                            public Processor createProcessor() throws 
Exception {
+                                return new DisabledProcessor();
+                            }
+                        };
+                    }
+                    return null;
+                });
+        ProcessorReifier.registerReifier(CircuitBreakerDefinition.class,
+                (route, processorDefinition) -> {
+                    if (processorDefinition instanceof 
CircuitBreakerDefinition cb) {
+                        return new ProcessorReifier<>(route, cb) {
+                            @Override
+                            public Processor createProcessor() throws 
Exception {
+                                return new DisabledProcessor();
+                            }
+                        };
+                    }
+                    return null;
+                });
+        ProcessorReifier.registerReifier(SagaDefinition.class,
+                (route, processorDefinition) -> {
+                    if (processorDefinition instanceof SagaDefinition sd) {
+                        return new ProcessorReifier<>(route, sd) {
+                            @Override
+                            public Processor createProcessor() throws 
Exception {
+                                return new DisabledProcessor();
+                            }
+                        };
+                    }
+                    return null;
+                });
+    }
+
+}

Reply via email to