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 45c22ffb59e7 CAMEL-23033: camel-yaml-dsl - Setting routePolicy on 
route should be routePolicyRef. Also polished docs, and made onException route 
dumper correct for handled/continued
45c22ffb59e7 is described below

commit 45c22ffb59e76958c6f0f689257fad393b1fd04b
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Feb 19 12:37:32 2026 +0100

    CAMEL-23033: camel-yaml-dsl - Setting routePolicy on route should be 
routePolicyRef. Also polished docs, and made onException route dumper correct 
for handled/continued
---
 .../apache/camel/model/OnExceptionDefinition.java  | 21 +++---
 .../ROOT/pages/camel-4x-upgrade-guide-4_18.adoc    |  6 ++
 .../ROOT/pages/camel-4x-upgrade-guide-4_19.adoc    |  3 +
 .../ROOT/pages/cronscheduledroutepolicy.adoc       | 46 +++++++++---
 docs/user-manual/modules/ROOT/pages/debugger.adoc  | 12 +--
 .../modules/ROOT/pages/defaulterrorhandler.adoc    | 87 +++++++++++++++++++++-
 .../modules/ROOT/pages/delay-interceptor.adoc      | 48 ++++++++----
 docs/user-manual/modules/ROOT/pages/endpoint.adoc  | 22 +++++-
 .../apache/camel/main/stub/StubBeanRepository.java |  7 ++
 .../deserializers/RouteDefinitionDeserializer.java |  4 +-
 .../generated/resources/schema/camelYamlDsl.json   |  2 +-
 .../org/apache/camel/dsl/yaml/RoutesTest.groovy    |  2 +-
 12 files changed, 209 insertions(+), 51 deletions(-)

diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
index b8fd7a16369f..f590c41eebb5 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
@@ -31,10 +31,9 @@ import org.apache.camel.Expression;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
-import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.model.language.ConstantExpression;
 import org.apache.camel.spi.AsPredicate;
 import org.apache.camel.spi.Metadata;
-import org.apache.camel.support.ExpressionToPredicateAdapter;
 import org.apache.camel.util.ObjectHelper;
 
 /**
@@ -222,8 +221,8 @@ public class OnExceptionDefinition extends 
OutputDefinition<OnExceptionDefinitio
      * @return         the builder
      */
     public OnExceptionDefinition handled(boolean handled) {
-        Expression expression = 
ExpressionBuilder.constantExpression(Boolean.toString(handled));
-        return handled(expression);
+        setHandled(new ExpressionSubElementDefinition(new 
ConstantExpression(Boolean.toString(handled))));
+        return this;
     }
 
     /**
@@ -233,7 +232,7 @@ public class OnExceptionDefinition extends 
OutputDefinition<OnExceptionDefinitio
      * @return         the builder
      */
     public OnExceptionDefinition handled(@AsPredicate Predicate handled) {
-        setHandledPolicy(handled);
+        setHandled(new ExpressionSubElementDefinition(handled));
         return this;
     }
 
@@ -244,7 +243,7 @@ public class OnExceptionDefinition extends 
OutputDefinition<OnExceptionDefinitio
      * @return         the builder
      */
     public OnExceptionDefinition handled(@AsPredicate Expression handled) {
-        setHandledPolicy(ExpressionToPredicateAdapter.toPredicate(handled));
+        setHandled(new ExpressionSubElementDefinition(handled));
         return this;
     }
 
@@ -257,8 +256,8 @@ public class OnExceptionDefinition extends 
OutputDefinition<OnExceptionDefinitio
      * @return           the builder
      */
     public OnExceptionDefinition continued(boolean continued) {
-        Expression expression = 
ExpressionBuilder.constantExpression(Boolean.toString(continued));
-        return continued(expression);
+        setContinued(new ExpressionSubElementDefinition(new 
ConstantExpression(Boolean.toString(continued))));
+        return this;
     }
 
     /**
@@ -270,7 +269,7 @@ public class OnExceptionDefinition extends 
OutputDefinition<OnExceptionDefinitio
      * @return           the builder
      */
     public OnExceptionDefinition continued(@AsPredicate Predicate continued) {
-        setContinuedPolicy(continued);
+        setContinued(new ExpressionSubElementDefinition(continued));
         return this;
     }
 
