You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/08/14 07:53:11 UTC

[camel] 17/21: CAMEL-13850: Source code generate ExchangeConstantProvider so we can do fast lookup of its constant values without reflection

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

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 17cfc8e735cc41e1aa4ab3eb176411cfa68992d1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Aug 13 18:19:34 2019 +0200

    CAMEL-13850: Source code generate ExchangeConstantProvider so we can do fast lookup of its constant values without reflection
---
 .../main/java/org/apache/camel/model/ProcessorDefinitionHelper.java   | 4 ++--
 .../java/org/apache/camel/tools/apt/ConstantProviderProcessor.java    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java b/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
index 947ee37..501317f 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
@@ -32,6 +32,7 @@ import javax.xml.namespace.QName;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
+import org.apache.camel.ExchangeConstantProvider;
 import org.apache.camel.NamedNode;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.ExecutorServiceManager;
@@ -765,8 +766,7 @@ public final class ProcessorDefinitionHelper {
                 // is the value a known field (currently we only support constants from Exchange.class)
                 if (text != null && text.startsWith("Exchange.")) {
                     String field = StringHelper.after(text, "Exchange.");
-                    // TODO: Avoid reflection via fields
-                    String constant = ObjectHelper.lookupConstantFieldValue(Exchange.class, field);
+                    String constant = ExchangeConstantProvider.lookup(field);
                     if (constant != null) {
                         text = constant;
                     } else {
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/ConstantProviderProcessor.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/ConstantProviderProcessor.java
index fa93112..9367d86 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/ConstantProviderProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/ConstantProviderProcessor.java
@@ -114,7 +114,7 @@ public class ConstantProviderProcessor extends AbstractCamelAnnotationProcessor
             w.write("        MAP = map;\n");
             w.write("    }\n");
             w.write("\n");
-            w.write("    public static String provider(String key) {\n");
+            w.write("    public static String lookup(String key) {\n");
             w.write("        return MAP.get(key);\n");
             w.write("    }\n");
             w.write("}\n");