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-7999: apt plugin should generate when clauses for CBR in the model.
Date Tue, 10 Feb 2015 07:45:50 GMT
Repository: camel
Updated Branches:
  refs/heads/master a4562daaa -> 8906357b9


CAMEL-7999: apt plugin should generate when clauses for CBR in the model.


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

Branch: refs/heads/master
Commit: 8906357b951e8051c308a957b7d46d270e2473ac
Parents: a4562da
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Feb 10 08:46:11 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Feb 10 08:46:11 2015 +0100

----------------------------------------------------------------------
 .../apache/camel/model/ChoiceDefinition.java    |  3 +
 .../camel/tools/apt/EipAnnotationProcessor.java | 81 +++++++++++++-------
 2 files changed, 58 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8906357b/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
index 498e614..b2160de 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
@@ -211,6 +211,9 @@ public class ChoiceDefinition extends ProcessorDefinition<ChoiceDefinition>
{
         return whenClauses;
     }
 
+    /**
+     * Sets the when clauses
+     */
     public void setWhenClauses(List<WhenDefinition> whenClauses) {
         this.whenClauses = whenClauses;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/8906357b/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 d3bda3b..cbcbdb9 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
@@ -268,6 +268,9 @@ public class EipAnnotationProcessor extends AbstractAnnotationProcessor
{
 
                     // special for expression
                     processRefExpression(roundEnv, originalClassType, classElement, elementRef,
fieldElement, fieldName, eipOptions, prefix);
+
+                    // special for when clauses
+                    processRefWhenClauses(roundEnv, originalClassType, elementRef, fieldElement,
fieldName, eipOptions, prefix);
                 }
             }
 
@@ -601,9 +604,49 @@ public class EipAnnotationProcessor extends AbstractAnnotationProcessor
{
     }
 
     /**
+     * Special for processing an @XmlElementRef outputs field
+     */
+    private void processOutputs(RoundEnvironment roundEnv, TypeElement originalClassType,
XmlElementRef elementRef,
+                                VariableElement fieldElement, String fieldName, Set<EipOption>
eipOptions, String prefix) {
+        if ("outputs".equals(fieldName) && supportOutputs(originalClassType)) {
+            String kind = "element";
+            String name = elementRef.name();
+            if (isNullOrEmpty(name) || "##default".equals(name)) {
+                name = fieldName;
+            }
+            name = prefix + name;
+            TypeMirror fieldType = fieldElement.asType();
+            String fieldTypeName = fieldType.toString();
+
+            // gather oneOf which extends any of the output base classes
+            Set<String> oneOfTypes = new TreeSet<String>();
+            // find all classes that has that superClassName
+            Set<TypeElement> children = new LinkedHashSet<TypeElement>();
+            for (String superclass : ONE_OF_OUTPUTS) {
+                findTypeElementChildren(roundEnv, children, superclass);
+            }
+            for (TypeElement child : children) {
+                XmlRootElement rootElement = child.getAnnotation(XmlRootElement.class);
+                if (rootElement != null) {
+                    String childName = rootElement.name();
+                    if (childName != null) {
+                        oneOfTypes.add(childName);
+                    }
+                }
+            }
+
+            // remove some types which are not intended as an output in eips
+            oneOfTypes.remove("route");
+
+            EipOption ep = new EipOption(name, kind, fieldTypeName, true, "", "", false,
false, null, true, oneOfTypes);
+            eipOptions.add(ep);
+        }
+    }
+
+    /**
      * Special for processing an @XmlElementRef expression field
      */
-    private void processRefExpression(RoundEnvironment roundEnv, TypeElement originalClassElement,
TypeElement classElement,
+    private void processRefExpression(RoundEnvironment roundEnv, TypeElement originalClassType,
TypeElement classElement,
                                       XmlElementRef elementRef, VariableElement fieldElement,
                                       String fieldName, Set<EipOption> eipOptions,
String prefix) {
         Elements elementUtils = processingEnv.getElementUtils();
@@ -619,7 +662,7 @@ public class EipAnnotationProcessor extends AbstractAnnotationProcessor
{
             String fieldTypeName = fieldType.toString();
 
             // find javadoc from original class as it will override the setExpression method
where we can provide the javadoc for the given EIP
-            String docComment = findJavaDoc(elementUtils, fieldElement, fieldName, name,
originalClassElement, true);
+            String docComment = findJavaDoc(elementUtils, fieldElement, fieldName, name,
originalClassType, true);
 
             // gather oneOf expression/predicates which uses language
             Set<String> oneOfTypes = new TreeSet<String>();
@@ -646,11 +689,13 @@ public class EipAnnotationProcessor extends AbstractAnnotationProcessor
{
     }
 
     /**
-     * Special for processing an @XmlElementRef outputs field
+     * Special for processing an @XmlElementRef when field
      */
-    private void processOutputs(RoundEnvironment roundEnv, TypeElement originalClassType,
XmlElementRef elementRef,
-                                VariableElement fieldElement, String fieldName, Set<EipOption>
eipOptions, String prefix) {
-        if ("outputs".equals(fieldName) && supportOutputs(originalClassType)) {
+    private void processRefWhenClauses(RoundEnvironment roundEnv, TypeElement originalClassType,
XmlElementRef elementRef,
+                                       VariableElement fieldElement, String fieldName, Set<EipOption>
eipOptions, String prefix) {
+        Elements elementUtils = processingEnv.getElementUtils();
+
+        if ("whenClauses".equals(fieldName)) {
             String kind = "element";
             String name = elementRef.name();
             if (isNullOrEmpty(name) || "##default".equals(name)) {
@@ -660,27 +705,11 @@ public class EipAnnotationProcessor extends AbstractAnnotationProcessor
{
             TypeMirror fieldType = fieldElement.asType();
             String fieldTypeName = fieldType.toString();
 
-            // gather oneOf which extends any of the output base classes
-            Set<String> oneOfTypes = new TreeSet<String>();
-            // find all classes that has that superClassName
-            Set<TypeElement> children = new LinkedHashSet<TypeElement>();
-            for (String superclass : ONE_OF_OUTPUTS) {
-                findTypeElementChildren(roundEnv, children, superclass);
-            }
-            for (TypeElement child : children) {
-                XmlRootElement rootElement = child.getAnnotation(XmlRootElement.class);
-                if (rootElement != null) {
-                    String childName = rootElement.name();
-                    if (childName != null) {
-                        oneOfTypes.add(childName);
-                    }
-                }
-            }
-
-            // remove some types which are not intended as an output in eips
-            oneOfTypes.remove("route");
+            // find javadoc from original class as it will override the setExpression method
where we can provide the javadoc for the given EIP
+            String docComment = findJavaDoc(elementUtils, fieldElement, fieldName, name,
originalClassType, true);
+            boolean deprecated = fieldElement.getAnnotation(Deprecated.class) != null;
 
-            EipOption ep = new EipOption(name, kind, fieldTypeName, true, "", "", false,
false, null, true, oneOfTypes);
+            EipOption ep = new EipOption(name, kind, fieldTypeName, false, "", docComment,
deprecated, false, null, false, null);
             eipOptions.add(ep);
         }
     }


Mime
View raw message