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

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

commit 260468a9922e58fa080fa1bcd9f99e0bd6bba3cc
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Thu Mar 14 18:11:54 2024 +0100

    CAMEL-17641: Generate json metadata for pojo beans in camel-core that end 
users can use such as AggregationStrategy implementations. And have that 
information in camel-catalog for tooling assistance.
---
 .../services/org/apache/camel/bean.properties      |  2 +-
 .../camel/bean/DefaultHeaderFilterStrategy.json    | 16 +++++++++
 .../camel/bean/FileIdempotentRepository.json       |  2 +-
 .../camel/bean/MemoryIdempotentRepository.json     |  2 +-
 .../camel/support/DefaultHeaderFilterStrategy.java | 41 +++++++++++++++++++---
 .../idempotent/FileIdempotentRepository.java       |  8 +++--
 .../idempotent/MemoryIdempotentRepository.java     |  2 +-
 .../maven/packaging/GeneratePojoBeanMojo.java      |  8 +++--
 8 files changed, 68 insertions(+), 13 deletions(-)

diff --git 
a/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean.properties
 
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean.properties
index 5a5da2cace5..25ce5d4b2f9 100644
--- 
a/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean.properties
+++ 
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean.properties
@@ -1,5 +1,5 @@
 # Generated by camel build tools - do NOT edit this file!
-bean=FileIdempotentRepository MemoryIdempotentRepository
+bean=DefaultHeaderFilterStrategy FileIdempotentRepository 
MemoryIdempotentRepository
 groupId=org.apache.camel
 artifactId=camel-support
 version=4.5.0-SNAPSHOT
