camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-10636: Component options docs - Include more details like endpoint options.
Date Thu, 22 Dec 2016 14:51:00 GMT
Repository: camel
Updated Branches:
  refs/heads/master f20b7f01e -> 52f04d40d


CAMEL-10636: Component options docs - Include more details like endpoint options.


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

Branch: refs/heads/master
Commit: 52f04d40dce7f836944a1970f010bb085c142600
Parents: f20b7f0
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Dec 22 15:50:48 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Dec 22 15:50:48 2016 +0100

----------------------------------------------------------------------
 .../springboot/JmsComponentConfiguration.java   |  2 +-
 .../camel/component/jms/JmsComponent.java       | 10 +--
 .../camel/component/jms/JmsConfiguration.java   |  2 +-
 .../tools/apt/EndpointAnnotationProcessor.java  | 70 ++++++++++++--------
 .../java/org/apache/camel/spi/Metadata.java     | 10 +++
 5 files changed, 60 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/52f04d40/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
b/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
index 3fd040a..65b1c6c 100644
--- a/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
+++ b/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
@@ -294,7 +294,7 @@ public class JmsComponentConfiguration {
      * is the lowest priority and 9 is the highest). The explicitQosEnabled
      * option must also be enabled in order for this option to have any effect.
      */
-    private Integer priority = 4;
+    private Integer priority = Integer;
     /**
      * Specifies whether to inhibit the delivery of messages published by its
      * own connection.

http://git-wip-us.apache.org/repos/asf/camel/blob/52f04d40/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
index 2d3b5cd..a996f65 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
@@ -265,7 +265,7 @@ public class JmsComponent extends HeaderFilterStrategyComponent implements
Appli
     /**
      * The JMS acknowledgement name, which is one of: SESSION_TRANSACTED, CLIENT_ACKNOWLEDGE,
AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE
      */