@@ -283,7 +282,7 @@ public class OnExceptionDefinition extends 
OutputDefinition<OnExceptionDefinitio
      * @return           the builder
      */
     public OnExceptionDefinition continued(@AsPredicate Expression continued) {
-        
setContinuedPolicy(ExpressionToPredicateAdapter.toPredicate(continued));
+        setContinued(new ExpressionSubElementDefinition(continued));
         return this;
     }
 
@@ -310,7 +309,7 @@ public class OnExceptionDefinition extends 
OutputDefinition<OnExceptionDefinitio
      * @return            the builder
      */
     public OnExceptionDefinition retryWhile(@AsPredicate Predicate retryWhile) 
{
-        setRetryWhilePolicy(retryWhile);
+        setRetryWhile(new ExpressionSubElementDefinition(retryWhile));
         return this;
     }
 
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc
index 0e791b5b5122..faf9f5c1cf37 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc
@@ -11,6 +11,12 @@ Note that manual migration is still required.
 See the xref:camel-upgrade-recipes-tool.adoc[documentation] page for details.
 ====
 
+== Upgrading from 4.18.0 to 4.18.1
+
+In the YAML DSL we have renamed `routePolicy` to `routePolicyRef` on the 
`route` node,
+as that is the correct name.
+
+
 == Upgrading Camel 4.17 to 4.18
 
 === camel-simple
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc
index c0e16e7696c1..05948c3420a5 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc
@@ -22,6 +22,9 @@ Removed 2 deprecated methods in Java DSL for `throttler` EIP.
 
 === camel-yaml-io / camel-xml-io
 
+In the YAML DSL we have renamed `routePolicy` to `routePolicyRef` on the 
`route` node,
+as that is the correct name.
+
 When dumping routes in YAML or XML format via `camel-yaml-io` or 
`camel-xml-io` then the structure of routes
 and all the EIP options now respect the intended order in the model.
 
diff --git a/docs/user-manual/modules/ROOT/pages/cronscheduledroutepolicy.adoc 
b/docs/user-manual/modules/ROOT/pages/cronscheduledroutepolicy.adoc
index 64a19d4aaa0a..8ae6fdcb37e4 100644
--- a/docs/user-manual/modules/ROOT/pages/cronscheduledroutepolicy.adoc
+++ b/docs/user-manual/modules/ROOT/pages/cronscheduledroutepolicy.adoc
@@ -26,16 +26,16 @@ information must be provided.
 === Starting a route
 
 [width="100%",cols="25%,25%,25%,25%",options="header",]
-|=======================================================================
+|===
 |Parameter Name |Type |Default Value |Description
 |routeStartTime |String |  |the initial scheduled date and time as a
 Cron Expression for route start
-|=======================================================================
+|===
 
 === Stopping a route
 
 [width="100%",cols="25%,25%,25%,25%",options="header",]
-|=======================================================================
+|===
 |Parameter Name |Type |Default Value |Description
 |routeStopTime |String |  |the initial scheduled date and time as a Cron
 Expression for route stop
@@ -45,33 +45,36 @@ initiating graceful route stop
 
 |routeStopTimeUnit |long |TimeUnit.MILLISECONDS |the time unit for the
 grace period expressed as `java.util.concurrent.TimeUnit`
-|=======================================================================
+|===
 
 === Suspending a route
 
 [width="100%",cols="25%,25%,25%,25%",options="header",]
-|=======================================================================
+|===
 |Parameter Name |Type |Default Value |Description
 |routeSuspendTime |String |  |the initial scheduled date and time as a
 Cron Expression for route suspension
-|=======================================================================
+|===
 
 === Resuming a route
 
 [width="100%",cols="25%,25%,25%,25%",options="header",]
-|=======================================================================
+|===
 |Parameter Name |Type |Default Value |Description
 |routeResumeTime |String |  |the initial scheduled date and time as a
 Cron Expression for route resumption
-|=======================================================================
+|===
 
 == Configuring the route policy
 
 Once the `org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy`
 is created it can be wired into the Camel route as follows:
 
-In Java:
+[tabs]
+====
 
