Changed the json schema slightly to alwyas include the javaType as well.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/83562e28 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/83562e28 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/83562e28 Branch: refs/heads/master Commit: 83562e28ff354ca6dbe5b2b582e3a5b222dcfe7a Parents: fafd4bb Author: Claus Ibsen <davscl...@apache.org> Authored: Fri Nov 7 10:56:29 2014 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Fri Nov 7 13:25:21 2014 +0100 ---------------------------------------------------------------------- .../camel/component/timer/TimerEndpoint.java | 24 ++++++++++ .../apache/camel/impl/DefaultCamelContext.java | 8 ++++ ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 2 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- ...ponentConfigurationAndDocumentationTest.java | 4 +- .../apache/camel/component/sql/SqlEndpoint.java | 46 ++++++++++++++++++++ ...ponentConfigurationAndDocumentationTest.java | 11 ++++- 19 files changed, 117 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java index bc8f4da..321167e 100644 --- a/camel-core/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java +++ b/camel-core/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java @@ -108,6 +108,9 @@ public class TimerEndpoint extends DefaultEndpoint implements MultipleConsumersS return timerName; } + /** + * The name of the timer + */ @ManagedAttribute(description = "Timer Name") public void setTimerName(String timerName) { this.timerName = timerName; @@ -118,6 +121,11 @@ public class TimerEndpoint extends DefaultEndpoint implements MultipleConsumersS return daemon; } + /** + * Specifies whether or not the thread associated with the timer endpoint runs as a daemon. + * <p/> + * The default value is true. + */ @ManagedAttribute(description = "Timer Daemon") public void setDaemon(boolean daemon) { this.daemon = daemon; @@ -128,6 +136,11 @@ public class TimerEndpoint extends DefaultEndpoint implements MultipleConsumersS return delay; } + /** + * The number of milliseconds to wait before the first event is generated. Should not be used in conjunction with the time option. + * <p/> + * The default value is 1000. + */ @ManagedAttribute(description = "Timer Delay") public void setDelay(long delay) { this.delay = delay; @@ -138,6 +151,9 @@ public class TimerEndpoint extends DefaultEndpoint implements MultipleConsumersS return fixedRate; } + /** + * Events take place at approximately regular intervals, separated by the specified period. + */ @ManagedAttribute(description = "Timer FixedRate") public void setFixedRate(boolean fixedRate) { this.fixedRate = fixedRate; @@ -148,6 +164,11 @@ public class TimerEndpoint extends DefaultEndpoint implements MultipleConsumersS return period; } + /** + * If greater than 0, generate periodic events every period milliseconds. + * <p/> + * The default value is 1000. + */ @ManagedAttribute(description = "Timer Period") public void setPeriod(long period) { this.period = period; @@ -167,6 +188,9 @@ public class TimerEndpoint extends DefaultEndpoint implements MultipleConsumersS return time; } + /** + * A java.util.Date the first event should be generated. If using the URI, the pattern expected is: yyyy-MM-dd HH:mm:ss or yyyy-MM-dd'T'HH:mm:ss. + */ public void setTime(Date time) { this.time = time; } http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java index 567a474..e2d665a 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java +++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java @@ -1137,12 +1137,20 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon if (json == null) { return null; } + List<Map<String, String>> rows = JsonSchemaHelper.parseJsonSchema(json); + // selected rows to use for answer Map<String, String[]> selected = new LinkedHashMap<>(); // insert values from uri Map<String, Object> options = URISupport.parseParameters(u); + + // extract consumer. prefix options + Map<String, Object> consumerOptions = IntrospectionSupport.extractProperties(options, "consumer."); + // and add back again without the consumer. prefix as that json schema omits that + options.putAll(consumerOptions); + for (Map.Entry<String, Object> entry : options.entrySet()) { String name = entry.getKey(); String value = ""; http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/bean/BeanComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/BeanComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/bean/BeanComponentConfigurationAndDocumentationTest.java index ebdc14b..66078fc 100644 --- a/camel-core/src/test/java/org/apache/camel/component/bean/BeanComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/bean/BeanComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class BeanComponentConfigurationAndDocumentationTest extends ContextTestS String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"method\": { \"type\": \"string\" }")); - assertTrue(json.contains("\"cache\": { \"type\": \"boolean\" }")); + assertTrue(json.contains("\"method\": { \"type\": \"string\"")); + assertTrue(json.contains("\"cache\": { \"type\": \"boolean\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/browse/BrowseComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/browse/BrowseComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/browse/BrowseComponentConfigurationAndDocumentationTest.java index 95b085c..13518bf 100644 --- a/camel-core/src/test/java/org/apache/camel/component/browse/BrowseComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/browse/BrowseComponentConfigurationAndDocumentationTest.java @@ -41,7 +41,7 @@ public class BrowseComponentConfigurationAndDocumentationTest extends ContextTes String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"synchronous\": { \"type\": \"boolean\" }")); + assertTrue(json.contains("\"synchronous\": { \"type\": \"boolean\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusComponentConfigurationAndDocumentationTest.java index f4e51db..477debe 100644 --- a/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusComponentConfigurationAndDocumentationTest.java @@ -42,8 +42,8 @@ public class ControlBusComponentConfigurationAndDocumentationTest extends Contex String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"action\": { \"type\": \"string\" }")); - assertTrue(json.contains("\"async\": { \"type\": \"boolean\" }")); + assertTrue(json.contains("\"action\": { \"type\": \"string\"")); + assertTrue(json.contains("\"async\": { \"type\": \"boolean\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatComponentConfigurationAndDocumentationTest.java index 0edc717..25e4f4d 100644 --- a/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/dataformat/DataFormatComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class DataFormatComponentConfigurationAndDocumentationTest extends Contex String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"operation\": { \"type\": \"string\" }")); - assertTrue(json.contains("\"synchronous\": { \"type\": \"boolean\" }")); + assertTrue(json.contains("\"operation\": { \"type\": \"string\"")); + assertTrue(json.contains("\"synchronous\": { \"type\": \"boolean\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetComponentConfigurationAndDocumentationTest.java index a564e58..15d9109 100644 --- a/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class DataSetComponentConfigurationAndDocumentationTest extends ContextTe String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"preloadSize\": { \"type\": \"integer\" }")); - assertTrue(json.contains("\"minRate\": { \"type\": \"integer\" }")); + assertTrue(json.contains("\"preloadSize\": { \"type\": \"integer\"")); + assertTrue(json.contains("\"minRate\": { \"type\": \"integer\"")); assertTrue(json.contains("\"exchangePattern\": { \"type\": \"string\", \"enum\":")); assertTrue(json.contains("\"InOut\"")); } http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/direct/DirectComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/direct/DirectComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/direct/DirectComponentConfigurationAndDocumentationTest.java index 44a1c0c..b17bb5a 100644 --- a/camel-core/src/test/java/org/apache/camel/component/direct/DirectComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/direct/DirectComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class DirectComponentConfigurationAndDocumentationTest extends ContextTes String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"timeout\": { \"type\": \"integer\" }")); - assertTrue(json.contains("\"block\": { \"type\": \"boolean\" }")); + assertTrue(json.contains("\"timeout\": { \"type\": \"integer\"")); + assertTrue(json.contains("\"block\": { \"type\": \"boolean\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmComponentConfigurationAndDocumentationTest.java index 9f18458..cd3f8dc 100644 --- a/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class DirectVmComponentConfigurationAndDocumentationTest extends ContextT String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"timeout\": { \"type\": \"integer\" }")); - assertTrue(json.contains("\"block\": { \"type\": \"boolean\" }")); + assertTrue(json.contains("\"timeout\": { \"type\": \"integer\"")); + assertTrue(json.contains("\"block\": { \"type\": \"boolean\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/file/FileComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileComponentConfigurationAndDocumentationTest.java index 97b75de..93be957 100644 --- a/camel-core/src/test/java/org/apache/camel/component/file/FileComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/file/FileComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class FileComponentConfigurationAndDocumentationTest extends ContextTestS String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"exclude\": { \"type\": \"string\" }")); - assertTrue(json.contains("\"delete\": { \"type\": \"boolean\" }")); + assertTrue(json.contains("\"exclude\": { \"type\": \"string\"")); + assertTrue(json.contains("\"delete\": { \"type\": \"boolean\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/language/LanguageComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/language/LanguageComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/language/LanguageComponentConfigurationAndDocumentationTest.java index 058d8c2..d19de92 100644 --- a/camel-core/src/test/java/org/apache/camel/component/language/LanguageComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/language/LanguageComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class LanguageComponentConfigurationAndDocumentationTest extends ContextT String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"script\": { \"type\": \"string\" }")); - assertTrue(json.contains("\"cacheScript\": { \"type\": \"boolean\" }")); + assertTrue(json.contains("\"script\": { \"type\": \"string\"")); + assertTrue(json.contains("\"cacheScript\": { \"type\": \"boolean\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/log/LogComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/log/LogComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/log/LogComponentConfigurationAndDocumentationTest.java index 18cdbdb..3ff8029 100644 --- a/camel-core/src/test/java/org/apache/camel/component/log/LogComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/log/LogComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class LogComponentConfigurationAndDocumentationTest extends ContextTestSu String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"level\": { \"type\": \"string\" }")); - assertTrue(json.contains("\"groupInterval\": { \"type\": \"integer\" }")); + assertTrue(json.contains("\"level\": { \"type\": \"string\"")); + assertTrue(json.contains("\"groupInterval\": { \"type\": \"integer\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/mock/MockComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/mock/MockComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/mock/MockComponentConfigurationAndDocumentationTest.java index e389256..9f0d2b7 100644 --- a/camel-core/src/test/java/org/apache/camel/component/mock/MockComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/mock/MockComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class MockComponentConfigurationAndDocumentationTest extends ContextTestS String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"expectedCount\": { \"type\": \"integer\" }")); - assertTrue(json.contains("\"retainFirst\": { \"type\": \"integer\" }")); + assertTrue(json.contains("\"expectedCount\": { \"type\": \"integer\"")); + assertTrue(json.contains("\"retainFirst\": { \"type\": \"integer\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/seda/SedaComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/seda/SedaComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/seda/SedaComponentConfigurationAndDocumentationTest.java index 14f11c4..ea4c2ff 100644 --- a/camel-core/src/test/java/org/apache/camel/component/seda/SedaComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/seda/SedaComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class SedaComponentConfigurationAndDocumentationTest extends ContextTestS String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"timeout\": { \"type\": \"integer\" }")); - assertTrue(json.contains("\"blockWhenFull\": { \"type\": \"boolean\" }")); + assertTrue(json.contains("\"timeout\": { \"type\": \"integer\"")); + assertTrue(json.contains("\"blockWhenFull\": { \"type\": \"boolean\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/test/TestComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/test/TestComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/test/TestComponentConfigurationAndDocumentationTest.java index b4e9b30..55544ba 100644 --- a/camel-core/src/test/java/org/apache/camel/component/test/TestComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/test/TestComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class TestComponentConfigurationAndDocumentationTest extends ContextTestS String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"retainFirst\": { \"type\": \"integer\" }")); - assertTrue(json.contains("\"timeout\": { \"type\": \"integer\" }")); + assertTrue(json.contains("\"retainFirst\": { \"type\": \"integer\"")); + assertTrue(json.contains("\"timeout\": { \"type\": \"integer\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/timer/TimerComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/timer/TimerComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/timer/TimerComponentConfigurationAndDocumentationTest.java index 3ef8c45..ab41177 100644 --- a/camel-core/src/test/java/org/apache/camel/component/timer/TimerComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/timer/TimerComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class TimerComponentConfigurationAndDocumentationTest extends ContextTest String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"timerName\": { \"type\": \"string\" }")); - assertTrue(json.contains("\"delay\": { \"type\": \"integer\" }")); + assertTrue(json.contains("\"timerName\": { \"type\": \"string\"")); + assertTrue(json.contains("\"delay\": { \"type\": \"integer\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/camel-core/src/test/java/org/apache/camel/component/xslt/XsltComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/xslt/XsltComponentConfigurationAndDocumentationTest.java b/camel-core/src/test/java/org/apache/camel/component/xslt/XsltComponentConfigurationAndDocumentationTest.java index 2c442e7..4de8f63 100644 --- a/camel-core/src/test/java/org/apache/camel/component/xslt/XsltComponentConfigurationAndDocumentationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/xslt/XsltComponentConfigurationAndDocumentationTest.java @@ -41,8 +41,8 @@ public class XsltComponentConfigurationAndDocumentationTest extends ContextTestS String json = compConf.createParameterJsonSchema(); assertNotNull(json); - assertTrue(json.contains("\"resourceUri\": { \"type\": \"string\" }")); - assertTrue(json.contains("\"synchronous\": { \"type\": \"boolean\" }")); + assertTrue(json.contains("\"resourceUri\": { \"type\": \"string\"")); + assertTrue(json.contains("\"synchronous\": { \"type\": \"boolean\"")); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlEndpoint.java b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlEndpoint.java index 2df9f23..9e0df84 100644 --- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlEndpoint.java +++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlEndpoint.java @@ -154,6 +154,9 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return processingStrategy; } + /** + * Allows to plugin to use a custom org.apache.camel.component.sql.SqlProcessingStrategy to execute queries when the consumer has processed the rows/batch. + */ public void setProcessingStrategy(SqlProcessingStrategy processingStrategy) { this.processingStrategy = processingStrategy; } @@ -162,6 +165,9 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return prepareStatementStrategy; } + /** + * Allows to plugin to use a custom org.apache.camel.component.sql.SqlPrepareStatementStrategy to control preparation of the query and prepared statement. + */ public void setPrepareStatementStrategy(SqlPrepareStatementStrategy prepareStatementStrategy) { this.prepareStatementStrategy = prepareStatementStrategy; } @@ -170,6 +176,9 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return onConsume; } + /** + * After processing each row then this query can be executed, if the Exchange was processed successfully, for example to mark the row as processed. The query can have parameter. + */ public void setOnConsume(String onConsume) { this.onConsume = onConsume; } @@ -178,6 +187,9 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return onConsumeFailed; } + /** + * After processing each row then this query can be executed, if the Exchange failed, for example to mark the row as failed. The query can have parameter. + */ public void setOnConsumeFailed(String onConsumeFailed) { this.onConsumeFailed = onConsumeFailed; } @@ -186,6 +198,9 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return onConsumeBatchComplete; } + /** + * After processing the entire batch, this query can be executed to bulk update rows etc. The query cannot have parameters. + */ public void setOnConsumeBatchComplete(String onConsumeBatchComplete) { this.onConsumeBatchComplete = onConsumeBatchComplete; } @@ -194,6 +209,9 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return allowNamedParameters; } + /** + * Whether to allow using named parameters in the queries. + */ public void setAllowNamedParameters(boolean allowNamedParameters) { this.allowNamedParameters = allowNamedParameters; } @@ -202,6 +220,11 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return alwaysPopulateStatement; } + /** + * If enabled then the populateStatement method from org.apache.camel.component.sql.SqlPrepareStatementStrategy is always invoked, + * also if there is no expected parameters to be prepared. When this is false then the populateStatement is only invoked if there + * is 1 or more expected parameters to be set; for example this avoids reading the message body/headers for SQL queries with no parameters. + */ public void setAlwaysPopulateStatement(boolean alwaysPopulateStatement) { this.alwaysPopulateStatement = alwaysPopulateStatement; } @@ -210,6 +233,12 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return separator; } + /** + * The separator to use when parameter values is taken from message body (if the body is a String type), to be inserted at # placeholders. + * Notice if you use named parameters, then a Map type is used instead. + * <p/> + * The default value is , + */ public void setSeparator(char separator) { this.separator = separator; } @@ -218,6 +247,13 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return outputType; } + /** + * Make the output of consumer or producer to SelectList as List of Map, or SelectOne as single Java object in the following way: + * a) If the query has only single column, then that JDBC Column object is returned. (such as SELECT COUNT( * ) FROM PROJECT will return a Long object. + * b) If the query has more than one column, then it will return a Map of that result. + * c) If the outputClass is set, then it will convert the query result into an Java bean object by calling all the setters that match the column names. It will assume your class has a default constructor to create instance with. + * d) If the query resulted in more than one rows, it throws an non-unique result exception. + */ public void setOutputType(SqlOutputType outputType) { this.outputType = outputType; } @@ -226,6 +262,9 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return outputClass; } + /** + * Specify the full package and class name to use as conversion when outputType=SelectOne. + */ public void setOutputClass(String outputClass) { this.outputClass = outputClass; } @@ -234,6 +273,10 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return parametersCount; } + /** + * If set greater than zero, then Camel will use this count value of parameters to replace instead of querying via JDBC metadata API. + * This is useful if the JDBC vendor could not return correct parameters count, then user may override instead. + */ public void setParametersCount(int parametersCount) { this.parametersCount = parametersCount; } @@ -242,6 +285,9 @@ public class SqlEndpoint extends DefaultPollingEndpoint { return noop; } + /** + * If set, will ignore the results of the SQL query and use the existing IN message as the OUT message for the continuation of processing + */ public void setNoop(boolean noop) { this.noop = noop; } http://git-wip-us.apache.org/repos/asf/camel/blob/83562e28/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlComponentConfigurationAndDocumentationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlComponentConfigurationAndDocumentationTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlComponentConfigurationAndDocumentationTest.java index 7f8714d..3ac52d5 100644 --- a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlComponentConfigurationAndDocumentationTest.java +++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlComponentConfigurationAndDocumentationTest.java @@ -33,7 +33,7 @@ public class SqlComponentConfigurationAndDocumentationTest extends CamelTestSupp @Test public void testComponentConfiguration() throws Exception { SqlComponent comp = context.getComponent("sql", SqlComponent.class); - EndpointConfiguration conf = comp.createConfiguration("sql:select?dataSourceRef=jdbc/myDataSource&allowNamedParameters=true"); + EndpointConfiguration conf = comp.createConfiguration("sql:select?dataSourceRef=jdbc/myDataSource&allowNamedParameters=true&consumer.delay=5000"); assertEquals("jdbc/myDataSource", conf.getParameter("dataSourceRef")); assertEquals("true", conf.getParameter("allowNamedParameters")); @@ -42,9 +42,18 @@ public class SqlComponentConfigurationAndDocumentationTest extends CamelTestSupp String json = compConf.createParameterJsonSchema(); assertNotNull(json); + assertTrue(json.contains("\"onConsumeBatchComplete\": { \"type\": \"string\"")); + assertTrue(json.contains("\"parametersCount\": { \"type\": \"integer\"")); + } + + @Test + public void testExplainEndpoint() throws Exception { + String json = context.explainEndpointJson("sql:select?dataSourceRef=jdbc/myDataSource&allowNamedParameters=true&consumer.onConsume=foo", true); + assertNotNull(json); assertTrue(json.contains("\"onConsumeBatchComplete\": { \"type\": \"string\"")); assertTrue(json.contains("\"parametersCount\": { \"type\": \"integer\"")); + assertTrue(json.contains(" \"onConsume\": { \"type\": \"string\", \"javaType\": \"java.lang.String\", \"value\": \"foo\"")); } @Test