You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2021/02/26 10:08:52 UTC
[camel] 04/09: CAMEL-12545: create a yaml based route loader (add
support for auto generated SagaOptionDefinition)
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit e840b4d2b8ad221244db11c6b6e4ca7c4c86ab0a
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Thu Feb 25 15:43:06 2021 +0100
CAMEL-12545: create a yaml based route loader (add support for auto generated SagaOptionDefinition)
---
.../apache/camel/model/SagaOptionDefinition.java | 12 +-
.../camel-yaml-dsl-deserializers/pom.xml | 3 +
.../dsl/yaml/deserializers/ModelDeserializers.java | 133 ++++++++++++++-------
.../deserializers/ModelDeserializersResolver.java | 1 +
.../dsl/yaml/deserializers/CustomResolver.java | 2 -
.../SagaOptionDefinitionDeserializer.java | 72 -----------
.../maven/dsl/yaml/GenerateYamlSupportMojo.java | 25 ++--
.../src/generated/resources/camel-yaml-dsl.json | 109 +++++++++++------
8 files changed, 199 insertions(+), 158 deletions(-)
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/SagaOptionDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/SagaOptionDefinition.java
index cf32a56..31cbe77 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/SagaOptionDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/SagaOptionDefinition.java
@@ -30,7 +30,7 @@ import org.apache.camel.spi.Metadata;
*/
@Metadata(label = "eip,routing")
@XmlAccessorType(XmlAccessType.FIELD)
-public class SagaOptionDefinition {
+public class SagaOptionDefinition implements HasExpressionType {
@XmlAttribute(required = true)
private String optionName;
@@ -73,4 +73,14 @@ public class SagaOptionDefinition {
public void setExpression(ExpressionDefinition expression) {
this.expression = expression;
}
+
+ @Override
+ public ExpressionDefinition getExpressionType() {
+ return getExpression();
+ }
+
+ @Override
+ public void setExpressionType(ExpressionDefinition expressionType) {
+ setExpression(expressionType);
+ }
}
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/pom.xml b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/pom.xml
index 9abcfd7..320bfac 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/pom.xml
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/pom.xml
@@ -130,6 +130,9 @@
<bannedDefinition>org.apache.camel.model.ExpressionSubElementDefinition</bannedDefinition>
<bannedDefinition>org.apache.camel.model.PropertyDefinitions</bannedDefinition>
</bannedDefinitions>
+ <additionalDefinitions>
+ <additionalDefinition>org.apache.camel.model.SagaOptionDefinition</additionalDefinition>
+ </additionalDefinitions>
</configuration>
</execution>
</executions>
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 07a3a14..5310e35 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
@@ -71,6 +71,7 @@ import org.apache.camel.model.RouteTemplatesDefinition;
import org.apache.camel.model.RoutesDefinition;
import org.apache.camel.model.RoutingSlipDefinition;
import org.apache.camel.model.SagaDefinition;
+import org.apache.camel.model.SagaOptionDefinition;
import org.apache.camel.model.SamplingDefinition;
import org.apache.camel.model.ScriptDefinition;
import org.apache.camel.model.SetBodyDefinition;
@@ -557,7 +558,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
nodes = "avro",
properties = {
@YamlProperty(name = "id", type = "string"),
- @YamlProperty(name = "instance-class-name", type = "string")
+ @YamlProperty(name = "instance-class-name", type = "string", required = true)
}
)
public static class AvroDataFormatDeserializer extends YamlDeserializerBase<AvroDataFormat> {
@@ -850,8 +851,8 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
@YamlProperty(name = "ignore-invalid-records", type = "boolean"),
@YamlProperty(name = "ignore-unexpected-records", type = "boolean"),
@YamlProperty(name = "ignore-unidentified-records", type = "boolean"),
- @YamlProperty(name = "mapping", type = "string"),
- @YamlProperty(name = "stream-name", type = "string"),
+ @YamlProperty(name = "mapping", type = "string", required = true),
+ @YamlProperty(name = "stream-name", type = "string", required = true),
@YamlProperty(name = "unmarshal-single-object", type = "boolean")
}
)
@@ -1481,7 +1482,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
@YamlProperty(name = "filter", type = "string"),
@YamlProperty(name = "inherit-error-handler", type = "boolean"),
@YamlProperty(name = "key", type = "string"),
- @YamlProperty(name = "operation", type = "string")
+ @YamlProperty(name = "operation", type = "string", required = true)
}
)
public static class ClaimCheckDefinitionDeserializer extends YamlDeserializerBase<ClaimCheckDefinition> {
@@ -1950,7 +1951,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
properties = {
@YamlProperty(name = "charset", type = "string"),
@YamlProperty(name = "inherit-error-handler", type = "boolean"),
- @YamlProperty(name = "type", type = "string")
+ @YamlProperty(name = "type", type = "string", required = true)
}
)
public static class ConvertBodyDefinitionDeserializer extends YamlDeserializerBase<ConvertBodyDefinition> {
@@ -2300,7 +2301,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
nodes = "custom-data-format",
properties = {
@YamlProperty(name = "id", type = "string"),
- @YamlProperty(name = "ref", type = "string")
+ @YamlProperty(name = "ref", type = "string", required = true)
}
)
public static class CustomDataFormatDeserializer extends YamlDeserializerBase<CustomDataFormat> {
@@ -2347,7 +2348,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
nodes = "custom-load-balancer",
properties = {
@YamlProperty(name = "id", type = "string"),
- @YamlProperty(name = "ref", type = "string")
+ @YamlProperty(name = "ref", type = "string", required = true)
}
)
public static class CustomLoadBalancerDefinitionDeserializer extends YamlDeserializerBase<CustomLoadBalancerDefinition> {
@@ -4931,8 +4932,8 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
nodes = "global-option",
properties = {
- @YamlProperty(name = "key", type = "string"),
- @YamlProperty(name = "value", type = "string")
+ @YamlProperty(name = "key", type = "string", required = true),
+ @YamlProperty(name = "value", type = "string", required = true)
}
)
public static class GlobalOptionDefinitionDeserializer extends YamlDeserializerBase<GlobalOptionDefinition> {
@@ -5009,7 +5010,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
@YamlProperty(name = "flattened", type = "boolean"),
@YamlProperty(name = "id", type = "string"),
@YamlProperty(name = "named-only", type = "boolean"),
- @YamlProperty(name = "pattern", type = "string")
+ @YamlProperty(name = "pattern", type = "string", required = true)
}
)
public static class GrokDataFormatDeserializer extends YamlDeserializerBase<GrokDataFormat> {
@@ -5780,7 +5781,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
@YamlProperty(name = "eager", type = "boolean"),
@YamlProperty(name = "expression", type = "object:org.apache.camel.model.language.ExpressionDefinition"),
@YamlProperty(name = "inherit-error-handler", type = "boolean"),
- @YamlProperty(name = "message-id-repository-ref", type = "string"),
+ @YamlProperty(name = "message-id-repository-ref", type = "string", required = true),
@YamlProperty(name = "remove-on-failure", type = "boolean"),
@YamlProperty(name = "skip-duplicate", type = "boolean"),
@YamlProperty(name = "steps", type = "array:org.apache.camel.model.ProcessorDefinition"),
@@ -6099,7 +6100,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
@YamlProperty(name = "after-uri", type = "string"),
@YamlProperty(name = "inherit-error-handler", type = "boolean"),
@YamlProperty(name = "skip-send-to-original-endpoint", type = "string"),
- @YamlProperty(name = "uri", type = "string"),
+ @YamlProperty(name = "uri", type = "string", required = true),
@YamlProperty(name = "steps", type = "array:org.apache.camel.model.ProcessorDefinition")
}
)
@@ -6287,7 +6288,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
nodes = "jaxb",
properties = {
@YamlProperty(name = "content-type-header", type = "boolean"),
- @YamlProperty(name = "context-path", type = "string"),
+ @YamlProperty(name = "context-path", type = "string", required = true),
@YamlProperty(name = "context-path-is-class-name", type = "boolean"),
@YamlProperty(name = "encoding", type = "string"),
@YamlProperty(name = "filter-non-xml-chars", type = "boolean"),
@@ -7017,7 +7018,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
properties = {
@YamlProperty(name = "expression", type = "string", required = true),
@YamlProperty(name = "id", type = "string"),
- @YamlProperty(name = "language", type = "string"),
+ @YamlProperty(name = "language", type = "string", required = true),
@YamlProperty(name = "trim", type = "boolean")
}
)
@@ -7204,7 +7205,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
@YamlProperty(name = "logger-ref", type = "string"),
@YamlProperty(name = "logging-level", type = "string"),
@YamlProperty(name = "marker", type = "string"),
- @YamlProperty(name = "message", type = "string")
+ @YamlProperty(name = "message", type = "string", required = true)
}
)
public static class LogDefinitionDeserializer extends YamlDeserializerBase<LogDefinition> {
@@ -8843,7 +8844,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
nodes = "policy",
properties = {
@YamlProperty(name = "inherit-error-handler", type = "boolean"),
- @YamlProperty(name = "ref", type = "string"),
+ @YamlProperty(name = "ref", type = "string", required = true),
@YamlProperty(name = "steps", type = "array:org.apache.camel.model.ProcessorDefinition")
}
)
@@ -9173,7 +9174,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
nodes = "process",
properties = {
@YamlProperty(name = "inherit-error-handler", type = "boolean"),
- @YamlProperty(name = "ref", type = "string")
+ @YamlProperty(name = "ref", type = "string", required = true)
}
)
public static class ProcessDefinitionDeserializer extends YamlDeserializerBase<ProcessDefinition> {
@@ -9213,8 +9214,8 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
nodes = "property",
properties = {
- @YamlProperty(name = "key", type = "string"),
- @YamlProperty(name = "value", type = "string")
+ @YamlProperty(name = "key", type = "string", required = true),
+ @YamlProperty(name = "value", type = "string", required = true)
}
)
public static class PropertyDefinitionDeserializer extends YamlDeserializerBase<PropertyDefinition> {
@@ -9872,7 +9873,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
nodes = "remove-header",
properties = {
- @YamlProperty(name = "header-name", type = "string"),
+ @YamlProperty(name = "header-name", type = "string", required = true),
@YamlProperty(name = "inherit-error-handler", type = "boolean")
}
)
@@ -9921,7 +9922,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
properties = {
@YamlProperty(name = "exclude-pattern", type = "string"),
@YamlProperty(name = "inherit-error-handler", type = "boolean"),
- @YamlProperty(name = "pattern", type = "string")
+ @YamlProperty(name = "pattern", type = "string", required = true)
}
)
public static class RemoveHeadersDefinitionDeserializer extends YamlDeserializerBase<RemoveHeadersDefinition> {
@@ -9974,7 +9975,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
properties = {
@YamlProperty(name = "exclude-pattern", type = "string"),
@YamlProperty(name = "inherit-error-handler", type = "boolean"),
- @YamlProperty(name = "pattern", type = "string")
+ @YamlProperty(name = "pattern", type = "string", required = true)
}
)
public static class RemovePropertiesDefinitionDeserializer extends YamlDeserializerBase<RemovePropertiesDefinition> {
@@ -10026,7 +10027,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
nodes = "remove-property",
properties = {
@YamlProperty(name = "inherit-error-handler", type = "boolean"),
- @YamlProperty(name = "property-name", type = "string")
+ @YamlProperty(name = "property-name", type = "string", required = true)
}
)
public static class RemovePropertyDefinitionDeserializer extends YamlDeserializerBase<RemovePropertyDefinition> {
@@ -10530,7 +10531,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
types = org.apache.camel.model.RestContextRefDefinition.class,
order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
nodes = "rest-context-ref",
- properties = @YamlProperty(name = "ref", type = "string")
+ properties = @YamlProperty(name = "ref", type = "string", required = true)
)
public static class RestContextRefDefinitionDeserializer extends YamlDeserializerBase<RestContextRefDefinition> {
public RestContextRefDefinitionDeserializer() {
@@ -10668,9 +10669,9 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
@YamlProperty(name = "default-value", type = "string"),
@YamlProperty(name = "description", type = "string"),
@YamlProperty(name = "examples", type = "array:org.apache.camel.model.rest.RestPropertyDefinition"),
- @YamlProperty(name = "name", type = "string"),
+ @YamlProperty(name = "name", type = "string", required = true),
@YamlProperty(name = "required", type = "boolean"),
- @YamlProperty(name = "type", type = "enum:body,formData,header,path,query")
+ @YamlProperty(name = "type", type = "enum:body,formData,header,path,query", required = true)
}
)
public static class RestOperationParamDefinitionDeserializer extends YamlDeserializerBase<RestOperationParamDefinition> {
@@ -10760,7 +10761,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
@YamlProperty(name = "data-type", type = "string"),
@YamlProperty(name = "description", type = "string"),
@YamlProperty(name = "example", type = "string"),
- @YamlProperty(name = "name", type = "string")
+ @YamlProperty(name = "name", type = "string", required = true)
}
)
public static class RestOperationResponseHeaderDefinitionDeserializer extends YamlDeserializerBase<RestOperationResponseHeaderDefinition> {
@@ -10832,7 +10833,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
@YamlProperty(name = "code", type = "string"),
@YamlProperty(name = "examples", type = "array:org.apache.camel.model.rest.RestPropertyDefinition"),
@YamlProperty(name = "header", type = "array:org.apache.camel.model.rest.RestOperationResponseHeaderDefinition"),
- @YamlProperty(name = "message", type = "string"),
+ @YamlProperty(name = "message", type = "string", required = true),
@YamlProperty(name = "response-model", type = "string")
}
)
@@ -10888,8 +10889,8 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
nodes = "rest-property",
properties = {
- @YamlProperty(name = "key", type = "string"),
- @YamlProperty(name = "value", type = "string")
+ @YamlProperty(name = "key", type = "string", required = true),
+ @YamlProperty(name = "value", type = "string", required = true)
}
)
public static class RestPropertyDefinitionDeserializer extends YamlDeserializerBase<RestPropertyDefinition> {
@@ -11353,7 +11354,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
nodes = "route-builder",
properties = {
@YamlProperty(name = "id", type = "string"),
- @YamlProperty(name = "ref", type = "string")
+ @YamlProperty(name = "ref", type = "string", required = true)
}
)
public static class RouteBuilderDefinitionDeserializer extends YamlDeserializerBase<RouteBuilderDefinition> {
@@ -11397,7 +11398,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
types = org.apache.camel.model.RouteContextRefDefinition.class,
order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
nodes = "route-context-ref",
- properties = @YamlProperty(name = "ref", type = "string")
+ properties = @YamlProperty(name = "ref", type = "string", required = true)
)
public static class RouteContextRefDefinitionDeserializer extends YamlDeserializerBase<RouteContextRefDefinition> {
public RouteContextRefDefinitionDeserializer() {
@@ -11478,7 +11479,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
types = org.apache.camel.model.RouteTemplateContextRefDefinition.class,
order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
nodes = "route-template-context-ref",
- properties = @YamlProperty(name = "ref", type = "string")
+ properties = @YamlProperty(name = "ref", type = "string", required = true)
)
public static class RouteTemplateContextRefDefinitionDeserializer extends YamlDeserializerBase<RouteTemplateContextRefDefinition> {
public RouteTemplateContextRefDefinitionDeserializer() {
@@ -11555,7 +11556,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
properties = {
@YamlProperty(name = "default-value", type = "string"),
@YamlProperty(name = "description", type = "string"),
- @YamlProperty(name = "name", type = "string")
+ @YamlProperty(name = "name", type = "string", required = true)
}
)
public static class RouteTemplateParameterDefinitionDeserializer extends YamlDeserializerBase<RouteTemplateParameterDefinition> {
@@ -11860,6 +11861,56 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
}
@YamlType(
+ types = org.apache.camel.model.SagaOptionDefinition.class,
+ order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
+ properties = {
+ @YamlProperty(name = "expression", type = "object:org.apache.camel.model.language.ExpressionDefinition"),
+ @YamlProperty(name = "option-name", type = "string", required = true),
+ @YamlProperty(name = "__extends", type = "object:org.apache.camel.model.language.ExpressionDefinition")
+ }
+ )
+ public static class SagaOptionDefinitionDeserializer extends YamlDeserializerBase<SagaOptionDefinition> {
+ public SagaOptionDefinitionDeserializer() {
+ super(SagaOptionDefinition.class);
+ }
+
+ @Override
+ protected SagaOptionDefinition newInstance() {
+ return new SagaOptionDefinition();
+ }
+
+ @Override
+ protected boolean setProperty(SagaOptionDefinition target, String propertyKey,
+ String propertyName, Node node) {
+ switch(propertyKey) {
+ case "expression": {
+ org.apache.camel.model.language.ExpressionDefinition val = asType(node, org.apache.camel.model.language.ExpressionDefinition.class);
+ target.setExpression(val);
+ break;
+ }
+ case "option-name": {
+ String val = asText(node);
+ target.setOptionName(val);
+ break;
+ }
+ default: {
+ ExpressionDefinition ed = target.getExpressionType();
+ if (ed != null) {
+ throw new org.apache.camel.dsl.yaml.common.exception.UnsupportedFieldException(propertyName, "an expression has already been configured (" + ed + ")");
+ }
+ ed = ExpressionDeserializers.constructExpressionType(propertyKey, node);
+ if (ed != null) {
+ target.setExpressionType(ed);
+ } else {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ }
+
+ @YamlType(
types = org.apache.camel.model.SamplingDefinition.class,
order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
nodes = "sample",
@@ -12738,7 +12789,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
properties = {
@YamlProperty(name = "expression", type = "object:org.apache.camel.model.language.ExpressionDefinition"),
@YamlProperty(name = "inherit-error-handler", type = "boolean"),
- @YamlProperty(name = "name", type = "string"),
+ @YamlProperty(name = "name", type = "string", required = true),
@YamlProperty(name = "__extends", type = "object:org.apache.camel.model.language.ExpressionDefinition")
}
)
@@ -12795,7 +12846,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
properties = {
@YamlProperty(name = "expression", type = "object:org.apache.camel.model.language.ExpressionDefinition"),
@YamlProperty(name = "inherit-error-handler", type = "boolean"),
- @YamlProperty(name = "name", type = "string"),
+ @YamlProperty(name = "name", type = "string", required = true),
@YamlProperty(name = "__extends", type = "object:org.apache.camel.model.language.ExpressionDefinition")
}
)
@@ -12919,7 +12970,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
nodes = "soapjaxb",
properties = {
- @YamlProperty(name = "context-path", type = "string"),
+ @YamlProperty(name = "context-path", type = "string", required = true),
@YamlProperty(name = "element-name-strategy-ref", type = "string"),
@YamlProperty(name = "encoding", type = "string"),
@YamlProperty(name = "id", type = "string"),
@@ -14076,7 +14127,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
@YamlProperty(name = "inherit-namespace-tag-name", type = "string"),
@YamlProperty(name = "regex", type = "boolean"),
@YamlProperty(name = "skip-first", type = "boolean"),
- @YamlProperty(name = "token", type = "string"),
+ @YamlProperty(name = "token", type = "string", required = true),
@YamlProperty(name = "trim", type = "boolean"),
@YamlProperty(name = "xml", type = "boolean")
}
@@ -15427,7 +15478,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
nodes = "weighted",
properties = {
- @YamlProperty(name = "distribution-ratio", type = "string"),
+ @YamlProperty(name = "distribution-ratio", type = "string", required = true),
@YamlProperty(name = "distribution-ratio-delimiter", type = "string"),
@YamlProperty(name = "id", type = "string"),
@YamlProperty(name = "round-robin", type = "string")
@@ -16481,11 +16532,11 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1,
nodes = "zookeeper-service-discovery",
properties = {
- @YamlProperty(name = "base-path", type = "string"),
+ @YamlProperty(name = "base-path", type = "string", required = true),
@YamlProperty(name = "connection-timeout", type = "string"),
@YamlProperty(name = "id", type = "string"),
@YamlProperty(name = "namespace", type = "string"),
- @YamlProperty(name = "nodes", type = "string"),
+ @YamlProperty(name = "nodes", type = "string", required = true),
@YamlProperty(name = "properties", type = "array:org.apache.camel.model.PropertyDefinition"),
@YamlProperty(name = "reconnect-base-sleep-time", type = "string"),
@YamlProperty(name = "reconnect-max-retries", type = "string"),
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializersResolver.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializersResolver.java
index 1ddeaa2..1cc0e16 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializersResolver.java
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializersResolver.java
@@ -304,6 +304,7 @@ public final class ModelDeserializersResolver implements YamlDeserializerResolve
case "org.apache.camel.model.dataformat.RssDataFormat": return new ModelDeserializers.RssDataFormatDeserializer();
case "saga": return new ModelDeserializers.SagaDefinitionDeserializer();
case "org.apache.camel.model.SagaDefinition": return new ModelDeserializers.SagaDefinitionDeserializer();
+ case "org.apache.camel.model.SagaOptionDefinition": return new ModelDeserializers.SagaOptionDefinitionDeserializer();
case "sample": return new ModelDeserializers.SamplingDefinitionDeserializer();
case "org.apache.camel.model.SamplingDefinition": return new ModelDeserializers.SamplingDefinitionDeserializer();
case "script": return new ModelDeserializers.ScriptDefinitionDeserializer();
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/CustomResolver.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/CustomResolver.java
index 20d77a0..d5aa2e6 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/CustomResolver.java
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/CustomResolver.java
@@ -58,8 +58,6 @@ public class CustomResolver implements YamlDeserializerResolver {
return new TryDefinitionDeserializer();
case "org.apache.camel.model.SagaActionUriDefinition":
return new SagaActionUriDefinitionDeserializer();
- case "org.apache.camel.model.SagaOptionDefinition":
- return new SagaOptionDefinitionDeserializer();
case "org.apache.camel.model.ProcessorDefinition":
return new ProcessorDefinitionDefinitionDeserializer();
case "to":
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/SagaOptionDefinitionDeserializer.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/SagaOptionDefinitionDeserializer.java
deleted file mode 100644
index 8448807..0000000
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/SagaOptionDefinitionDeserializer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.dsl.yaml.deserializers;
-
-import org.apache.camel.dsl.yaml.common.YamlDeserializerBase;
-import org.apache.camel.dsl.yaml.common.YamlDeserializerResolver;
-import org.apache.camel.model.SagaOptionDefinition;
-import org.apache.camel.model.language.ExpressionDefinition;
-import org.apache.camel.spi.annotations.YamlProperty;
-import org.apache.camel.spi.annotations.YamlType;
-import org.snakeyaml.engine.v2.nodes.Node;
-
-@YamlType(
- types = SagaOptionDefinition.class,
- order = YamlDeserializerResolver.ORDER_DEFAULT,
- properties = {
- @YamlProperty(name = "__extends", type = "ref:org.apache.camel.model.language.ExpressionDefinition"),
- @YamlProperty(name = "option-name", type = "string", required = true)
- })
-public class SagaOptionDefinitionDeserializer extends YamlDeserializerBase<SagaOptionDefinition> {
- public SagaOptionDefinitionDeserializer() {
- super(SagaOptionDefinition.class);
- }
-
- @Override
- protected SagaOptionDefinition newInstance() {
- return new SagaOptionDefinition();
- }
-
- @Override
- protected boolean setProperty(SagaOptionDefinition target, String propertyKey, String propertyName, Node value) {
- switch (propertyKey) {
- case "option-name":
- target.setOptionName(asText(value));
- break;
- case "expression":
- ExpressionDefinition ed = ExpressionDeserializers.constructExpressionType(value);
- if (ed != null) {
- target.setExpression(ed);
- }
- break;
- default:
- return false;
- }
-
- return true;
- }
-
- @Override
- protected void handleUnknownProperty(SagaOptionDefinition target, String propertyKey, String propertyName, Node node) {
- ExpressionDefinition ed = ExpressionDeserializers.constructExpressionType(propertyKey, node);
- if (ed != null) {
- target.setExpression(ed);
- } else {
- super.handleUnknownProperty(target, propertyKey, propertyName, node);
- }
- }
-}
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 b164130..33185c0 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
@@ -133,6 +133,8 @@ public abstract class GenerateYamlSupportMojo extends AbstractMojo {
protected MavenProject project;
@Parameter
protected List<String> bannedDefinitions;
+ @Parameter
+ protected List<String> additionalDefinitions;
@Override
public void execute() throws MojoFailureException {
@@ -307,12 +309,18 @@ public abstract class GenerateYamlSupportMojo extends AbstractMojo {
}
protected Stream<ClassInfo> all() {
- return Stream.of(XML_ROOT_ELEMENT_ANNOTATION_CLASS, XML_TYPE_CLASS)
- .map(view::getAnnotations)
- .flatMap(Collection::stream)
- .map(AnnotationInstance::target)
- .filter(at -> at.kind() == AnnotationTarget.Kind.CLASS)
- .map(AnnotationTarget::asClass)
+ Stream<ClassInfo> discovered = Stream.of(XML_ROOT_ELEMENT_ANNOTATION_CLASS, XML_TYPE_CLASS)
+ .map(view::getAnnotations)
+ .flatMap(Collection::stream)
+ .map(AnnotationInstance::target)
+ .filter(at -> at.kind() == AnnotationTarget.Kind.CLASS)
+ .map(AnnotationTarget::asClass);
+
+ Stream<ClassInfo> additional = additionalDefinitions != null
+ ? additionalDefinitions.stream().map(DotName::createSimple).map(view::getClassByName)
+ : Stream.empty();
+
+ return Stream.concat(discovered, additional)
.filter(ci -> (ci.flags() & Modifier.ABSTRACT) == 0)
.filter(ci -> !isBanned(ci))
.filter(ci -> !ci.isEnum())
@@ -515,7 +523,10 @@ public abstract class GenerateYamlSupportMojo extends AbstractMojo {
annotationValue(fi, METADATA_ANNOTATION_CLASS, "required")
.map(AnnotationValue::asBoolean),
annotationValue(fi, XML_VALUE_ANNOTATION_CLASS, "required")
- .map(AnnotationValue::asBoolean)).orElse(false);
+ .map(AnnotationValue::asBoolean),
+ annotationValue(fi, XML_ATTRIBUTE_ANNOTATION_CLASS, "required")
+ .map(AnnotationValue::asBoolean))
+ .orElse(false);
}
protected boolean extendsType(ClassInfo ci, DotName superType) {
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json
index 4a59104..4555f0c 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json
@@ -443,7 +443,8 @@
"strategy-ref" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "operation" ]
},
"org.apache.camel.model.ContextScanDefinition" : {
"type" : "object",
@@ -481,7 +482,8 @@
"type" : "string"
}
}
- } ]
+ } ],
+ "required" : [ "type" ]
},
"org.apache.camel.model.DataFormatDefinition" : {
"type" : "object",
@@ -757,7 +759,8 @@
"value" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "key", "value" ]
},
"org.apache.camel.model.GlobalOptionsDefinition" : {
"type" : "object",
@@ -904,7 +907,8 @@
"$ref" : "#/items/definitions/org.apache.camel.model.ProcessorDefinition"
}
}
- }
+ },
+ "required" : [ "message-id-repository-ref" ]
},
"org.apache.camel.model.InOnlyDefinition" : {
"oneOf" : [ {
@@ -1010,7 +1014,8 @@
"type" : "string"
}
}
- } ]
+ } ],
+ "required" : [ "uri" ]
},
"org.apache.camel.model.LoadBalanceDefinition" : {
"type" : "object",
@@ -1080,7 +1085,8 @@
"type" : "string"
}
}
- } ]
+ } ],
+ "required" : [ "message" ]
},
"org.apache.camel.model.LoopDefinition" : {
"type" : "object",
@@ -1506,7 +1512,8 @@
"$ref" : "#/items/definitions/org.apache.camel.model.ProcessorDefinition"
}
}
- }
+ },
+ "required" : [ "ref" ]
},
"org.apache.camel.model.PollEnrichDefinition" : {
"type" : "object",
@@ -1552,7 +1559,8 @@
"ref" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "ref" ]
},
"org.apache.camel.model.PropertyDefinition" : {
"type" : "object",
@@ -1563,7 +1571,8 @@
"value" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "key", "value" ]
},
"org.apache.camel.model.RecipientListDefinition" : {
"type" : "object",
@@ -1714,7 +1723,8 @@
"type" : "boolean"
}
}
- } ]
+ } ],
+ "required" : [ "header-name" ]
},
"org.apache.camel.model.RemoveHeadersDefinition" : {
"oneOf" : [ {
@@ -1732,7 +1742,8 @@
"type" : "string"
}
}
- } ]
+ } ],
+ "required" : [ "pattern" ]
},
"org.apache.camel.model.RemovePropertiesDefinition" : {
"oneOf" : [ {
@@ -1750,7 +1761,8 @@
"type" : "string"
}
}
- } ]
+ } ],
+ "required" : [ "pattern" ]
},
"org.apache.camel.model.RemovePropertyDefinition" : {
"oneOf" : [ {
@@ -1765,7 +1777,8 @@
"type" : "string"
}
}
- } ]
+ } ],
+ "required" : [ "property-name" ]
},
"org.apache.camel.model.ResequenceDefinition" : {
"type" : "object",
@@ -1844,7 +1857,8 @@
"ref" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "ref" ]
},
"org.apache.camel.model.RollbackDefinition" : {
"oneOf" : [ {
@@ -1880,7 +1894,8 @@
"type" : "string"
}
}
- } ]
+ } ],
+ "required" : [ "ref" ]
},
"org.apache.camel.model.RouteContextRefDefinition" : {
"type" : "object",
@@ -1888,7 +1903,8 @@
"ref" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "ref" ]
},
"org.apache.camel.model.RouteDefinition" : {
"type" : "object",
@@ -1917,7 +1933,8 @@
"ref" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "ref" ]
},
"org.apache.camel.model.RouteTemplateDefinition" : {
"type" : "object",
@@ -1945,7 +1962,8 @@
"name" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "name" ]
},
"org.apache.camel.model.RouteTemplatesDefinition" : {
"type" : "object",
@@ -2048,7 +2066,13 @@
},
"org.apache.camel.model.SagaOptionDefinition" : {
"type" : "object",
+ "anyOf" : [ {
+ "$ref" : "#/items/definitions/org.apache.camel.model.language.ExpressionDefinition"
+ } ],
"properties" : {
+ "expression" : {
+ "$ref" : "#/items/definitions/org.apache.camel.model.language.ExpressionDefinition"
+ },
"option-name" : {
"type" : "string"
}
@@ -2131,7 +2155,8 @@
"name" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "name" ]
},
"org.apache.camel.model.SetPropertyDefinition" : {
"type" : "object",
@@ -2148,7 +2173,8 @@
"name" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "name" ]
},
"org.apache.camel.model.SortDefinition" : {
"type" : "object",
@@ -3369,7 +3395,8 @@
"session-timeout" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "base-path", "nodes" ]
},
"org.apache.camel.model.config.BatchResequencerConfig" : {
"type" : "object",
@@ -3475,7 +3502,8 @@
"type" : "string"
}
}
- } ]
+ } ],
+ "required" : [ "instance-class-name" ]
},
"org.apache.camel.model.dataformat.BarcodeDataFormat" : {
"type" : "object",
@@ -3544,7 +3572,8 @@
"unmarshal-single-object" : {
"type" : "boolean"
}
- }
+ },
+ "required" : [ "mapping", "stream-name" ]
},
"org.apache.camel.model.dataformat.BindyDataFormat" : {
"type" : "object",
@@ -3755,7 +3784,8 @@
"type" : "string"
}
}
- } ]
+ } ],
+ "required" : [ "ref" ]
},
"org.apache.camel.model.dataformat.DataFormatsDefinition" : {
"type" : "object",
@@ -4047,7 +4077,8 @@
"pattern" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "pattern" ]
},
"org.apache.camel.model.dataformat.GzipDataFormat" : {
"type" : "object",
@@ -4195,7 +4226,8 @@
"xml-stream-writer-wrapper" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "context-path" ]
},
"org.apache.camel.model.dataformat.JsonApiDataFormat" : {
"type" : "object",
@@ -4418,7 +4450,8 @@
"type" : "string"
}
}
- } ]
+ } ],
+ "required" : [ "context-path" ]
},
"org.apache.camel.model.dataformat.SyslogDataFormat" : {
"type" : "object",
@@ -5173,7 +5206,7 @@
"type" : "boolean"
}
},
- "required" : [ "expression" ]
+ "required" : [ "expression", "language" ]
},
"org.apache.camel.model.language.MethodCallExpression" : {
"oneOf" : [ {
@@ -5351,7 +5384,7 @@
}
}
} ],
- "required" : [ "expression" ]
+ "required" : [ "expression", "token" ]
},
"org.apache.camel.model.language.XMLTokenizerExpression" : {
"oneOf" : [ {
@@ -5468,7 +5501,8 @@
"type" : "string"
}
}
- } ]
+ } ],
+ "required" : [ "ref" ]
},
"org.apache.camel.model.loadbalancer.FailoverLoadBalancerDefinition" : {
"type" : "object",
@@ -5543,7 +5577,8 @@
"round-robin" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "distribution-ratio" ]
},
"org.apache.camel.model.rest.DeleteVerbDefinition" : {
"type" : "object",
@@ -6215,7 +6250,8 @@
"type" : "string"
}
}
- }
+ },
+ "required" : [ "name", "type" ]
},
"org.apache.camel.model.rest.RestOperationResponseHeaderDefinition" : {
"type" : "object",
@@ -6248,7 +6284,8 @@
"type" : "string"
}
}
- }
+ },
+ "required" : [ "name" ]
},
"org.apache.camel.model.rest.RestOperationResponseMsgDefinition" : {
"type" : "object",
@@ -6274,7 +6311,8 @@
"response-model" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "message" ]
},
"org.apache.camel.model.rest.RestPropertyDefinition" : {
"type" : "object",
@@ -6285,7 +6323,8 @@
"value" : {
"type" : "string"
}
- }
+ },
+ "required" : [ "key", "value" ]
},
"org.apache.camel.model.rest.RestSecuritiesDefinition" : {
"type" : "object",