+Java::
++
 [source,java]
 ----
 CronScheduledRoutePolicy startPolicy = new CronScheduledRoutePolicy();
@@ -82,8 +85,8 @@ from("direct:start")
     .to("mock:success");
 ----
 
-And with Spring XML:
-
+Spring XML::
++
 [source,xml]
 ----
 <bean id="startPolicy" 
class="org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy">
@@ -98,6 +101,27 @@ And with Spring XML:
 </camelContext>
 ----
 
+YAML::
++
+[source,yaml]
+----
+- beans:
+  - name: startPolicy
+    type: org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy
+    properties:
+      routeStartTime: "*/3 * * * * ?"
+- route:
+    id: testRoute
+    autoStartup: "false"
+    routePolicyRef: startPolicy
+    from:
+      uri: direct:start
+      steps:
+        - to:
+            uri: mock:success
+----
+====
+
 IMPORTANT: Notice how the route to be scheduled *MUST* be configured to not
 xref:configuring-route-startup-ordering-and-autostartup.adoc[auto-startup], to 
let
 the route scheduler take control of starting and stopping the route 
accordingly.
diff --git a/docs/user-manual/modules/ROOT/pages/debugger.adoc 
b/docs/user-manual/modules/ROOT/pages/debugger.adoc
index 572ee3690035..c15b78275869 100644
--- a/docs/user-manual/modules/ROOT/pages/debugger.adoc
+++ b/docs/user-manual/modules/ROOT/pages/debugger.adoc
@@ -15,14 +15,14 @@ method and return `true`.
 In this unit test
 
 [source,java]
------------------------------------------------
+----
 public class DebugTest extends CamelTestSupport
------------------------------------------------
+----
 
 We want to debug the following route
 
 [source,java]
------------------------------------------------
+----
 @Override
 protected RouteBuilder createRouteBuilder() throws Exception {
     return new RouteBuilder() {
@@ -36,7 +36,7 @@ protected RouteBuilder createRouteBuilder() throws Exception {
         }
     };
 }
------------------------------------------------
+----
 
 Which can easily done by overriding the `debugBefore` method as shown
 
@@ -83,7 +83,7 @@ A trick to debug a Camel route written with Java DSL is to 
modify the route to i
 For instance:
 
 [source,java]
------------------------------------------------
+----
 public class MyRouteBuilder extends RouteBuilder {
 
     @Override
@@ -101,7 +101,7 @@ public class MyRouteBuilder extends RouteBuilder {
                .log("${body}");
     }
 }
------------------------------------------------
+----
 
 === Implementing a custom debugger
 
diff --git a/docs/user-manual/modules/ROOT/pages/defaulterrorhandler.adoc 
b/docs/user-manual/modules/ROOT/pages/defaulterrorhandler.adoc
index 21f0f72f410b..d4cf70d01dea 100644
--- a/docs/user-manual/modules/ROOT/pages/defaulterrorhandler.adoc
+++ b/docs/user-manual/modules/ROOT/pages/defaulterrorhandler.adoc
@@ -30,6 +30,11 @@ In this route below, any exception thrown in, such as the 
`validateOrder`
 bean, will be propagated back to the caller via the jetty endpoint, which
 then returns an HTTP error message back to the client.
 
+[tabs]
+====
+
+Java::
++
 [source,java]
 ----
 from("jetty:http://localhost/myservice/order";)
@@ -37,21 +42,99 @@ from("jetty:http://localhost/myservice/order";)
   .to("jms:queue:order");
 ----
 
+XML::
++
+[source,xml]
+----
+<route>
+    <from uri="jetty:http://localhost/myservice/order"/>
+    <to uri="bean:validateOrder"/>
+    <to uri="jms:queue:order"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: jetty:http://localhost/myservice/order
+      steps:
+        - to:
+            uri: bean:validateOrder
+        - to:
+            uri: jms:queue:order
+----
+====
+
 We can add an `onException` in case we want to catch certain exceptions
 and route them differently, for instance to catch a
-`ValidationException` and return a fixed response to the caller.
+`org.apache.camel.ValidationException` and return a fixed response to the 
caller.
+
+[tabs]
+====
 
