You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/04/14 11:32:54 UTC

[camel] branch main created (now 856f14a5a13)

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

acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


      at 856f14a5a13 CAMEL-17968: camel-jbang - Add option to specify override property

This branch includes the following new commits:

     new b3087add15d Regen for commit 2a9c87fafb6ec31f2c8e90643fd482c74d27ac96
     new 856f14a5a13 CAMEL-17968: camel-jbang - Add option to specify override property

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel] 01/02: Regen for commit 2a9c87fafb6ec31f2c8e90643fd482c74d27ac96

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b3087add15d42c191b15abcbf1ca82b5eca1db10
Author: oscerd <os...@users.noreply.github.com>
AuthorDate: Thu Apr 14 10:46:27 2022 +0000

    Regen for commit 2a9c87fafb6ec31f2c8e90643fd482c74d27ac96
    
    Signed-off-by: GitHub <no...@github.com>
---
 .../apache/camel/catalog/models/errorHandler.json  | 24 ++++------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/errorHandler.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/errorHandler.json
index b35eb757c4a..ddcf5343eb1 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/errorHandler.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/errorHandler.json
@@ -3,32 +3,16 @@
     "kind": "model",
     "name": "errorHandler",
     "title": "Error Handler",
-    "description": "Error handler settings",
+    "description": "Camel error handling.",
     "deprecated": false,
