You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2019/09/16 14:58:22 UTC

[camel] branch master updated: CAMEL-13981: make sure that the property helper...

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

zregvart 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 6e8691c  CAMEL-13981: make sure that the property helper...
6e8691c is described below

commit 6e8691c908875f64942f7c97321bf3028b8f5a81
Author: Zoran Regvart <zr...@apache.org>
AuthorDate: Mon Sep 16 16:57:44 2019 +0200

    CAMEL-13981: make sure that the property helper...
    
    ... class is generated
    
    The helper class would be generated if the `last` boolean flag was set
    and the conditions in the helper did not prevent further execution of
    the `processModelClass` method.
    
    For example if the last processed element is abstract, and it might be
    depending on the order of the elements in the `Set` of processed
    elements the `DefinitionPropertiesPlaceholderProviderHelper.java` would
    not be generated.
---
 .../camel/tools/apt/CoreEipAnnotationProcessorHelper.java      | 10 +---------
 .../org/apache/camel/tools/apt/ModelAnnotationProcessor.java   |  7 +++++--
 .../camel/tools/apt/SpringAnnotationProcessorHelper.java       |  2 +-
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessorHelper.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessorHelper.java
index fa0be2b..b53d63b 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessorHelper.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessorHelper.java
@@ -54,7 +54,6 @@ import static org.apache.camel.tools.apt.AnnotationProcessorHelper.findTypeEleme
 import static org.apache.camel.tools.apt.AnnotationProcessorHelper.hasSuperClass;
 import static org.apache.camel.tools.apt.AnnotationProcessorHelper.implementsInterface;
 import static org.apache.camel.tools.apt.AnnotationProcessorHelper.processFile;
-import static org.apache.camel.tools.apt.PropertyPlaceholderGenerator.generatePropertyPlaceholderDefinitionsHelper;
 import static org.apache.camel.tools.apt.helper.JsonSchemaHelper.sanitizeDescription;
 import static org.apache.camel.tools.apt.helper.Strings.canonicalClassName;
 import static org.apache.camel.tools.apt.helper.Strings.isNullOrEmpty;
@@ -89,7 +88,7 @@ public class CoreEipAnnotationProcessorHelper {
     private boolean skipUnwanted = true;
 
     protected void processModelClass(final ProcessingEnvironment processingEnv, final RoundEnvironment roundEnv,
-                                     final TypeElement classElement, Set<String> propertyPlaceholderDefinitions, final boolean last) {
+                                     final TypeElement classElement, Set<String> propertyPlaceholderDefinitions) {
         final String javaTypeName = canonicalClassName(classElement.getQualifiedName().toString());
         String packageName = javaTypeName.substring(0, javaTypeName.lastIndexOf("."));
 
@@ -128,13 +127,6 @@ public class CoreEipAnnotationProcessorHelper {
         // write json schema and property placeholder provider
         processFile(processingEnv, packageName, fileName, writer -> writeJSonSchemeAndPropertyPlaceholderProvider(processingEnv, writer,
                 roundEnv, classElement, rootElement, javaTypeName, name, propertyPlaceholderDefinitions));
-
-        // if last then generate source code for helper that contains all the generated property placeholder providers
-        // (this allows fast property placeholders at runtime without reflection overhead)
-        if (last) {
-            processingEnv.getMessager().printMessage(Kind.WARNING, String.format("Generating placeholder definitions helper for %d definitions", propertyPlaceholderDefinitions.size()));
-            generatePropertyPlaceholderDefinitionsHelper(processingEnv, roundEnv, propertyPlaceholderDefinitions);
-        }
     }
 
     protected void writeJSonSchemeAndPropertyPlaceholderProvider(ProcessingEnvironment processingEnv, PrintWriter writer, RoundEnvironment roundEnv, TypeElement classElement,
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/ModelAnnotationProcessor.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/ModelAnnotationProcessor.java
index d312ca8..b92cdba 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/ModelAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/ModelAnnotationProcessor.java
@@ -87,14 +87,17 @@ public class ModelAnnotationProcessor extends AbstractCamelAnnotationProcessor {
         Iterator<? extends Element> it = coreElements.iterator();
         while (it.hasNext()) {
             TypeElement classElement = (TypeElement) it.next();
-            coreProcessor.processModelClass(processingEnv, roundEnv, classElement, propertyPlaceholderDefinitions, !it.hasNext());
+            coreProcessor.processModelClass(processingEnv, roundEnv, classElement, propertyPlaceholderDefinitions);
         }
 
         it = springElements.iterator();
         while (it.hasNext()) {
             TypeElement classElement = (TypeElement) it.next();
-            springProcessor.processModelClass(processingEnv, roundEnv, classElement, !it.hasNext());
+            springProcessor.processModelClass(processingEnv, roundEnv, classElement);
         }
+
+        messager.printMessage(Kind.WARNING, String.format("Generating placeholder definitions helper for %d definitions", propertyPlaceholderDefinitions.size()));
+        PropertyPlaceholderGenerator.generatePropertyPlaceholderDefinitionsHelper(processingEnv, roundEnv, propertyPlaceholderDefinitions);
     }
 
 }
\ No newline at end of file
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/SpringAnnotationProcessorHelper.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/SpringAnnotationProcessorHelper.java
index fff0004..7259f47 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/SpringAnnotationProcessorHelper.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/SpringAnnotationProcessorHelper.java
@@ -57,7 +57,7 @@ import static org.apache.camel.tools.apt.helper.Strings.safeNull;
 public class SpringAnnotationProcessorHelper {
 
     protected void processModelClass(final ProcessingEnvironment processingEnv, final RoundEnvironment roundEnv,
-                                     final TypeElement classElement, final boolean last) {
+                                     final TypeElement classElement) {
         final String javaTypeName = canonicalClassName(classElement.getQualifiedName().toString());
         String packageName = javaTypeName.substring(0, javaTypeName.lastIndexOf("."));