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/24 16:58:10 UTC

[camel] 02/03: CAMEL-13870: Generating fast component options configurer

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 5c1f5820f456a7e4b32587a2d1aa6eb05c4e6a62
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Aug 24 16:35:30 2019 +0200

    CAMEL-13870: Generating fast component options configurer
---
 .../src/main/docs/properties-component.adoc               |  3 +--
 .../camel/component/properties/PropertiesComponent.java   |  6 +++---
 .../camel/core/xml/AbstractCamelContextFactoryBean.java   |  2 +-
 .../springboot/PropertiesComponentConfiguration.java      | 15 ---------------
 .../camel/tools/apt/EndpointAnnotationProcessor.java      | 10 ++++++++++
 .../src/main/java/org/apache/camel/spi/Metadata.java      |  5 +++++
 6 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/components/camel-properties/src/main/docs/properties-component.adoc b/components/camel-properties/src/main/docs/properties-component.adoc
index 2b9fcdd..d542d8d 100644
--- a/components/camel-properties/src/main/docs/properties-component.adoc
+++ b/components/camel-properties/src/main/docs/properties-component.adoc
@@ -15,14 +15,13 @@ Where *key* is the key for the property to lookup
 == Options
 
 // component options: START
-The Properties component supports 12 options, which are listed below.
+The Properties component supports 11 options, which are listed below.
 
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *locations* (common) | A list of locations to load properties. This option will override any default locations and only use the locations from this option. |  | List
 | *location* (common) | A list of locations to load properties. You can use comma to separate multiple locations. This option will override any default locations and only use the locations from this option. |  | String
 | *encoding* (common) | Encoding to use when loading properties file from the file system or classpath. If no encoding has been set, then the properties files is loaded using ISO-8859-1 encoding (latin-1) as documented by java.util.Properties#load(java.io.InputStream) |  | String
 | *propertiesParser* (common) | To use a custom PropertiesParser |  | PropertiesParser
diff --git a/components/camel-properties/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java b/components/camel-properties/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
index 1613bab..8b83d12 100644
--- a/components/camel-properties/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
+++ b/components/camel-properties/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
@@ -106,8 +106,8 @@ public class PropertiesComponent extends DefaultComponent implements org.apache.
     private PropertiesParser propertiesParser = new DefaultPropertiesParser(this);
     private final PropertiesLookup propertiesLookup = new DefaultPropertiesLookup(this);
     private final List<PropertiesSource> sources = new ArrayList<>();
-    private List<PropertiesLocation> locations = Collections.emptyList();
-
+    @Metadata(skip = true)
+    private List<PropertiesLocation> locations = new ArrayList<>();
     @Metadata
     private String location;
     @Metadata
@@ -283,7 +283,7 @@ public class PropertiesComponent extends DefaultComponent implements org.apache.
      * A list of locations to load properties.
      * This option will override any default locations and only use the locations from this option.
      */
-    private void setLocations(List<PropertiesLocation> locations) {
+    public void setLocations(List<PropertiesLocation> locations) {
         // reset locations
         locations = parseLocations(locations);
         this.locations = Collections.unmodifiableList(locations);
diff --git a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index abdbbd2..8fbc61d 100644
--- a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -627,7 +627,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
             }
 
             PropertiesComponent pc = new PropertiesComponent();
-            locations.forEach(pc::addLocation);
+            pc.setLocations(locations);
             pc.setEncoding(def.getEncoding());
 
             if (def.isIgnoreMissingLocation() != null) {
diff --git a/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java
index 5a0d072..ad7ad86 100644
--- a/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-properties-starter/src/main/java/org/apache/camel/component/properties/springboot/PropertiesComponentConfiguration.java
@@ -16,9 +16,7 @@
  */
 package org.apache.camel.component.properties.springboot;
 
-import java.util.List;
 import javax.annotation.Generated;
-import org.apache.camel.component.properties.PropertiesLocation;
 import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
@@ -40,11 +38,6 @@ public class PropertiesComponentConfiguration
      */
     private Boolean enabled;
     /**
-     * A list of locations to load properties. This option will override any
-     * default locations and only use the locations from this option.
-     */
-    private List<PropertiesLocation> locations;
-    /**
      * A list of locations to load properties. You can use comma to separate
      * multiple locations. This option will override any default locations and
      * only use the locations from this option.
@@ -108,14 +101,6 @@ public class PropertiesComponentConfiguration
      */
     private Boolean basicPropertyBinding = false;
 
-    public List<PropertiesLocation> getLocations() {
-        return locations;
-    }
-
-    public void setLocations(List<PropertiesLocation> locations) {
-        this.locations = locations;
-    }
-
     public String getLocation() {
         return location;
     }
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 bd396e1..4d7621b 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
@@ -552,6 +552,10 @@ public class EndpointAnnotationProcessor extends AbstractCamelAnnotationProcesso
                 String methodName = method.getSimpleName().toString();
                 boolean deprecated = method.getAnnotation(Deprecated.class) != null;
                 Metadata metadata = method.getAnnotation(Metadata.class);
+                if (metadata != null && metadata.skip()) {
+                    continue;
+                }
+
                 String deprecationNote = null;
                 if (metadata != null) {
                     deprecationNote = metadata.deprecationNote();
@@ -580,6 +584,9 @@ public class EndpointAnnotationProcessor extends AbstractCamelAnnotationProcesso
                 if (field != null && metadata == null) {
                     metadata = field.getAnnotation(Metadata.class);
                 }
+                if (metadata != null && metadata.skip()) {
+                    continue;
+                }
 
                 boolean required = metadata != null && metadata.required();
                 String label = metadata != null ? metadata.label() : null;
@@ -676,6 +683,9 @@ public class EndpointAnnotationProcessor extends AbstractCamelAnnotationProcesso
             for (VariableElement fieldElement : fieldElements) {
 
                 Metadata metadata = fieldElement.getAnnotation(Metadata.class);
+                if (metadata != null && metadata.skip()) {
+                    continue;
+                }
                 boolean deprecated = fieldElement.getAnnotation(Deprecated.class) != null;
                 String deprecationNote = null;
                 if (metadata != null) {
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 60de377..873952d 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
@@ -100,4 +100,9 @@ public @interface Metadata {
      */
     String deprecationNote() default "";
 
+    /**
+     * Whether to skip this option
+     */
+    boolean skip() default false;
+
 }