+Java::
++
 [source,java]
 ----
 onException(ValidationException.class)
   .handled(true)
-  .transform(body(constant("INVALID ORDER")));
+  .transform(constant("INVALID ORDER"));
 
 from("jetty:http://localhost/myservice/order";)
   .to("bean:validateOrder")
   .to("jms:queue:order");
 ----
 
+XML::
++
+[source,xml]
+----
+<onException>
+    <exception>org.apache.camel.ValidationException</exception>
+    <handled>
+        <constant>true</constant>
+    </handled>
+    <transform>
+        <constant>INVALID ORDER</constant>
+    </transform>
+</onException>
+
+<route>
+    <from uri="jetty:http://localhost/myservice/order"/>
+    <to uri="bean:validateOrder"/>
+    <to uri="jms:queue:order"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- onException:
+    exception:
+      - org.apache.camel.ValidationException
+    handled:
+      constant:
+        expression: "true"
+    steps:
+      - transform:
+          expression:
+            constant:
+              expression: INVALID ORDER
+- route:
+    from:
+      uri: jetty:http://localhost/myservice/order
+      steps:
+        - to:
+            uri: bean:validateOrder
+        - to:
+            uri: jms:queue:order
+----
+====
+
 When the `ValidationException` is thrown from the `validateOrder` bean,
 it is intercepted by Camel error handler which lets the
 `onException(ValidationException.class)` handle the exception.
diff --git a/docs/user-manual/modules/ROOT/pages/delay-interceptor.adoc 
b/docs/user-manual/modules/ROOT/pages/delay-interceptor.adoc
index 078c705d4e97..85bd57a780ec 100644
--- a/docs/user-manual/modules/ROOT/pages/delay-interceptor.adoc
+++ b/docs/user-manual/modules/ROOT/pages/delay-interceptor.adoc
@@ -14,10 +14,11 @@ The delayer can be configured on two levels:
 - Camel context: _Globally_
 - Route: _Individually per route_
 
-=== Configuring using XML DSL
+=== Configuring using Spring XML
 
 Set the `delayer` attribute of the `<camelContext>` tag as shown below:
 
+.Spring XML
 [source,xml]
 
--------------------------------------------------------------------------------------------------
 <camelContext id="camel" delayer="500" 
xmlns="http://activemq.apache.org/camel/schema/spring";>
@@ -44,24 +45,41 @@ as you like. Per route will override the camel context 
setting.
 
 For example, the route below is only the first route that has a delayer with 
200 milliseconds.
 
-[source,xml]
-----
-<camelContext>
-   <route delayer="200">
-     ...
-   </route>
-
-   <route>
-     ...
-   </route>
-</camelContext>
-----
-
-And in Java DSL:
+[tabs]
+====
 
+Java::
++
 [source,java]
 ----
 from("direct:start").delayer(200)
     .to("mock:result")
 ----
 
+XML::
++
+[source,xml]
+----
+<route delayer="200">
+ ...
+</route>
+
+<route>
+ ...
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    delayer: 200
+    from:
+      uri: direct:start
+      steps:
+        - to:
+            uri: mock:result
+----
+====
+
diff --git a/docs/user-manual/modules/ROOT/pages/endpoint.adoc 
b/docs/user-manual/modules/ROOT/pages/endpoint.adoc
index 6815ba9371df..704a7bb9bc9f 100644
--- a/docs/user-manual/modules/ROOT/pages/endpoint.adoc
+++ b/docs/user-manual/modules/ROOT/pages/endpoint.adoc
@@ -13,14 +13,19 @@ The following example route demonstrates the use of a 
xref:components::file-comp
 consumer endpoint and a * xref:components::jms-component.adoc[JMS] producer 
endpoint,
 by their xref:manual::uris.adoc[URIs]:
 
+[tabs]
+====
+
+Java::
++
 [source,java]
 ----
 from("file:messages/foo")
     .to("jms:queue:foo");
 ----
 
-And in XML:
-
+XML::
++
 [source,xml]
 ----
 <route>
@@ -29,6 +34,19 @@ And in XML:
 </route>
 ----
 
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: file:messages/foo
+      steps:
+        - to:
+            uri: jms:queue:foo
+----
+====
+
 == Endpoint API
 
 You will almost never have the need for creating endpoints manually via Java 