diff --git 
a/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/DefaultHeaderFilterStrategy.json
 
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/DefaultHeaderFilterStrategy.json
new file mode 100644
index 00000000000..8d359b034cd
--- /dev/null
+++ 
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/DefaultHeaderFilterStrategy.json
@@ -0,0 +1,16 @@
+{
+  "bean": {
+    "kind": "bean",
+    "name": "DefaultHeaderFilterStrategy",
+    "javaType": "org.apache.camel.support.DefaultHeaderFilterStrategy",
+    "interfaceType": "org.apache.camel.spi.HeaderFilterStrategy",
+    "title": "Default Header Filter Strategy",
+    "description": "The default header filtering strategy. Users can configure 
which headers is allowed or denied.",
+    "deprecated": true,
+    "groupId": "org.apache.camel",
+    "artifactId": "camel-support",
+    "version": "4.5.0-SNAPSHOT",
+    "options": { "allowNullValues": { "index": 0, "kind": "property", 
"displayName": "Allow Null Values", "label": "advanced", "required": false, 
"type": "object", "javaType": 
"org.apache.camel.support.DefaultHeaderFilterStrategy", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": "false", "description": 
"Whether to allow null values. By default a header is skipped if its value is 
null. Setting this to true will preserve the header." }, "caseInsensitive": { 
"index [...]
+  }
+}
+
diff --git 
a/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/FileIdempotentRepository.json
 
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/FileIdempotentRepository.json
index 48cdb0868ab..e40fb4b2bee 100644
--- 
a/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/FileIdempotentRepository.json
+++ 
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/FileIdempotentRepository.json
@@ -10,7 +10,7 @@
     "groupId": "org.apache.camel",
     "artifactId": "camel-support",
     "version": "4.5.0-SNAPSHOT",
-    "options": { "dropOldestFileStore": { "index": 0, "kind": "property", 
"displayName": "Drop Oldest File Store", "required": false, "type": "integer", 
"javaType": "long", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "1000", "description": "Sets the number of oldest entries to 
drop from the file store when the maximum capacity is hit to reduce disk space 
to allow room for new entries." }, "fileStore": { "index": 1, "kind": 
"property", "displayName": "File St [...]
+    "options": { "dropOldestFileStore": { "index": 0, "kind": "property", 
"displayName": "Drop Oldest File Store", "required": false, "type": "object", 
"javaType": 
"org.apache.camel.support.processor.idempotent.FileIdempotentRepository", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 
"1000", "description": "Sets the number of oldest entries to drop from the file 
store when the maximum capacity is hit to reduce disk space to allow room for 
new entries." }, "file [...]
   }
 }
 
diff --git 
a/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/MemoryIdempotentRepository.json
 
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/MemoryIdempotentRepository.json
index 84aac9a7c66..4c152136b51 100644
--- 
a/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/MemoryIdempotentRepository.json
+++ 
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/MemoryIdempotentRepository.json
@@ -10,7 +10,7 @@
     "groupId": "org.apache.camel",
     "artifactId": "camel-support",
     "version": "4.5.0-SNAPSHOT",
-    "options": { "cacheSize": { "index": 0, "kind": "property", "displayName": 
"Cache Size", "required": false, "type": "integer", "javaType": "int", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 
"1000", "description": "Maximum elements that can be stored in-memory" } }
+    "options": { "cacheSize": { "index": 0, "kind": "property", "displayName": 
"Cache Size", "required": false, "type": "object", "javaType": 
"org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 
"1000", "description": "Maximum elements that can be stored in-memory" } }
   }
 }
 
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/DefaultHeaderFilterStrategy.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/DefaultHeaderFilterStrategy.java
index 7a99e29ab16..901af91262f 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/DefaultHeaderFilterStrategy.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/DefaultHeaderFilterStrategy.java
@@ -23,17 +23,20 @@ import java.util.regex.Pattern;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.spi.Metadata;
 
 /**
  * The default header filtering strategy. Users can configure filter by 
setting filter set and/or setting a regular
  * expression. Subclass can add extended filter logic in
  * {@link #extendedFilter(org.apache.camel.spi.HeaderFilterStrategy.Direction, 
String, Object, org.apache.camel.Exchange)}
- *
+ * <p>
  * Filters are associated with directions (in or out). "In" direction is 
referred to propagating headers "to" Camel
  * message. The "out" direction is opposite which is referred to propagating 
headers from Camel message to a native
  * message like JMS and CXF message. You can see example of 
DefaultHeaderFilterStrategy are being extended and invoked
  * in camel-jms and camel-cxf components.
  */
+@Metadata(label = "bean",
+          description = "The default header filtering strategy. Users can 
configure which headers is allowed or denied.")
 public class DefaultHeaderFilterStrategy implements HeaderFilterStrategy {
 
     /**
@@ -49,17 +52,35 @@ public class DefaultHeaderFilterStrategy implements 
HeaderFilterStrategy {
      */
     public static final String[] CAMEL_FILTER_STARTS_WITH = new String[] { 
"Camel", "camel", "org.apache.camel." };
 
+    @Metadata(javaType = "java.lang.String",
+              description = "Sets the in direction filter set. The in 
direction is referred to copying headers from an external message to a Camel 
message."
+                            + " Multiple patterns can be separated by comma")
     private Set<String> inFilter;
     private Pattern inFilterPattern;
     private String[] inFilterStartsWith;
 
+    @Metadata(javaType = "java.lang.String",
+              description = "Sets the out direction filter set. The out 
direction is referred to copying headers from a Camel message to an external 
message."
+                            + " Multiple patterns can be separated by comma")
     private Set<String> outFilter;
     private Pattern outFilterPattern;
     private String[] outFilterStartsWith;
 
+    @Metadata(label = "advanced", defaultValue = "false",
+              description = "Whether header names should be converted to lower 
case before checking it with the filter Set."
+                            + " It does not affect filtering using regular 
expression pattern.")
     private boolean lowerCase;
+    @Metadata(label = "advanced", defaultValue = "false",
+              description = "Whether to allow null values. By default a header 
is skipped if its value is null. Setting this to true will preserve the 
header.")
     private boolean allowNullValues;
+    @Metadata(label = "advanced", defaultValue = "false",
+              description = "Sets the caseInsensitive property which is a 
boolean to determine whether header names should be case insensitive"
+                            + " when checking it with the filter set. It does 
not affect filtering using regular expression pattern.")
     private boolean caseInsensitive;
+    @Metadata(label = "advanced", defaultValue = "true",
+              description = "Sets what to do when a pattern or filter set is 
matched."
+                            + " When set to true, a match will filter out the 
header. This is the default value for backwards compatibility."
+                            + " When set to false, the pattern or filter will 
indicate that the header must be kept; anything not matched will be filtered 
(skipped).")
     private boolean filterOnMatch = true; // defaults to the previous behaviour
 
     @Override
@@ -96,6 +117,12 @@ public class DefaultHeaderFilterStrategy implements 
HeaderFilterStrategy {
         outFilter = value;
     }
 
+    public void setOutFilter(String value) {
+        if (value != null) {
+            this.outFilter = Set.of(value.split(","));
+        }
+    }
+
     /**
      * Sets the "out" direction filter by starts with pattern. The "out" 
direction is referred to copying headers from a
      * Camel message to an external message.
@@ -166,6 +193,12 @@ public class DefaultHeaderFilterStrategy implements 
HeaderFilterStrategy {
         inFilter = value;
     }
 
+    public void setInFilter(String value) {
+        if (value != null) {
+            this.inFilter = Set.of(value.split(","));
+        }
+    }
+
     /**
      * Sets the "in" direction filter by starts with pattern. The "in" 
direction is referred to copying headers from an
      * external message to a Camel message.
@@ -255,7 +288,7 @@ public class DefaultHeaderFilterStrategy implements 
HeaderFilterStrategy {
 
     /**
      * Whether to allow null values.
-     *
+     * <p>
      * By default a header is skipped if its value is null. Setting this to 
true will preserve the header.
      */
     public void setAllowNullValues(boolean value) {
@@ -269,9 +302,9 @@ public class DefaultHeaderFilterStrategy implements 
HeaderFilterStrategy {
     /**
      * Sets the filterOnMatch property which is a boolean to determine what to 
do when a pattern or filter set is
      * matched.
-     *
+     * <p>
      * When set to true, a match will filter out the header. This is the 
default value for backwards compatibility.
-     *
+     * <p>
      * When set to false, the pattern or filter will indicate that the header 
must be kept; anything not matched will be
      * filtered (skipped).
      *
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/FileIdempotentRepository.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/FileIdempotentRepository.java
index c1f4b296ee7..7770ba84ba9 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/FileIdempotentRepository.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/FileIdempotentRepository.java
@@ -52,7 +52,7 @@ import org.slf4j.LoggerFactory;
  * file store and make room for newer entries.
  */
 @Metadata(label = "bean",
-        description = "A file based IdempotentRepository.")
+          description = "A file based IdempotentRepository.")
 @ManagedResource(description = "File based idempotent repository")
 public class FileIdempotentRepository extends ServiceSupport implements 
IdempotentRepository {
 
@@ -64,10 +64,12 @@ public class FileIdempotentRepository extends 
ServiceSupport implements Idempote
 
     @Metadata(description = "File name of the repository (incl directory)", 
required = true)
     private File fileStore;
-    @Metadata(description = "The maximum file size for the file store in 
bytes. The default value is 32mb", defaultValue = "" + 32 * 1024 * 1000L)
+    @Metadata(description = "The maximum file size for the file store in 
bytes. The default value is 32mb",
+              defaultValue = "" + 32 * 1024 * 1000L)
     private long maxFileStoreSize = 32 * 1024 * 1000L; // 32mb store file
     @Metadata(description = "Sets the number of oldest entries to drop from 
the file store when the maximum capacity is hit to reduce disk"
-                            + " space to allow room for new entries.", 
defaultValue = "1000")
+                            + " space to allow room for new entries.",
+              defaultValue = "1000")
     private long dropOldestFileStore = 1000;
 
     public FileIdempotentRepository() {
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/MemoryIdempotentRepository.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/MemoryIdempotentRepository.java
index 22a0d14506e..898489d9bde 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/MemoryIdempotentRepository.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/processor/idempotent/MemoryIdempotentRepository.java
@@ -33,7 +33,7 @@ import org.apache.camel.support.service.ServiceSupport;
  * Care should be taken to use a suitable underlying {@link Map} to avoid this 
class being a memory leak.
  */
 @Metadata(label = "bean",
-        description = "A memory based IdempotentRepository.")
+          description = "A memory based IdempotentRepository.")
 @ManagedResource(description = "Memory based idempotent repository")
 public class MemoryIdempotentRepository extends ServiceSupport implements 
IdempotentRepository {
     private Map<String, Object> cache;
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GeneratePojoBeanMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GeneratePojoBeanMojo.java
index 4787b307841..f9d3e0f6400 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GeneratePojoBeanMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GeneratePojoBeanMojo.java
@@ -191,8 +191,12 @@ public class GeneratePojoBeanMojo extends 
AbstractGeneratorMojo {
                         }
                         o.setDisplayName(displayName);
                         o.setDeprecated(fi.hasAnnotation(Deprecated.class));
-                        o.setJavaType(fi.type().name().toString());
-                        o.setType(getType(o.getJavaType(), false, false));
+                        String javaType = annotationValue(ai, "javaType");
+                        if (javaType == null) {
+                            javaType = ci.name().toString();
+                        }
+                        o.setJavaType(javaType);
+                        o.setType(getType(javaType, false, false));
                         o.setDescription(annotationValue(ai, "description"));
                         String enums = annotationValue(ai, "enums");
                         if (enums != null) {

Reply via email to