[camel] branch CAMEL-13870 updated: CAMEL-13870: Fast property configuration of Camel endpoints. Work in progress.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch CAMEL-13870 updated: CAMEL-13870: Fast property configuration of Camel endpoints. Work in progress.

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

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


The following commit(s) were added to refs/heads/CAMEL-13870 by this push:
     new 8d699bb  CAMEL-13870: Fast property configuration of Camel endpoints. Work in progress.
8d699bb is described below

commit 8d699bb0bf23592fadd1e7101f0a0b4c82b386c4
Author: Claus Ibsen <[hidden email]>
AuthorDate: Thu Aug 22 14:21:43 2019 +0200

    CAMEL-13870: Fast property configuration of Camel endpoints. Work in progress.
---
 .../src/main/docs/spring-boot.adoc                 |  4 ++-
 .../spring/boot/CamelConfigurationProperties.java  | 14 ++++++++
 .../camel/main/DefaultConfigurationProperties.java | 19 +++++++++++
 .../apt/EndpointPropertyConfigurerGenerator.java   | 38 +++++++++++++++-------
 4 files changed, 63 insertions(+), 12 deletions(-)

diff --git a/components/camel-spring-boot/src/main/docs/spring-boot.adoc b/components/camel-spring-boot/src/main/docs/spring-boot.adoc
index 155da7f..6715705 100644
--- a/components/camel-spring-boot/src/main/docs/spring-boot.adoc
+++ b/components/camel-spring-boot/src/main/docs/spring-boot.adoc
@@ -89,7 +89,7 @@ When using Spring Boot make sure to use the following Maven dependency to have s
 ----
 
 
-The component supports 127 options, which are listed below.
+The component supports 129 options, which are listed below.
 
 
 
@@ -146,6 +146,8 @@ The component supports 127 options, which are listed below.
 | *camel.springboot.allow-use-original-message* | Sets whether to allow access to the original message from Camel's error handler, or from org.apache.camel.spi.UnitOfWork.getOriginalInMessage(). Turning this off can optimize performance, as defensive copy of the original message is not needed. Default is false. | false | Boolean
 | *camel.springboot.auto-startup* | Sets whether the object should automatically start when Camel starts. Important: Currently only routes can be disabled, as CamelContext's are always started. Note: When setting auto startup false on CamelContext then that takes precedence and no routes is started. You would need to start CamelContext explicit using the org.apache.camel.CamelContext.start() method, to start the context, and then you would need to start the routes manually using Camelcon [...]
 | *camel.springboot.backlog-tracing* | Sets whether backlog tracing is enabled or not. Default is false. | false | Boolean
+| *camel.springboot.bean-introspection-extended-statistics* | Sets whether bean introspection uses extended statistics. The default is false. | false | Boolean
+| *camel.springboot.bean-introspection-logging-level* | Sets the logging level used by bean introspection, logging activity of its usage. The default is TRACE. |  | LoggingLevel
 | *camel.springboot.consumer-template-cache-size* | Consumer template endpoints cache size. | 1000 | Integer
 | *camel.springboot.duration-max-idle-seconds* | To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. You can use this to run Spring Boot for a short while. | 0 | Integer
 | *camel.springboot.duration-max-messages* | To specify how many messages to process by Camel before automatic terminating the JVM. You can use this to run Spring Boot for a short while. | 0 | Integer
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
index 8e884a6..b20a47b 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.spring.boot;
 
+import org.apache.camel.LoggingLevel;
 import org.apache.camel.ManagementStatisticsLevel;
 import org.apache.camel.main.DefaultConfigurationProperties;
 import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -444,6 +445,19 @@ public class CamelConfigurationProperties extends DefaultConfigurationProperties
      */
     private String threadNamePattern;
 
+    /**
+     * Sets whether bean introspection uses extended statistics.
+     * The default is false.
+     */
+    private boolean beanIntrospectionExtendedStatistics;
+
+    /**
+     * Sets the logging level used by bean introspection, logging activity of its usage.
+     * The default is TRACE.
+     */
+    private LoggingLevel beanIntrospectionLoggingLevel;
+
+
     // Getters & setters
     // -----------------
 
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
index 5be730d..3e92f77 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
@@ -1149,4 +1149,23 @@ public abstract class DefaultConfigurationProperties<T> {
         this.routeFilterExcludePattern = routeFilterExcludePattern;
         return (T) this;
     }
