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 2024/03/14 18:49:07 UTC
(camel) 07/10: 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.
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 9f8ce52c101b39e6571bea77f62fcb35671bccee
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Mar 14 17:38:29 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.
---
.../META-INF/services/org/apache/camel/bean.properties | 7 +++++++
.../org/apache/camel/bean/FileIdempotentRepository.json | 16 ++++++++++++++++
.../apache/camel/bean/MemoryIdempotentRepository.json | 16 ++++++++++++++++
.../processor/idempotent/FileIdempotentRepository.java | 10 ++++++++--
.../processor/idempotent/MemoryIdempotentRepository.java | 5 +++++
5 files changed, 52 insertions(+), 2 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
new file mode 100644
index 00000000000..5a5da2cace5
--- /dev/null
+++ b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+bean=FileIdempotentRepository MemoryIdempotentRepository
+groupId=org.apache.camel
+artifactId=camel-support
+version=4.5.0-SNAPSHOT
+projectName=Camel :: Support
+projectDescription=The Camel Support
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
new file mode 100644
index 00000000000..48cdb0868ab
--- /dev/null
+++ b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/FileIdempotentRepository.json
@@ -0,0 +1,16 @@
+{
+ "bean": {
+ "kind": "bean",
+ "name": "FileIdempotentRepository",
+ "javaType": "org.apache.camel.support.processor.idempotent.FileIdempotentRepository",
+ "interfaceType": "org.apache.camel.spi.IdempotentRepository",
+ "title": "File Idempotent Repository",
+ "description": "A file based IdempotentRepository.",
+ "deprecated": false,
+ "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 [...]
+ }
+}
+
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
new file mode 100644
index 00000000000..84aac9a7c66
--- /dev/null
+++ b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/MemoryIdempotentRepository.json
@@ -0,0 +1,16 @@
+{
+ "bean": {
+ "kind": "bean",
+ "name": "MemoryIdempotentRepository",
+ "javaType": "org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository",
+ "interfaceType": "org.apache.camel.spi.IdempotentRepository",
+ "title": "Memory Idempotent Repository",
+ "description": "A memory based IdempotentRepository.",
+ "deprecated": false,
+ "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" } }
+ }
+}
+
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 085b4da115b..c1f4b296ee7 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
@@ -29,6 +29,7 @@ import org.apache.camel.api.management.ManagedAttribute;
import org.apache.camel.api.management.ManagedOperation;
import org.apache.camel.api.management.ManagedResource;
import org.apache.camel.spi.IdempotentRepository;
+import org.apache.camel.spi.Metadata;
import org.apache.camel.support.LRUCache;
import org.apache.camel.support.LRUCacheFactory;
import org.apache.camel.support.service.ServiceSupport;
@@ -50,18 +51,23 @@ import org.slf4j.LoggerFactory;
* {@link #getDropOldestFileStore()} (is default 1000) number of entries from the file store is dropped to reduce the
* file store and make room for newer entries.
*/
+@Metadata(label = "bean",
+ description = "A file based IdempotentRepository.")
@ManagedResource(description = "File based idempotent repository")
public class FileIdempotentRepository extends ServiceSupport implements IdempotentRepository {
private static final Logger LOG = LoggerFactory.getLogger(FileIdempotentRepository.class);
-
private static final String STORE_DELIMITER = "\n";
private final AtomicBoolean init = new AtomicBoolean();
-
private Map<String, Object> cache;
+
+ @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)
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")
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 5a8cf516f40..22a0d14506e 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
@@ -22,6 +22,7 @@ import org.apache.camel.api.management.ManagedAttribute;
import org.apache.camel.api.management.ManagedOperation;
import org.apache.camel.api.management.ManagedResource;
import org.apache.camel.spi.IdempotentRepository;
+import org.apache.camel.spi.Metadata;
import org.apache.camel.support.LRUCache;
import org.apache.camel.support.LRUCacheFactory;
import org.apache.camel.support.service.ServiceSupport;
@@ -31,9 +32,13 @@ import org.apache.camel.support.service.ServiceSupport;
* <p/>
* 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.")
@ManagedResource(description = "Memory based idempotent repository")
public class MemoryIdempotentRepository extends ServiceSupport implements IdempotentRepository {
private Map<String, Object> cache;
+
+ @Metadata(description = "Maximum elements that can be stored in-memory", defaultValue = "1000")
private int cacheSize;
public MemoryIdempotentRepository() {