-    @Metadata(defaultValue = "AUTO_ACKNOWLEDGE", label = "consumer",
+    @Metadata(defaultValue = "AUTO_ACKNOWLEDGE", label = "consumer", enums = "SESSION_TRANSACTED,CLIENT_ACKNOWLEDGE,AUTO_ACKNOWLEDGE,DUPS_OK_ACKNOWLEDGE",
             description = "The JMS acknowledgement name, which is one of: SESSION_TRANSACTED,
CLIENT_ACKNOWLEDGE, AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE")
     public void setAcknowledgementModeName(String consumerAcknowledgementMode) {
         getConfiguration().setAcknowledgementModeName(consumerAcknowledgementMode);
@@ -294,7 +294,7 @@ public class JmsComponent extends HeaderFilterStrategyComponent implements
Appli
      * Possible values are: CACHE_AUTO, CACHE_CONNECTION, CACHE_CONSUMER, CACHE_NONE, and
CACHE_SESSION.
      * The default setting is CACHE_AUTO. See the Spring documentation and Transactions Cache
Levels for more information.
      */
-    @Metadata(defaultValue = "CACHE_AUTO", label = "consumer",
+    @Metadata(defaultValue = "CACHE_AUTO", label = "consumer", enums = "CACHE_AUTO,CACHE_CONNECTION,CACHE_CONSUMER,CACHE_NONE,CACHE_SESSION",
             description = "Sets the cache level by name for the underlying JMS resources."
                     + " Possible values are: CACHE_AUTO, CACHE_CONNECTION, CACHE_CONSUMER,
CACHE_NONE, and CACHE_SESSION."
                     + " The default setting is CACHE_AUTO. See the Spring documentation and
Transactions Cache Levels for more information.")
@@ -311,7 +311,7 @@ public class JmsComponent extends HeaderFilterStrategyComponent implements
Appli
      * Note: If using temporary queues then CACHE_NONE is not allowed,
      * and you must use a higher value such as CACHE_CONSUMER or CACHE_SESSION.
      */
-    @Metadata(label = "producer,advanced",
+    @Metadata(label = "producer,advanced", enums = "CACHE_AUTO,CACHE_CONNECTION,CACHE_CONSUMER,CACHE_NONE,CACHE_SESSION",
             description = "Sets the cache level by name for the reply consumer when doing
request/reply over JMS."
                     + " This option only applies when using fixed reply queues (not temporary)."
                     + " Camel will by default use: CACHE_CONSUMER for exclusive or shared
w/ replyToSelectorName."
@@ -401,7 +401,7 @@ public class JmsComponent extends HeaderFilterStrategyComponent implements
Appli
      * Possibles values are those defined by javax.jms.DeliveryMode.
      * NON_PERSISTENT = 1 and PERSISTENT = 2.
      */
-    @Metadata(label = "producer",
+    @Metadata(label = "producer", enums = "1,2",
             description = "Specifies the delivery mode to be used."
                     + " Possibles values are those defined by javax.jms.DeliveryMode."
                     + " NON_PERSISTENT = 1 and PERSISTENT = 2.")
@@ -625,7 +625,7 @@ public class JmsComponent extends HeaderFilterStrategyComponent implements
Appli
      * Values greater than 1 specify the message priority when sending (where 0 is the lowest
priority and 9 is the highest).
      * The explicitQosEnabled option must also be enabled in order for this option to have
any effect.
      */
-    @Metadata(defaultValue = "" + Message.DEFAULT_PRIORITY, label = "producer",
+    @Metadata(defaultValue = "" + Message.DEFAULT_PRIORITY, enums = "1,2,3,4,5,6,7,8,9",
label = "producer",
             description = "Values greater than 1 specify the message priority when sending
(where 0 is the lowest priority and 9 is the highest)."
                     + " The explicitQosEnabled option must also be enabled in order for this
option to have any effect.")
     public void setPriority(int priority) {

http://git-wip-us.apache.org/repos/asf/camel/blob/52f04d40/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
index 6ac017b..b1b9724 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
@@ -401,7 +401,7 @@ public class JmsConfiguration implements Cloneable {
                     + "  must be executed synchronously (Camel 3.0 may support async transactions).")
     private boolean asyncConsumer;
     // the cacheLevelName of reply manager
-    @UriParam(label = "producer,advanced",
+    @UriParam(label = "producer,advanced", enums = "CACHE_AUTO,CACHE_CONNECTION,CACHE_CONSUMER,CACHE_NONE,CACHE_SESSION",
             description = "Sets the cache level by name for the reply consumer when doing
request/reply over JMS."
                     + " This option only applies when using fixed reply queues (not temporary)."
                     + " Camel will by default use: CACHE_CONSUMER for exclusive or shared
w/ replyToSelectorName."

http://git-wip-us.apache.org/repos/asf/camel/blob/52f04d40/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 c072cc9..82bab2d 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
@@ -96,7 +96,7 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
         return true;
     }
 
-    protected void processEndpointClass(final RoundEnvironment roundEnv, final TypeElement
classElement) {
+    private void processEndpointClass(final RoundEnvironment roundEnv, final TypeElement
classElement) {
         final UriEndpoint uriEndpoint = classElement.getAnnotation(UriEndpoint.class);
         if (uriEndpoint != null) {
             String scheme = uriEndpoint.scheme();
@@ -108,10 +108,10 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
                 // for example camel-mail has a bunch of component schema names that does
that
                 String[] schemes = scheme.split(",");
                 String[] titles = title.split(",");
-                String[] extendsSchemes = extendsScheme != null ? extendsScheme.split(",")
: null;
+                String[] extendsSchemes = extendsScheme.split(",");
                 for (int i = 0; i < schemes.length; i++) {
                     final String alias = schemes[i];
-                    final String extendsAlias = extendsSchemes != null ? (i < extendsSchemes.length
? extendsSchemes[i] : extendsSchemes[0]) : null;
+                    final String extendsAlias = i < extendsSchemes.length ? extendsSchemes[i]
: extendsSchemes[0];
                     String aTitle = i < titles.length ? titles[i] : titles[0];
 
                     // some components offer a secure alternative which we need to amend
the title accordingly
@@ -189,7 +189,7 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
 
         writeHtmlDocumentationAndFieldInjections(writer, roundEnv, componentModel, classElement,
"", uriEndpoint.excludeProperties());
 
-        // only if its a consuemr capable component
+        // only if its a consumer capable component
         if (uriEndpoint.consumerOnly() || !uriEndpoint.producerOnly()) {
             // This code is not my fault, it seems to honestly be the hacky way to find a
class name in APT :)
             TypeMirror consumerType = null;
@@ -599,7 +599,7 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
 
                 String required = metadata != null ? metadata.required() : null;
                 String label = metadata != null ? metadata.label() : null;
-                boolean secret = metadata != null ? metadata.secret() : false;
+                boolean secret = metadata != null && metadata.secret();
 
                 // we do not yet have default values / notes / as no annotation support yet
                 // String defaultValueNote = param.defaultValueNote();
@@ -628,15 +628,27 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
 
                 // gather enums
                 Set<String> enums = new LinkedHashSet<String>();
-                boolean isEnum = fieldTypeElement != null && fieldTypeElement.getKind()
== ElementKind.ENUM;
-                if (isEnum) {
-                    TypeElement enumClass = findTypeElement(processingEnv, roundEnv, fieldTypeElement.asType().toString());
-                    // find all the enum constants which has the possible enum value that
can be used
-                    List<VariableElement> fields = ElementFilter.fieldsIn(enumClass.getEnclosedElements());
-                    for (VariableElement var : fields) {
-                        if (var.getKind() == ElementKind.ENUM_CONSTANT) {
-                            String val = var.toString();
-                            enums.add(val);
+
+                boolean isEnum;
+                if (metadata != null && !Strings.isNullOrEmpty(metadata.enums()))
{
+                    isEnum = true;
+                    String[] values = metadata.enums().split(",");
+                    for (String val : values) {
+                        enums.add(val);
+                    }
+                } else {
+                    isEnum = fieldTypeElement != null && fieldTypeElement.getKind()
== ElementKind.ENUM;
+                    if (isEnum) {
+                        TypeElement enumClass = findTypeElement(processingEnv, roundEnv,
fieldTypeElement.asType().toString());
+                        if (enumClass != null) {
+                            // find all the enum constants which has the possible enum value
that can be used
+                            List<VariableElement> fields = ElementFilter.fieldsIn(enumClass.getEnclosedElements());
+                            for (VariableElement var : fields) {
+                                if (var.getKind() == ElementKind.ENUM_CONSTANT) {
+                                    String val = var.toString();
+                                    enums.add(val);
+                                }
+                            }
                         }
                     }
                 }
@@ -689,7 +701,7 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
                     }
 
                     String defaultValue = path.defaultValue();
-                    if (defaultValue == null && metadata != null) {
+                    if (Strings.isNullOrEmpty(defaultValue) && metadata != null)
{
                         defaultValue = metadata.defaultValue();
                     }
                     String defaultValueNote = path.defaultValueNote();
@@ -723,11 +735,13 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
                         if (isEnum) {
                             TypeElement enumClass = findTypeElement(processingEnv, roundEnv,
fieldTypeElement.asType().toString());
                             // find all the enum constants which has the possible enum value
that can be used
-                            List<VariableElement> fields = ElementFilter.fieldsIn(enumClass.getEnclosedElements());
-                            for (VariableElement var : fields) {
-                                if (var.getKind() == ElementKind.ENUM_CONSTANT) {
-                                    String val = var.toString();
-                                    enums.add(val);
+                            if (enumClass != null) {
+                                List<VariableElement> fields = ElementFilter.fieldsIn(enumClass.getEnclosedElements());
+                                for (VariableElement var : fields) {
+                                    if (var.getKind() == ElementKind.ENUM_CONSTANT) {
+                                        String val = var.toString();
+                                        enums.add(val);
+                                    }
                                 }
                             }
                         }
@@ -810,12 +824,14 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
                             isEnum = fieldTypeElement != null && fieldTypeElement.getKind()
== ElementKind.ENUM;
                             if (isEnum) {
                                 TypeElement enumClass = findTypeElement(processingEnv, roundEnv,
fieldTypeElement.asType().toString());
-                                // find all the enum constants which has the possible enum
value that can be used
-                                List<VariableElement> fields = ElementFilter.fieldsIn(enumClass.getEnclosedElements());
-                                for (VariableElement var : fields) {
-                                    if (var.getKind() == ElementKind.ENUM_CONSTANT) {
-                                        String val = var.toString();
-                                        enums.add(val);
+                                if (enumClass != null) {
+                                    // find all the enum constants which has the possible
enum value that can be used
+                                    List<VariableElement> fields = ElementFilter.fieldsIn(enumClass.getEnclosedElements());
+                                    for (VariableElement var : fields) {
+                                        if (var.getKind() == ElementKind.ENUM_CONSTANT) {
+                                            String val = var.toString();
+                                            enums.add(val);
+                                        }
                                     }
                                 }
                             }
@@ -860,7 +876,7 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
         return false;
     }
 
-    protected static Map<String, String> parseAsMap(String data) {
+    private static Map<String, String> parseAsMap(String data) {
         Map<String, String> answer = new HashMap<String, String>();
         String[] lines = data.split("\n");
         for (String line : lines) {

http://git-wip-us.apache.org/repos/asf/camel/blob/52f04d40/tooling/spi-annotations/src/main/java/org/apache/camel/spi/Metadata.java
----------------------------------------------------------------------
diff --git a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/Metadata.java b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/Metadata.java
index 5adebc1..241361e 100644
--- a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/Metadata.java
+++ b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/Metadata.java
@@ -62,6 +62,16 @@ public @interface Metadata {
     String description() default "";
 
     /**
+     * Allows to define enums this options accepts.
+     * <p/>
+     * If the type is already an enum, then this option should not be used; instead you can
use
+     * this option when the type is a String that only accept certain values.
+     * <p/>
+     * Multiple values is separated by comma.
+     */
+    String enums() default "";
+
+    /**
      * Whether the option is secret/sensitive information such as a password.
      */
     boolean secret() default false;


Mime
View raw message