+
+    /**
+     * Sets whether bean introspection uses extended statistics.
+     * The default is false.
+     */
+    public T withBeanIntrospectionExtendedStatistics(boolean beanIntrospectionExtendedStatistics) {
+        this.beanIntrospectionExtendedStatistics = beanIntrospectionExtendedStatistics;
+        return (T) this;
+    }
+
+    /**
+     * Sets the logging level used by bean introspection, logging activity of its usage.
+     * The default is TRACE.
+     */
+    public T withBeanIntrospectionLoggingLevel(LoggingLevel beanIntrospectionLoggingLevel) {
+        this.beanIntrospectionLoggingLevel = beanIntrospectionLoggingLevel;
+        return (T) this;
+    }
+
 }
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java
index 7aa8661..ec2ddb5 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java
@@ -33,7 +33,9 @@ import static org.apache.camel.tools.apt.AnnotationProcessorHelper.dumpException
 
 public final class EndpointPropertyConfigurerGenerator {
 
-    // TODO: We can omit the read properties as we only use the writes
+    // at the moment we do not need getters (read) so lets turn them off
+    private static final boolean GENERATE_READ = false;
+    private static final boolean GENERATE_WRITE = true;
 
     private EndpointPropertyConfigurerGenerator() {
     }
@@ -41,8 +43,6 @@ public final class EndpointPropertyConfigurerGenerator {
     public static void generateExtendConfigurer(ProcessingEnvironment processingEnv, TypeElement parent,
                                                 String pn, String cn, String fqn) {
 
-
-
         Writer w = null;
         try {
             JavaFileObject src = processingEnv.getFiler().createSourceFile(fqn, parent);
@@ -96,8 +96,12 @@ public final class EndpointPropertyConfigurerGenerator {
             w.write(" */\n");
             w.write("public class " + cn + " extends EndpointPropertyConfigurerSupport {\n");
             w.write("\n");
-            w.write("    private final Map<String, Supplier<Object>> readPlaceholders = new HashMap<>(" + size + ");\n");
-            w.write("    private final Map<String, Consumer<Object>> writePlaceholders = new HashMap<>(" + size + ");\n");
+            if (GENERATE_READ) {
+                w.write("    private final Map<String, Supplier<Object>> readPlaceholders = new HashMap<>(" + size + ");\n");
+            }
+            if (GENERATE_WRITE) {
+                w.write("    private final Map<String, Consumer<Object>> writePlaceholders = new HashMap<>(" + size + ");\n");
+            }
             w.write("\n");
 
             // add constructor
@@ -108,22 +112,34 @@ public final class EndpointPropertyConfigurerGenerator {
             for (EndpointOption option : options) {
                 String getOrSet = option.getName();
                 getOrSet = Character.toUpperCase(getOrSet.charAt(0)) + getOrSet.substring(1);
-                String getterLambda = getterLambda(getOrSet, option.getName(), option.getType(), option.getConfigurationField());
-                String setterLambda = setterLambda(getOrSet, option.getName(), option.getType(), option.getConfigurationField());
-                w.write("        readPlaceholders.put(\"" + option.getName() + "\", " + getterLambda + ");\n");
-                w.write("        writePlaceholders.put(\"" + option.getName() + "\", " + setterLambda + ");\n");
+                if (GENERATE_READ) {
+                    String getterLambda = getterLambda(getOrSet, option.getName(), option.getType(), option.getConfigurationField());
+                    w.write("        readPlaceholders.put(\"" + option.getName() + "\", " + getterLambda + ");\n");
+                }
+                if (GENERATE_WRITE) {
+                    String setterLambda = setterLambda(getOrSet, option.getName(), option.getType(), option.getConfigurationField());
+                    w.write("        writePlaceholders.put(\"" + option.getName() + "\", " + setterLambda + ");\n");
+                }
             }
 
             w.write("    }\n");
             w.write("\n");
             w.write("    @Override\n");
             w.write("    public Map<String, Supplier<Object>> getReadPropertyPlaceholderOptions(CamelContext camelContext) {\n");
-            w.write("        return readPlaceholders;\n");
+            if (GENERATE_READ) {
+                w.write("        return readPlaceholders;\n");
+            } else {
+                w.write("        return null;\n");
+            }
             w.write("    }\n");
             w.write("\n");
             w.write("    @Override\n");
             w.write("    public Map<String, Consumer<Object>> getWritePropertyPlaceholderOptions(CamelContext camelContext) {\n");
-            w.write("        return writePlaceholders;\n");
+            if (GENERATE_WRITE) {
+                w.write("        return writePlaceholders;\n");
+            } else {
+                w.write("        return null;\n");
+            }
             w.write("    }\n");
             w.write("\n");
             w.write("}\n");