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

davsclaus pushed a commit to branch route-eh-xml
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 88813a5bd0b5f41dfdc0bd20f84748a5125339c6
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Apr 13 11:57:34 2024 +0200

    CAMEL-20665: YAML DSL Inconsistency - StreamCaching vs streamCache. Also 
mark some DSL in Java DSL as deprecated to make the DSLs consistent so Java DSL 
does not have special options.
---
 .../org/apache/camel/model/RouteDefinition.java    | 54 ++++++++++++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_6.adoc     | 30 +++++++++++-
 .../deserializers/RouteDefinitionDeserializer.java | 11 ++++-
 .../generated/resources/schema/camelYamlDsl.json   |  2 +-
 .../apache/camel/dsl/yaml/PipeLoaderTest.groovy    |  2 +-
 .../apache/camel/dsl/yaml/RouteTemplateTest.groovy |  2 +-
 .../org/apache/camel/dsl/yaml/RoutesTest.groovy    |  6 +--
 .../kamelets/route-timer-source.kamelet.yaml       |  2 +-
 8 files changed, 100 insertions(+), 9 deletions(-)

diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java
index 9941dd27a3b..3e0e103e449 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java
@@ -328,6 +328,7 @@ public class RouteDefinition extends 
OutputDefinition<RouteDefinition>
      *
      * @return the builder
      */
