You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2023/04/07 13:48:59 UTC

[camel-quarkus] branch 4749/templated-route-support created (now 7c9a956ba1)

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

nfilotto pushed a change to branch 4749/templated-route-support
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


      at 7c9a956ba1 Ref #4749 - java-joor-dsl - Add templated route support to native mode

This branch includes the following new commits:

     new 7c9a956ba1 Ref #4749 - java-joor-dsl - Add templated route support to native mode

The 1 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.



[camel-quarkus] 01/01: Ref #4749 - java-joor-dsl - Add templated route support to native mode

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch 4749/templated-route-support
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 7c9a956ba1911a07b8f227c04290a0b8fc95405c
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Apr 7 15:48:05 2023 +0200

    Ref #4749 - java-joor-dsl - Add templated route support to native mode
---
 .../dsl/java/joor/runtime/JavaJoorDslRecorder.java |  1 +
 .../resources/routes/MyRoutesWithTemplate.java     | 27 +++++++++++++++++++
 .../src/main/resources/routes/MyTemplate.java      | 30 ++++++++++++++++++++++
 .../quarkus/dsl/java/joor/JavaJoorDslTest.java     |  4 +--
 4 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/extensions/java-joor-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/java/joor/runtime/JavaJoorDslRecorder.java b/extensions/java-joor-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/java/joor/runtime/JavaJoorDslRecorder.java
index 246627e7d6..f914bc9d84 100644
--- a/extensions/java-joor-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/java/joor/runtime/JavaJoorDslRecorder.java
+++ b/extensions/java-joor-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/java/joor/runtime/JavaJoorDslRecorder.java
@@ -50,6 +50,7 @@ public class JavaJoorDslRecorder {
                     CamelContextAware.trySetCamelContext(obj, context.getValue());
                     ResourceAware.trySetResource(obj, ResourceHelper.fromString(location, ""));
                     context.getValue().addRoutes(builder);
+                    context.getValue().addTemplatedRoutes(builder);
                 } else {
                     LOG.warn("Ignoring the class {} as it is not of type RoutesBuilder", className);
                 }
diff --git a/integration-tests/java-joor-dsl/src/main/resources/routes/MyRoutesWithTemplate.java b/integration-tests/java-joor-dsl/src/main/resources/routes/MyRoutesWithTemplate.java
new file mode 100644
index 0000000000..4b836f0190
--- /dev/null
+++ b/integration-tests/java-joor-dsl/src/main/resources/routes/MyRoutesWithTemplate.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyRoutesWithTemplate extends RouteBuilder {
+    @Override
+    public void configure() throws Exception {
+        templatedRoute("someTemplate")
+                .routeId("routes-with-template")
+                .parameter("id", "routes-with-template")
+                .parameter("body", "Hi PK");
+    }
+}
diff --git a/integration-tests/java-joor-dsl/src/main/resources/routes/MyTemplate.java b/integration-tests/java-joor-dsl/src/main/resources/routes/MyTemplate.java
new file mode 100644
index 0000000000..0e4fe84f66
--- /dev/null
+++ b/integration-tests/java-joor-dsl/src/main/resources/routes/MyTemplate.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyTemplate extends RouteBuilder {
+    @Override
+    public void configure() throws Exception {
+        routeTemplate("someTemplate")
+                .templateParameter("id")
+                .templateParameter("body")
+                .route()
+                .from("direct:{{id}}")
+                .setBody().constant("{{body}}")
+                .setBody().simple("${body.endsWith('PK')}");
+    }
+}
diff --git a/integration-tests/java-joor-dsl/src/test/java/org/apache/camel/quarkus/dsl/java/joor/JavaJoorDslTest.java b/integration-tests/java-joor-dsl/src/test/java/org/apache/camel/quarkus/dsl/java/joor/JavaJoorDslTest.java
index 38998a3cb5..767196aeaf 100644
--- a/integration-tests/java-joor-dsl/src/test/java/org/apache/camel/quarkus/dsl/java/joor/JavaJoorDslTest.java
+++ b/integration-tests/java-joor-dsl/src/test/java/org/apache/camel/quarkus/dsl/java/joor/JavaJoorDslTest.java
@@ -76,13 +76,13 @@ class JavaJoorDslTest {
                 .then()
                 .statusCode(200)
                 .body(CoreMatchers.is(
-                        "inner-classes-route,my-java-route,reflection-route,routes-with-bean,routes-with-inner-bean,routes-with-nested-class,routes-with-rest,routes-with-rest-get"));
+                        "inner-classes-route,my-java-route,reflection-route,routes-with-bean,routes-with-inner-bean,routes-with-nested-class,routes-with-rest,routes-with-rest-get,routes-with-template"));
 
         RestAssured.given()
                 .get("/java-joor-dsl/main/successful/routes")
                 .then()
                 .statusCode(200)
-                .body(CoreMatchers.is("3"));
+                .body(CoreMatchers.is("4"));
     }
 
     @Test