This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 9f7ee94d94eb9ac5cf839a13075ff66b1b91d70e Author: Claus Ibsen <[email protected]> AuthorDate: Tue Dec 13 12:24:31 2022 +0100 CAMEL-18748: camel-yaml-dsl - error-handler should be aligned to camel-core-model to be consistent. --- .../dsl/yaml/deserializers/ModelDeserializers.java | 6 ++++++ .../ErrorHandlerBuilderDeserializer.java | 2 +- .../dsl/yaml/GenerateYamlDeserializersMojo.java | 4 +++- .../maven/dsl/yaml/GenerateYamlSupportMojo.java | 2 ++ .../generated/resources/schema/camel-yaml-dsl.json | 22 +++++++++++++--------- .../generated/resources/schema/camelYamlDsl.json | 22 +++++++++++++--------- .../apache/camel/dsl/yaml/ErrorHandlerTest.groovy | 16 +++++++++++++++- 7 files changed, 53 insertions(+), 21 deletions(-) diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java index c145a00e276..f57d04256ca 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java @@ -11605,6 +11605,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport { "ref-error-handler", "refErrorHandler" }, + inline = true, types = org.apache.camel.model.errorhandler.RefErrorHandlerDefinition.class, order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1, properties = { @@ -11622,6 +11623,11 @@ public final class ModelDeserializers extends YamlDeserializerSupport { return new RefErrorHandlerDefinition(); } + @Override + protected RefErrorHandlerDefinition newInstance(String value) { + return new RefErrorHandlerDefinition(value); + } + @Override protected boolean setProperty(RefErrorHandlerDefinition target, String propertyKey, String propertyName, Node node) { diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/ErrorHandlerBuilderDeserializer.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/ErrorHandlerBuilderDeserializer.java index cf4dd57040f..5162d6d2808 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/ErrorHandlerBuilderDeserializer.java +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/ErrorHandlerBuilderDeserializer.java @@ -58,7 +58,7 @@ import static org.apache.camel.dsl.yaml.common.YamlDeserializerSupport.setDeseri @YamlProperty(name = "no-error-handler", type = "object:org.apache.camel.model.errorhandler.NoErrorHandlerDefinition"), @YamlProperty(name = "ref-error-handler", - type = "object:org.apache.camel.model.errorhandler.ErrorHandlerRefDefinition"), + type = "object:org.apache.camel.model.errorhandler.RefErrorHandlerDefinition"), @YamlProperty(name = "spring-transaction-error-handler", type = "object:org.apache.camel.model.errorhandler.SpringTransactionErrorHandlerDefinition"), }) diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlDeserializersMojo.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlDeserializersMojo.java index 7540ff306f0..0759ffe4a24 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlDeserializersMojo.java +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlDeserializersMojo.java @@ -428,7 +428,9 @@ public class GenerateYamlDeserializersMojo extends GenerateYamlSupportMojo { for (MethodInfo ctor: info.constructors()) { // do not generate inline for error handlers (only ref error handler is allowed) - if (implementType(info, ERROR_HANDLER_DEFINITION_CLASS)) { + boolean eh = implementType(info, ERROR_HANDLER_DEFINITION_CLASS); + boolean ref = eh && implementType(info, REF_ERROR_HANDLER_DEFINITION_CLASS); + if (eh && !ref) { break; } diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlSupportMojo.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlSupportMojo.java index dd26b56ff68..d9f1b022c24 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlSupportMojo.java +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin/src/main/java/org/apache/camel/maven/dsl/yaml/GenerateYamlSupportMojo.java @@ -108,6 +108,8 @@ public abstract class GenerateYamlSupportMojo extends AbstractMojo { = DotName.createSimple("org.apache.camel.spi.IdAware"); public static final DotName ERROR_HANDLER_DEFINITION_CLASS = DotName.createSimple("org.apache.camel.model.errorhandler.BaseErrorHandlerDefinition"); + public static final DotName REF_ERROR_HANDLER_DEFINITION_CLASS + = DotName.createSimple("org.apache.camel.model.errorhandler.RefErrorHandlerDefinition"); public static final DotName YAML_TYPE_ANNOTATION = DotName.createSimple("org.apache.camel.spi.annotations.YamlType"); diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json index b467bb50431..50f00b2ce6e 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json @@ -323,7 +323,7 @@ "$ref" : "#/items/definitions/org.apache.camel.model.errorhandler.NoErrorHandlerDefinition" }, "ref-error-handler" : { - "$ref" : "#/items/definitions/org.apache.camel.model.errorhandler.ErrorHandlerRefDefinition" + "$ref" : "#/items/definitions/org.apache.camel.model.errorhandler.RefErrorHandlerDefinition" }, "spring-transaction-error-handler" : { "$ref" : "#/items/definitions/org.apache.camel.model.errorhandler.SpringTransactionErrorHandlerDefinition" @@ -6130,15 +6130,19 @@ } }, "org.apache.camel.model.errorhandler.RefErrorHandlerDefinition" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "string" - }, - "ref" : { - "type" : "string" + "oneOf" : [ { + "type" : "string" + }, { + "type" : "object", + "properties" : { + "id" : { + "type" : "string" + }, + "ref" : { + "type" : "string" + } } - }, + } ], "required" : [ "ref" ] }, "org.apache.camel.model.errorhandler.SpringTransactionErrorHandlerDefinition" : { diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json index a30cf7da4b7..9507a8dec6f 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json @@ -230,7 +230,7 @@ "$ref" : "#/items/definitions/org.apache.camel.model.errorhandler.NoErrorHandlerDefinition" }, "refErrorHandler" : { - "$ref" : "#/items/definitions/org.apache.camel.model.errorhandler.ErrorHandlerRefDefinition" + "$ref" : "#/items/definitions/org.apache.camel.model.errorhandler.RefErrorHandlerDefinition" }, "springTransactionErrorHandler" : { "$ref" : "#/items/definitions/org.apache.camel.model.errorhandler.SpringTransactionErrorHandlerDefinition" @@ -6034,15 +6034,19 @@ } }, "org.apache.camel.model.errorhandler.RefErrorHandlerDefinition" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "string" - }, - "ref" : { - "type" : "string" + "oneOf" : [ { + "type" : "string" + }, { + "type" : "object", + "properties" : { + "id" : { + "type" : "string" + }, + "ref" : { + "type" : "string" + } } - }, + } ], "required" : [ "ref" ] }, "org.apache.camel.model.errorhandler.SpringTransactionErrorHandlerDefinition" : { diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/ErrorHandlerTest.groovy b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/ErrorHandlerTest.groovy index 87d672f2ad5..b66d919020d 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/ErrorHandlerTest.groovy +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/ErrorHandlerTest.groovy @@ -72,11 +72,25 @@ class ErrorHandlerTest extends YamlTestSupport { when: context.start() then: - with(context.getErrorHandlerFactory(), ErrorHandlerRefDefinition) { + with(context.getErrorHandlerFactory(), RefErrorHandlerDefinition) { ref == 'myErrorHandler' } } + def "error-handler (ref inlined)"() { + setup: + loadRoutes """ + - error-handler: + ref-error-handler: "myErrorHandler" + """ + when: + context.start() + then: + with(context.getErrorHandlerFactory(), RefErrorHandlerDefinition) { + ref == 'myErrorHandler' + } + } + def "error-handler (dead-letter-channel)"() { setup: loadRoutes """