+    @Deprecated
     public RouteDefinition noStreamCaching() {
         setStreamCache("false");
         return this;
@@ -338,6 +339,7 @@ public class RouteDefinition extends 
OutputDefinition<RouteDefinition>
      *
      * @return the builder
      */
+    @Deprecated
     public RouteDefinition streamCaching() {
         setStreamCache("true");
         return this;
@@ -348,17 +350,31 @@ public class RouteDefinition extends 
OutputDefinition<RouteDefinition>
      *
      * @param  streamCache whether to use stream caching (true or false), the 
value can be a property placeholder
      * @return             the builder
+     * @deprecated use {@link #streamCache(String)}
      */
+    @Deprecated
     public RouteDefinition streamCaching(String streamCache) {
         setStreamCache(streamCache);
         return this;
     }
 
+    /**
+     * Enable or disables stream caching for this route.
+     *
+     * @param  streamCache whether to use stream caching (true or false), the 
value can be a property placeholder
+     * @return             the builder
+     */
+    public RouteDefinition streamCache(String streamCache) {
+        setStreamCache(streamCache);
+        return this;
+    }
+
     /**
      * Disable tracing for this route.
      *
      * @return the builder
      */
+    @Deprecated
     public RouteDefinition noTracing() {
         setTrace("false");
         return this;
@@ -369,6 +385,7 @@ public class RouteDefinition extends 
OutputDefinition<RouteDefinition>
      *
      * @return the builder
      */
+    @Deprecated
     public RouteDefinition tracing() {
         setTrace("true");
         return this;
@@ -380,11 +397,34 @@ public class RouteDefinition extends 
OutputDefinition<RouteDefinition>
      * @param  tracing whether to use tracing (true or false), the value can 
be a property placeholder
      * @return         the builder
      */
+    @Deprecated
     public RouteDefinition tracing(String tracing) {
         setTrace(tracing);
         return this;
     }
 
+    /**
+     * Enables or disables tracing for this route.
+     *
+     * @param  trace   whether to use tracing (true or false)
+     * @return         the builder
+     */
+    public RouteDefinition trace(boolean trace) {
+        setTrace(Boolean.toString(trace));
+        return this;
+    }
+
+    /**
+     * Enables or disables tracing for this route.
+     *
+     * @param  trace   whether to use tracing (true or false), the value can 
be a property placeholder
+     * @return         the builder
+     */
+    public RouteDefinition trace(String trace) {
+        setTrace(trace);
+        return this;
+    }
+
     /**
      * Enable message history for this route.
      *
@@ -395,6 +435,17 @@ public class RouteDefinition extends 
OutputDefinition<RouteDefinition>
         return this;
     }
 
+    /**
+     * Enable message history for this route.
+     *
+     * @param  messageHistory whether to use message history (true or false)
+     * @return                the builder
+     */
+    public RouteDefinition messageHistory(boolean messageHistory) {
+        setMessageHistory(Boolean.toString(messageHistory));
+        return this;
+    }
+
     /**
      * Enable message history for this route.
      *
@@ -433,6 +484,7 @@ public class RouteDefinition extends 
OutputDefinition<RouteDefinition>
      *
      * @return the builder
      */
+    @Deprecated
     public RouteDefinition noMessageHistory() {
         setMessageHistory("false");
         return this;
@@ -443,6 +495,7 @@ public class RouteDefinition extends 
OutputDefinition<RouteDefinition>
      *
      * @return the builder
      */
+    @Deprecated
     public RouteDefinition noDelayer() {
         setDelayer("0");
         return this;
@@ -490,6 +543,7 @@ public class RouteDefinition extends 
OutputDefinition<RouteDefinition>
      *
      * @return the builder
      */
+    @Deprecated
     public RouteDefinition noAutoStartup() {
         setAutoStartup("false");
         return this;
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_6.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_6.adoc
index 258d52658e5..43f80e2c33d 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_6.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_6.adoc
@@ -65,4 +65,32 @@ instead of `org.apache.camel.Consumer`.
 
 === camel-kafka
 
-The Kafka component now supports custom subscription adapters for applications 
with very complex subscription logic.
\ No newline at end of file
+The Kafka component now supports custom subscription adapters for applications 
with very complex subscription logic.
+
+=== camel-yaml-dsl
+
+Renamed `streamCaching` to `streamCache` on the `route`
+
+Before:
+
+[source,yaml]
+----
+route:
+  streamCaching: false
+  from:
+    uri: "direct:foo"
+    steps:
+      - to: "mock:bar"
+----
+
+After:
+
+[source,yaml]
+----
+route:
+  streamCache: false
+  from:
+    uri: "direct:foo"
+    steps:
+      - to: "mock:bar"
+----
\ No newline at end of file
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 413065acf39..e87622c7732 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
@@ -28,6 +28,8 @@ import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.spi.annotations.YamlIn;
 import org.apache.camel.spi.annotations.YamlProperty;
 import org.apache.camel.spi.annotations.YamlType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.snakeyaml.engine.v2.nodes.MappingNode;
 import org.snakeyaml.engine.v2.nodes.Node;
 import org.snakeyaml.engine.v2.nodes.NodeTuple;
@@ -47,7 +49,7 @@ import org.snakeyaml.engine.v2.nodes.NodeTuple;
                   @YamlProperty(name = "autoStartup", type = "boolean"),
                   @YamlProperty(name = "routePolicy", type = "string"),
                   @YamlProperty(name = "startupOrder", type = "number"),
-                  @YamlProperty(name = "streamCaching", type = "boolean"),
+                  @YamlProperty(name = "streamCache", type = "boolean"),
                   @YamlProperty(name = "messageHistory", type = "boolean"),
                   @YamlProperty(name = "logMask", type = "boolean"),
                   @YamlProperty(name = "trace", type = "boolean"),
@@ -65,6 +67,8 @@ import org.snakeyaml.engine.v2.nodes.NodeTuple;
           })
 public class RouteDefinitionDeserializer extends 
YamlDeserializerBase<RouteDefinition> {
 
+    private static final Logger LOG = 
LoggerFactory.getLogger(RouteDefinitionDeserializer.class);
+
     public RouteDefinitionDeserializer() {
         super(RouteDefinition.class);
     }
@@ -114,6 +118,11 @@ public class RouteDefinitionDeserializer extends 
YamlDeserializerBase<RouteDefin
                     target.setStartupOrder(asInt(val));
                     break;
                 case "streamCaching":
+                    // backwards compatible
+                    LOG.warn("Old option name detected! Option streamCaching 
should be renamed to streamCache");
+                    target.setStreamCache(asText(val));
+                    break;
+                case "streamCache":
                     target.setStreamCache(asText(val));
                     break;
                 case "logMask":
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 ab523aadfc5..158aa6eac22 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
@@ -5243,7 +5243,7 @@
           "startupOrder" : {
             "type" : "number"
           },
-          "streamCaching" : {
+          "streamCache" : {
             "type" : "boolean"
           },
           "trace" : {
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/PipeLoaderTest.groovy
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/PipeLoaderTest.groovy
index 858b8df4f72..767f788885c 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/PipeLoaderTest.groovy
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/PipeLoaderTest.groovy
@@ -705,7 +705,7 @@ class PipeLoaderTest extends YamlTestSupport {
 
         with (context.routeDefinitions[1]) {
             template == true
-            // stream-caching is disabled in the kamelet
+            // stream-cache is disabled in the kamelet
             streamCache == "false"
             messageHistory == "true"
         }
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RouteTemplateTest.groovy
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RouteTemplateTest.groovy
index 4efb3fcef9c..907d2ae049b 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RouteTemplateTest.groovy
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RouteTemplateTest.groovy
@@ -416,7 +416,7 @@ class RouteTemplateTest extends YamlTestSupport {
                       - name: "foo"
                       - name: "bar"
                     route:
-                      streamCaching: false
+                      streamCache: false
                       messageHistory: true
                       logMask: true
                       from:
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 ee19ea61da6..f3970c28742 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
@@ -283,7 +283,7 @@ class RoutesTest extends YamlTestSupport {
         loadRoutes '''
                 - route:
                     id: demo-route
-                    streamCaching: true
+                    streamCache: true
                     autoStartup: false
                     startupOrder: 123
                     routePolicy: "myPolicy"
@@ -427,12 +427,12 @@ class RoutesTest extends YamlTestSupport {
         Assertions.assertEquals(2, 
context.getRoute("bar").filter("bbb*").size());
     }
 
-    def "Error: kebab-case: stream-cacing"() {
+    def "Error: kebab-case: stream-cache"() {
         when:
         var route = '''
                 - route:
                     id: demo-route
-                    stream-caching: true
+                    stream-cache: true
                     auto-startup: false
                     startup-order: 123
                     route-policy: "myPolicy"
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/resources/kamelets/route-timer-source.kamelet.yaml
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/resources/kamelets/route-timer-source.kamelet.yaml
index 0608d771e6d..6fc6fd0cd3d 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/resources/kamelets/route-timer-source.kamelet.yaml
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/resources/kamelets/route-timer-source.kamelet.yaml
@@ -57,7 +57,7 @@ spec:
     - "camel:kamelet"
   template:
     route:
-      stream-caching: false
+      stream-cache: false
       message-history: true
       from:
         uri: timer:tick

Reply via email to