-    "label": "spring,configuration,error",
-    "javaType": "org.apache.camel.spring.xml.SpringErrorHandlerDefinition",
+    "label": "configuration,error",
+    "javaType": "org.apache.camel.model.ErrorHandlerDefinition",
     "abstract": false,
     "input": false,
     "output": false
   },
   "properties": {
-    "type": { "kind": "attribute", "displayName": "Type", "required": true, "type": "enum", "javaType": "org.apache.camel.spring.xml.SpringErrorHandlerType", "enum": [ "dead-letter-channel", "default-error-handler", "no-error-handler", "transaction-error-handler" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "DefaultErrorHandler", "description": "The type of the error handler" },
-    "deadLetterUri": { "kind": "attribute", "displayName": "Dead Letter Uri", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The dead letter endpoint uri for the Dead Letter error handler." },
-    "deadLetterHandleNewException": { "kind": "attribute", "displayName": "Dead Letter Handle New Exception", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Whether the dead letter channel should handle (and ignore) any new exception that may been thrown during sending the message to the dead letter endpoint. The default value is true which means any such kind of exception is handled and ignor [...]
-    "level": { "kind": "attribute", "displayName": "Level", "required": false, "type": "enum", "javaType": "org.apache.camel.LoggingLevel", "enum": [ "debug", "error", "info", "off", "trace", "warn" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "ERROR", "description": "Logging level to use when using the logging error handler type." },
-    "rollbackLoggingLevel": { "kind": "attribute", "displayName": "Rollback Logging Level", "required": false, "type": "enum", "javaType": "org.apache.camel.LoggingLevel", "enum": [ "debug", "error", "info", "off", "trace", "warn" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "WARN", "description": "Sets the logging level to use for logging transactional rollback. This option is default WARN." },
-    "logName": { "kind": "attribute", "displayName": "Log Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of the logger to use for the logging error handler" },
-    "useOriginalMessage": { "kind": "attribute", "displayName": "Use Original Message", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Will use the original input org.apache.camel.Message (original body and headers) when an org.apache.camel.Exchange is moved to the dead letter queue. Notice: this only applies when all redeliveries attempt have failed and the org.apache [...]
-    "useOriginalBody": { "kind": "attribute", "displayName": "Use Original Body", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Will use the original input org.apache.camel.Message body (original body only) when an org.apache.camel.Exchange is moved to the dead letter queue. Notice: this only applies when all redeliveries attempt have failed and the org.apache.camel.E [...]
-    "transactionTemplateRef": { "kind": "attribute", "displayName": "Transaction Template Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "References to the org.springframework.transaction.support.TransactionTemplate to use with the transaction error handler." },
-    "transactionManagerRef": { "kind": "attribute", "displayName": "Transaction Manager Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "References to the org.springframework.transaction.PlatformTransactionManager to use with the transaction error handler." },
-    "onRedeliveryRef": { "kind": "attribute", "displayName": "On Redelivery Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a reference to a processor that should be processed before a redelivery attempt. Can be used to change the org.apache.camel.Exchange before its being redelivered." },
-    "onExceptionOccurredRef": { "kind": "attribute", "displayName": "On Exception Occurred Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a reference to a processor that should be processed just after an exception occurred. Can be used to perform custom logging about the occurred exception at the exact time it happened. Important: Any exception thrown from this processor will be ign [...]
-    "onPrepareFailureRef": { "kind": "attribute", "displayName": "On Prepare Failure Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a reference to a processor to prepare the org.apache.camel.Exchange before handled by the failure processor \/ dead letter channel. This allows for example to enrich the message before sending to a dead letter queue." },
-    "retryWhileRef": { "kind": "attribute", "displayName": "Retry While Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a reference to an retry while expression. Will continue retrying until expression evaluates to false." },
-    "redeliveryPolicyRef": { "kind": "attribute", "displayName": "Redelivery Policy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a reference to a RedeliveryPolicy to be used for redelivery settings." },
-    "executorServiceRef": { "kind": "attribute", "displayName": "Executor Service Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a reference to a thread pool to be used by the error handler" },
-    "redeliveryPolicy": { "kind": "element", "displayName": "Redelivery Policy", "required": false, "type": "object", "javaType": "org.apache.camel.spring.xml.CamelRedeliveryPolicyFactoryBean", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the redelivery settings" },
+    "errorHandlerType": { "kind": "element", "displayName": "Error Handler Type", "required": true, "type": "object", "javaType": "org.apache.camel.ErrorHandlerFactory", "oneOf": [ "deadLetterChannel", "defaultErrorHandler", "jtaTransactionErrorHandler", "noErrorHandler", "springTransactionErrorHandler" ], "deprecated": false, "autowired": false, "secret": false, "description": "The specific error handler in use." },
     "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" }
   }
 }


[camel] 02/02: CAMEL-17968: camel-jbang - Add option to specify override property

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 856f14a5a13008837d2891b08d6ae8e9a48a3915
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Apr 14 12:56:50 2022 +0200

    CAMEL-17968: camel-jbang - Add option to specify override property
---
 .../component/properties/PropertiesComponent.java  | 43 +---------------------
 .../apache/camel/dsl/jbang/core/commands/Run.java  | 15 ++++++++
 .../src/main/resources/templates/java.tmpl         |  4 +-
 .../src/main/resources/templates/xml.tmpl          |  2 +-
 4 files changed, 19 insertions(+), 45 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java b/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
index 7c0e2b30059..807476cd392 100644
--- a/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
+++ b/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
@@ -224,48 +224,7 @@ public class PropertiesComponent extends ServiceSupport
 
     @Override
     public Properties loadProperties(Predicate<String> filter) {
-        OrderedLocationProperties prop = new OrderedLocationProperties();
-
-        // use initial properties
-        if (initialProperties != null) {
-            for (String name : initialProperties.stringPropertyNames()) {
-                if (filter.test(name)) {
-                    prop.put("initial", name, initialProperties.get(name));
-                }
-            }
-        }
-
-        if (!sources.isEmpty()) {
-            // sources are ordered according to {@link org.apache.camel.support.OrderComparator} so
-            // it is needed to iterate them in reverse order otherwise lower priority sources may
-            // override properties from higher priority ones
-            for (int i = sources.size(); i-- > 0;) {
-                PropertiesSource ps = sources.get(i);
-                if (ps instanceof LoadablePropertiesSource) {
-                    LoadablePropertiesSource lps = (LoadablePropertiesSource) ps;
-                    Properties p = lps.loadProperties(filter);
-                    if (p instanceof OrderedLocationProperties) {
-                        prop.putAll((OrderedLocationProperties) p);
-                    } else if (ps instanceof LocationPropertiesSource) {
-                        String loc = ((LocationPropertiesSource) ps).getLocation().getPath();
-                        prop.putAll(loc, p);
-                    } else {
-                        prop.putAll(lps.getName(), p);
-                    }
-                }
-            }
-        }
-
-        // use override properties
-        if (overrideProperties != null) {
-            for (String name : overrideProperties.stringPropertyNames()) {
-                if (filter.test(name)) {
-                    prop.put("override", name, overrideProperties.get(name));
-                }
-            }
-        }
-
-        return prop;
+        return loadProperties(filter, k -> k);
     }
 
     @Override
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index c68bdae82e0..5df6f627f20 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -40,6 +40,7 @@ import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.AntPathMatcher;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StringHelper;
 import picocli.CommandLine.Command;
 import picocli.CommandLine.Option;
 import picocli.CommandLine.Parameters;
@@ -97,6 +98,9 @@ class Run implements Callable<Integer> {
             description = "Load properties file for route placeholders (ex. /path/to/file.properties")
     private String propertiesFiles;
 
+    @Option(names = { "-p", "--prop", "--property" }, description = "Additional properties (override existing)", arity = "0")
+    private String[] property;
+
     @Option(names = { "--file-lock" }, defaultValue = "true",
             description = "Whether to create a temporary file lock, which upon deleting triggers this process to terminate")
     private boolean fileLock = true;
@@ -180,6 +184,17 @@ class Run implements Callable<Integer> {
         main.addInitialProperty("camel.main.tracing", trace ? "true" : "false");
         main.addInitialProperty("camel.main.modeline", modeline ? "true" : "false");
 
+        // override properties as arguments
+        if (property != null) {
+            for (String p : property) {
+                String k = StringHelper.before(p, "=");
+                String v = StringHelper.after(p, "=");
+                if (k != null && v != null) {
+                    main.addOverrideProperty(k, v);
+                }
+            }
+        }
+
         if (maxMessages > 0) {
             main.addInitialProperty("camel.main.durationMaxMessages", String.valueOf(maxMessages));
         }
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/java.tmpl b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/java.tmpl
index 47b14123e12..722e7fc0fe6 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/java.tmpl
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/java.tmpl
@@ -1,4 +1,4 @@
-// camel-k: language=java
+// camel-k: language=java property=time=1000
 
 import org.apache.camel.builder.RouteBuilder;
 
@@ -8,7 +8,7 @@ public class {{ .Name }} extends RouteBuilder {
     public void configure() throws Exception {
 
         // Write your routes here, for example:
-        from("timer:java?period=1000").routeId("java")
+        from("timer:java?period={{time}}").routeId("java")
             .setBody()
                 .simple("Hello Camel from ${routeId}")
             .log("${body}");
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/xml.tmpl b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/xml.tmpl
index 4287489e30a..290384f2898 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/xml.tmpl
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/xml.tmpl
@@ -9,7 +9,7 @@
 
 	<!-- Write your routes here, for example: -->
     <route id="xml">
-        <from uri="timer:xml?period=1000"/>
+        <from uri="timer:xml?period={{time:1000}}"/>
         <setBody>
             <simple>Hello Camel from ${routeId}</simple>
         </setBody>