You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/04/29 10:06:48 UTC

[camel] branch master updated: Lets make camel-jooq syntax more tooling friendly

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

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 6408205  Lets make camel-jooq syntax more tooling friendly
6408205 is described below

commit 640820556a0ff4158291f4f68347d62c176e2a34
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Apr 29 12:06:36 2019 +0200

    Lets make camel-jooq syntax more tooling friendly
---
 .../camel-jooq/src/main/docs/jooq-component.adoc     | 20 ++++++++++++++++----
 .../camel/component/jooq/JooqConfiguration.java      |  6 +++---
 .../apache/camel/component/jooq/JooqEndpoint.java    |  2 +-
 .../camel/component/jooq/JooqComponentTest.java      |  6 +++---
 .../camel/component/jooq/JooqPlainSQLTest.java       |  6 +++---
 .../camel/component/jooq/JooqProducerTest.java       |  6 +++---
 .../camel-jooq/src/test/resources/camel-context.xml  |  8 ++++----
 components/readme.adoc                               |  2 +-
 .../main/resources/META-INF/spring/camel-context.xml |  2 +-
 9 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/components/camel-jooq/src/main/docs/jooq-component.adoc b/components/camel-jooq/src/main/docs/jooq-component.adoc
index 8a64ec0..f3a5ba4 100644
--- a/components/camel-jooq/src/main/docs/jooq-component.adoc
+++ b/components/camel-jooq/src/main/docs/jooq-component.adoc
@@ -57,23 +57,22 @@ The JOOQ component supports 2 options, which are listed below.
 The JOOQ endpoint is configured using URI syntax:
 
 ----
-jooq:entityType/operation
+jooq:entityType
 ----
 
 with the following path and query parameters:
 