API.
diff --git 
a/dsl/camel-kamelet-main-support/src/main/java/org/apache/camel/main/stub/StubBeanRepository.java
 
b/dsl/camel-kamelet-main-support/src/main/java/org/apache/camel/main/stub/StubBeanRepository.java
index a4e1264d53bf..427ac9938527 100644
--- 
a/dsl/camel-kamelet-main-support/src/main/java/org/apache/camel/main/stub/StubBeanRepository.java
+++ 
b/dsl/camel-kamelet-main-support/src/main/java/org/apache/camel/main/stub/StubBeanRepository.java
@@ -36,8 +36,10 @@ import org.apache.camel.spi.AggregationRepository;
 import org.apache.camel.spi.BeanRepository;
 import org.apache.camel.spi.ClaimCheckRepository;
 import org.apache.camel.spi.IdempotentRepository;
+import org.apache.camel.spi.RoutePolicy;
 import org.apache.camel.spi.StateRepository;
 import org.apache.camel.support.PatternHelper;
+import org.apache.camel.support.RoutePolicySupport;
 import 
org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository;
 import org.apache.camel.support.processor.state.MemoryStateRepository;
 import org.slf4j.Logger;
@@ -55,6 +57,8 @@ public class StubBeanRepository implements BeanRepository {
     private final AggregateController service6 = new 
DefaultAggregateController();
     private final LoadBalancer service7 = new RoundRobinLoadBalancer();
     private final Comparator<?> service8 = (o1, o2) -> 0;
+    private final RoutePolicy service9 = new RoutePolicySupport() {
+    };
 
     private final String stubPattern;
 
@@ -126,6 +130,9 @@ public class StubBeanRepository implements BeanRepository {
         if (Comparator.class.isAssignableFrom(type)) {
             return (T) service8;
         }
+        if (RoutePolicy.class.isAssignableFrom(type)) {
+            return (T) service9;
+        }
         if (Logger.class.isAssignableFrom(type)) {
             return (T) LOG;
         }
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/RouteDefinitionDeserializer.java
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/RouteDefinitionDeserializer.java
index faecdd84b368..90567986a281 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/RouteDefinitionDeserializer.java
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/RouteDefinitionDeserializer.java
@@ -48,7 +48,7 @@ import org.snakeyaml.engine.v2.nodes.NodeTuple;
                   @YamlProperty(name = "precondition", type = "string"),
                   @YamlProperty(name = "routeConfigurationId", type = 
"string"),
                   @YamlProperty(name = "autoStartup", type = "boolean"),
-                  @YamlProperty(name = "routePolicy", type = "string"),
+                  @YamlProperty(name = "routePolicyRef", type = "string"),
                   @YamlProperty(name = "startupOrder", type = "number"),
                   @YamlProperty(name = "streamCache", type = "boolean"),
                   @YamlProperty(name = "messageHistory", type = "boolean"),
@@ -115,7 +115,7 @@ public class RouteDefinitionDeserializer extends 
YamlDeserializerBase<RouteDefin
                 case "autoStartup":
                     target.setAutoStartup(asText(val));
                     break;
-                case "routePolicy":
+                case "routePolicyRef":
                     target.setRoutePolicyRef(asText(val));
                     break;
                 case "startupOrder":
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
index 229bac40f092..982fd079a6a5 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
@@ -5861,7 +5861,7 @@
           "routeConfigurationId" : {
             "type" : "string"
           },
-          "routePolicy" : {
+          "routePolicyRef" : {
             "type" : "string"
           },
           "shutdownRoute" : {
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RoutesTest.groovy
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RoutesTest.groovy
index dbf21e0c89f6..9811203fe2bd 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RoutesTest.groovy
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RoutesTest.groovy
@@ -286,7 +286,7 @@ class RoutesTest extends YamlTestSupport {
                     streamCache: true
                     autoStartup: false
                     startupOrder: 123
-                    routePolicy: "myPolicy"
+                    routePolicyRef: "myPolicy"
                     shutdownRoute: "Defer"
                     shutdownRunningTask: "CompleteAllTasks"
                     from:

Reply via email to