camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/7] camel git commit: CAMEL-9470: Component docs - Some options support using an optional prefix such as consumer.
Date Sun, 03 Jan 2016 16:56:23 GMT
CAMEL-9470: Component docs - Some options support using an optional prefix such as consumer.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/45439600
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/45439600
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/45439600

Branch: refs/heads/camel-2.16.x
Commit: 45439600f960b80daa71b57665428364c00cb474
Parents: 36d8e02
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Jan 3 14:39:27 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Jan 3 17:53:49 2016 +0100

----------------------------------------------------------------------
 .../camel/impl/ScheduledPollEndpoint.java       | 30 ++++++++++----------
 .../camel/tools/apt/EipAnnotationProcessor.java |  2 +-
 .../tools/apt/EndpointAnnotationProcessor.java  | 16 ++++++++---
 .../tools/apt/helper/JsonSchemaHelper.java      |  9 +++++-
 .../camel/tools/apt/model/EndpointOption.java   |  9 +++++-
 .../tools/apt/EndpointOptionComparatorTest.java |  8 +++---
 .../java/org/apache/camel/spi/UriParam.java     |  7 +++++
 7 files changed, 55 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/45439600/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java b/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
index 28d438a..48420a4 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
@@ -44,41 +44,41 @@ public abstract class ScheduledPollEndpoint extends DefaultEndpoint {
     private static final String QUARTZ_2_SCHEDULER = "org.apache.camel.pollconsumer.quartz2.QuartzScheduledPollConsumerScheduler";
 
     // if adding more options then align with org.apache.camel.impl.ScheduledPollConsumer
-    @UriParam(defaultValue = "true", label = "consumer,scheduler", description = "Whether
the scheduler should be auto started.")
+    @UriParam(optionalPrefix = "consumer.", defaultValue = "true", label = "consumer,scheduler",
description = "Whether the scheduler should be auto started.")
     private boolean startScheduler = true;
-    @UriParam(defaultValue = "1000", label = "consumer,scheduler", description = "Milliseconds
before the first poll starts.")
+    @UriParam(optionalPrefix = "consumer.", defaultValue = "1000", label = "consumer,scheduler",
description = "Milliseconds before the first poll starts.")
     private long initialDelay = 1000;
-    @UriParam(defaultValue = "500", label = "consumer,scheduler", description = "Milliseconds
before the next poll.")
+    @UriParam(optionalPrefix = "consumer.", defaultValue = "500", label = "consumer,scheduler",
description = "Milliseconds before the next poll.")
     private long delay = 500;
-    @UriParam(defaultValue = "MILLISECONDS", label = "consumer,scheduler", description =
"Time unit for initialDelay and delay options.")
+    @UriParam(optionalPrefix = "consumer.", defaultValue = "MILLISECONDS", label = "consumer,scheduler",
description = "Time unit for initialDelay and delay options.")
     private TimeUnit timeUnit = TimeUnit.MILLISECONDS;
-    @UriParam(defaultValue = "true", label = "consumer,scheduler", description = "Controls
if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details.")
+    @UriParam(optionalPrefix = "consumer.", defaultValue = "true", label = "consumer,scheduler",
description = "Controls if fixed delay or fixed rate is used. See ScheduledExecutorService
in JDK for details.")
     private boolean useFixedDelay = true;
-    @UriParam(label = "consumer,advanced", description = "A pluggable org.apache.camel.PollingConsumerPollingStrategy
allowing you to provide your custom implementation"
+    @UriParam(optionalPrefix = "consumer.", label = "consumer,advanced", description = "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.")
     private PollingConsumerPollStrategy pollStrategy = new DefaultPollingConsumerPollStrategy();
-    @UriParam(defaultValue = "TRACE", label = "consumer,scheduler",
+    @UriParam(optionalPrefix = "consumer.", defaultValue = "TRACE", label = "consumer,scheduler",
             description = "The consumer logs a start/complete log line when it polls. This
option allows you to configure the logging level for that.")
     private LoggingLevel runLoggingLevel = LoggingLevel.TRACE;
-    @UriParam(label = "consumer", description = "If the polling consumer did not poll any
files, you can enable this option to send an empty message (no body) instead.")
+    @UriParam(optionalPrefix = "consumer.", label = "consumer", description = "If the polling
consumer did not poll any files, you can enable this option to send an empty message (no body)
instead.")
     private boolean sendEmptyMessageWhenIdle;
-    @UriParam(label = "consumer,scheduler", description = "If greedy is enabled, then the
ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages.")
+    @UriParam(optionalPrefix = "consumer.", label = "consumer,scheduler", description = "If
greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous
run polled 1 or more messages.")
     private boolean greedy;
-    @UriParam(enums = "none,spring,quartz2", defaultValue = "none", label = "consumer,scheduler",
description = "To use a cron scheduler from either camel-spring or camel-quartz2 component")
+    @UriParam(optionalPrefix = "consumer.", enums = "none,spring,quartz2", defaultValue =
"none", label = "consumer,scheduler", description = "To use a cron scheduler from either camel-spring
or camel-quartz2 component")
     private ScheduledPollConsumerScheduler scheduler;
     private String schedulerName = "none"; // used when configuring scheduler using a string
value
-    @UriParam(label = "consumer,scheduler", description = "To configure additional properties
when using a custom scheduler or any of the Quartz2, Spring based scheduler.")
+    @UriParam(optionalPrefix = "consumer.", label = "consumer,scheduler", description = "To
configure additional properties when using a custom scheduler or any of the Quartz2, Spring
based scheduler.")
     private Map<String, Object> schedulerProperties;
-    @UriParam(label = "consumer,scheduler",
+    @UriParam(optionalPrefix = "consumer.", label = "consumer,scheduler",
             description = "Allows for configuring a custom/shared thread pool to use for
the consumer. By default each consumer has its own single threaded thread pool.")
     private ScheduledExecutorService scheduledExecutorService;
-    @UriParam(label = "consumer,scheduler", description = "To let the scheduled polling consumer
backoff if there has been a number of subsequent idles/errors in a row."
+    @UriParam(optionalPrefix = "consumer.", label = "consumer,scheduler", description = "To
let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors
in a row."
             + " The multiplier is then the number of polls that will be skipped before the
next actual attempt is happening again."
             + " When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold
must also be configured.")
     private int backoffMultiplier;
-    @UriParam(label = "consumer,scheduler", description = "The number of subsequent idle
polls that should happen before the backoffMultipler should kick-in.")
+    @UriParam(optionalPrefix = "consumer.", label = "consumer,scheduler", description = "The
number of subsequent idle polls that should happen before the backoffMultipler should kick-in.")
     private int backoffIdleThreshold;
-    @UriParam(label = "consumer,scheduler", description = "The number of subsequent error
polls (failed due some error) that should happen before the backoffMultipler should kick-in.")
+    @UriParam(optionalPrefix = "consumer.", label = "consumer,scheduler", description = "The
number of subsequent error polls (failed due some error) that should happen before the backoffMultipler
should kick-in.")
     private int backoffErrorThreshold;
 
     protected ScheduledPollEndpoint(String endpointUri, Component component) {

http://git-wip-us.apache.org/repos/asf/camel/blob/45439600/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
index e817d64..294804c 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EipAnnotationProcessor.java
@@ -207,7 +207,7 @@ public class EipAnnotationProcessor extends AbstractAnnotationProcessor
{
             String doc = entry.getDocumentation();
             doc = sanitizeDescription(doc, false);
             buffer.append(JsonSchemaHelper.toJson(entry.getName(), entry.getKind(), entry.isRequired(),
entry.getType(), entry.getDefaultValue(), doc,
-                    entry.isDeprecated(), null, null, entry.isEnumType(), entry.getEnums(),
entry.isOneOf(), entry.getOneOfTypes()));
+                    entry.isDeprecated(), null, null, entry.isEnumType(), entry.getEnums(),
entry.isOneOf(), entry.getOneOfTypes(), null));
         }
         buffer.append("\n  }");
 

http://git-wip-us.apache.org/repos/asf/camel/blob/45439600/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
index a8304b3..8658f90 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
@@ -247,8 +247,11 @@ public class EndpointAnnotationProcessor extends AbstractAnnotationProcessor
{
                 defaultValue = "false";
             }
 
+            // component options do not have optional prefix
+            String optionalPrefix = "";
+
             buffer.append(JsonSchemaHelper.toJson(entry.getName(), "property", required,
entry.getType(), defaultValue, doc,
-                    entry.isDeprecated(), entry.getGroup(), entry.getLabel(), entry.isEnumType(),
entry.getEnums(), false, null));
+                    entry.isDeprecated(), entry.getGroup(), entry.getLabel(), entry.isEnumType(),
entry.getEnums(), false, null, optionalPrefix));
         }
         buffer.append("\n  },");
 
@@ -292,8 +295,11 @@ public class EndpointAnnotationProcessor extends AbstractAnnotationProcessor
{
                 defaultValue = "false";
             }
 
+            // @UriPath options do not have optional prefix
+            String optionalPrefix = "";
+
             buffer.append(JsonSchemaHelper.toJson(entry.getName(), "path", required, entry.getType(),
defaultValue, doc,
-                    entry.isDeprecated(), entry.getGroup(), entry.getLabel(), entry.isEnumType(),
entry.getEnums(), false, null));
+                    entry.isDeprecated(), entry.getGroup(), entry.getLabel(), entry.isEnumType(),
entry.getEnums(), false, null, optionalPrefix));
         }
 
         // sort the endpoint options in the standard order we prefer
@@ -332,9 +338,10 @@ public class EndpointAnnotationProcessor extends AbstractAnnotationProcessor
{
                 // fallback as false for boolean types
                 defaultValue = "false";
             }
+            String optionalPrefix = entry.getOptionalPrefix();
 
             buffer.append(JsonSchemaHelper.toJson(entry.getName(), "parameter", required,
entry.getType(), defaultValue,
-                    doc, entry.isDeprecated(), entry.getGroup(), entry.getLabel(), entry.isEnumType(),
entry.getEnums(), false, null));
+                    doc, entry.isDeprecated(), entry.getGroup(), entry.getLabel(), entry.isEnumType(),
entry.getEnums(), false, null, optionalPrefix));
         }
         buffer.append("\n  }");
 
@@ -655,6 +662,7 @@ public class EndpointAnnotationProcessor extends AbstractAnnotationProcessor
{
                     }
                     name = prefix + name;
 
+                    String optionalPrefix = param.optionalPrefix();
                     String defaultValue = param.defaultValue();
                     if (defaultValue == null && metadata != null) {
                         defaultValue = metadata.defaultValue();
@@ -719,7 +727,7 @@ public class EndpointAnnotationProcessor extends AbstractAnnotationProcessor
{
 
                         String group = EndpointHelper.labelAsGroupName(label, componentModel.isConsumerOnly(),
componentModel.isProducerOnly());
                         EndpointOption option = new EndpointOption(name, fieldTypeName, required,
defaultValue, defaultValueNote,
-                                docComment.trim(), deprecated, group, label, isEnum, enums);
+                                docComment.trim(), optionalPrefix, deprecated, group, label,
isEnum, enums);
                         endpointOptions.add(option);
                     }
                 }

http://git-wip-us.apache.org/repos/asf/camel/blob/45439600/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java
index f892093..51cf907 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java
@@ -41,7 +41,8 @@ public final class JsonSchemaHelper {
     }
 
     public static String toJson(String name, String kind, Boolean required, String type,
String defaultValue, String description,
-                                Boolean deprecated, String group, String label, boolean enumType,
Set<String> enums, boolean oneOfType, Set<String> oneOffTypes) {
+                                Boolean deprecated, String group, String label, boolean enumType,
Set<String> enums,
+                                boolean oneOfType, Set<String> oneOffTypes, String
optionalPrefix) {
         String typeName = JsonSchemaHelper.getType(type, enumType);
 
         StringBuilder sb = new StringBuilder();
@@ -95,6 +96,12 @@ public final class JsonSchemaHelper {
             sb.append(", \"javaType\": \"" + type + "\"");
         }
 
+        if (!Strings.isNullOrEmpty(optionalPrefix)) {
+            sb.append(", \"optionalPrefix\": ");
+            String text = safeDefaultValue(optionalPrefix);
+            sb.append(Strings.doubleQuote(text));
+        }
+
         if (deprecated != null) {
             sb.append(", \"deprecated\": ");
             sb.append(Strings.doubleQuote(deprecated.toString()));

http://git-wip-us.apache.org/repos/asf/camel/blob/45439600/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointOption.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointOption.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointOption.java
index 2755167..3a367cf 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointOption.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointOption.java
@@ -30,6 +30,7 @@ public final class EndpointOption {
     private String defaultValue;
     private String defaultValueNote;
     private String documentation;
+    private String optionalPrefix;
     private boolean deprecated;
     private String group;
     private String label;
@@ -37,13 +38,15 @@ public final class EndpointOption {
     private Set<String> enums;
 
     public EndpointOption(String name, String type, String required, String defaultValue,
String defaultValueNote,
-                          String documentation, boolean deprecated,  String group, String
label, boolean enumType, Set<String> enums) {
+                          String documentation, String optionalPrefix, boolean deprecated,
 String group, String label,
+                          boolean enumType, Set<String> enums) {
         this.name = name;
         this.type = type;
         this.required = required;
         this.defaultValue = defaultValue;
         this.defaultValueNote = defaultValueNote;
         this.documentation = documentation;
+        this.optionalPrefix = optionalPrefix;
         this.deprecated = deprecated;
         this.group = group;
         this.label = label;
@@ -71,6 +74,10 @@ public final class EndpointOption {
         return documentation;
     }
 
+    public String getOptionalPrefix() {
+        return optionalPrefix;
+    }
+
     public boolean isDeprecated() {
         return deprecated;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/45439600/tooling/apt/src/test/java/org/apache/camel/tools/apt/EndpointOptionComparatorTest.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/test/java/org/apache/camel/tools/apt/EndpointOptionComparatorTest.java
b/tooling/apt/src/test/java/org/apache/camel/tools/apt/EndpointOptionComparatorTest.java
index ceb834f..3d4a4fe 100644
--- a/tooling/apt/src/test/java/org/apache/camel/tools/apt/EndpointOptionComparatorTest.java
+++ b/tooling/apt/src/test/java/org/apache/camel/tools/apt/EndpointOptionComparatorTest.java
@@ -39,10 +39,10 @@ public class EndpointOptionComparatorTest {
         String group3 = EndpointHelper.labelAsGroupName(label3, false, false);
         String group4 = EndpointHelper.labelAsGroupName(label4, false, false);
 
-        EndpointOption op1 = new EndpointOption("first", "string", "true", "", "", "blah",
false, group1, label1, false, null);
-        EndpointOption op2 = new EndpointOption("synchronous", "string", "true", "", "",
"blah", false, group2, label2, false, null);
-        EndpointOption op3 = new EndpointOption("second", "string", "true", "", "", "blah",
false, group3, label3, false, null);
-        EndpointOption op4 = new EndpointOption("country", "string", "true", "", "", "blah",
false, group4, label4, false, null);
+        EndpointOption op1 = new EndpointOption("first", "string", "true", "", "", "blah",
null, false, group1, label1, false, null);
+        EndpointOption op2 = new EndpointOption("synchronous", "string", "true", "", "",
"blah", null, false, group2, label2, false, null);
+        EndpointOption op3 = new EndpointOption("second", "string", "true", "", "", "blah",
null, false, group3, label3, false, null);
+        EndpointOption op4 = new EndpointOption("country", "string", "true", "", "", "blah",
null, false, group4, label4, false, null);
 
         List<EndpointOption> list = new ArrayList<EndpointOption>();
         list.add(op1);

http://git-wip-us.apache.org/repos/asf/camel/blob/45439600/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParam.java
----------------------------------------------------------------------
diff --git a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParam.java b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParam.java
index 59e4bcd..ef45b2f 100644
--- a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParam.java
+++ b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParam.java
@@ -84,4 +84,11 @@ public @interface UriParam {
      */
     String javaType() default "";
 
+    /**
+     * If the parameter can be configured with an optional prefix.
+     * <p/>
+     * For example to configure consumer options, the parameters can be prefixed with <tt>consumer.</tt>,
eg <tt>consumer.delay=5000</tt>
+     */
+    String optionalPrefix() default "";
+
 }
\ No newline at end of file


Mime
View raw message