-==== Path Parameters (2 parameters):
+==== Path Parameters (1 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
 | *entityType* | JOOQ entity class |  | Class
-| *operation* | Type of operation to execute on query | NONE | JooqOperation
 |===
 
 
-==== Query Parameters (21 parameters):
+==== Query Parameters (22 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -85,6 +84,7 @@ with the following path and query parameters:
 | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
 | *pollStrategy* (consumer) | A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel. |  | PollingConsumerPoll Strategy
+| *operation* (producer) | Type of operation to execute on query | NONE | JooqOperation
 | *query* (producer) | To execute plain SQL query |  | String
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
 | *backoffErrorThreshold* (scheduler) | The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in. |  | int
@@ -136,6 +136,18 @@ The component supports 7 options, which are listed below.
 |===
 // spring-boot-auto-configure options: END
 
+==== Operations
+
+When using jooq as a producer you can use any of the following `JooqOperation` operations:
+
+[width="100%",cols="1,2",options="header"]
+|===
+| Operation | Description
+| none | Execute a query (default)
+| execute | Execute a query with no expected results
+| fetch | Execute a query and the result of the query is stored as the new message body
+|===
+
 ==== Example:
 JOOQ configuration:
 
diff --git a/components/camel-jooq/src/main/java/org/apache/camel/component/jooq/JooqConfiguration.java b/components/camel-jooq/src/main/java/org/apache/camel/component/jooq/JooqConfiguration.java
index 8e0cda8..1ae55df 100644
--- a/components/camel-jooq/src/main/java/org/apache/camel/component/jooq/JooqConfiguration.java
+++ b/components/camel-jooq/src/main/java/org/apache/camel/component/jooq/JooqConfiguration.java
@@ -28,12 +28,12 @@ public class JooqConfiguration implements Cloneable {
     @UriPath(label = "common", description = "JOOQ entity class")
     private Class<?> entityType;
 
+    @UriParam(label = "producer", description = "Type of operation to execute on query", defaultValue = "NONE")
+    private JooqOperation operation = JooqOperation.NONE;
+
     @UriParam(label = "consumer", defaultValue = "true", description = "Delete entity after it is consumed")
     private boolean consumeDelete = true;
 
-    @UriPath(label = "producer", description = "Type of operation to execute on query", defaultValue = "NONE")
-    private JooqOperation operation = JooqOperation.NONE;
-
     @UriParam(label = "producer", description = "To execute plain SQL query")
     private String query;
 
diff --git a/components/camel-jooq/src/main/java/org/apache/camel/component/jooq/JooqEndpoint.java b/components/camel-jooq/src/main/java/org/apache/camel/component/jooq/JooqEndpoint.java
index 810a655..1cfe595 100644
--- a/components/camel-jooq/src/main/java/org/apache/camel/component/jooq/JooqEndpoint.java
+++ b/components/camel-jooq/src/main/java/org/apache/camel/component/jooq/JooqEndpoint.java
@@ -29,7 +29,7 @@ import org.apache.camel.support.ScheduledPollEndpoint;
 import org.jooq.Query;
 import org.jooq.ResultQuery;
 
-@UriEndpoint(firstVersion = "3.0.0", scheme = "jooq", syntax = "jooq:entityType/operation", title = "JOOQ", label = "database")
+@UriEndpoint(firstVersion = "3.0.0", scheme = "jooq", syntax = "jooq:entityType", title = "JOOQ", label = "database")
 public class JooqEndpoint extends ScheduledPollEndpoint {
 
     private Expression producerExpression;
diff --git a/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqComponentTest.java b/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqComponentTest.java
index 2dfbba4..8055315 100644
--- a/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqComponentTest.java
+++ b/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqComponentTest.java
@@ -29,11 +29,11 @@ public class JooqComponentTest extends BaseJooqTest {
         assertEquals(JooqOperation.NONE, ep1.getConfiguration().getOperation());
         assertEquals(BookStoreRecord.class, ep1.getConfiguration().getEntityType());
 
-        JooqEndpoint ep2 = (JooqEndpoint) component.createEndpoint("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/execute");
+        JooqEndpoint ep2 = (JooqEndpoint) component.createEndpoint("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=execute");
         assertEquals(JooqOperation.EXECUTE, ep2.getConfiguration().getOperation());
         assertEquals(BookStoreRecord.class, ep2.getConfiguration().getEntityType());
 
-        JooqEndpoint ep3 = (JooqEndpoint) component.createEndpoint("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/fetch");
+        JooqEndpoint ep3 = (JooqEndpoint) component.createEndpoint("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=fetch");
         assertEquals(JooqOperation.FETCH, ep3.getConfiguration().getOperation());
         assertEquals(BookStoreRecord.class, ep3.getConfiguration().getEntityType());
     }
@@ -41,6 +41,6 @@ public class JooqComponentTest extends BaseJooqTest {
     @Test(expected = TypeConversionException.class)
     public void testNonDefaultConfig() throws Exception {
         JooqComponent component = (JooqComponent) context().getComponent("jooq");
-        component.createEndpoint("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/unexpectedOperation");
+        component.createEndpoint("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=unexpectedOperation");
     }
 }
diff --git a/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqPlainSQLTest.java b/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqPlainSQLTest.java
index b4f0564..2908902 100644
--- a/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqPlainSQLTest.java
+++ b/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqPlainSQLTest.java
@@ -57,7 +57,7 @@ public class JooqPlainSQLTest extends BaseJooqTest {
 
         // Delete
         actual = (Result) producerTemplate.sendBody(context.getEndpoint("direct:deleteSQL"), ExchangePattern.InOut, null);
-        Assert.assertEquals(null, actual);
+        Assert.assertNull(actual);
 
         // Select
         actual = (Result) producerTemplate.sendBody(context.getEndpoint("direct:selectSQL"), ExchangePattern.InOut, null);
@@ -80,11 +80,11 @@ public class JooqPlainSQLTest extends BaseJooqTest {
 
                 // Producer SQL query select
                 from("direct:selectSQL")
-                        .to("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/fetch?query=select * from book_store x where x.name = 'test'");
+                        .to("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=fetch&query=select * from book_store x where x.name = 'test'");
 
                 // Producer SQL query delete
                 from("direct:deleteSQL")
-                        .to("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/execute?query=delete from book_store x where x.name = 'test'");
+                        .to("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=execute&query=delete from book_store x where x.name = 'test'");
 
                 // Consumer SQL query
                 from("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?query=select * from book_store x where x.name = 'test'&initialDelay=0&delay=100")
diff --git a/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqProducerTest.java b/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqProducerTest.java
index 09033dc..76ab63f 100644
--- a/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqProducerTest.java
+++ b/components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqProducerTest.java
@@ -74,13 +74,13 @@ public class JooqProducerTest extends BaseJooqTest {
                         .to("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord");
 
                 from("direct:update")
-                        .to("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/execute");
+                        .to("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=execute");
 
                 from("direct:delete")
-                        .to("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/execute");
+                        .to("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=execute");
 
                 from("direct:select")
-                        .to("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/fetch");
+                        .to("jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=fetch");
             }
         };
     }
diff --git a/components/camel-jooq/src/test/resources/camel-context.xml b/components/camel-jooq/src/test/resources/camel-context.xml
index 8138361..5f7a313 100644
--- a/components/camel-jooq/src/test/resources/camel-context.xml
+++ b/components/camel-jooq/src/test/resources/camel-context.xml
@@ -51,7 +51,7 @@
             <transform>
                 <method ref="bookStoreBean" method="select"/>
             </transform>
-            <to uri="jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/fetch"/>
+            <to uri="jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=fetch"/>
             <log message="Fetched ${body}"/>
         </route>
 
@@ -61,7 +61,7 @@
             <transform>
                 <method ref="bookStoreBean" method="delete"/>
             </transform>
-            <to uri="jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/execute"/>
+            <to uri="jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=execute"/>
             <log message="Executed ${body}"/>
         </route>
 
@@ -74,14 +74,14 @@
         <!-- SQL: select -->
         <route id="sql-select">
             <from uri="direct:sql-select"/>
-            <to uri="jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/fetch?query=select * from book_store x where x.name = 'test'"/>
+            <to uri="jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=fetch&amp;query=select * from book_store x where x.name = 'test'"/>
             <log message="Fetched ${body}"/>
         </route>
 
         <!-- SQL: delete -->
         <route id="sql-delete">
             <from uri="direct:sql-delete"/>
-            <to uri="jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord/execute?query=delete from book_store x where x.name = 'test'"/>
+            <to uri="jooq://org.apache.camel.component.jooq.db.tables.records.BookStoreRecord?operation=execute&amp;query=delete from book_store x where x.name = 'test'"/>
             <log message="Fetched ${body}"/>
         </route>
 
diff --git a/components/readme.adoc b/components/readme.adoc
index 64ca5f3..65d48c8 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -473,7 +473,7 @@ Number of Components: 294 in 231 JAR artifacts (0 deprecated)
 `jolt:resourceUri` | 2.16 | The jolt component allows you to process a JSON messages using an JOLT specification (such as JSON-JSON transformation).
 
 | link:camel-jooq/src/main/docs/jooq-component.adoc[JOOQ] (camel-jooq) +
-`jooq:entityType/operation` | 3.0 | The jooq component enables you to store and retrieve entities from databases using JOOQ
+`jooq:entityType` | 3.0 | The jooq component enables you to store and retrieve entities from databases using JOOQ
 
 | link:camel-jpa/src/main/docs/jpa-component.adoc[JPA] (camel-jpa) +
 `jpa:entityType` | 1.0 | The jpa component enables you to store and retrieve Java objects from databases using JPA.
diff --git a/examples/camel-example-jooq/src/main/resources/META-INF/spring/camel-context.xml b/examples/camel-example-jooq/src/main/resources/META-INF/spring/camel-context.xml
index 38637c0..065c0c8 100644
--- a/examples/camel-example-jooq/src/main/resources/META-INF/spring/camel-context.xml
+++ b/examples/camel-example-jooq/src/main/resources/META-INF/spring/camel-context.xml
@@ -52,7 +52,7 @@
             <transform>
                 <method ref="book-store" method="select"/>
             </transform>
-            <to uri="jooq://org.apache.camel.examples.jooq.db.tables.records.BookStoreRecord/fetch"/>
+            <to uri="jooq://org.apache.camel.examples.jooq.db.tables.records.BookStoreRecord?operation=fetch"/>
             <log message="Selected: ${body}"/>
         </route>