From 66f94d64db5e0849547b20101834b5f2e257d8cb Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Thu, 21 May 2026 10:14:29 +0200 Subject: [PATCH 1/9] CAMEL-23596: camel-yaml-io - Add YamlPrinter for direct YAML serialization Add a lightweight YamlPrinter that serializes Map/Collection structures to block-style YAML text without any Jackson dependency. This is the foundation for replacing the hand-written YamlWriter with a generated direct YAML writer. Co-Authored-By: Claude --- .../org/apache/camel/yaml/io/YamlPrinter.java | 190 ++++++++++++++ .../apache/camel/yaml/io/YamlPrinterTest.java | 231 ++++++++++++++++++ 2 files changed, 421 insertions(+) create mode 100644 core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlPrinter.java create mode 100644 core/camel-yaml-io/src/test/java/org/apache/camel/yaml/io/YamlPrinterTest.java diff --git a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlPrinter.java b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlPrinter.java new file mode 100644 index 0000000000000..cfaf60b8c5af1 --- /dev/null +++ b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlPrinter.java @@ -0,0 +1,190 @@ +/* + * 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.yaml.io; + +import java.util.Collection; +import java.util.Map; +import java.util.regex.Pattern; + +/** + * Serializes {@link Map} / {@link Collection} structures (typically from Camel's {@code JsonObject} / + * {@code JsonArray}) to block-style YAML text. Produces a constrained YAML subset: no anchors, aliases, flow mappings, + * tags, or multi-document streams. + */ +public final class YamlPrinter { + + private static final String INDENT = " "; + private static final Pattern NUMBER_PATTERN = Pattern.compile("-?(0|[1-9]\\d*)(\\.\\d+)?([eE][+-]?\\d+)?"); + + private YamlPrinter() { + } + + public static String print(Collection roots) { + StringBuilder sb = new StringBuilder(); + writeSequenceItems(sb, roots, 0, true); + if (!sb.isEmpty() && sb.charAt(sb.length() - 1) != '\n') { + sb.append('\n'); + } + return sb.toString(); + } + + private static void writeSequenceItems(StringBuilder sb, Collection items, int indent, boolean topLevel) { + for (Object item : items) { + writeIndent(sb, indent); + sb.append("- "); + if (item instanceof Map map) { + if (map.isEmpty()) { + sb.append("{}\n"); + } else { + writeMappingEntries(sb, map, indent + 1, true); + } + } else if (item instanceof Collection col) { + sb.append('\n'); + writeSequenceItems(sb, col, indent + 1, false); + } else { + writeScalar(sb, item); + sb.append('\n'); + } + } + } + + @SuppressWarnings("unchecked") + private static void writeMappingEntries(StringBuilder sb, Map map, int indent, boolean firstInline) { + boolean first = true; + for (Map.Entry entry : map.entrySet()) { + String key = String.valueOf(entry.getKey()); + Object value = entry.getValue(); + + if (first && firstInline) { + first = false; + } else { + writeIndent(sb, indent); + } + + sb.append(key).append(':'); + + if (value instanceof Map childMap) { + if (childMap.isEmpty()) { + sb.append(" {}\n"); + } else { + sb.append('\n'); + writeMappingEntries(sb, childMap, indent + 1, false); + } + } else if (value instanceof Collection col) { + sb.append('\n'); + writeSequenceItems(sb, col, indent + 1, false); + } else { + sb.append(' '); + if (value instanceof String s && s.contains("\n")) { + writeBlockScalar(sb, s, indent + 1); + } else { + writeScalar(sb, value); + sb.append('\n'); + } + } + } + } + + private static void writeBlockScalar(StringBuilder sb, String value, int indent) { + if (value.endsWith("\n")) { + sb.append("|\n"); + } else { + sb.append("|-\n"); + } + for (String line : value.split("\n", -1)) { + if (line.isEmpty()) { + sb.append('\n'); + } else { + writeIndent(sb, indent); + sb.append(line).append('\n'); + } + } + } + + private static void writeScalar(StringBuilder sb, Object value) { + if (value == null) { + sb.append("null"); + } else if (value instanceof Boolean) { + sb.append(value); + } else if (value instanceof Number) { + sb.append(value); + } else { + String s = String.valueOf(value); + if (needsQuoting(s)) { + sb.append('"'); + sb.append(s.replace("\\", "\\\\").replace("\"", "\\\"")); + sb.append('"'); + } else { + sb.append(s); + } + } + } + + static boolean needsQuoting(String s) { + if (s.isEmpty()) { + return true; + } + + char first = s.charAt(0); + if (first == ' ' || first == '\t' || first == '-' || first == '?' || first == '*' + || first == '&' || first == '!' || first == '%' || first == '@' || first == '`' + || first == '\'' || first == '"' || first == '{' || first == '[' || first == '>' + || first == '|' || first == '#' || first == '$') { + return true; + } + + if (s.charAt(s.length() - 1) == ' ' || s.charAt(s.length() - 1) == '\t') { + return true; + } + + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + if (c == ':' && i + 1 < s.length() && s.charAt(i + 1) == ' ') { + return true; + } + if (c == '#' && i > 0 && s.charAt(i - 1) == ' ') { + return true; + } + if (c == '\n') { + return true; + } + } + + if (isYamlKeyword(s)) { + return true; + } + + if (NUMBER_PATTERN.matcher(s).matches()) { + return true; + } + + return false; + } + + private static boolean isYamlKeyword(String s) { + return "true".equalsIgnoreCase(s) || "false".equalsIgnoreCase(s) + || "yes".equalsIgnoreCase(s) || "no".equalsIgnoreCase(s) + || "on".equalsIgnoreCase(s) || "off".equalsIgnoreCase(s) + || "null".equalsIgnoreCase(s) || "~".equals(s); + } + + private static void writeIndent(StringBuilder sb, int level) { + for (int i = 0; i < level; i++) { + sb.append(INDENT); + } + } +} diff --git a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/io/YamlPrinterTest.java b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/io/YamlPrinterTest.java new file mode 100644 index 0000000000000..d07fbc82de04e --- /dev/null +++ b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/io/YamlPrinterTest.java @@ -0,0 +1,231 @@ +/* + * 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.yaml.io; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class YamlPrinterTest { + + @Test + void simpleRoute() { + var route = orderedMap( + "id", "myRoute", + "from", orderedMap( + "uri", "timer:yaml", + "parameters", orderedMap( + "period", 1234, + "includeMetadata", true), + "steps", List.of( + Map.of("log", orderedMap("message", "${body}"))))); + + var roots = List.of(Map.of("route", route)); + String yaml = YamlPrinter.print(roots); + + String expected = "- route:\n" + + " id: myRoute\n" + + " from:\n" + + " uri: timer:yaml\n" + + " parameters:\n" + + " period: 1234\n" + + " includeMetadata: true\n" + + " steps:\n" + + " - log:\n" + + " message: \"${body}\"\n"; + assertEquals(expected, yaml); + } + + @Test + void choiceWithWhenAndOtherwise() { + var when1 = orderedMap( + "expression", orderedMap( + "simple", orderedMap("expression", "${header.age} < 21")), + "steps", List.of( + Map.of("to", orderedMap("uri", "mock:young")))); + var when2 = orderedMap( + "expression", orderedMap( + "simple", orderedMap("expression", "${header.age} > 70")), + "steps", List.of( + Map.of("to", orderedMap("uri", "mock:senior")))); + var otherwise = orderedMap( + "steps", List.of( + Map.of("to", orderedMap("uri", "mock:work")))); + + var choice = orderedMap( + "when", List.of(when1, when2), + "otherwise", otherwise); + + var route = orderedMap( + "from", orderedMap( + "uri", "direct:start", + "steps", List.of(Map.of("choice", choice)))); + + String yaml = YamlPrinter.print(List.of(Map.of("route", route))); + + assertTrue(yaml.contains("- choice:")); + assertTrue(yaml.contains(" when:")); + assertTrue(yaml.contains(" otherwise:")); + assertTrue(yaml.contains(" - to:")); + } + + @Test + void emptyMapping() { + var roots = List.of( + Map.of("route", orderedMap( + "from", orderedMap( + "uri", "timer:foo", + "steps", List.of( + Map.of("marshal", orderedMap("csv", Map.of())), + Map.of("log", orderedMap("message", "${body}"))))))); + + String yaml = YamlPrinter.print(roots); + assertTrue(yaml.contains("csv: {}"), "Empty mapping should be inline {}"); + } + + @Test + void multiLineString() { + var roots = List.of( + Map.of("route", orderedMap( + "from", orderedMap( + "uri", "direct:start", + "steps", List.of( + Map.of("setBody", orderedMap( + "expression", orderedMap( + "constant", orderedMap( + "expression", "{\n key: '123'\n}"))))))))); + + String yaml = YamlPrinter.print(roots); + assertTrue(yaml.contains("|-"), "Multi-line without trailing newline should use |-"); + assertTrue(yaml.contains(" key: '123'")); + } + + @Test + void multiLineStringWithTrailingNewline() { + var roots = List.of( + Map.of("test", orderedMap("value", "line1\nline2\n"))); + + String yaml = YamlPrinter.print(roots); + assertTrue(yaml.contains("|\n"), "Multi-line with trailing newline should use |"); + } + + @Test + void quotingRules() { + assertTrue(YamlPrinter.needsQuoting(""), "empty string"); + assertTrue(YamlPrinter.needsQuoting("true"), "boolean true"); + assertTrue(YamlPrinter.needsQuoting("false"), "boolean false"); + assertTrue(YamlPrinter.needsQuoting("TRUE"), "boolean TRUE"); + assertTrue(YamlPrinter.needsQuoting("yes"), "boolean yes"); + assertTrue(YamlPrinter.needsQuoting("no"), "boolean no"); + assertTrue(YamlPrinter.needsQuoting("on"), "boolean on"); + assertTrue(YamlPrinter.needsQuoting("off"), "boolean off"); + assertTrue(YamlPrinter.needsQuoting("null"), "null"); + assertTrue(YamlPrinter.needsQuoting("~"), "tilde"); + assertTrue(YamlPrinter.needsQuoting("123"), "integer"); + assertTrue(YamlPrinter.needsQuoting("3.14"), "float"); + assertTrue(YamlPrinter.needsQuoting("-42"), "negative number"); + assertTrue(YamlPrinter.needsQuoting("foo: bar"), "contains colon-space"); + assertTrue(YamlPrinter.needsQuoting("foo #comment"), "contains space-hash"); + assertTrue(YamlPrinter.needsQuoting("- item"), "starts with dash-space"); + assertTrue(YamlPrinter.needsQuoting("*ref"), "starts with star"); + assertTrue(YamlPrinter.needsQuoting("&anchor"), "starts with ampersand"); + assertTrue(YamlPrinter.needsQuoting("{flow}"), "starts with brace"); + assertTrue(YamlPrinter.needsQuoting("[flow]"), "starts with bracket"); + + assertFalse(YamlPrinter.needsQuoting("hello"), "simple word"); + assertFalse(YamlPrinter.needsQuoting("Hello World"), "simple phrase"); + assertFalse(YamlPrinter.needsQuoting("timer:yaml"), "URI"); + assertFalse(YamlPrinter.needsQuoting("mock:result"), "simple URI"); + assertTrue(YamlPrinter.needsQuoting("${body}"), "starts with $"); + assertFalse(YamlPrinter.needsQuoting("foo.bar"), "dotted name"); + assertFalse(YamlPrinter.needsQuoting("my-route-id"), "dashed name"); + } + + @Test + void booleanAndNumberValues() { + var roots = List.of(Map.of("config", orderedMap( + "enabled", true, + "count", 42, + "name", "test"))); + + String yaml = YamlPrinter.print(roots); + assertTrue(yaml.contains("enabled: true")); + assertTrue(yaml.contains("count: 42")); + assertTrue(yaml.contains("name: test")); + } + + @Test + void multipleRoots() { + var route1 = orderedMap("id", "r1", "from", orderedMap("uri", "direct:a")); + var route2 = orderedMap("id", "r2", "from", orderedMap("uri", "direct:b")); + + String yaml = YamlPrinter.print(List.of( + Map.of("route", route1), + Map.of("route", route2))); + + long routeCount = yaml.lines().filter(l -> l.equals("- route:")).count(); + assertEquals(2, routeCount); + } + + @Test + void restWithEmptySteps() { + var roots = List.of( + Map.of("rest", orderedMap( + "path", "/api", + "steps", List.of( + Map.of("get", orderedMap("path", "/hello")))))); + + String yaml = YamlPrinter.print(roots); + assertTrue(yaml.contains("- rest:")); + assertTrue(yaml.contains(" path: /api")); + assertTrue(yaml.contains(" - get:")); + } + + @Test + void stringStartingWithDollarQuoted() { + var roots = List.of(Map.of("test", orderedMap( + "expr", "${header.age} < 21"))); + + String yaml = YamlPrinter.print(roots); + assertTrue(yaml.contains("expr: \"${header.age} < 21\""), + "Starts with $ — should be quoted: " + yaml); + } + + @Test + void stringWithColonSpaceQuoted() { + var roots = List.of(Map.of("test", orderedMap( + "value", "key: value"))); + + String yaml = YamlPrinter.print(roots); + assertTrue(yaml.contains("value: \"key: value\""), + "Colon-space must be quoted: " + yaml); + } + + private static Map orderedMap(Object... keysAndValues) { + Map map = new LinkedHashMap<>(); + for (int i = 0; i < keysAndValues.length; i += 2) { + map.put((String) keysAndValues[i], keysAndValues[i + 1]); + } + return map; + } +} From a3c62cd80377c5e17001cebfe6ee803d3bbbb406 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Thu, 21 May 2026 10:57:25 +0200 Subject: [PATCH 2/9] CAMEL-23596: camel-yaml-io - Replace hand-written YamlWriter with generated direct YAML writer Replace the 600-line hand-written YamlWriter (with 43+ hardcoded special cases) with a generated YamlModelWriter that builds JsonObject/JsonArray structures directly from model classes and serializes them via YamlPrinter. New pipeline (2 conversions): Model -> Generated YamlModelWriter -> JsonObject -> YamlPrinter -> YAML String Old pipeline (6 conversions): Model -> ModelWriter -> YamlWriter -> EipNode -> JsonObject -> Jackson -> YAML Key changes: - New Velocity template model-yaml-writer.vm that generates doWrite* methods returning JsonObject instead of emitting XML-style startElement/endElement - New YamlDirectModelWriterGeneratorMojo that generates YamlModelWriter.java - New YamlModelWriterSupport base class with helper methods for building JsonObject structures (doWriteAttribute, doWriteChildElement, expandUri, etc.) - LwModelToYAMLDumper now uses YamlModelWriter instead of old ModelWriter - Property classification happens at code-generation time, not runtime, eliminating the root cause of CAMEL-23593 bugs Co-Authored-By: Claude Opus 4.6 --- core/camel-yaml-io/pom.xml | 2 + .../camel/yaml/out/YamlModelWriter.java | 3928 +++++++++++++++++ .../camel/yaml/LwModelToYAMLDumper.java | 129 +- .../yaml/out/YamlModelWriterSupport.java | 235 + .../packaging/ModelWriterGeneratorMojo.java | 6 +- .../YamlDirectModelWriterGeneratorMojo.java | 79 + .../resources/velocity/model-yaml-writer.vm | 298 ++ 7 files changed, 4621 insertions(+), 56 deletions(-) create mode 100644 core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java create mode 100644 core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/YamlModelWriterSupport.java create mode 100644 tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlDirectModelWriterGeneratorMojo.java create mode 100644 tooling/maven/camel-package-maven-plugin/src/main/resources/velocity/model-yaml-writer.vm diff --git a/core/camel-yaml-io/pom.xml b/core/camel-yaml-io/pom.xml index 1d21353b2299a..8616b7446245b 100644 --- a/core/camel-yaml-io/pom.xml +++ b/core/camel-yaml-io/pom.xml @@ -34,6 +34,7 @@ 4.0.0 true + true @@ -100,6 +101,7 @@ generate-sources generate-yaml-writer + generate-yaml-direct-writer diff --git a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java new file mode 100644 index 0000000000000..7c78c711d7ec0 --- /dev/null +++ b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java @@ -0,0 +1,3928 @@ +/* + * 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. + */ + +/** + * Generated by camel build tools - do NOT edit this file! + */ +package org.apache.camel.yaml.out; + +import java.util.ArrayList; +import java.util.Base64; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import javax.annotation.processing.Generated; + +import org.apache.camel.util.json.JsonArray; +import org.apache.camel.util.json.JsonObject; + +import org.apache.camel.model.*; +import org.apache.camel.model.app.*; +import org.apache.camel.model.config.*; +import org.apache.camel.model.dataformat.*; +import org.apache.camel.model.errorhandler.*; +import org.apache.camel.model.language.*; +import org.apache.camel.model.loadbalancer.*; +import org.apache.camel.model.rest.*; +import org.apache.camel.model.tokenizer.*; +import org.apache.camel.model.transformer.*; +import org.apache.camel.model.validator.*; + +@Generated("org.apache.camel.maven.packaging.YamlDirectModelWriterGeneratorMojo") +@SuppressWarnings({"deprecation","rawtypes"}) +public class YamlModelWriter extends YamlModelWriterSupport { + + public JsonObject writeAggregateDefinition(AggregateDefinition def) { + return wrapNode("aggregate", doWriteAggregateDefinition(def)); + } + public JsonObject writeBeanDefinition(BeanDefinition def) { + return wrapNode("bean", doWriteBeanDefinition(def)); + } + public JsonObject writeBeanFactoryDefinition(BeanFactoryDefinition def) { + return wrapNode("beanFactory", doWriteBeanFactoryDefinition(def)); + } + public JsonObject writeCatchDefinition(CatchDefinition def) { + return wrapNode("doCatch", doWriteCatchDefinition(def)); + } + public JsonObject writeChoiceDefinition(ChoiceDefinition def) { + return wrapNode("choice", doWriteChoiceDefinition(def)); + } + public JsonObject writeCircuitBreakerDefinition(CircuitBreakerDefinition def) { + return wrapNode("circuitBreaker", doWriteCircuitBreakerDefinition(def)); + } + public JsonObject writeClaimCheckDefinition(ClaimCheckDefinition def) { + return wrapNode("claimCheck", doWriteClaimCheckDefinition(def)); + } + public JsonObject writeContextScanDefinition(ContextScanDefinition def) { + return wrapNode("contextScan", doWriteContextScanDefinition(def)); + } + public JsonObject writeConvertBodyDefinition(ConvertBodyDefinition def) { + return wrapNode("convertBodyTo", doWriteConvertBodyDefinition(def)); + } + public JsonObject writeConvertHeaderDefinition(ConvertHeaderDefinition def) { + return wrapNode("convertHeaderTo", doWriteConvertHeaderDefinition(def)); + } + public JsonObject writeConvertVariableDefinition(ConvertVariableDefinition def) { + return wrapNode("convertVariableTo", doWriteConvertVariableDefinition(def)); + } + public JsonObject writeDelayDefinition(DelayDefinition def) { + return wrapNode("delay", doWriteDelayDefinition(def)); + } + public JsonObject writeDynamicRouterDefinition(DynamicRouterDefinition def) { + return wrapNode("dynamicRouter", doWriteDynamicRouterDefinition(def)); + } + public JsonObject writeEnrichDefinition(EnrichDefinition def) { + return wrapNode("enrich", doWriteEnrichDefinition(def)); + } + public JsonObject writeErrorHandlerDefinition(ErrorHandlerDefinition def) { + return wrapNode("errorHandler", doWriteErrorHandlerDefinition(def)); + } + public JsonObject writeExpressionSubElementDefinition(ExpressionSubElementDefinition def) { + return wrapNode("expression", doWriteExpressionSubElementDefinition(def)); + } + public JsonObject writeFaultToleranceConfigurationDefinition(FaultToleranceConfigurationDefinition def) { + return wrapNode("faultToleranceConfiguration", doWriteFaultToleranceConfigurationDefinition(def)); + } + public JsonObject writeFilterDefinition(FilterDefinition def) { + return wrapNode("filter", doWriteFilterDefinition(def)); + } + public JsonObject writeFinallyDefinition(FinallyDefinition def) { + return wrapNode("doFinally", doWriteFinallyDefinition(def)); + } + public JsonObject writeFromDefinition(FromDefinition def) { + return wrapNode("from", doWriteFromDefinition(def)); + } + public JsonObject writeGlobalOptionDefinition(GlobalOptionDefinition def) { + return wrapNode("globalOption", doWriteGlobalOptionDefinition(def)); + } + public JsonObject writeGlobalOptionsDefinition(GlobalOptionsDefinition def) { + return wrapNode("globalOptions", doWriteGlobalOptionsDefinition(def)); + } + public JsonObject writeIdempotentConsumerDefinition(IdempotentConsumerDefinition def) { + return wrapNode("idempotentConsumer", doWriteIdempotentConsumerDefinition(def)); + } + public JsonObject writeInputTypeDefinition(InputTypeDefinition def) { + return wrapNode("inputType", doWriteInputTypeDefinition(def)); + } + public JsonObject writeInterceptDefinition(InterceptDefinition def) { + return wrapNode("intercept", doWriteInterceptDefinition(def)); + } + public JsonObject writeInterceptFromDefinition(InterceptFromDefinition def) { + return wrapNode("interceptFrom", doWriteInterceptFromDefinition(def)); + } + public JsonObject writeInterceptSendToEndpointDefinition(InterceptSendToEndpointDefinition def) { + return wrapNode("interceptSendToEndpoint", doWriteInterceptSendToEndpointDefinition(def)); + } + public JsonObject writeKameletDefinition(KameletDefinition def) { + return wrapNode("kamelet", doWriteKameletDefinition(def)); + } + public JsonObject writeLoadBalanceDefinition(LoadBalanceDefinition def) { + return wrapNode("loadBalance", doWriteLoadBalanceDefinition(def)); + } + public JsonObject writeLogDefinition(LogDefinition def) { + return wrapNode("log", doWriteLogDefinition(def)); + } + public JsonObject writeLoopDefinition(LoopDefinition def) { + return wrapNode("loop", doWriteLoopDefinition(def)); + } + public JsonObject writeMarshalDefinition(MarshalDefinition def) { + return wrapNode("marshal", doWriteMarshalDefinition(def)); + } + public JsonObject writeMulticastDefinition(MulticastDefinition def) { + return wrapNode("multicast", doWriteMulticastDefinition(def)); + } + public JsonObject writeOnCompletionDefinition(OnCompletionDefinition def) { + return wrapNode("onCompletion", doWriteOnCompletionDefinition(def)); + } + public JsonObject writeOnExceptionDefinition(OnExceptionDefinition def) { + return wrapNode("onException", doWriteOnExceptionDefinition(def)); + } + public JsonObject writeOnFallbackDefinition(OnFallbackDefinition def) { + return wrapNode("onFallback", doWriteOnFallbackDefinition(def)); + } + public JsonObject writeOnWhenDefinition(OnWhenDefinition def) { + return wrapNode("onWhen", doWriteOnWhenDefinition(def)); + } + public JsonObject writeOptimisticLockRetryPolicyDefinition(OptimisticLockRetryPolicyDefinition def) { + return wrapNode("optimisticLockRetryPolicy", doWriteOptimisticLockRetryPolicyDefinition(def)); + } + public JsonObject writeOtherwiseDefinition(OtherwiseDefinition def) { + return wrapNode("otherwise", doWriteOtherwiseDefinition(def)); + } + public JsonObject writeOutputTypeDefinition(OutputTypeDefinition def) { + return wrapNode("outputType", doWriteOutputTypeDefinition(def)); + } + public JsonObject writePackageScanDefinition(PackageScanDefinition def) { + return wrapNode("packageScan", doWritePackageScanDefinition(def)); + } + public JsonObject writePausableDefinition(PausableDefinition def) { + return wrapNode("pausable", doWritePausableDefinition(def)); + } + public JsonObject writePipelineDefinition(PipelineDefinition def) { + return wrapNode("pipeline", doWritePipelineDefinition(def)); + } + public JsonObject writePolicyDefinition(PolicyDefinition def) { + return wrapNode("policy", doWritePolicyDefinition(def)); + } + public JsonObject writePollDefinition(PollDefinition def) { + return wrapNode("poll", doWritePollDefinition(def)); + } + public JsonObject writePollEnrichDefinition(PollEnrichDefinition def) { + return wrapNode("pollEnrich", doWritePollEnrichDefinition(def)); + } + public JsonObject writeProcessDefinition(ProcessDefinition def) { + return wrapNode("process", doWriteProcessDefinition(def)); + } + public JsonObject writePropertyDefinition(PropertyDefinition def) { + return wrapNode("property", doWritePropertyDefinition(def)); + } + public JsonObject writePropertyExpressionDefinition(PropertyExpressionDefinition def) { + return wrapNode("propertyExpression", doWritePropertyExpressionDefinition(def)); + } + public JsonObject writeRecipientListDefinition(RecipientListDefinition def) { + return wrapNode("recipientList", doWriteRecipientListDefinition(def)); + } + public JsonObject writeRedeliveryPolicyDefinition(RedeliveryPolicyDefinition def) { + return wrapNode("redeliveryPolicy", doWriteRedeliveryPolicyDefinition(def)); + } + public JsonObject writeRemoveHeaderDefinition(RemoveHeaderDefinition def) { + return wrapNode("removeHeader", doWriteRemoveHeaderDefinition(def)); + } + public JsonObject writeRemoveHeadersDefinition(RemoveHeadersDefinition def) { + return wrapNode("removeHeaders", doWriteRemoveHeadersDefinition(def)); + } + public JsonObject writeRemovePropertiesDefinition(RemovePropertiesDefinition def) { + return wrapNode("removeProperties", doWriteRemovePropertiesDefinition(def)); + } + public JsonObject writeRemovePropertyDefinition(RemovePropertyDefinition def) { + return wrapNode("removeProperty", doWriteRemovePropertyDefinition(def)); + } + public JsonObject writeRemoveVariableDefinition(RemoveVariableDefinition def) { + return wrapNode("removeVariable", doWriteRemoveVariableDefinition(def)); + } + public JsonObject writeResequenceDefinition(ResequenceDefinition def) { + return wrapNode("resequence", doWriteResequenceDefinition(def)); + } + public JsonObject writeResilience4jConfigurationDefinition(Resilience4jConfigurationDefinition def) { + return wrapNode("resilience4jConfiguration", doWriteResilience4jConfigurationDefinition(def)); + } + public JsonObject writeRestContextRefDefinition(RestContextRefDefinition def) { + return wrapNode("restContextRef", doWriteRestContextRefDefinition(def)); + } + public JsonObject writeResumableDefinition(ResumableDefinition def) { + return wrapNode("resumable", doWriteResumableDefinition(def)); + } + public JsonObject writeRollbackDefinition(RollbackDefinition def) { + return wrapNode("rollback", doWriteRollbackDefinition(def)); + } + public JsonObject writeRouteBuilderDefinition(RouteBuilderDefinition def) { + return wrapNode("routeBuilder", doWriteRouteBuilderDefinition(def)); + } + public JsonObject writeRouteConfigurationContextRefDefinition(RouteConfigurationContextRefDefinition def) { + return wrapNode("routeConfigurationContextRef", doWriteRouteConfigurationContextRefDefinition(def)); + } + public JsonObject writeRouteConfigurationDefinition(RouteConfigurationDefinition def) { + return wrapNode("routeConfiguration", doWriteRouteConfigurationDefinition(def)); + } + public JsonObject writeRouteConfigurationsDefinition(RouteConfigurationsDefinition def) { + return wrapNode("routeConfigurations", doWriteRouteConfigurationsDefinition(def)); + } + public JsonObject writeRouteContextRefDefinition(RouteContextRefDefinition def) { + return wrapNode("routeContextRef", doWriteRouteContextRefDefinition(def)); + } + public JsonObject writeRouteDefinition(RouteDefinition def) { + return wrapNode("route", doWriteRouteDefinition(def)); + } + public JsonObject writeRouteTemplateContextRefDefinition(RouteTemplateContextRefDefinition def) { + return wrapNode("routeTemplateContextRef", doWriteRouteTemplateContextRefDefinition(def)); + } + public JsonObject writeRouteTemplateDefinition(RouteTemplateDefinition def) { + return wrapNode("routeTemplate", doWriteRouteTemplateDefinition(def)); + } + public JsonObject writeRouteTemplateParameterDefinition(RouteTemplateParameterDefinition def) { + return wrapNode("templateParameter", doWriteRouteTemplateParameterDefinition(def)); + } + public JsonObject writeRouteTemplatesDefinition(RouteTemplatesDefinition def) { + return wrapNode("routeTemplates", doWriteRouteTemplatesDefinition(def)); + } + public JsonObject writeRoutesDefinition(RoutesDefinition def) { + return wrapNode("routes", doWriteRoutesDefinition(def)); + } + public JsonObject writeRoutingSlipDefinition(RoutingSlipDefinition def) { + return wrapNode("routingSlip", doWriteRoutingSlipDefinition(def)); + } + public JsonObject writeSagaDefinition(SagaDefinition def) { + return wrapNode("saga", doWriteSagaDefinition(def)); + } + public JsonObject writeSamplingDefinition(SamplingDefinition def) { + return wrapNode("sample", doWriteSamplingDefinition(def)); + } + public JsonObject writeScriptDefinition(ScriptDefinition def) { + return wrapNode("script", doWriteScriptDefinition(def)); + } + public JsonObject writeSetBodyDefinition(SetBodyDefinition def) { + return wrapNode("setBody", doWriteSetBodyDefinition(def)); + } + public JsonObject writeSetExchangePatternDefinition(SetExchangePatternDefinition def) { + return wrapNode("setExchangePattern", doWriteSetExchangePatternDefinition(def)); + } + public JsonObject writeSetHeaderDefinition(SetHeaderDefinition def) { + return wrapNode("setHeader", doWriteSetHeaderDefinition(def)); + } + public JsonObject writeSetHeadersDefinition(SetHeadersDefinition def) { + return wrapNode("setHeaders", doWriteSetHeadersDefinition(def)); + } + public JsonObject writeSetPropertyDefinition(SetPropertyDefinition def) { + return wrapNode("setProperty", doWriteSetPropertyDefinition(def)); + } + public JsonObject writeSetVariableDefinition(SetVariableDefinition def) { + return wrapNode("setVariable", doWriteSetVariableDefinition(def)); + } + public JsonObject writeSetVariablesDefinition(SetVariablesDefinition def) { + return wrapNode("setVariables", doWriteSetVariablesDefinition(def)); + } + public JsonObject writeSortDefinition(SortDefinition def) { + return wrapNode("sort", doWriteSortDefinition(def)); + } + public JsonObject writeSplitDefinition(SplitDefinition def) { + return wrapNode("split", doWriteSplitDefinition(def)); + } + public JsonObject writeStepDefinition(StepDefinition def) { + return wrapNode("step", doWriteStepDefinition(def)); + } + public JsonObject writeStopDefinition(StopDefinition def) { + return wrapNode("stop", doWriteStopDefinition(def)); + } + public JsonObject writeTemplatedRouteDefinition(TemplatedRouteDefinition def) { + return wrapNode("templatedRoute", doWriteTemplatedRouteDefinition(def)); + } + public JsonObject writeTemplatedRouteParameterDefinition(TemplatedRouteParameterDefinition def) { + return wrapNode("templatedRouteParameter", doWriteTemplatedRouteParameterDefinition(def)); + } + public JsonObject writeTemplatedRoutesDefinition(TemplatedRoutesDefinition def) { + return wrapNode("templatedRoutes", doWriteTemplatedRoutesDefinition(def)); + } + public JsonObject writeThreadPoolProfileDefinition(ThreadPoolProfileDefinition def) { + return wrapNode("threadPoolProfile", doWriteThreadPoolProfileDefinition(def)); + } + public JsonObject writeThreadsDefinition(ThreadsDefinition def) { + return wrapNode("threads", doWriteThreadsDefinition(def)); + } + public JsonObject writeThrottleDefinition(ThrottleDefinition def) { + return wrapNode("throttle", doWriteThrottleDefinition(def)); + } + public JsonObject writeThrowExceptionDefinition(ThrowExceptionDefinition def) { + return wrapNode("throwException", doWriteThrowExceptionDefinition(def)); + } + public JsonObject writeToDefinition(ToDefinition def) { + return wrapNode("to", doWriteToDefinition(def)); + } + public JsonObject writeToDynamicDefinition(ToDynamicDefinition def) { + return wrapNode("toD", doWriteToDynamicDefinition(def)); + } + public JsonObject writeTokenizerDefinition(TokenizerDefinition def) { + return wrapNode("tokenizer", doWriteTokenizerDefinition(def)); + } + public JsonObject writeTransactedDefinition(TransactedDefinition def) { + return wrapNode("transacted", doWriteTransactedDefinition(def)); + } + public JsonObject writeTransformDataTypeDefinition(TransformDataTypeDefinition def) { + return wrapNode("transformDataType", doWriteTransformDataTypeDefinition(def)); + } + public JsonObject writeTransformDefinition(TransformDefinition def) { + return wrapNode("transform", doWriteTransformDefinition(def)); + } + public JsonObject writeTryDefinition(TryDefinition def) { + return wrapNode("doTry", doWriteTryDefinition(def)); + } + public JsonObject writeUnmarshalDefinition(UnmarshalDefinition def) { + return wrapNode("unmarshal", doWriteUnmarshalDefinition(def)); + } + public JsonObject writeValidateDefinition(ValidateDefinition def) { + return wrapNode("validate", doWriteValidateDefinition(def)); + } + public JsonObject writeValueDefinition(ValueDefinition def) { + return wrapNode("value", doWriteValueDefinition(def)); + } + public JsonObject writeWhenDefinition(WhenDefinition def) { + return wrapNode("when", doWriteWhenDefinition(def)); + } + public JsonObject writeWireTapDefinition(WireTapDefinition def) { + return wrapNode("wireTap", doWriteWireTapDefinition(def)); + } + public JsonObject writeApplicationDefinition(ApplicationDefinition def) { + return wrapNode("camel", doWriteApplicationDefinition(def)); + } + public JsonObject writeBeansDefinition(BeansDefinition def) { + return wrapNode("beans", doWriteBeansDefinition(def)); + } + public JsonObject writeBatchResequencerConfig(BatchResequencerConfig def) { + return wrapNode("batchConfig", doWriteBatchResequencerConfig(def)); + } + public JsonObject writeStreamResequencerConfig(StreamResequencerConfig def) { + return wrapNode("streamConfig", doWriteStreamResequencerConfig(def)); + } + public JsonObject writeASN1DataFormat(ASN1DataFormat def) { + return wrapNode("asn1", doWriteASN1DataFormat(def)); + } + public JsonObject writeAvroDataFormat(AvroDataFormat def) { + return wrapNode("avro", doWriteAvroDataFormat(def)); + } + public JsonObject writeBarcodeDataFormat(BarcodeDataFormat def) { + return wrapNode("barcode", doWriteBarcodeDataFormat(def)); + } + public JsonObject writeBase64DataFormat(Base64DataFormat def) { + return wrapNode("base64", doWriteBase64DataFormat(def)); + } + public JsonObject writeBeanioDataFormat(BeanioDataFormat def) { + return wrapNode("beanio", doWriteBeanioDataFormat(def)); + } + public JsonObject writeBindyDataFormat(BindyDataFormat def) { + return wrapNode("bindy", doWriteBindyDataFormat(def)); + } + public JsonObject writeCBORDataFormat(CBORDataFormat def) { + return wrapNode("cbor", doWriteCBORDataFormat(def)); + } + public JsonObject writeCryptoDataFormat(CryptoDataFormat def) { + return wrapNode("crypto", doWriteCryptoDataFormat(def)); + } + public JsonObject writeCsvDataFormat(CsvDataFormat def) { + return wrapNode("csv", doWriteCsvDataFormat(def)); + } + public JsonObject writeCustomDataFormat(CustomDataFormat def) { + return wrapNode("custom", doWriteCustomDataFormat(def)); + } + public JsonObject writeDataFormatsDefinition(DataFormatsDefinition def) { + return wrapNode("dataFormats", doWriteDataFormatsDefinition(def)); + } + public JsonObject writeDfdlDataFormat(DfdlDataFormat def) { + return wrapNode("dfdl", doWriteDfdlDataFormat(def)); + } + public JsonObject writeFhirJsonDataFormat(FhirJsonDataFormat def) { + return wrapNode("fhirJson", doWriteFhirJsonDataFormat(def)); + } + public JsonObject writeFhirXmlDataFormat(FhirXmlDataFormat def) { + return wrapNode("fhirXml", doWriteFhirXmlDataFormat(def)); + } + public JsonObject writeFlatpackDataFormat(FlatpackDataFormat def) { + return wrapNode("flatpack", doWriteFlatpackDataFormat(def)); + } + public JsonObject writeForyDataFormat(ForyDataFormat def) { + return wrapNode("fory", doWriteForyDataFormat(def)); + } + public JsonObject writeGrokDataFormat(GrokDataFormat def) { + return wrapNode("grok", doWriteGrokDataFormat(def)); + } + public JsonObject writeGroovyJSonDataFormat(GroovyJSonDataFormat def) { + return wrapNode("groovyJson", doWriteGroovyJSonDataFormat(def)); + } + public JsonObject writeGroovyXmlDataFormat(GroovyXmlDataFormat def) { + return wrapNode("groovyXml", doWriteGroovyXmlDataFormat(def)); + } + public JsonObject writeGzipDeflaterDataFormat(GzipDeflaterDataFormat def) { + return wrapNode("gzipDeflater", doWriteGzipDeflaterDataFormat(def)); + } + public JsonObject writeHL7DataFormat(HL7DataFormat def) { + return wrapNode("hl7", doWriteHL7DataFormat(def)); + } + public JsonObject writeIcalDataFormat(IcalDataFormat def) { + return wrapNode("ical", doWriteIcalDataFormat(def)); + } + public JsonObject writeIso8583DataFormat(Iso8583DataFormat def) { + return wrapNode("iso8583", doWriteIso8583DataFormat(def)); + } + public JsonObject writeJacksonXMLDataFormat(JacksonXMLDataFormat def) { + return wrapNode("jacksonXml", doWriteJacksonXMLDataFormat(def)); + } + public JsonObject writeJaxbDataFormat(JaxbDataFormat def) { + return wrapNode("jaxb", doWriteJaxbDataFormat(def)); + } + public JsonObject writeJsonApiDataFormat(JsonApiDataFormat def) { + return wrapNode("jsonApi", doWriteJsonApiDataFormat(def)); + } + public JsonObject writeJsonDataFormat(JsonDataFormat def) { + return wrapNode("json", doWriteJsonDataFormat(def)); + } + public JsonObject writeLZFDataFormat(LZFDataFormat def) { + return wrapNode("lzf", doWriteLZFDataFormat(def)); + } + public JsonObject writeMimeMultipartDataFormat(MimeMultipartDataFormat def) { + return wrapNode("mimeMultipart", doWriteMimeMultipartDataFormat(def)); + } + public JsonObject writeOcsfDataFormat(OcsfDataFormat def) { + return wrapNode("ocsf", doWriteOcsfDataFormat(def)); + } + public JsonObject writePGPDataFormat(PGPDataFormat def) { + return wrapNode("pgp", doWritePGPDataFormat(def)); + } + public JsonObject writePQCDataFormat(PQCDataFormat def) { + return wrapNode("pqc", doWritePQCDataFormat(def)); + } + public JsonObject writeParquetAvroDataFormat(ParquetAvroDataFormat def) { + return wrapNode("parquetAvro", doWriteParquetAvroDataFormat(def)); + } + public JsonObject writeProtobufDataFormat(ProtobufDataFormat def) { + return wrapNode("protobuf", doWriteProtobufDataFormat(def)); + } + public JsonObject writeRssDataFormat(RssDataFormat def) { + return wrapNode("rss", doWriteRssDataFormat(def)); + } + public JsonObject writeSmooksDataFormat(SmooksDataFormat def) { + return wrapNode("smooks", doWriteSmooksDataFormat(def)); + } + public JsonObject writeSoapDataFormat(SoapDataFormat def) { + return wrapNode("soap", doWriteSoapDataFormat(def)); + } + public JsonObject writeSwiftMtDataFormat(SwiftMtDataFormat def) { + return wrapNode("swiftMt", doWriteSwiftMtDataFormat(def)); + } + public JsonObject writeSwiftMxDataFormat(SwiftMxDataFormat def) { + return wrapNode("swiftMx", doWriteSwiftMxDataFormat(def)); + } + public JsonObject writeSyslogDataFormat(SyslogDataFormat def) { + return wrapNode("syslog", doWriteSyslogDataFormat(def)); + } + public JsonObject writeTarFileDataFormat(TarFileDataFormat def) { + return wrapNode("tarFile", doWriteTarFileDataFormat(def)); + } + public JsonObject writeThriftDataFormat(ThriftDataFormat def) { + return wrapNode("thrift", doWriteThriftDataFormat(def)); + } + public JsonObject writeUniVocityCsvDataFormat(UniVocityCsvDataFormat def) { + return wrapNode("univocityCsv", doWriteUniVocityCsvDataFormat(def)); + } + public JsonObject writeUniVocityFixedDataFormat(UniVocityFixedDataFormat def) { + return wrapNode("univocityFixed", doWriteUniVocityFixedDataFormat(def)); + } + public JsonObject writeUniVocityHeader(UniVocityHeader def) { + return wrapNode("univocityHeader", doWriteUniVocityHeader(def)); + } + public JsonObject writeUniVocityTsvDataFormat(UniVocityTsvDataFormat def) { + return wrapNode("univocityTsv", doWriteUniVocityTsvDataFormat(def)); + } + public JsonObject writeXMLSecurityDataFormat(XMLSecurityDataFormat def) { + return wrapNode("xmlSecurity", doWriteXMLSecurityDataFormat(def)); + } + public JsonObject writeYAMLDataFormat(YAMLDataFormat def) { + return wrapNode("yaml", doWriteYAMLDataFormat(def)); + } + public JsonObject writeZipDeflaterDataFormat(ZipDeflaterDataFormat def) { + return wrapNode("zipDeflater", doWriteZipDeflaterDataFormat(def)); + } + public JsonObject writeZipFileDataFormat(ZipFileDataFormat def) { + return wrapNode("zipFile", doWriteZipFileDataFormat(def)); + } + public JsonObject writeDeadLetterChannelDefinition(DeadLetterChannelDefinition def) { + return wrapNode("deadLetterChannel", doWriteDeadLetterChannelDefinition(def)); + } + public JsonObject writeDefaultErrorHandlerDefinition(DefaultErrorHandlerDefinition def) { + return wrapNode("defaultErrorHandler", doWriteDefaultErrorHandlerDefinition(def)); + } + public JsonObject writeJtaTransactionErrorHandlerDefinition(JtaTransactionErrorHandlerDefinition def) { + return wrapNode("jtaTransactionErrorHandler", doWriteJtaTransactionErrorHandlerDefinition(def)); + } + public JsonObject writeNoErrorHandlerDefinition(NoErrorHandlerDefinition def) { + return wrapNode("noErrorHandler", doWriteNoErrorHandlerDefinition(def)); + } + public JsonObject writeRefErrorHandlerDefinition(RefErrorHandlerDefinition def) { + return wrapNode("refErrorHandler", doWriteRefErrorHandlerDefinition(def)); + } + public JsonObject writeSpringTransactionErrorHandlerDefinition(SpringTransactionErrorHandlerDefinition def) { + return wrapNode("springTransactionErrorHandler", doWriteSpringTransactionErrorHandlerDefinition(def)); + } + public JsonObject writeCSimpleExpression(CSimpleExpression def) { + return wrapNode("csimple", doWriteCSimpleExpression(def)); + } + public JsonObject writeConstantExpression(ConstantExpression def) { + return wrapNode("constant", doWriteConstantExpression(def)); + } + public JsonObject writeDatasonnetExpression(DatasonnetExpression def) { + return wrapNode("datasonnet", doWriteDatasonnetExpression(def)); + } + public JsonObject writeExchangePropertyExpression(ExchangePropertyExpression def) { + return wrapNode("exchangeProperty", doWriteExchangePropertyExpression(def)); + } + public JsonObject writeExpressionDefinition(ExpressionDefinition def) { + return wrapNode("##default", doWriteExpressionDefinition(def)); + } + public JsonObject writeGroovyExpression(GroovyExpression def) { + return wrapNode("groovy", doWriteGroovyExpression(def)); + } + public JsonObject writeHeaderExpression(HeaderExpression def) { + return wrapNode("header", doWriteHeaderExpression(def)); + } + public JsonObject writeHl7TerserExpression(Hl7TerserExpression def) { + return wrapNode("hl7terser", doWriteHl7TerserExpression(def)); + } + public JsonObject writeJavaExpression(JavaExpression def) { + return wrapNode("java", doWriteJavaExpression(def)); + } + public JsonObject writeJavaScriptExpression(JavaScriptExpression def) { + return wrapNode("js", doWriteJavaScriptExpression(def)); + } + public JsonObject writeJoorExpression(JoorExpression def) { + return wrapNode("joor", doWriteJoorExpression(def)); + } + public JsonObject writeJqExpression(JqExpression def) { + return wrapNode("jq", doWriteJqExpression(def)); + } + public JsonObject writeJsonPathExpression(JsonPathExpression def) { + return wrapNode("jsonpath", doWriteJsonPathExpression(def)); + } + public JsonObject writeLanguageExpression(LanguageExpression def) { + return wrapNode("language", doWriteLanguageExpression(def)); + } + public JsonObject writeMethodCallExpression(MethodCallExpression def) { + return wrapNode("method", doWriteMethodCallExpression(def)); + } + public JsonObject writeMvelExpression(MvelExpression def) { + return wrapNode("mvel", doWriteMvelExpression(def)); + } + public JsonObject writeOgnlExpression(OgnlExpression def) { + return wrapNode("ognl", doWriteOgnlExpression(def)); + } + public JsonObject writePythonExpression(PythonExpression def) { + return wrapNode("python", doWritePythonExpression(def)); + } + public JsonObject writeRefExpression(RefExpression def) { + return wrapNode("ref", doWriteRefExpression(def)); + } + public JsonObject writeSimpleExpression(SimpleExpression def) { + return wrapNode("simple", doWriteSimpleExpression(def)); + } + public JsonObject writeSpELExpression(SpELExpression def) { + return wrapNode("spel", doWriteSpELExpression(def)); + } + public JsonObject writeTokenizerExpression(TokenizerExpression def) { + return wrapNode("tokenize", doWriteTokenizerExpression(def)); + } + public JsonObject writeVariableExpression(VariableExpression def) { + return wrapNode("variable", doWriteVariableExpression(def)); + } + public JsonObject writeWasmExpression(WasmExpression def) { + return wrapNode("wasm", doWriteWasmExpression(def)); + } + public JsonObject writeXMLTokenizerExpression(XMLTokenizerExpression def) { + return wrapNode("xtokenize", doWriteXMLTokenizerExpression(def)); + } + public JsonObject writeXPathExpression(XPathExpression def) { + return wrapNode("xpath", doWriteXPathExpression(def)); + } + public JsonObject writeXQueryExpression(XQueryExpression def) { + return wrapNode("xquery", doWriteXQueryExpression(def)); + } + public JsonObject writeCustomLoadBalancerDefinition(CustomLoadBalancerDefinition def) { + return wrapNode("customLoadBalancer", doWriteCustomLoadBalancerDefinition(def)); + } + public JsonObject writeFailoverLoadBalancerDefinition(FailoverLoadBalancerDefinition def) { + return wrapNode("failoverLoadBalancer", doWriteFailoverLoadBalancerDefinition(def)); + } + public JsonObject writeRandomLoadBalancerDefinition(RandomLoadBalancerDefinition def) { + return wrapNode("randomLoadBalancer", doWriteRandomLoadBalancerDefinition(def)); + } + public JsonObject writeRoundRobinLoadBalancerDefinition(RoundRobinLoadBalancerDefinition def) { + return wrapNode("roundRobinLoadBalancer", doWriteRoundRobinLoadBalancerDefinition(def)); + } + public JsonObject writeStickyLoadBalancerDefinition(StickyLoadBalancerDefinition def) { + return wrapNode("stickyLoadBalancer", doWriteStickyLoadBalancerDefinition(def)); + } + public JsonObject writeTopicLoadBalancerDefinition(TopicLoadBalancerDefinition def) { + return wrapNode("topicLoadBalancer", doWriteTopicLoadBalancerDefinition(def)); + } + public JsonObject writeWeightedLoadBalancerDefinition(WeightedLoadBalancerDefinition def) { + return wrapNode("weightedLoadBalancer", doWriteWeightedLoadBalancerDefinition(def)); + } + public JsonObject writeApiKeyDefinition(ApiKeyDefinition def) { + return wrapNode("apiKey", doWriteApiKeyDefinition(def)); + } + public JsonObject writeBasicAuthDefinition(BasicAuthDefinition def) { + return wrapNode("basicAuth", doWriteBasicAuthDefinition(def)); + } + public JsonObject writeBearerTokenDefinition(BearerTokenDefinition def) { + return wrapNode("bearerToken", doWriteBearerTokenDefinition(def)); + } + public JsonObject writeDeleteDefinition(DeleteDefinition def) { + return wrapNode("delete", doWriteDeleteDefinition(def)); + } + public JsonObject writeGetDefinition(GetDefinition def) { + return wrapNode("get", doWriteGetDefinition(def)); + } + public JsonObject writeHeadDefinition(HeadDefinition def) { + return wrapNode("head", doWriteHeadDefinition(def)); + } + public JsonObject writeMutualTLSDefinition(MutualTLSDefinition def) { + return wrapNode("mutualTLS", doWriteMutualTLSDefinition(def)); + } + public JsonObject writeOAuth2Definition(OAuth2Definition def) { + return wrapNode("oauth2", doWriteOAuth2Definition(def)); + } + public JsonObject writeOpenApiDefinition(OpenApiDefinition def) { + return wrapNode("openApi", doWriteOpenApiDefinition(def)); + } + public JsonObject writeOpenIdConnectDefinition(OpenIdConnectDefinition def) { + return wrapNode("openIdConnect", doWriteOpenIdConnectDefinition(def)); + } + public JsonObject writeParamDefinition(ParamDefinition def) { + return wrapNode("param", doWriteParamDefinition(def)); + } + public JsonObject writePatchDefinition(PatchDefinition def) { + return wrapNode("patch", doWritePatchDefinition(def)); + } + public JsonObject writePostDefinition(PostDefinition def) { + return wrapNode("post", doWritePostDefinition(def)); + } + public JsonObject writePutDefinition(PutDefinition def) { + return wrapNode("put", doWritePutDefinition(def)); + } + public JsonObject writeResponseHeaderDefinition(ResponseHeaderDefinition def) { + return wrapNode("responseHeader", doWriteResponseHeaderDefinition(def)); + } + public JsonObject writeResponseMessageDefinition(ResponseMessageDefinition def) { + return wrapNode("responseMessage", doWriteResponseMessageDefinition(def)); + } + public JsonObject writeRestBindingDefinition(RestBindingDefinition def) { + return wrapNode("restBinding", doWriteRestBindingDefinition(def)); + } + public JsonObject writeRestConfigurationDefinition(RestConfigurationDefinition def) { + return wrapNode("restConfiguration", doWriteRestConfigurationDefinition(def)); + } + public JsonObject writeRestDefinition(RestDefinition def) { + return wrapNode("rest", doWriteRestDefinition(def)); + } + public JsonObject writeRestPropertyDefinition(RestPropertyDefinition def) { + return wrapNode("restProperty", doWriteRestPropertyDefinition(def)); + } + public JsonObject writeRestSecuritiesDefinition(RestSecuritiesDefinition def) { + return wrapNode("securityDefinitions", doWriteRestSecuritiesDefinition(def)); + } + public JsonObject writeRestsDefinition(RestsDefinition def) { + return wrapNode("rests", doWriteRestsDefinition(def)); + } + public JsonObject writeSecurityDefinition(SecurityDefinition def) { + return wrapNode("security", doWriteSecurityDefinition(def)); + } + public JsonObject writeLangChain4jCharacterTokenizerDefinition(LangChain4jCharacterTokenizerDefinition def) { + return wrapNode("langChain4jCharacterTokenizer", doWriteLangChain4jCharacterTokenizerDefinition(def)); + } + public JsonObject writeLangChain4jLineTokenizerDefinition(LangChain4jLineTokenizerDefinition def) { + return wrapNode("langChain4jLineTokenizer", doWriteLangChain4jLineTokenizerDefinition(def)); + } + public JsonObject writeLangChain4jParagraphTokenizerDefinition(LangChain4jParagraphTokenizerDefinition def) { + return wrapNode("langChain4jParagraphTokenizer", doWriteLangChain4jParagraphTokenizerDefinition(def)); + } + public JsonObject writeLangChain4jSentenceTokenizerDefinition(LangChain4jSentenceTokenizerDefinition def) { + return wrapNode("langChain4jSentenceTokenizer", doWriteLangChain4jSentenceTokenizerDefinition(def)); + } + public JsonObject writeLangChain4jWordTokenizerDefinition(LangChain4jWordTokenizerDefinition def) { + return wrapNode("langChain4jWordTokenizer", doWriteLangChain4jWordTokenizerDefinition(def)); + } + public JsonObject writeCustomTransformerDefinition(CustomTransformerDefinition def) { + return wrapNode("customTransformer", doWriteCustomTransformerDefinition(def)); + } + public JsonObject writeDataFormatTransformerDefinition(DataFormatTransformerDefinition def) { + return wrapNode("dataFormatTransformer", doWriteDataFormatTransformerDefinition(def)); + } + public JsonObject writeEndpointTransformerDefinition(EndpointTransformerDefinition def) { + return wrapNode("endpointTransformer", doWriteEndpointTransformerDefinition(def)); + } + public JsonObject writeLoadTransformerDefinition(LoadTransformerDefinition def) { + return wrapNode("loadTransformer", doWriteLoadTransformerDefinition(def)); + } + public JsonObject writeTransformersDefinition(TransformersDefinition def) { + return wrapNode("transformers", doWriteTransformersDefinition(def)); + } + public JsonObject writeCustomValidatorDefinition(CustomValidatorDefinition def) { + return wrapNode("customValidator", doWriteCustomValidatorDefinition(def)); + } + public JsonObject writeEndpointValidatorDefinition(EndpointValidatorDefinition def) { + return wrapNode("endpointValidator", doWriteEndpointValidatorDefinition(def)); + } + public JsonObject writePredicateValidatorDefinition(PredicateValidatorDefinition def) { + return wrapNode("predicateValidator", doWritePredicateValidatorDefinition(def)); + } + public JsonObject writeValidatorsDefinition(ValidatorsDefinition def) { + return wrapNode("validators", doWriteValidatorsDefinition(def)); + } + + public JsonObject writeOptionalIdentifiedDefinitionRef(OptionalIdentifiedDefinition def) { + return doWriteOptionalIdentifiedDefinitionRef(def); + } + + protected JsonObject doWriteAggregateDefinition(AggregateDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "parallelProcessing", def.getParallelProcessing(), null); + doWriteAttribute(jo, "optimisticLocking", def.getOptimisticLocking(), null); + doWriteAttribute(jo, "optimisticLockingSyncRetry", def.getOptimisticLockingSyncRetry(), "false"); + doWriteAttribute(jo, "executorService", def.getExecutorService(), null); + doWriteAttribute(jo, "timeoutCheckerExecutorService", def.getTimeoutCheckerExecutorService(), null); + doWriteAttribute(jo, "aggregateController", def.getAggregateController(), null); + doWriteAttribute(jo, "aggregationRepository", def.getAggregationRepository(), null); + doWriteAttribute(jo, "aggregationStrategy", def.getAggregationStrategy(), null); + doWriteAttribute(jo, "aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); + doWriteAttribute(jo, "aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); + doWriteAttribute(jo, "completionSize", def.getCompletionSize(), null); + doWriteAttribute(jo, "completionInterval", def.getCompletionInterval(), null); + doWriteAttribute(jo, "completionTimeout", def.getCompletionTimeout(), null); + doWriteAttribute(jo, "completionTimeoutCheckerInterval", def.getCompletionTimeoutCheckerInterval(), "1000"); + doWriteAttribute(jo, "completionFromBatchConsumer", def.getCompletionFromBatchConsumer(), null); + doWriteAttribute(jo, "completionOnNewCorrelationGroup", def.getCompletionOnNewCorrelationGroup(), null); + doWriteAttribute(jo, "eagerCheckCompletion", def.getEagerCheckCompletion(), null); + doWriteAttribute(jo, "ignoreInvalidCorrelationKeys", def.getIgnoreInvalidCorrelationKeys(), null); + doWriteAttribute(jo, "closeCorrelationKeyOnCompletion", def.getCloseCorrelationKeyOnCompletion(), null); + doWriteAttribute(jo, "discardOnCompletionTimeout", def.getDiscardOnCompletionTimeout(), null); + doWriteAttribute(jo, "discardOnAggregationFailure", def.getDiscardOnAggregationFailure(), null); + doWriteAttribute(jo, "forceCompletionOnStop", def.getForceCompletionOnStop(), null); + doWriteAttribute(jo, "completeAllOnStop", def.getCompleteAllOnStop(), null); + doWriteChildElement(jo, "optimisticLockRetryPolicy", def.getOptimisticLockRetryPolicyDefinition(), this::doWriteOptimisticLockRetryPolicyDefinition); + doWriteChildElement(jo, "correlationExpression", def.getCorrelationExpression(), this::doWriteExpressionSubElementDefinition); + doWriteChildElement(jo, "completionPredicate", def.getCompletionPredicate(), this::doWriteExpressionSubElementDefinition); + doWriteChildElement(jo, "completionTimeoutExpression", def.getCompletionTimeoutExpression(), this::doWriteExpressionSubElementDefinition); + doWriteChildElement(jo, "completionSizeExpression", def.getCompletionSizeExpression(), this::doWriteExpressionSubElementDefinition); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected void doWriteBasicExpressionNodeElements(JsonObject jo, BasicExpressionNode def) { + doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + } + protected JsonObject doWriteBasicExpressionNode(BasicExpressionNode def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteBasicExpressionNodeElements(jo, def); + return jo; + } + protected void doWriteBasicOutputExpressionNodeElements(JsonObject jo, BasicOutputExpressionNode def) { + doWriteBasicExpressionNodeElements(jo, def); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + } + protected JsonObject doWriteBasicOutputExpressionNode(BasicOutputExpressionNode def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteBasicOutputExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteBeanDefinition(BeanDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + doWriteAttribute(jo, "method", def.getMethod(), null); + doWriteAttribute(jo, "beanType", def.getBeanType(), null); + doWriteAttribute(jo, "scope", def.getScope(), "Singleton"); + return jo; + } + protected JsonObject doWriteBeanFactoryDefinition(BeanFactoryDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteAttribute(jo, "type", def.getType(), null); + doWriteAttribute(jo, "initMethod", def.getInitMethod(), null); + doWriteAttribute(jo, "destroyMethod", def.getDestroyMethod(), null); + doWriteAttribute(jo, "factoryMethod", def.getFactoryMethod(), null); + doWriteAttribute(jo, "factoryBean", def.getFactoryBean(), null); + doWriteAttribute(jo, "builderClass", def.getBuilderClass(), null); + doWriteAttribute(jo, "builderMethod", def.getBuilderMethod(), "build"); + doWriteAttribute(jo, "scriptLanguage", def.getScriptLanguage(), null); + doWriteAttribute(jo, "scriptPropertyPlaceholders", def.getScriptPropertyPlaceholders(), "true"); + doWriteChildElement(jo, "constructors", new BeanConstructorsAdapter().marshal(def.getConstructors()), this::doWriteBeanConstructorsDefinition); + doWriteChildElement(jo, "properties", new BeanPropertiesAdapter().marshal(def.getProperties()), this::doWriteBeanPropertiesDefinition); + if (def.getScript() != null) { + jo.put("script", def.getScript()); + } + return jo; + } + protected JsonObject doWriteCatchDefinition(CatchDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteStringList(jo, null, "exception", def.getExceptions()); + doWriteChildElement(jo, "onWhen", def.getOnWhen(), this::doWriteOnWhenDefinition); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteChoiceDefinition(ChoiceDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "precondition", def.getPrecondition(), "false"); + doWriteElementRefList(jo, null, def.getWhenClauses(), this::doWriteWhenDefinitionRef); + doWriteChildElement(jo, "otherwise", def.getOtherwise(), this::doWriteOtherwiseDefinition); + return jo; + } + protected JsonObject doWriteCircuitBreakerDefinition(CircuitBreakerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "configuration", def.getConfiguration(), null); + doWriteAttribute(jo, "inheritErrorHandler", toString(def.getInheritErrorHandler()), "false"); + doWriteChildElement(jo, "resilience4jConfiguration", def.getResilience4jConfiguration(), this::doWriteResilience4jConfigurationDefinition); + doWriteChildElement(jo, "faultToleranceConfiguration", def.getFaultToleranceConfiguration(), this::doWriteFaultToleranceConfigurationDefinition); + doWriteChildElement(jo, "onFallback", def.getOnFallback(), this::doWriteOnFallbackDefinition); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteClaimCheckDefinition(ClaimCheckDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "operation", def.getOperation(), null); + doWriteAttribute(jo, "key", def.getKey(), null); + doWriteAttribute(jo, "filter", def.getFilter(), null); + doWriteAttribute(jo, "aggregationStrategy", def.getAggregationStrategy(), null); + doWriteAttribute(jo, "aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); + return jo; + } + protected JsonObject doWriteContextScanDefinition(ContextScanDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "includeNonSingletons", def.getIncludeNonSingletons(), null); + doWriteStringList(jo, null, "excludes", def.getExcludes()); + doWriteStringList(jo, null, "includes", def.getIncludes()); + return jo; + } + protected JsonObject doWriteConvertBodyDefinition(ConvertBodyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "type", def.getType(), null); + doWriteAttribute(jo, "mandatory", def.getMandatory(), "true"); + doWriteAttribute(jo, "charset", def.getCharset(), null); + return jo; + } + protected JsonObject doWriteConvertHeaderDefinition(ConvertHeaderDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteAttribute(jo, "type", def.getType(), null); + doWriteAttribute(jo, "toName", def.getToName(), null); + doWriteAttribute(jo, "mandatory", def.getMandatory(), "true"); + doWriteAttribute(jo, "charset", def.getCharset(), null); + return jo; + } + protected JsonObject doWriteConvertVariableDefinition(ConvertVariableDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteAttribute(jo, "type", def.getType(), null); + doWriteAttribute(jo, "toName", def.getToName(), null); + doWriteAttribute(jo, "mandatory", def.getMandatory(), "true"); + doWriteAttribute(jo, "charset", def.getCharset(), null); + return jo; + } + protected JsonObject doWriteDataFormatDefinition(DataFormatDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + return jo; + } + protected JsonObject doWriteDelayDefinition(DelayDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "asyncDelayed", def.getAsyncDelayed(), "true"); + doWriteAttribute(jo, "callerRunsWhenRejected", def.getCallerRunsWhenRejected(), "true"); + doWriteAttribute(jo, "executorService", def.getExecutorService(), null); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteDynamicRouterDefinition(DynamicRouterDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "uriDelimiter", def.getUriDelimiter(), ","); + doWriteAttribute(jo, "ignoreInvalidEndpoints", def.getIgnoreInvalidEndpoints(), null); + doWriteAttribute(jo, "cacheSize", def.getCacheSize(), null); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteEnrichDefinition(EnrichDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "variableSend", def.getVariableSend(), null); + doWriteAttribute(jo, "variableReceive", def.getVariableReceive(), null); + doWriteAttribute(jo, "aggregationStrategy", def.getAggregationStrategy(), null); + doWriteAttribute(jo, "aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); + doWriteAttribute(jo, "aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); + doWriteAttribute(jo, "aggregateOnException", def.getAggregateOnException(), null); + doWriteAttribute(jo, "shareUnitOfWork", def.getShareUnitOfWork(), null); + doWriteAttribute(jo, "cacheSize", def.getCacheSize(), null); + doWriteAttribute(jo, "ignoreInvalidEndpoint", def.getIgnoreInvalidEndpoint(), null); + doWriteAttribute(jo, "allowOptimisedComponents", def.getAllowOptimisedComponents(), "true"); + doWriteAttribute(jo, "autoStartComponents", def.getAutoStartComponents(), "true"); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteErrorHandlerDefinition(ErrorHandlerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + if (def.getErrorHandlerType() != null) { + switch (def.getErrorHandlerType().getClass().getSimpleName()) { + case "DeadLetterChannelDefinition" -> doWriteChildElement(jo, "deadLetterChannel", (DeadLetterChannelDefinition) def.getErrorHandlerType(), this::doWriteDeadLetterChannelDefinition); + case "DefaultErrorHandlerDefinition" -> doWriteChildElement(jo, "defaultErrorHandler", (DefaultErrorHandlerDefinition) def.getErrorHandlerType(), this::doWriteDefaultErrorHandlerDefinition); + case "NoErrorHandlerDefinition" -> doWriteChildElement(jo, "noErrorHandler", (NoErrorHandlerDefinition) def.getErrorHandlerType(), this::doWriteNoErrorHandlerDefinition); + case "RefErrorHandlerDefinition" -> doWriteChildElement(jo, "refErrorHandler", (RefErrorHandlerDefinition) def.getErrorHandlerType(), this::doWriteRefErrorHandlerDefinition); + case "JtaTransactionErrorHandlerDefinition" -> doWriteChildElement(jo, "jtaTransactionErrorHandler", (JtaTransactionErrorHandlerDefinition) def.getErrorHandlerType(), this::doWriteJtaTransactionErrorHandlerDefinition); + case "SpringTransactionErrorHandlerDefinition" -> doWriteChildElement(jo, "springTransactionErrorHandler", (SpringTransactionErrorHandlerDefinition) def.getErrorHandlerType(), this::doWriteSpringTransactionErrorHandlerDefinition); + } + } + return jo; + } + protected void doWriteExpressionNodeElements(JsonObject jo, ExpressionNode def) { + doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + } + protected JsonObject doWriteExpressionNode(ExpressionNode def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteExpressionSubElementDefinition(ExpressionSubElementDefinition def) { + JsonObject jo = new JsonObject(); + doWriteElementRef(jo, def.getExpressionType(), this::doWriteExpressionDefinitionRef); + return jo; + } + protected void doWriteFaultToleranceConfigurationCommonAttributes(JsonObject jo, FaultToleranceConfigurationCommon def) { + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "delay", def.getDelay(), "5000"); + doWriteAttribute(jo, "bulkheadWaitingTaskQueue", def.getBulkheadWaitingTaskQueue(), "10"); + doWriteAttribute(jo, "typedGuard", def.getTypedGuard(), null); + doWriteAttribute(jo, "failureRatio", def.getFailureRatio(), "50"); + doWriteAttribute(jo, "timeoutDuration", def.getTimeoutDuration(), "1000"); + doWriteAttribute(jo, "timeoutEnabled", def.getTimeoutEnabled(), "false"); + doWriteAttribute(jo, "timeoutPoolSize", def.getTimeoutPoolSize(), "10"); + doWriteAttribute(jo, "successThreshold", def.getSuccessThreshold(), "1"); + doWriteAttribute(jo, "requestVolumeThreshold", def.getRequestVolumeThreshold(), "20"); + doWriteAttribute(jo, "bulkheadMaxConcurrentCalls", def.getBulkheadMaxConcurrentCalls(), "10"); + doWriteAttribute(jo, "threadOffloadExecutorService", def.getThreadOffloadExecutorService(), null); + doWriteAttribute(jo, "bulkheadEnabled", def.getBulkheadEnabled(), "false"); + } + protected JsonObject doWriteFaultToleranceConfigurationCommon(FaultToleranceConfigurationCommon def) { + JsonObject jo = new JsonObject(); + doWriteFaultToleranceConfigurationCommonAttributes(jo, def); + return jo; + } + protected JsonObject doWriteFaultToleranceConfigurationDefinition(FaultToleranceConfigurationDefinition def) { + JsonObject jo = new JsonObject(); + doWriteFaultToleranceConfigurationCommonAttributes(jo, def); + return jo; + } + protected JsonObject doWriteFilterDefinition(FilterDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "statusPropertyName", def.getStatusPropertyName(), null); + doWriteOutputExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteFinallyDefinition(FinallyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteFromDefinition(FromDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "uri", def.getUri(), null); + doWriteAttribute(jo, "variableReceive", def.getVariableReceive(), null); + return jo; + } + protected JsonObject doWriteGlobalOptionDefinition(GlobalOptionDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "key", def.getKey(), null); + doWriteAttribute(jo, "value", def.getValue(), null); + return jo; + } + protected JsonObject doWriteGlobalOptionsDefinition(GlobalOptionsDefinition def) { + JsonObject jo = new JsonObject(); + doWriteChildList(jo, null, "globalOption", def.getGlobalOptions(), this::doWriteGlobalOptionDefinition); + return jo; + } + protected JsonObject doWriteIdempotentConsumerDefinition(IdempotentConsumerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "idempotentRepository", def.getIdempotentRepository(), null); + doWriteAttribute(jo, "eager", def.getEager(), "true"); + doWriteAttribute(jo, "completionEager", def.getCompletionEager(), "false"); + doWriteAttribute(jo, "skipDuplicate", def.getSkipDuplicate(), "true"); + doWriteAttribute(jo, "removeOnFailure", def.getRemoveOnFailure(), "true"); + doWriteOutputExpressionNodeElements(jo, def); + return jo; + } + protected void doWriteIdentifiedTypeAttributes(JsonObject jo, IdentifiedType def) { + doWriteAttribute(jo, "id", def.getId(), null); + } + protected JsonObject doWriteIdentifiedType(IdentifiedType def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + return jo; + } + protected JsonObject doWriteInputTypeDefinition(InputTypeDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "urn", def.getUrn(), null); + doWriteAttribute(jo, "validate", def.getValidate(), "false"); + return jo; + } + protected void doWriteInterceptDefinitionElements(JsonObject jo, InterceptDefinition def) { + doWriteChildElement(jo, "onWhen", def.getOnWhen(), this::doWriteOnWhenDefinition); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + } + protected JsonObject doWriteInterceptDefinition(InterceptDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteInterceptDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteInterceptFromDefinition(InterceptFromDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "uri", def.getUri(), null); + doWriteInterceptDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteInterceptSendToEndpointDefinition(InterceptSendToEndpointDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "uri", def.getUri(), null); + doWriteAttribute(jo, "skipSendToOriginalEndpoint", def.getSkipSendToOriginalEndpoint(), null); + doWriteAttribute(jo, "afterUri", def.getAfterUri(), null); + doWriteChildElement(jo, "onWhen", def.getOnWhen(), this::doWriteOnWhenDefinition); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteKameletDefinition(KameletDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteLoadBalanceDefinition(LoadBalanceDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + if (def.getLoadBalancerType() != null) { + switch (def.getLoadBalancerType().getClass().getSimpleName()) { + case "CustomLoadBalancerDefinition" -> doWriteChildElement(jo, "customLoadBalancer", (CustomLoadBalancerDefinition) def.getLoadBalancerType(), this::doWriteCustomLoadBalancerDefinition); + case "FailoverLoadBalancerDefinition" -> doWriteChildElement(jo, "failoverLoadBalancer", (FailoverLoadBalancerDefinition) def.getLoadBalancerType(), this::doWriteFailoverLoadBalancerDefinition); + case "RandomLoadBalancerDefinition" -> doWriteChildElement(jo, "randomLoadBalancer", (RandomLoadBalancerDefinition) def.getLoadBalancerType(), this::doWriteRandomLoadBalancerDefinition); + case "RoundRobinLoadBalancerDefinition" -> doWriteChildElement(jo, "roundRobinLoadBalancer", (RoundRobinLoadBalancerDefinition) def.getLoadBalancerType(), this::doWriteRoundRobinLoadBalancerDefinition); + case "StickyLoadBalancerDefinition" -> doWriteChildElement(jo, "stickyLoadBalancer", (StickyLoadBalancerDefinition) def.getLoadBalancerType(), this::doWriteStickyLoadBalancerDefinition); + case "TopicLoadBalancerDefinition" -> doWriteChildElement(jo, "topicLoadBalancer", (TopicLoadBalancerDefinition) def.getLoadBalancerType(), this::doWriteTopicLoadBalancerDefinition); + case "WeightedLoadBalancerDefinition" -> doWriteChildElement(jo, "weightedLoadBalancer", (WeightedLoadBalancerDefinition) def.getLoadBalancerType(), this::doWriteWeightedLoadBalancerDefinition); + } + } + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteLoadBalancerDefinition(LoadBalancerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + return jo; + } + protected JsonObject doWriteLogDefinition(LogDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "message", def.getMessage(), null); + doWriteAttribute(jo, "loggingLevel", def.getLoggingLevel(), "INFO"); + doWriteAttribute(jo, "logName", def.getLogName(), null); + doWriteAttribute(jo, "marker", def.getMarker(), null); + doWriteAttribute(jo, "logger", def.getLogger(), null); + doWriteAttribute(jo, "logLanguage", def.getLogLanguage(), null); + return jo; + } + protected JsonObject doWriteLoopDefinition(LoopDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "copy", def.getCopy(), null); + doWriteAttribute(jo, "doWhile", def.getDoWhile(), null); + doWriteAttribute(jo, "breakOnShutdown", def.getBreakOnShutdown(), null); + doWriteAttribute(jo, "onPrepare", def.getOnPrepare(), null); + doWriteOutputExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteMarshalDefinition(MarshalDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "variableSend", def.getVariableSend(), null); + doWriteAttribute(jo, "variableReceive", def.getVariableReceive(), null); + if (def.getDataFormatType() != null) { + switch (def.getDataFormatType().getClass().getSimpleName()) { + case "ASN1DataFormat" -> doWriteChildElement(jo, "asn1", (ASN1DataFormat) def.getDataFormatType(), this::doWriteASN1DataFormat); + case "AvroDataFormat" -> doWriteChildElement(jo, "avro", (AvroDataFormat) def.getDataFormatType(), this::doWriteAvroDataFormat); + case "BarcodeDataFormat" -> doWriteChildElement(jo, "barcode", (BarcodeDataFormat) def.getDataFormatType(), this::doWriteBarcodeDataFormat); + case "Base64DataFormat" -> doWriteChildElement(jo, "base64", (Base64DataFormat) def.getDataFormatType(), this::doWriteBase64DataFormat); + case "BeanioDataFormat" -> doWriteChildElement(jo, "beanio", (BeanioDataFormat) def.getDataFormatType(), this::doWriteBeanioDataFormat); + case "BindyDataFormat" -> doWriteChildElement(jo, "bindy", (BindyDataFormat) def.getDataFormatType(), this::doWriteBindyDataFormat); + case "CBORDataFormat" -> doWriteChildElement(jo, "cbor", (CBORDataFormat) def.getDataFormatType(), this::doWriteCBORDataFormat); + case "CryptoDataFormat" -> doWriteChildElement(jo, "crypto", (CryptoDataFormat) def.getDataFormatType(), this::doWriteCryptoDataFormat); + case "CsvDataFormat" -> doWriteChildElement(jo, "csv", (CsvDataFormat) def.getDataFormatType(), this::doWriteCsvDataFormat); + case "CustomDataFormat" -> doWriteChildElement(jo, "custom", (CustomDataFormat) def.getDataFormatType(), this::doWriteCustomDataFormat); + case "DfdlDataFormat" -> doWriteChildElement(jo, "dfdl", (DfdlDataFormat) def.getDataFormatType(), this::doWriteDfdlDataFormat); + case "FhirJsonDataFormat" -> doWriteChildElement(jo, "fhirJson", (FhirJsonDataFormat) def.getDataFormatType(), this::doWriteFhirJsonDataFormat); + case "FhirXmlDataFormat" -> doWriteChildElement(jo, "fhirXml", (FhirXmlDataFormat) def.getDataFormatType(), this::doWriteFhirXmlDataFormat); + case "FlatpackDataFormat" -> doWriteChildElement(jo, "flatpack", (FlatpackDataFormat) def.getDataFormatType(), this::doWriteFlatpackDataFormat); + case "ForyDataFormat" -> doWriteChildElement(jo, "fory", (ForyDataFormat) def.getDataFormatType(), this::doWriteForyDataFormat); + case "GrokDataFormat" -> doWriteChildElement(jo, "grok", (GrokDataFormat) def.getDataFormatType(), this::doWriteGrokDataFormat); + case "GroovyJSonDataFormat" -> doWriteChildElement(jo, "groovyJson", (GroovyJSonDataFormat) def.getDataFormatType(), this::doWriteGroovyJSonDataFormat); + case "GroovyXmlDataFormat" -> doWriteChildElement(jo, "groovyXml", (GroovyXmlDataFormat) def.getDataFormatType(), this::doWriteGroovyXmlDataFormat); + case "GzipDeflaterDataFormat" -> doWriteChildElement(jo, "gzipDeflater", (GzipDeflaterDataFormat) def.getDataFormatType(), this::doWriteGzipDeflaterDataFormat); + case "HL7DataFormat" -> doWriteChildElement(jo, "hl7", (HL7DataFormat) def.getDataFormatType(), this::doWriteHL7DataFormat); + case "IcalDataFormat" -> doWriteChildElement(jo, "ical", (IcalDataFormat) def.getDataFormatType(), this::doWriteIcalDataFormat); + case "Iso8583DataFormat" -> doWriteChildElement(jo, "iso8583", (Iso8583DataFormat) def.getDataFormatType(), this::doWriteIso8583DataFormat); + case "JacksonXMLDataFormat" -> doWriteChildElement(jo, "jacksonXml", (JacksonXMLDataFormat) def.getDataFormatType(), this::doWriteJacksonXMLDataFormat); + case "JaxbDataFormat" -> doWriteChildElement(jo, "jaxb", (JaxbDataFormat) def.getDataFormatType(), this::doWriteJaxbDataFormat); + case "JsonDataFormat" -> doWriteChildElement(jo, "json", (JsonDataFormat) def.getDataFormatType(), this::doWriteJsonDataFormat); + case "JsonApiDataFormat" -> doWriteChildElement(jo, "jsonApi", (JsonApiDataFormat) def.getDataFormatType(), this::doWriteJsonApiDataFormat); + case "LZFDataFormat" -> doWriteChildElement(jo, "lzf", (LZFDataFormat) def.getDataFormatType(), this::doWriteLZFDataFormat); + case "MimeMultipartDataFormat" -> doWriteChildElement(jo, "mimeMultipart", (MimeMultipartDataFormat) def.getDataFormatType(), this::doWriteMimeMultipartDataFormat); + case "OcsfDataFormat" -> doWriteChildElement(jo, "ocsf", (OcsfDataFormat) def.getDataFormatType(), this::doWriteOcsfDataFormat); + case "ParquetAvroDataFormat" -> doWriteChildElement(jo, "parquetAvro", (ParquetAvroDataFormat) def.getDataFormatType(), this::doWriteParquetAvroDataFormat); + case "PGPDataFormat" -> doWriteChildElement(jo, "pgp", (PGPDataFormat) def.getDataFormatType(), this::doWritePGPDataFormat); + case "PQCDataFormat" -> doWriteChildElement(jo, "pqc", (PQCDataFormat) def.getDataFormatType(), this::doWritePQCDataFormat); + case "ProtobufDataFormat" -> doWriteChildElement(jo, "protobuf", (ProtobufDataFormat) def.getDataFormatType(), this::doWriteProtobufDataFormat); + case "RssDataFormat" -> doWriteChildElement(jo, "rss", (RssDataFormat) def.getDataFormatType(), this::doWriteRssDataFormat); + case "SmooksDataFormat" -> doWriteChildElement(jo, "smooks", (SmooksDataFormat) def.getDataFormatType(), this::doWriteSmooksDataFormat); + case "SoapDataFormat" -> doWriteChildElement(jo, "soap", (SoapDataFormat) def.getDataFormatType(), this::doWriteSoapDataFormat); + case "SwiftMtDataFormat" -> doWriteChildElement(jo, "swiftMt", (SwiftMtDataFormat) def.getDataFormatType(), this::doWriteSwiftMtDataFormat); + case "SwiftMxDataFormat" -> doWriteChildElement(jo, "swiftMx", (SwiftMxDataFormat) def.getDataFormatType(), this::doWriteSwiftMxDataFormat); + case "SyslogDataFormat" -> doWriteChildElement(jo, "syslog", (SyslogDataFormat) def.getDataFormatType(), this::doWriteSyslogDataFormat); + case "TarFileDataFormat" -> doWriteChildElement(jo, "tarFile", (TarFileDataFormat) def.getDataFormatType(), this::doWriteTarFileDataFormat); + case "ThriftDataFormat" -> doWriteChildElement(jo, "thrift", (ThriftDataFormat) def.getDataFormatType(), this::doWriteThriftDataFormat); + case "UniVocityCsvDataFormat" -> doWriteChildElement(jo, "univocityCsv", (UniVocityCsvDataFormat) def.getDataFormatType(), this::doWriteUniVocityCsvDataFormat); + case "UniVocityFixedDataFormat" -> doWriteChildElement(jo, "univocityFixed", (UniVocityFixedDataFormat) def.getDataFormatType(), this::doWriteUniVocityFixedDataFormat); + case "UniVocityTsvDataFormat" -> doWriteChildElement(jo, "univocityTsv", (UniVocityTsvDataFormat) def.getDataFormatType(), this::doWriteUniVocityTsvDataFormat); + case "XMLSecurityDataFormat" -> doWriteChildElement(jo, "xmlSecurity", (XMLSecurityDataFormat) def.getDataFormatType(), this::doWriteXMLSecurityDataFormat); + case "YAMLDataFormat" -> doWriteChildElement(jo, "yaml", (YAMLDataFormat) def.getDataFormatType(), this::doWriteYAMLDataFormat); + case "ZipDeflaterDataFormat" -> doWriteChildElement(jo, "zipDeflater", (ZipDeflaterDataFormat) def.getDataFormatType(), this::doWriteZipDeflaterDataFormat); + case "ZipFileDataFormat" -> doWriteChildElement(jo, "zipFile", (ZipFileDataFormat) def.getDataFormatType(), this::doWriteZipFileDataFormat); + } + } + return jo; + } + protected JsonObject doWriteMulticastDefinition(MulticastDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "aggregationStrategy", def.getAggregationStrategy(), null); + doWriteAttribute(jo, "aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); + doWriteAttribute(jo, "aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); + doWriteAttribute(jo, "parallelAggregate", def.getParallelAggregate(), null); + doWriteAttribute(jo, "parallelProcessing", def.getParallelProcessing(), null); + doWriteAttribute(jo, "synchronous", def.getSynchronous(), null); + doWriteAttribute(jo, "streaming", def.getStreaming(), null); + doWriteAttribute(jo, "stopOnException", def.getStopOnException(), null); + doWriteAttribute(jo, "timeout", def.getTimeout(), "0"); + doWriteAttribute(jo, "executorService", def.getExecutorService(), null); + doWriteAttribute(jo, "onPrepare", def.getOnPrepare(), null); + doWriteAttribute(jo, "shareUnitOfWork", def.getShareUnitOfWork(), null); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteOnCompletionDefinition(OnCompletionDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "mode", def.getMode(), "AfterConsumer"); + doWriteAttribute(jo, "onCompleteOnly", def.getOnCompleteOnly(), null); + doWriteAttribute(jo, "onFailureOnly", def.getOnFailureOnly(), null); + doWriteAttribute(jo, "parallelProcessing", def.getParallelProcessing(), null); + doWriteAttribute(jo, "executorService", def.getExecutorService(), null); + doWriteAttribute(jo, "useOriginalMessage", def.getUseOriginalMessage(), null); + doWriteChildElement(jo, "onWhen", def.getOnWhen(), this::doWriteOnWhenDefinition); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteOnExceptionDefinition(OnExceptionDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "redeliveryPolicyRef", def.getRedeliveryPolicyRef(), null); + doWriteAttribute(jo, "onRedeliveryRef", def.getOnRedeliveryRef(), null); + doWriteAttribute(jo, "onExceptionOccurredRef", def.getOnExceptionOccurredRef(), null); + doWriteAttribute(jo, "useOriginalMessage", def.getUseOriginalMessage(), null); + doWriteAttribute(jo, "useOriginalBody", def.getUseOriginalBody(), null); + doWriteStringList(jo, null, "exception", def.getExceptions()); + doWriteChildElement(jo, "redeliveryPolicy", def.getRedeliveryPolicyType(), this::doWriteRedeliveryPolicyDefinition); + doWriteChildElement(jo, "onWhen", def.getOnWhen(), this::doWriteOnWhenDefinition); + doWriteChildElement(jo, "retryWhile", def.getRetryWhile(), this::doWriteExpressionSubElementDefinition); + doWriteChildElement(jo, "handled", def.getHandled(), this::doWriteExpressionSubElementDefinition); + doWriteChildElement(jo, "continued", def.getContinued(), this::doWriteExpressionSubElementDefinition); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteOnFallbackDefinition(OnFallbackDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "fallbackViaNetwork", def.getFallbackViaNetwork(), "false"); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteOnWhenDefinition(OnWhenDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + return jo; + } + protected JsonObject doWriteOptimisticLockRetryPolicyDefinition(OptimisticLockRetryPolicyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "maximumRetries", def.getMaximumRetries(), null); + doWriteAttribute(jo, "retryDelay", def.getRetryDelay(), "50"); + doWriteAttribute(jo, "maximumRetryDelay", def.getMaximumRetryDelay(), "1000"); + doWriteAttribute(jo, "exponentialBackOff", def.getExponentialBackOff(), "true"); + doWriteAttribute(jo, "randomBackOff", def.getRandomBackOff(), null); + return jo; + } + protected void doWriteOptionalIdentifiedDefinitionAttributes(JsonObject jo, OptionalIdentifiedDefinition def) { + doWriteAttribute(jo, "customId", toString(def.getCustomId()), null); + doWriteAttribute(jo, "id", def.getId(), null); + doWriteAttribute(jo, "note", def.getNote(), null); + doWriteAttribute(jo, "description", def.getDescription(), null); + } + protected JsonObject doWriteOptionalIdentifiedDefinition(OptionalIdentifiedDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteOtherwiseDefinition(OtherwiseDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "disabled", def.getDisabled(), null); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected void doWriteOutputExpressionNodeElements(JsonObject jo, OutputExpressionNode def) { + doWriteExpressionNodeElements(jo, def); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + } + protected JsonObject doWriteOutputExpressionNode(OutputExpressionNode def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteOutputExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteOutputTypeDefinition(OutputTypeDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "urn", def.getUrn(), null); + doWriteAttribute(jo, "validate", def.getValidate(), "false"); + return jo; + } + protected JsonObject doWritePackageScanDefinition(PackageScanDefinition def) { + JsonObject jo = new JsonObject(); + doWriteStringList(jo, null, "package", def.getPackages()); + doWriteStringList(jo, null, "excludes", def.getExcludes()); + doWriteStringList(jo, null, "includes", def.getIncludes()); + return jo; + } + protected JsonObject doWritePausableDefinition(PausableDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "consumerListener", def.getConsumerListener(), null); + doWriteAttribute(jo, "untilCheck", def.getUntilCheck(), null); + return jo; + } + protected JsonObject doWritePipelineDefinition(PipelineDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWritePolicyDefinition(PolicyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWritePollDefinition(PollDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "variableReceive", def.getVariableReceive(), null); + doWriteAttribute(jo, "uri", def.getUri(), null); + doWriteAttribute(jo, "timeout", def.getTimeout(), "20000"); + return jo; + } + protected JsonObject doWritePollEnrichDefinition(PollEnrichDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "variableReceive", def.getVariableReceive(), null); + doWriteAttribute(jo, "aggregationStrategy", def.getAggregationStrategy(), null); + doWriteAttribute(jo, "aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); + doWriteAttribute(jo, "aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); + doWriteAttribute(jo, "aggregateOnException", def.getAggregateOnException(), null); + doWriteAttribute(jo, "timeout", def.getTimeout(), "-1"); + doWriteAttribute(jo, "cacheSize", def.getCacheSize(), null); + doWriteAttribute(jo, "ignoreInvalidEndpoint", def.getIgnoreInvalidEndpoint(), null); + doWriteAttribute(jo, "allowOptimisedComponents", def.getAllowOptimisedComponents(), "true"); + doWriteAttribute(jo, "autoStartComponents", def.getAutoStartComponents(), "true"); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteProcessDefinition(ProcessDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + return jo; + } + protected void doWriteProcessorDefinitionAttributes(JsonObject jo, ProcessorDefinition def) { + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "disabled", def.getDisabled(), null); + } + protected JsonObject doWriteProcessorDefinition(ProcessorDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWritePropertyDefinition(PropertyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "key", def.getKey(), null); + doWriteAttribute(jo, "value", def.getValue(), null); + return jo; + } + protected JsonObject doWritePropertyDefinitions(PropertyDefinitions def) { + JsonObject jo = new JsonObject(); + doWriteChildList(jo, null, "property", def.getProperties(), this::doWritePropertyDefinition); + return jo; + } + protected JsonObject doWritePropertyExpressionDefinition(PropertyExpressionDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "key", def.getKey(), null); + doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + return jo; + } + protected JsonObject doWriteRecipientListDefinition(RecipientListDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "delimiter", def.getDelimiter(), ","); + doWriteAttribute(jo, "aggregationStrategy", def.getAggregationStrategy(), null); + doWriteAttribute(jo, "aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); + doWriteAttribute(jo, "aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); + doWriteAttribute(jo, "parallelAggregate", def.getParallelAggregate(), null); + doWriteAttribute(jo, "parallelProcessing", def.getParallelProcessing(), null); + doWriteAttribute(jo, "synchronous", def.getSynchronous(), null); + doWriteAttribute(jo, "timeout", def.getTimeout(), "0"); + doWriteAttribute(jo, "executorService", def.getExecutorService(), null); + doWriteAttribute(jo, "stopOnException", def.getStopOnException(), null); + doWriteAttribute(jo, "ignoreInvalidEndpoints", def.getIgnoreInvalidEndpoints(), null); + doWriteAttribute(jo, "streaming", def.getStreaming(), null); + doWriteAttribute(jo, "onPrepare", def.getOnPrepare(), null); + doWriteAttribute(jo, "cacheSize", def.getCacheSize(), null); + doWriteAttribute(jo, "shareUnitOfWork", def.getShareUnitOfWork(), null); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteRedeliveryPolicyDefinition(RedeliveryPolicyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "maximumRedeliveries", def.getMaximumRedeliveries(), null); + doWriteAttribute(jo, "redeliveryDelay", def.getRedeliveryDelay(), "1000"); + doWriteAttribute(jo, "asyncDelayedRedelivery", def.getAsyncDelayedRedelivery(), null); + doWriteAttribute(jo, "backOffMultiplier", def.getBackOffMultiplier(), "2.0"); + doWriteAttribute(jo, "useExponentialBackOff", def.getUseExponentialBackOff(), null); + doWriteAttribute(jo, "collisionAvoidanceFactor", def.getCollisionAvoidanceFactor(), "0.15"); + doWriteAttribute(jo, "useCollisionAvoidance", def.getUseCollisionAvoidance(), null); + doWriteAttribute(jo, "maximumRedeliveryDelay", def.getMaximumRedeliveryDelay(), "60000"); + doWriteAttribute(jo, "retriesExhaustedLogLevel", def.getRetriesExhaustedLogLevel(), "ERROR"); + doWriteAttribute(jo, "retryAttemptedLogLevel", def.getRetryAttemptedLogLevel(), "DEBUG"); + doWriteAttribute(jo, "retryAttemptedLogInterval", def.getRetryAttemptedLogInterval(), "1"); + doWriteAttribute(jo, "logRetryAttempted", def.getLogRetryAttempted(), "true"); + doWriteAttribute(jo, "logStackTrace", def.getLogStackTrace(), "true"); + doWriteAttribute(jo, "logRetryStackTrace", def.getLogRetryStackTrace(), null); + doWriteAttribute(jo, "logHandled", def.getLogHandled(), null); + doWriteAttribute(jo, "logNewException", def.getLogNewException(), "true"); + doWriteAttribute(jo, "logContinued", def.getLogContinued(), null); + doWriteAttribute(jo, "logExhausted", def.getLogExhausted(), "true"); + doWriteAttribute(jo, "logExhaustedMessageHistory", def.getLogExhaustedMessageHistory(), null); + doWriteAttribute(jo, "logExhaustedMessageBody", def.getLogExhaustedMessageBody(), null); + doWriteAttribute(jo, "disableRedelivery", def.getDisableRedelivery(), null); + doWriteAttribute(jo, "delayPattern", def.getDelayPattern(), null); + doWriteAttribute(jo, "allowRedeliveryWhileStopping", def.getAllowRedeliveryWhileStopping(), "true"); + doWriteAttribute(jo, "exchangeFormatterRef", def.getExchangeFormatterRef(), null); + return jo; + } + protected JsonObject doWriteRemoveHeaderDefinition(RemoveHeaderDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "name", def.getName(), null); + return jo; + } + protected JsonObject doWriteRemoveHeadersDefinition(RemoveHeadersDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "pattern", def.getPattern(), null); + doWriteAttribute(jo, "excludePattern", def.getExcludePattern(), null); + return jo; + } + protected JsonObject doWriteRemovePropertiesDefinition(RemovePropertiesDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "pattern", def.getPattern(), null); + doWriteAttribute(jo, "excludePattern", def.getExcludePattern(), null); + return jo; + } + protected JsonObject doWriteRemovePropertyDefinition(RemovePropertyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "name", def.getName(), null); + return jo; + } + protected JsonObject doWriteRemoveVariableDefinition(RemoveVariableDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "name", def.getName(), null); + return jo; + } + protected JsonObject doWriteResequenceDefinition(ResequenceDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + if (def.getResequencerConfig() != null) { + switch (def.getResequencerConfig().getClass().getSimpleName()) { + case "BatchResequencerConfig" -> doWriteChildElement(jo, "batchConfig", (BatchResequencerConfig) def.getResequencerConfig(), this::doWriteBatchResequencerConfig); + case "StreamResequencerConfig" -> doWriteChildElement(jo, "streamConfig", (StreamResequencerConfig) def.getResequencerConfig(), this::doWriteStreamResequencerConfig); + } + } + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected void doWriteResilience4jConfigurationCommonAttributes(JsonObject jo, Resilience4jConfigurationCommon def) { + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "failureRateThreshold", def.getFailureRateThreshold(), "50"); + doWriteAttribute(jo, "bulkheadMaxWaitDuration", def.getBulkheadMaxWaitDuration(), "0"); + doWriteAttribute(jo, "slowCallDurationThreshold", def.getSlowCallDurationThreshold(), "60"); + doWriteAttribute(jo, "timeoutCancelRunningFuture", def.getTimeoutCancelRunningFuture(), "true"); + doWriteAttribute(jo, "minimumNumberOfCalls", def.getMinimumNumberOfCalls(), "100"); + doWriteAttribute(jo, "timeoutDuration", def.getTimeoutDuration(), "1000"); + doWriteAttribute(jo, "timeoutEnabled", def.getTimeoutEnabled(), "false"); + doWriteAttribute(jo, "timeoutExecutorService", def.getTimeoutExecutorService(), null); + doWriteAttribute(jo, "permittedNumberOfCallsInHalfOpenState", def.getPermittedNumberOfCallsInHalfOpenState(), "10"); + doWriteAttribute(jo, "throwExceptionWhenHalfOpenOrOpenState", def.getThrowExceptionWhenHalfOpenOrOpenState(), "false"); + doWriteAttribute(jo, "slowCallRateThreshold", def.getSlowCallRateThreshold(), "100"); + doWriteAttribute(jo, "micrometerEnabled", def.getMicrometerEnabled(), "false"); + doWriteAttribute(jo, "writableStackTraceEnabled", def.getWritableStackTraceEnabled(), "true"); + doWriteAttribute(jo, "automaticTransitionFromOpenToHalfOpenEnabled", def.getAutomaticTransitionFromOpenToHalfOpenEnabled(), "false"); + doWriteAttribute(jo, "circuitBreaker", def.getCircuitBreaker(), null); + doWriteAttribute(jo, "slidingWindowSize", def.getSlidingWindowSize(), "100"); + doWriteAttribute(jo, "config", def.getConfig(), null); + doWriteAttribute(jo, "bulkheadMaxConcurrentCalls", def.getBulkheadMaxConcurrentCalls(), "25"); + doWriteAttribute(jo, "slidingWindowType", def.getSlidingWindowType(), "COUNT_BASED"); + doWriteAttribute(jo, "bulkheadEnabled", def.getBulkheadEnabled(), "false"); + doWriteAttribute(jo, "waitDurationInOpenState", def.getWaitDurationInOpenState(), "60"); + } + protected void doWriteResilience4jConfigurationCommonElements(JsonObject jo, Resilience4jConfigurationCommon def) { + doWriteStringList(jo, null, "ignoreException", def.getIgnoreExceptions()); + doWriteStringList(jo, null, "recordException", def.getRecordExceptions()); + } + protected JsonObject doWriteResilience4jConfigurationCommon(Resilience4jConfigurationCommon def) { + JsonObject jo = new JsonObject(); + doWriteResilience4jConfigurationCommonAttributes(jo, def); + doWriteResilience4jConfigurationCommonElements(jo, def); + return jo; + } + protected JsonObject doWriteResilience4jConfigurationDefinition(Resilience4jConfigurationDefinition def) { + JsonObject jo = new JsonObject(); + doWriteResilience4jConfigurationCommonAttributes(jo, def); + doWriteResilience4jConfigurationCommonElements(jo, def); + return jo; + } + protected JsonObject doWriteRestContextRefDefinition(RestContextRefDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "ref", def.getRef(), null); + return jo; + } + protected JsonObject doWriteResumableDefinition(ResumableDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "resumeStrategy", def.getResumeStrategy(), null); + doWriteAttribute(jo, "loggingLevel", def.getLoggingLevel(), "ERROR"); + doWriteAttribute(jo, "intermittent", def.getIntermittent(), "false"); + return jo; + } + protected JsonObject doWriteRollbackDefinition(RollbackDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "message", def.getMessage(), null); + doWriteAttribute(jo, "markRollbackOnly", def.getMarkRollbackOnly(), null); + doWriteAttribute(jo, "markRollbackOnlyLast", def.getMarkRollbackOnlyLast(), null); + return jo; + } + protected JsonObject doWriteRouteBuilderDefinition(RouteBuilderDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + return jo; + } + protected JsonObject doWriteRouteConfigurationContextRefDefinition(RouteConfigurationContextRefDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "ref", def.getRef(), null); + return jo; + } + protected JsonObject doWriteRouteConfigurationDefinition(RouteConfigurationDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "precondition", def.getPrecondition(), null); + doWriteChildList(jo, null, "onException", def.getOnExceptions(), this::doWriteOnExceptionDefinition); + doWriteChildList(jo, null, "onCompletion", def.getOnCompletions(), this::doWriteOnCompletionDefinition); + doWriteChildList(jo, null, "interceptSendToEndpoint", def.getInterceptSendTos(), this::doWriteInterceptSendToEndpointDefinition); + doWriteChildList(jo, null, "interceptFrom", def.getInterceptFroms(), this::doWriteInterceptFromDefinition); + doWriteChildList(jo, null, "intercept", def.getIntercepts(), this::doWriteInterceptDefinition); + doWriteChildElement(jo, "errorHandler", def.getErrorHandler(), this::doWriteErrorHandlerDefinition); + return jo; + } + protected JsonObject doWriteRouteConfigurationsDefinition(RouteConfigurationsDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteElementRefList(jo, null, def.getRouteConfigurations(), this::doWriteRouteConfigurationDefinitionRef); + return jo; + } + protected JsonObject doWriteRouteContextRefDefinition(RouteContextRefDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "ref", def.getRef(), null); + return jo; + } + protected JsonObject doWriteRouteDefinition(RouteDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "template", toString(def.isTemplate()), null); + doWriteAttribute(jo, "kamelet", toString(def.isKamelet()), null); + doWriteAttribute(jo, "rest", toString(def.isRest()), null); + doWriteAttribute(jo, "group", def.getGroup(), null); + doWriteAttribute(jo, "nodePrefixId", def.getNodePrefixId(), null); + doWriteAttribute(jo, "routeConfigurationId", def.getRouteConfigurationId(), null); + doWriteAttribute(jo, "autoStartup", def.getAutoStartup(), "true"); + doWriteAttribute(jo, "startupOrder", toString(def.getStartupOrder()), null); + doWriteAttribute(jo, "streamCache", def.getStreamCache(), null); + doWriteAttribute(jo, "trace", def.getTrace(), null); + doWriteAttribute(jo, "messageHistory", def.getMessageHistory(), null); + doWriteAttribute(jo, "logMask", def.getLogMask(), null); + doWriteAttribute(jo, "delayer", def.getDelayer(), null); + doWriteAttribute(jo, "errorHandlerRef", def.getErrorHandlerRef(), null); + doWriteAttribute(jo, "routePolicyRef", def.getRoutePolicyRef(), null); + doWriteAttribute(jo, "shutdownRoute", def.getShutdownRoute(), "Default"); + doWriteAttribute(jo, "shutdownRunningTask", def.getShutdownRunningTask(), "CompleteCurrentTaskOnly"); + doWriteAttribute(jo, "precondition", def.getPrecondition(), null); + doWriteChildList(jo, null, "routeProperty", def.getRouteProperties(), this::doWritePropertyDefinition); + doWriteChildElement(jo, "errorHandler", def.getErrorHandler(), this::doWriteErrorHandlerDefinition); + doWriteElementRef(jo, def.getInput(), this::doWriteFromDefinitionRef); + doWriteElementRef(jo, def.getInputType(), this::doWriteInputTypeDefinitionRef); + doWriteElementRef(jo, def.getOutputType(), this::doWriteOutputTypeDefinitionRef); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteRouteTemplateContextRefDefinition(RouteTemplateContextRefDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "ref", def.getRef(), null); + return jo; + } + protected JsonObject doWriteRouteTemplateDefinition(RouteTemplateDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteChildList(jo, null, "templateParameter", def.getTemplateParameters(), this::doWriteRouteTemplateParameterDefinition); + doWriteChildList(jo, null, "templateBean", def.getTemplateBeans(), this::doWriteBeanFactoryDefinition); + doWriteChildElement(jo, "route", def.getRoute(), this::doWriteRouteDefinition); + return jo; + } + protected JsonObject doWriteRouteTemplateParameterDefinition(RouteTemplateParameterDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "description", def.getDescription(), null); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteAttribute(jo, "required", toString(def.getRequired()), null); + doWriteAttribute(jo, "defaultValue", def.getDefaultValue(), null); + return jo; + } + protected JsonObject doWriteRouteTemplatesDefinition(RouteTemplatesDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteElementRefList(jo, null, def.getRouteTemplates(), this::doWriteRouteTemplateDefinitionRef); + return jo; + } + protected JsonObject doWriteRoutesDefinition(RoutesDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteElementRefList(jo, null, def.getRoutes(), this::doWriteRouteDefinitionRef); + return jo; + } + protected JsonObject doWriteRoutingSlipDefinition(RoutingSlipDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "uriDelimiter", def.getUriDelimiter(), ","); + doWriteAttribute(jo, "ignoreInvalidEndpoints", def.getIgnoreInvalidEndpoints(), null); + doWriteAttribute(jo, "cacheSize", def.getCacheSize(), null); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteSagaDefinition(SagaDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "sagaService", def.getSagaService(), null); + doWriteAttribute(jo, "propagation", def.getPropagation(), "REQUIRED"); + doWriteAttribute(jo, "completionMode", def.getCompletionMode(), "AUTO"); + doWriteAttribute(jo, "timeout", def.getTimeout(), null); + doWriteAttribute(jo, "compensation", def.getCompensation(), null); + doWriteAttribute(jo, "completion", def.getCompletion(), null); + doWriteChildList(jo, null, "option", def.getOptions(), this::doWritePropertyExpressionDefinition); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteSamplingDefinition(SamplingDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "samplePeriod", def.getSamplePeriod(), "1000"); + doWriteAttribute(jo, "messageFrequency", def.getMessageFrequency(), null); + return jo; + } + protected JsonObject doWriteScriptDefinition(ScriptDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected void doWriteSendDefinitionAttributes(JsonObject jo, SendDefinition def) { + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "uri", def.getUri(), null); + } + protected JsonObject doWriteSendDefinition(SendDefinition def) { + JsonObject jo = new JsonObject(); + doWriteSendDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteSetBodyDefinition(SetBodyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteSetExchangePatternDefinition(SetExchangePatternDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "pattern", def.getPattern(), null); + return jo; + } + protected JsonObject doWriteSetHeaderDefinition(SetHeaderDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteSetHeadersDefinition(SetHeadersDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteElementRefList(jo, null, def.getHeaders(), this::doWriteSetHeaderDefinitionRef); + return jo; + } + protected JsonObject doWriteSetPropertyDefinition(SetPropertyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteSetVariableDefinition(SetVariableDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteSetVariablesDefinition(SetVariablesDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteElementRefList(jo, null, def.getVariables(), this::doWriteSetVariableDefinitionRef); + return jo; + } + protected JsonObject doWriteSortDefinition(SortDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "comparator", def.getComparator(), null); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteSplitDefinition(SplitDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "delimiter", def.getDelimiter(), ","); + doWriteAttribute(jo, "aggregationStrategy", def.getAggregationStrategy(), null); + doWriteAttribute(jo, "aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); + doWriteAttribute(jo, "aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); + doWriteAttribute(jo, "parallelAggregate", def.getParallelAggregate(), null); + doWriteAttribute(jo, "parallelProcessing", def.getParallelProcessing(), null); + doWriteAttribute(jo, "synchronous", def.getSynchronous(), null); + doWriteAttribute(jo, "streaming", def.getStreaming(), null); + doWriteAttribute(jo, "stopOnException", def.getStopOnException(), null); + doWriteAttribute(jo, "timeout", def.getTimeout(), "0"); + doWriteAttribute(jo, "executorService", def.getExecutorService(), null); + doWriteAttribute(jo, "onPrepare", def.getOnPrepare(), null); + doWriteAttribute(jo, "shareUnitOfWork", def.getShareUnitOfWork(), null); + doWriteOutputExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteStepDefinition(StepDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteStopDefinition(StopDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteTemplatedRouteDefinition(TemplatedRouteDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "routeTemplateRef", def.getRouteTemplateRef(), null); + doWriteAttribute(jo, "routeId", def.getRouteId(), null); + doWriteAttribute(jo, "prefixId", def.getPrefixId(), null); + doWriteAttribute(jo, "group", def.getGroup(), null); + doWriteChildList(jo, null, "parameter", def.getParameters(), this::doWriteTemplatedRouteParameterDefinition); + doWriteChildList(jo, null, "bean", def.getBeans(), this::doWriteBeanFactoryDefinition); + return jo; + } + protected JsonObject doWriteTemplatedRouteParameterDefinition(TemplatedRouteParameterDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteAttribute(jo, "value", def.getValue(), null); + return jo; + } + protected JsonObject doWriteTemplatedRoutesDefinition(TemplatedRoutesDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteElementRefList(jo, null, def.getTemplatedRoutes(), this::doWriteTemplatedRouteDefinitionRef); + return jo; + } + protected JsonObject doWriteThreadPoolProfileDefinition(ThreadPoolProfileDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "defaultProfile", def.getDefaultProfile(), null); + doWriteAttribute(jo, "poolSize", def.getPoolSize(), null); + doWriteAttribute(jo, "maxPoolSize", def.getMaxPoolSize(), null); + doWriteAttribute(jo, "keepAliveTime", def.getKeepAliveTime(), null); + doWriteAttribute(jo, "timeUnit", def.getTimeUnit(), null); + doWriteAttribute(jo, "maxQueueSize", def.getMaxQueueSize(), null); + doWriteAttribute(jo, "allowCoreThreadTimeOut", def.getAllowCoreThreadTimeOut(), null); + doWriteAttribute(jo, "rejectedPolicy", def.getRejectedPolicy(), null); + return jo; + } + protected JsonObject doWriteThreadsDefinition(ThreadsDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "executorService", def.getExecutorService(), null); + doWriteAttribute(jo, "poolSize", def.getPoolSize(), null); + doWriteAttribute(jo, "maxPoolSize", def.getMaxPoolSize(), null); + doWriteAttribute(jo, "keepAliveTime", def.getKeepAliveTime(), null); + doWriteAttribute(jo, "timeUnit", def.getTimeUnit(), null); + doWriteAttribute(jo, "maxQueueSize", def.getMaxQueueSize(), null); + doWriteAttribute(jo, "allowCoreThreadTimeOut", def.getAllowCoreThreadTimeOut(), null); + doWriteAttribute(jo, "threadName", def.getThreadName(), "Threads"); + doWriteAttribute(jo, "rejectedPolicy", def.getRejectedPolicy(), null); + doWriteAttribute(jo, "callerRunsWhenRejected", def.getCallerRunsWhenRejected(), "true"); + return jo; + } + protected JsonObject doWriteThrottleDefinition(ThrottleDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "mode", def.getMode(), "TotalRequests"); + doWriteAttribute(jo, "executorService", def.getExecutorService(), null); + doWriteAttribute(jo, "asyncDelayed", def.getAsyncDelayed(), null); + doWriteAttribute(jo, "callerRunsWhenRejected", def.getCallerRunsWhenRejected(), "true"); + doWriteAttribute(jo, "rejectExecution", def.getRejectExecution(), null); + doWriteAttribute(jo, "timePeriodMillis", def.getTimePeriodMillis(), "1000"); + doWriteExpressionNodeElements(jo, def); + doWriteChildElement(jo, "correlationExpression", def.getCorrelationExpression(), this::doWriteExpressionSubElementDefinition); + return jo; + } + protected JsonObject doWriteThrowExceptionDefinition(ThrowExceptionDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "message", def.getMessage(), null); + doWriteAttribute(jo, "exceptionType", def.getExceptionType(), null); + doWriteAttribute(jo, "ref", def.getRef(), null); + return jo; + } + protected JsonObject doWriteToDefinition(ToDefinition def) { + JsonObject jo = new JsonObject(); + doWriteSendDefinitionAttributes(jo, def); + doWriteAttribute(jo, "variableSend", def.getVariableSend(), null); + doWriteAttribute(jo, "variableReceive", def.getVariableReceive(), null); + doWriteAttribute(jo, "pattern", def.getPattern(), null); + return jo; + } + protected void doWriteToDynamicDefinitionAttributes(JsonObject jo, ToDynamicDefinition def) { + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "uri", def.getUri(), null); + doWriteAttribute(jo, "variableSend", def.getVariableSend(), null); + doWriteAttribute(jo, "variableReceive", def.getVariableReceive(), null); + doWriteAttribute(jo, "pattern", def.getPattern(), null); + doWriteAttribute(jo, "cacheSize", def.getCacheSize(), null); + doWriteAttribute(jo, "ignoreInvalidEndpoint", def.getIgnoreInvalidEndpoint(), null); + doWriteAttribute(jo, "allowOptimisedComponents", def.getAllowOptimisedComponents(), "true"); + doWriteAttribute(jo, "autoStartComponents", def.getAutoStartComponents(), "true"); + } + protected JsonObject doWriteToDynamicDefinition(ToDynamicDefinition def) { + JsonObject jo = new JsonObject(); + doWriteToDynamicDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteTokenizerDefinition(TokenizerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + if (def.getTokenizerImplementation() != null) { + switch (def.getTokenizerImplementation().getClass().getSimpleName()) { + case "LangChain4jCharacterTokenizerDefinition" -> doWriteChildElement(jo, "langChain4jCharacterTokenizer", (LangChain4jCharacterTokenizerDefinition) def.getTokenizerImplementation(), this::doWriteLangChain4jCharacterTokenizerDefinition); + case "LangChain4jLineTokenizerDefinition" -> doWriteChildElement(jo, "langChain4jLineTokenizer", (LangChain4jLineTokenizerDefinition) def.getTokenizerImplementation(), this::doWriteLangChain4jLineTokenizerDefinition); + case "LangChain4jParagraphTokenizerDefinition" -> doWriteChildElement(jo, "langChain4jParagraphTokenizer", (LangChain4jParagraphTokenizerDefinition) def.getTokenizerImplementation(), this::doWriteLangChain4jParagraphTokenizerDefinition); + case "LangChain4jSentenceTokenizerDefinition" -> doWriteChildElement(jo, "langChain4jSentenceTokenizer", (LangChain4jSentenceTokenizerDefinition) def.getTokenizerImplementation(), this::doWriteLangChain4jSentenceTokenizerDefinition); + case "LangChain4jWordTokenizerDefinition" -> doWriteChildElement(jo, "langChain4jWordTokenizer", (LangChain4jWordTokenizerDefinition) def.getTokenizerImplementation(), this::doWriteLangChain4jWordTokenizerDefinition); + } + } + return jo; + } + protected JsonObject doWriteTokenizerImplementationDefinition(TokenizerImplementationDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + return jo; + } + protected JsonObject doWriteTransactedDefinition(TransactedDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteTransformDataTypeDefinition(TransformDataTypeDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "fromType", def.getFromType(), null); + doWriteAttribute(jo, "toType", def.getToType(), null); + return jo; + } + protected JsonObject doWriteTransformDefinition(TransformDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteTryDefinition(TryDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + return jo; + } + protected JsonObject doWriteUnmarshalDefinition(UnmarshalDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "variableSend", def.getVariableSend(), null); + doWriteAttribute(jo, "variableReceive", def.getVariableReceive(), null); + doWriteAttribute(jo, "allowNullBody", def.getAllowNullBody(), "false"); + if (def.getDataFormatType() != null) { + switch (def.getDataFormatType().getClass().getSimpleName()) { + case "ASN1DataFormat" -> doWriteChildElement(jo, "asn1", (ASN1DataFormat) def.getDataFormatType(), this::doWriteASN1DataFormat); + case "AvroDataFormat" -> doWriteChildElement(jo, "avro", (AvroDataFormat) def.getDataFormatType(), this::doWriteAvroDataFormat); + case "BarcodeDataFormat" -> doWriteChildElement(jo, "barcode", (BarcodeDataFormat) def.getDataFormatType(), this::doWriteBarcodeDataFormat); + case "Base64DataFormat" -> doWriteChildElement(jo, "base64", (Base64DataFormat) def.getDataFormatType(), this::doWriteBase64DataFormat); + case "BeanioDataFormat" -> doWriteChildElement(jo, "beanio", (BeanioDataFormat) def.getDataFormatType(), this::doWriteBeanioDataFormat); + case "BindyDataFormat" -> doWriteChildElement(jo, "bindy", (BindyDataFormat) def.getDataFormatType(), this::doWriteBindyDataFormat); + case "CBORDataFormat" -> doWriteChildElement(jo, "cbor", (CBORDataFormat) def.getDataFormatType(), this::doWriteCBORDataFormat); + case "CryptoDataFormat" -> doWriteChildElement(jo, "crypto", (CryptoDataFormat) def.getDataFormatType(), this::doWriteCryptoDataFormat); + case "CsvDataFormat" -> doWriteChildElement(jo, "csv", (CsvDataFormat) def.getDataFormatType(), this::doWriteCsvDataFormat); + case "CustomDataFormat" -> doWriteChildElement(jo, "custom", (CustomDataFormat) def.getDataFormatType(), this::doWriteCustomDataFormat); + case "DfdlDataFormat" -> doWriteChildElement(jo, "dfdl", (DfdlDataFormat) def.getDataFormatType(), this::doWriteDfdlDataFormat); + case "FhirJsonDataFormat" -> doWriteChildElement(jo, "fhirJson", (FhirJsonDataFormat) def.getDataFormatType(), this::doWriteFhirJsonDataFormat); + case "FhirXmlDataFormat" -> doWriteChildElement(jo, "fhirXml", (FhirXmlDataFormat) def.getDataFormatType(), this::doWriteFhirXmlDataFormat); + case "FlatpackDataFormat" -> doWriteChildElement(jo, "flatpack", (FlatpackDataFormat) def.getDataFormatType(), this::doWriteFlatpackDataFormat); + case "ForyDataFormat" -> doWriteChildElement(jo, "fory", (ForyDataFormat) def.getDataFormatType(), this::doWriteForyDataFormat); + case "GrokDataFormat" -> doWriteChildElement(jo, "grok", (GrokDataFormat) def.getDataFormatType(), this::doWriteGrokDataFormat); + case "GroovyJSonDataFormat" -> doWriteChildElement(jo, "groovyJson", (GroovyJSonDataFormat) def.getDataFormatType(), this::doWriteGroovyJSonDataFormat); + case "GroovyXmlDataFormat" -> doWriteChildElement(jo, "groovyXml", (GroovyXmlDataFormat) def.getDataFormatType(), this::doWriteGroovyXmlDataFormat); + case "GzipDeflaterDataFormat" -> doWriteChildElement(jo, "gzipDeflater", (GzipDeflaterDataFormat) def.getDataFormatType(), this::doWriteGzipDeflaterDataFormat); + case "HL7DataFormat" -> doWriteChildElement(jo, "hl7", (HL7DataFormat) def.getDataFormatType(), this::doWriteHL7DataFormat); + case "IcalDataFormat" -> doWriteChildElement(jo, "ical", (IcalDataFormat) def.getDataFormatType(), this::doWriteIcalDataFormat); + case "Iso8583DataFormat" -> doWriteChildElement(jo, "iso8583", (Iso8583DataFormat) def.getDataFormatType(), this::doWriteIso8583DataFormat); + case "JacksonXMLDataFormat" -> doWriteChildElement(jo, "jacksonXml", (JacksonXMLDataFormat) def.getDataFormatType(), this::doWriteJacksonXMLDataFormat); + case "JaxbDataFormat" -> doWriteChildElement(jo, "jaxb", (JaxbDataFormat) def.getDataFormatType(), this::doWriteJaxbDataFormat); + case "JsonDataFormat" -> doWriteChildElement(jo, "json", (JsonDataFormat) def.getDataFormatType(), this::doWriteJsonDataFormat); + case "JsonApiDataFormat" -> doWriteChildElement(jo, "jsonApi", (JsonApiDataFormat) def.getDataFormatType(), this::doWriteJsonApiDataFormat); + case "LZFDataFormat" -> doWriteChildElement(jo, "lzf", (LZFDataFormat) def.getDataFormatType(), this::doWriteLZFDataFormat); + case "MimeMultipartDataFormat" -> doWriteChildElement(jo, "mimeMultipart", (MimeMultipartDataFormat) def.getDataFormatType(), this::doWriteMimeMultipartDataFormat); + case "OcsfDataFormat" -> doWriteChildElement(jo, "ocsf", (OcsfDataFormat) def.getDataFormatType(), this::doWriteOcsfDataFormat); + case "ParquetAvroDataFormat" -> doWriteChildElement(jo, "parquetAvro", (ParquetAvroDataFormat) def.getDataFormatType(), this::doWriteParquetAvroDataFormat); + case "PGPDataFormat" -> doWriteChildElement(jo, "pgp", (PGPDataFormat) def.getDataFormatType(), this::doWritePGPDataFormat); + case "PQCDataFormat" -> doWriteChildElement(jo, "pqc", (PQCDataFormat) def.getDataFormatType(), this::doWritePQCDataFormat); + case "ProtobufDataFormat" -> doWriteChildElement(jo, "protobuf", (ProtobufDataFormat) def.getDataFormatType(), this::doWriteProtobufDataFormat); + case "RssDataFormat" -> doWriteChildElement(jo, "rss", (RssDataFormat) def.getDataFormatType(), this::doWriteRssDataFormat); + case "SmooksDataFormat" -> doWriteChildElement(jo, "smooks", (SmooksDataFormat) def.getDataFormatType(), this::doWriteSmooksDataFormat); + case "SoapDataFormat" -> doWriteChildElement(jo, "soap", (SoapDataFormat) def.getDataFormatType(), this::doWriteSoapDataFormat); + case "SwiftMtDataFormat" -> doWriteChildElement(jo, "swiftMt", (SwiftMtDataFormat) def.getDataFormatType(), this::doWriteSwiftMtDataFormat); + case "SwiftMxDataFormat" -> doWriteChildElement(jo, "swiftMx", (SwiftMxDataFormat) def.getDataFormatType(), this::doWriteSwiftMxDataFormat); + case "SyslogDataFormat" -> doWriteChildElement(jo, "syslog", (SyslogDataFormat) def.getDataFormatType(), this::doWriteSyslogDataFormat); + case "TarFileDataFormat" -> doWriteChildElement(jo, "tarFile", (TarFileDataFormat) def.getDataFormatType(), this::doWriteTarFileDataFormat); + case "ThriftDataFormat" -> doWriteChildElement(jo, "thrift", (ThriftDataFormat) def.getDataFormatType(), this::doWriteThriftDataFormat); + case "UniVocityCsvDataFormat" -> doWriteChildElement(jo, "univocityCsv", (UniVocityCsvDataFormat) def.getDataFormatType(), this::doWriteUniVocityCsvDataFormat); + case "UniVocityFixedDataFormat" -> doWriteChildElement(jo, "univocityFixed", (UniVocityFixedDataFormat) def.getDataFormatType(), this::doWriteUniVocityFixedDataFormat); + case "UniVocityTsvDataFormat" -> doWriteChildElement(jo, "univocityTsv", (UniVocityTsvDataFormat) def.getDataFormatType(), this::doWriteUniVocityTsvDataFormat); + case "XMLSecurityDataFormat" -> doWriteChildElement(jo, "xmlSecurity", (XMLSecurityDataFormat) def.getDataFormatType(), this::doWriteXMLSecurityDataFormat); + case "YAMLDataFormat" -> doWriteChildElement(jo, "yaml", (YAMLDataFormat) def.getDataFormatType(), this::doWriteYAMLDataFormat); + case "ZipDeflaterDataFormat" -> doWriteChildElement(jo, "zipDeflater", (ZipDeflaterDataFormat) def.getDataFormatType(), this::doWriteZipDeflaterDataFormat); + case "ZipFileDataFormat" -> doWriteChildElement(jo, "zipFile", (ZipFileDataFormat) def.getDataFormatType(), this::doWriteZipFileDataFormat); + } + } + return jo; + } + protected JsonObject doWriteValidateDefinition(ValidateDefinition def) { + JsonObject jo = new JsonObject(); + doWriteProcessorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "predicateExceptionFactory", def.getPredicateExceptionFactory(), null); + doWriteExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteValueDefinition(ValueDefinition def) { + JsonObject jo = new JsonObject(); + doWriteValue(jo, def.getValue()); + return jo; + } + protected JsonObject doWriteWhenDefinition(WhenDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "disabled", def.getDisabled(), null); + doWriteBasicOutputExpressionNodeElements(jo, def); + return jo; + } + protected JsonObject doWriteWireTapDefinition(WireTapDefinition def) { + JsonObject jo = new JsonObject(); + doWriteToDynamicDefinitionAttributes(jo, def); + doWriteAttribute(jo, "copy", def.getCopy(), "true"); + doWriteAttribute(jo, "dynamicUri", def.getDynamicUri(), "true"); + doWriteAttribute(jo, "onPrepare", def.getOnPrepare(), null); + doWriteAttribute(jo, "executorService", def.getExecutorService(), null); + return jo; + } + protected JsonObject doWriteApplicationDefinition(ApplicationDefinition def) { + JsonObject jo = new JsonObject(); + doWriteBeansDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteBeanConstructorDefinition(BeanConstructorDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "index", toString(def.getIndex()), null); + doWriteAttribute(jo, "value", def.getValue(), null); + return jo; + } + protected JsonObject doWriteBeanConstructorsDefinition(BeanConstructorsDefinition def) { + JsonObject jo = new JsonObject(); + doWriteChildList(jo, null, "constructor", def.getConstructors(), this::doWriteBeanConstructorDefinition); + return jo; + } + protected JsonObject doWriteBeanPropertiesDefinition(BeanPropertiesDefinition def) { + JsonObject jo = new JsonObject(); + doWriteChildList(jo, null, "property", def.getProperties(), this::doWriteBeanPropertyDefinition); + return jo; + } + protected JsonObject doWriteBeanPropertyDefinition(BeanPropertyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "key", def.getKey(), null); + doWriteAttribute(jo, "value", def.getValue(), null); + doWriteChildElement(jo, "properties", def.getProperties(), this::doWriteBeanPropertiesDefinition); + return jo; + } + protected void doWriteBeansDefinitionElements(JsonObject jo, BeansDefinition def) { + doWriteChildList(jo, null, "component-scan", def.getComponentScanning(), this::doWriteComponentScanDefinition); + doWriteChildList(jo, null, "bean", def.getBeans(), this::doWriteBeanFactoryDefinition); + // @XmlAnyElement - not applicable for YAML + doWriteChildList(jo, null, "sslContextParameters", def.getSslContextParameters(), this::doWriteSSLContextParametersDefinition); + doWriteChildList(jo, "dataFormats", "dataFormat", def.getDataFormats(), this::doWriteDataFormatDefinition); + doWriteChildList(jo, null, "restConfiguration", def.getRestConfigurations(), this::doWriteRestConfigurationDefinition); + doWriteChildList(jo, null, "rest", def.getRests(), this::doWriteRestDefinition); + doWriteChildList(jo, null, "routeConfiguration", def.getRouteConfigurations(), this::doWriteRouteConfigurationDefinition); + doWriteChildList(jo, null, "routeTemplate", def.getRouteTemplates(), this::doWriteRouteTemplateDefinition); + doWriteChildList(jo, null, "templatedRoute", def.getTemplatedRoutes(), this::doWriteTemplatedRouteDefinition); + doWriteChildList(jo, null, "route", def.getRoutes(), this::doWriteRouteDefinition); + } + protected JsonObject doWriteBeansDefinition(BeansDefinition def) { + JsonObject jo = new JsonObject(); + doWriteBeansDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteComponentScanDefinition(ComponentScanDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "base-package", def.getBasePackage(), null); + return jo; + } + protected JsonObject doWriteSSLContextParametersDefinition(SSLContextParametersDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "id", def.getId(), null); + doWriteAttribute(jo, "provider", def.getProvider(), null); + doWriteAttribute(jo, "secureSocketProtocol", def.getSecureSocketProtocol(), "TLSv1.3"); + doWriteAttribute(jo, "certAlias", def.getCertAlias(), null); + doWriteAttribute(jo, "sessionTimeout", def.getSessionTimeout(), "86400"); + doWriteAttribute(jo, "cipherSuites", def.getCipherSuites(), null); + doWriteAttribute(jo, "cipherSuitesInclude", def.getCipherSuitesInclude(), null); + doWriteAttribute(jo, "cipherSuitesExclude", def.getCipherSuitesExclude(), null); + doWriteAttribute(jo, "namedGroups", def.getNamedGroups(), null); + doWriteAttribute(jo, "namedGroupsInclude", def.getNamedGroupsInclude(), null); + doWriteAttribute(jo, "namedGroupsExclude", def.getNamedGroupsExclude(), null); + doWriteAttribute(jo, "signatureSchemes", def.getSignatureSchemes(), null); + doWriteAttribute(jo, "signatureSchemesInclude", def.getSignatureSchemesInclude(), null); + doWriteAttribute(jo, "signatureSchemesExclude", def.getSignatureSchemesExclude(), null); + doWriteAttribute(jo, "keyStore", def.getKeyStore(), null); + doWriteAttribute(jo, "keyStoreType", def.getKeyStoreType(), null); + doWriteAttribute(jo, "keyStoreProvider", def.getKeyStoreProvider(), null); + doWriteAttribute(jo, "keystorePassword", def.getKeystorePassword(), null); + doWriteAttribute(jo, "trustStore", def.getTrustStore(), null); + doWriteAttribute(jo, "trustStorePassword", def.getTrustStorePassword(), null); + doWriteAttribute(jo, "trustAllCertificates", def.getTrustAllCertificates(), null); + doWriteAttribute(jo, "keyManagerAlgorithm", def.getKeyManagerAlgorithm(), null); + doWriteAttribute(jo, "keyManagerProvider", def.getKeyManagerProvider(), null); + doWriteAttribute(jo, "secureRandomAlgorithm", def.getSecureRandomAlgorithm(), null); + doWriteAttribute(jo, "secureRandomProvider", def.getSecureRandomProvider(), null); + doWriteAttribute(jo, "clientAuthentication", def.getClientAuthentication(), "NONE"); + return jo; + } + protected JsonObject doWriteBatchResequencerConfig(BatchResequencerConfig def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "batchSize", def.getBatchSize(), "100"); + doWriteAttribute(jo, "batchTimeout", def.getBatchTimeout(), "1000"); + doWriteAttribute(jo, "allowDuplicates", def.getAllowDuplicates(), null); + doWriteAttribute(jo, "reverse", def.getReverse(), null); + doWriteAttribute(jo, "ignoreInvalidExchanges", def.getIgnoreInvalidExchanges(), null); + return jo; + } + protected JsonObject doWriteResequencerConfig(ResequencerConfig def) { + JsonObject jo = new JsonObject(); + return jo; + } + protected JsonObject doWriteStreamResequencerConfig(StreamResequencerConfig def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "capacity", def.getCapacity(), "1000"); + doWriteAttribute(jo, "timeout", def.getTimeout(), "1000"); + doWriteAttribute(jo, "deliveryAttemptInterval", def.getDeliveryAttemptInterval(), "1000"); + doWriteAttribute(jo, "ignoreInvalidExchanges", def.getIgnoreInvalidExchanges(), null); + doWriteAttribute(jo, "rejectOld", def.getRejectOld(), null); + doWriteAttribute(jo, "comparator", def.getComparator(), null); + return jo; + } + protected JsonObject doWriteASN1DataFormat(ASN1DataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "unmarshalType", def.getUnmarshalTypeName(), null); + doWriteAttribute(jo, "usingIterator", def.getUsingIterator(), null); + return jo; + } + protected JsonObject doWriteAvroDataFormat(AvroDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "unmarshalType", def.getUnmarshalTypeName(), null); + doWriteAttribute(jo, "collectionType", def.getCollectionTypeName(), null); + doWriteAttribute(jo, "jsonView", def.getJsonViewTypeName(), null); + doWriteAttribute(jo, "instanceClassName", def.getInstanceClassName(), null); + doWriteAttribute(jo, "library", toString(def.getLibrary()), "avroJackson"); + doWriteAttribute(jo, "objectMapper", def.getObjectMapper(), null); + doWriteAttribute(jo, "useDefaultObjectMapper", def.getUseDefaultObjectMapper(), "true"); + doWriteAttribute(jo, "include", def.getInclude(), null); + doWriteAttribute(jo, "allowJmsType", def.getAllowJmsType(), null); + doWriteAttribute(jo, "useList", def.getUseList(), null); + doWriteAttribute(jo, "moduleClassNames", def.getModuleClassNames(), null); + doWriteAttribute(jo, "moduleRefs", def.getModuleRefs(), null); + doWriteAttribute(jo, "enableFeatures", def.getEnableFeatures(), null); + doWriteAttribute(jo, "disableFeatures", def.getDisableFeatures(), null); + doWriteAttribute(jo, "allowUnmarshallType", def.getAllowUnmarshallType(), null); + doWriteAttribute(jo, "timezone", def.getTimezone(), null); + doWriteAttribute(jo, "autoDiscoverObjectMapper", def.getAutoDiscoverObjectMapper(), null); + doWriteAttribute(jo, "contentTypeHeader", def.getContentTypeHeader(), "true"); + doWriteAttribute(jo, "schemaResolver", def.getSchemaResolver(), null); + doWriteAttribute(jo, "autoDiscoverSchemaResolver", def.getAutoDiscoverSchemaResolver(), "true"); + return jo; + } + protected JsonObject doWriteBarcodeDataFormat(BarcodeDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "barcodeFormat", def.getBarcodeFormat(), "QR_CODE"); + doWriteAttribute(jo, "imageType", def.getImageType(), "PNG"); + doWriteAttribute(jo, "width", def.getWidth(), "100"); + doWriteAttribute(jo, "height", def.getHeight(), "100"); + return jo; + } + protected JsonObject doWriteBase64DataFormat(Base64DataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "lineLength", def.getLineLength(), "76"); + doWriteAttribute(jo, "lineSeparator", def.getLineSeparator(), null); + doWriteAttribute(jo, "urlSafe", def.getUrlSafe(), null); + return jo; + } + protected JsonObject doWriteBeanioDataFormat(BeanioDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "mapping", def.getMapping(), null); + doWriteAttribute(jo, "streamName", def.getStreamName(), null); + doWriteAttribute(jo, "ignoreUnidentifiedRecords", def.getIgnoreUnidentifiedRecords(), null); + doWriteAttribute(jo, "ignoreUnexpectedRecords", def.getIgnoreUnexpectedRecords(), null); + doWriteAttribute(jo, "ignoreInvalidRecords", def.getIgnoreInvalidRecords(), null); + doWriteAttribute(jo, "encoding", def.getEncoding(), null); + doWriteAttribute(jo, "beanReaderErrorHandlerType", def.getBeanReaderErrorHandlerType(), null); + doWriteAttribute(jo, "unmarshalSingleObject", def.getUnmarshalSingleObject(), null); + return jo; + } + protected JsonObject doWriteBindyDataFormat(BindyDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "classType", def.getClassTypeAsString(), null); + doWriteAttribute(jo, "type", def.getType(), null); + doWriteAttribute(jo, "defaultValueStringAsNull", def.getDefaultValueStringAsNull(), null); + doWriteAttribute(jo, "allowEmptyStream", def.getAllowEmptyStream(), "false"); + doWriteAttribute(jo, "unwrapSingleInstance", def.getUnwrapSingleInstance(), "true"); + doWriteAttribute(jo, "locale", def.getLocale(), null); + return jo; + } + protected JsonObject doWriteCBORDataFormat(CBORDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "unmarshalType", def.getUnmarshalTypeName(), null); + doWriteAttribute(jo, "collectionType", def.getCollectionTypeName(), null); + doWriteAttribute(jo, "objectMapper", def.getObjectMapper(), null); + doWriteAttribute(jo, "useDefaultObjectMapper", def.getUseDefaultObjectMapper(), "true"); + doWriteAttribute(jo, "useList", def.getUseList(), "false"); + doWriteAttribute(jo, "allowUnmarshallType", def.getAllowUnmarshallType(), "false"); + doWriteAttribute(jo, "prettyPrint", def.getPrettyPrint(), "false"); + doWriteAttribute(jo, "allowJmsType", def.getAllowJmsType(), "false"); + doWriteAttribute(jo, "enableFeatures", def.getEnableFeatures(), null); + doWriteAttribute(jo, "disableFeatures", def.getDisableFeatures(), null); + return jo; + } + protected JsonObject doWriteCryptoDataFormat(CryptoDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "algorithm", def.getAlgorithm(), null); + doWriteAttribute(jo, "key", def.getKey(), null); + doWriteAttribute(jo, "cryptoProvider", def.getCryptoProvider(), null); + doWriteAttribute(jo, "initVector", def.getInitVector(), null); + doWriteAttribute(jo, "algorithmParameterSpec", def.getAlgorithmParameterSpec(), null); + doWriteAttribute(jo, "bufferSize", def.getBufferSize(), "4096"); + doWriteAttribute(jo, "macAlgorithm", def.getMacAlgorithm(), "HmacSHA1"); + doWriteAttribute(jo, "shouldAppendHMAC", def.getShouldAppendHMAC(), "true"); + doWriteAttribute(jo, "inline", def.getInline(), "false"); + return jo; + } + protected JsonObject doWriteCsvDataFormat(CsvDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "format", def.getFormat(), "DEFAULT"); + doWriteAttribute(jo, "commentMarkerDisabled", def.getCommentMarkerDisabled(), null); + doWriteAttribute(jo, "commentMarker", def.getCommentMarker(), null); + doWriteAttribute(jo, "delimiter", def.getDelimiter(), null); + doWriteAttribute(jo, "escapeDisabled", def.getEscapeDisabled(), null); + doWriteAttribute(jo, "escape", def.getEscape(), null); + doWriteAttribute(jo, "headerDisabled", def.getHeaderDisabled(), null); + doWriteAttribute(jo, "header", def.getHeader(), null); + doWriteAttribute(jo, "allowMissingColumnNames", def.getAllowMissingColumnNames(), null); + doWriteAttribute(jo, "ignoreEmptyLines", def.getIgnoreEmptyLines(), null); + doWriteAttribute(jo, "ignoreSurroundingSpaces", def.getIgnoreSurroundingSpaces(), null); + doWriteAttribute(jo, "nullStringDisabled", def.getNullStringDisabled(), null); + doWriteAttribute(jo, "nullString", def.getNullString(), null); + doWriteAttribute(jo, "quoteDisabled", def.getQuoteDisabled(), null); + doWriteAttribute(jo, "quote", def.getQuote(), null); + doWriteAttribute(jo, "recordSeparatorDisabled", def.getRecordSeparatorDisabled(), null); + doWriteAttribute(jo, "recordSeparator", def.getRecordSeparator(), null); + doWriteAttribute(jo, "skipHeaderRecord", def.getSkipHeaderRecord(), null); + doWriteAttribute(jo, "quoteMode", def.getQuoteMode(), null); + doWriteAttribute(jo, "ignoreHeaderCase", def.getIgnoreHeaderCase(), null); + doWriteAttribute(jo, "trim", def.getTrim(), null); + doWriteAttribute(jo, "trailingDelimiter", def.getTrailingDelimiter(), null); + doWriteAttribute(jo, "marshallerFactoryRef", def.getMarshallerFactoryRef(), null); + doWriteAttribute(jo, "lazyLoad", def.getLazyLoad(), null); + doWriteAttribute(jo, "useMaps", def.getUseMaps(), null); + doWriteAttribute(jo, "useOrderedMaps", def.getUseOrderedMaps(), null); + doWriteAttribute(jo, "recordConverterRef", def.getRecordConverterRef(), null); + doWriteAttribute(jo, "captureHeaderRecord", def.getCaptureHeaderRecord(), null); + return jo; + } + protected JsonObject doWriteCustomDataFormat(CustomDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + return jo; + } + protected JsonObject doWriteDataFormatsDefinition(DataFormatsDefinition def) { + JsonObject jo = new JsonObject(); + if (def.getDataFormats() != null) { + for (var item : def.getDataFormats()) { + switch (item.getClass().getSimpleName()) { + case "ASN1DataFormat" -> doWriteChildElement(jo, "asn1", (ASN1DataFormat) item, this::doWriteASN1DataFormat); + case "AvroDataFormat" -> doWriteChildElement(jo, "avro", (AvroDataFormat) item, this::doWriteAvroDataFormat); + case "BarcodeDataFormat" -> doWriteChildElement(jo, "barcode", (BarcodeDataFormat) item, this::doWriteBarcodeDataFormat); + case "Base64DataFormat" -> doWriteChildElement(jo, "base64", (Base64DataFormat) item, this::doWriteBase64DataFormat); + case "BeanioDataFormat" -> doWriteChildElement(jo, "beanio", (BeanioDataFormat) item, this::doWriteBeanioDataFormat); + case "BindyDataFormat" -> doWriteChildElement(jo, "bindy", (BindyDataFormat) item, this::doWriteBindyDataFormat); + case "CBORDataFormat" -> doWriteChildElement(jo, "cbor", (CBORDataFormat) item, this::doWriteCBORDataFormat); + case "CryptoDataFormat" -> doWriteChildElement(jo, "crypto", (CryptoDataFormat) item, this::doWriteCryptoDataFormat); + case "CsvDataFormat" -> doWriteChildElement(jo, "csv", (CsvDataFormat) item, this::doWriteCsvDataFormat); + case "CustomDataFormat" -> doWriteChildElement(jo, "custom", (CustomDataFormat) item, this::doWriteCustomDataFormat); + case "DfdlDataFormat" -> doWriteChildElement(jo, "dfdl", (DfdlDataFormat) item, this::doWriteDfdlDataFormat); + case "FhirJsonDataFormat" -> doWriteChildElement(jo, "fhirJson", (FhirJsonDataFormat) item, this::doWriteFhirJsonDataFormat); + case "FhirXmlDataFormat" -> doWriteChildElement(jo, "fhirXml", (FhirXmlDataFormat) item, this::doWriteFhirXmlDataFormat); + case "FlatpackDataFormat" -> doWriteChildElement(jo, "flatpack", (FlatpackDataFormat) item, this::doWriteFlatpackDataFormat); + case "ForyDataFormat" -> doWriteChildElement(jo, "fory", (ForyDataFormat) item, this::doWriteForyDataFormat); + case "GrokDataFormat" -> doWriteChildElement(jo, "grok", (GrokDataFormat) item, this::doWriteGrokDataFormat); + case "GroovyJSonDataFormat" -> doWriteChildElement(jo, "groovyJson", (GroovyJSonDataFormat) item, this::doWriteGroovyJSonDataFormat); + case "GroovyXmlDataFormat" -> doWriteChildElement(jo, "groovyXml", (GroovyXmlDataFormat) item, this::doWriteGroovyXmlDataFormat); + case "GzipDeflaterDataFormat" -> doWriteChildElement(jo, "gzipDeflater", (GzipDeflaterDataFormat) item, this::doWriteGzipDeflaterDataFormat); + case "HL7DataFormat" -> doWriteChildElement(jo, "hl7", (HL7DataFormat) item, this::doWriteHL7DataFormat); + case "IcalDataFormat" -> doWriteChildElement(jo, "ical", (IcalDataFormat) item, this::doWriteIcalDataFormat); + case "Iso8583DataFormat" -> doWriteChildElement(jo, "iso8583", (Iso8583DataFormat) item, this::doWriteIso8583DataFormat); + case "JacksonXMLDataFormat" -> doWriteChildElement(jo, "jacksonXml", (JacksonXMLDataFormat) item, this::doWriteJacksonXMLDataFormat); + case "JaxbDataFormat" -> doWriteChildElement(jo, "jaxb", (JaxbDataFormat) item, this::doWriteJaxbDataFormat); + case "JsonDataFormat" -> doWriteChildElement(jo, "json", (JsonDataFormat) item, this::doWriteJsonDataFormat); + case "JsonApiDataFormat" -> doWriteChildElement(jo, "jsonApi", (JsonApiDataFormat) item, this::doWriteJsonApiDataFormat); + case "LZFDataFormat" -> doWriteChildElement(jo, "lzf", (LZFDataFormat) item, this::doWriteLZFDataFormat); + case "MimeMultipartDataFormat" -> doWriteChildElement(jo, "mimeMultipart", (MimeMultipartDataFormat) item, this::doWriteMimeMultipartDataFormat); + case "OcsfDataFormat" -> doWriteChildElement(jo, "ocsf", (OcsfDataFormat) item, this::doWriteOcsfDataFormat); + case "ParquetAvroDataFormat" -> doWriteChildElement(jo, "parquetAvro", (ParquetAvroDataFormat) item, this::doWriteParquetAvroDataFormat); + case "PGPDataFormat" -> doWriteChildElement(jo, "pgp", (PGPDataFormat) item, this::doWritePGPDataFormat); + case "PQCDataFormat" -> doWriteChildElement(jo, "pqc", (PQCDataFormat) item, this::doWritePQCDataFormat); + case "ProtobufDataFormat" -> doWriteChildElement(jo, "protobuf", (ProtobufDataFormat) item, this::doWriteProtobufDataFormat); + case "RssDataFormat" -> doWriteChildElement(jo, "rss", (RssDataFormat) item, this::doWriteRssDataFormat); + case "SmooksDataFormat" -> doWriteChildElement(jo, "smooks", (SmooksDataFormat) item, this::doWriteSmooksDataFormat); + case "SoapDataFormat" -> doWriteChildElement(jo, "soap", (SoapDataFormat) item, this::doWriteSoapDataFormat); + case "SwiftMtDataFormat" -> doWriteChildElement(jo, "swiftMt", (SwiftMtDataFormat) item, this::doWriteSwiftMtDataFormat); + case "SwiftMxDataFormat" -> doWriteChildElement(jo, "swiftMx", (SwiftMxDataFormat) item, this::doWriteSwiftMxDataFormat); + case "SyslogDataFormat" -> doWriteChildElement(jo, "syslog", (SyslogDataFormat) item, this::doWriteSyslogDataFormat); + case "TarFileDataFormat" -> doWriteChildElement(jo, "tarFile", (TarFileDataFormat) item, this::doWriteTarFileDataFormat); + case "ThriftDataFormat" -> doWriteChildElement(jo, "thrift", (ThriftDataFormat) item, this::doWriteThriftDataFormat); + case "UniVocityCsvDataFormat" -> doWriteChildElement(jo, "univocityCsv", (UniVocityCsvDataFormat) item, this::doWriteUniVocityCsvDataFormat); + case "UniVocityFixedDataFormat" -> doWriteChildElement(jo, "univocityFixed", (UniVocityFixedDataFormat) item, this::doWriteUniVocityFixedDataFormat); + case "UniVocityTsvDataFormat" -> doWriteChildElement(jo, "univocityTsv", (UniVocityTsvDataFormat) item, this::doWriteUniVocityTsvDataFormat); + case "XMLSecurityDataFormat" -> doWriteChildElement(jo, "xmlSecurity", (XMLSecurityDataFormat) item, this::doWriteXMLSecurityDataFormat); + case "YAMLDataFormat" -> doWriteChildElement(jo, "yaml", (YAMLDataFormat) item, this::doWriteYAMLDataFormat); + case "ZipDeflaterDataFormat" -> doWriteChildElement(jo, "zipDeflater", (ZipDeflaterDataFormat) item, this::doWriteZipDeflaterDataFormat); + case "ZipFileDataFormat" -> doWriteChildElement(jo, "zipFile", (ZipFileDataFormat) item, this::doWriteZipFileDataFormat); + } + } + } + return jo; + } + protected JsonObject doWriteDfdlDataFormat(DfdlDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "schemaUri", def.getSchemaUri(), null); + doWriteAttribute(jo, "rootElement", def.getRootElement(), null); + doWriteAttribute(jo, "rootNamespace", def.getRootNamespace(), null); + return jo; + } + protected void doWriteFhirDataformatAttributes(JsonObject jo, FhirDataformat def) { + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "contentTypeHeader", def.getContentTypeHeader(), "true"); + doWriteAttribute(jo, "dontStripVersionsFromReferencesAtPaths", def.getDontStripVersionsFromReferencesAtPaths(), null); + doWriteAttribute(jo, "parserOptions", def.getParserOptions(), null); + doWriteAttribute(jo, "prettyPrint", def.getPrettyPrint(), null); + doWriteAttribute(jo, "dontEncodeElements", def.getDontEncodeElements(), null); + doWriteAttribute(jo, "summaryMode", def.getSummaryMode(), null); + doWriteAttribute(jo, "forceResourceId", def.getForceResourceId(), null); + doWriteAttribute(jo, "encodeElementsAppliesToChildResourcesOnly", def.getEncodeElementsAppliesToChildResourcesOnly(), null); + doWriteAttribute(jo, "parserErrorHandler", def.getParserErrorHandler(), null); + doWriteAttribute(jo, "serverBaseUrl", def.getServerBaseUrl(), null); + doWriteAttribute(jo, "fhirVersion", def.getFhirVersion(), "R4"); + doWriteAttribute(jo, "suppressNarratives", def.getSuppressNarratives(), null); + doWriteAttribute(jo, "fhirContext", def.getFhirContext(), null); + doWriteAttribute(jo, "stripVersionsFromReferences", def.getStripVersionsFromReferences(), null); + doWriteAttribute(jo, "encodeElements", def.getEncodeElements(), null); + doWriteAttribute(jo, "preferTypes", def.getPreferTypes(), null); + doWriteAttribute(jo, "overrideResourceIdWithBundleEntryFullUrl", def.getOverrideResourceIdWithBundleEntryFullUrl(), null); + doWriteAttribute(jo, "omitResourceId", def.getOmitResourceId(), null); + } + protected JsonObject doWriteFhirDataformat(FhirDataformat def) { + JsonObject jo = new JsonObject(); + doWriteFhirDataformatAttributes(jo, def); + return jo; + } + protected JsonObject doWriteFhirJsonDataFormat(FhirJsonDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteFhirDataformatAttributes(jo, def); + return jo; + } + protected JsonObject doWriteFhirXmlDataFormat(FhirXmlDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteFhirDataformatAttributes(jo, def); + return jo; + } + protected JsonObject doWriteFlatpackDataFormat(FlatpackDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "definition", def.getDefinition(), null); + doWriteAttribute(jo, "fixed", def.getFixed(), null); + doWriteAttribute(jo, "delimiter", def.getDelimiter(), ","); + doWriteAttribute(jo, "ignoreFirstRecord", def.getIgnoreFirstRecord(), "true"); + doWriteAttribute(jo, "allowShortLines", def.getAllowShortLines(), null); + doWriteAttribute(jo, "ignoreExtraColumns", def.getIgnoreExtraColumns(), null); + doWriteAttribute(jo, "textQualifier", def.getTextQualifier(), null); + doWriteAttribute(jo, "parserFactory", def.getParserFactory(), null); + return jo; + } + protected JsonObject doWriteForyDataFormat(ForyDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "unmarshalType", def.getUnmarshalTypeName(), null); + doWriteAttribute(jo, "requireClassRegistration", def.getRequireClassRegistration(), "true"); + doWriteAttribute(jo, "threadSafe", def.getThreadSafe(), "true"); + doWriteAttribute(jo, "allowAutoWiredFory", def.getAllowAutoWiredFory(), "true"); + return jo; + } + protected JsonObject doWriteGrokDataFormat(GrokDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "pattern", def.getPattern(), null); + doWriteAttribute(jo, "flattened", def.getFlattened(), null); + doWriteAttribute(jo, "allowMultipleMatchesPerLine", def.getAllowMultipleMatchesPerLine(), "true"); + doWriteAttribute(jo, "namedOnly", def.getNamedOnly(), null); + return jo; + } + protected JsonObject doWriteGroovyJSonDataFormat(GroovyJSonDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "prettyPrint", def.getPrettyPrint(), "true"); + return jo; + } + protected JsonObject doWriteGroovyXmlDataFormat(GroovyXmlDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "attributeMapping", def.getAttributeMapping(), "true"); + return jo; + } + protected JsonObject doWriteGzipDeflaterDataFormat(GzipDeflaterDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + return jo; + } + protected JsonObject doWriteHL7DataFormat(HL7DataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "parser", def.getParser(), null); + doWriteAttribute(jo, "validate", def.getValidate(), "true"); + return jo; + } + protected JsonObject doWriteIcalDataFormat(IcalDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "validating", def.getValidating(), null); + return jo; + } + protected JsonObject doWriteIso8583DataFormat(Iso8583DataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "configFile", def.getConfigFile(), "j8583-config.xml"); + doWriteAttribute(jo, "isoType", def.getIsoType(), null); + doWriteAttribute(jo, "allowAutoWiredMessageFormat", def.getAllowAutoWiredMessageFormat(), "true"); + return jo; + } + protected JsonObject doWriteJacksonXMLDataFormat(JacksonXMLDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "unmarshalType", def.getUnmarshalTypeName(), null); + doWriteAttribute(jo, "collectionType", def.getCollectionTypeName(), null); + doWriteAttribute(jo, "jsonView", def.getJsonViewTypeName(), null); + doWriteAttribute(jo, "xmlMapper", def.getXmlMapper(), null); + doWriteAttribute(jo, "prettyPrint", def.getPrettyPrint(), null); + doWriteAttribute(jo, "allowUnmarshallType", def.getAllowUnmarshallType(), null); + doWriteAttribute(jo, "include", def.getInclude(), null); + doWriteAttribute(jo, "allowJmsType", def.getAllowJmsType(), null); + doWriteAttribute(jo, "useList", def.getUseList(), null); + doWriteAttribute(jo, "timezone", def.getTimezone(), null); + doWriteAttribute(jo, "enableJaxbAnnotationModule", def.getEnableJaxbAnnotationModule(), null); + doWriteAttribute(jo, "moduleClassNames", def.getModuleClassNames(), null); + doWriteAttribute(jo, "moduleRefs", def.getModuleRefs(), null); + doWriteAttribute(jo, "enableFeatures", def.getEnableFeatures(), null); + doWriteAttribute(jo, "disableFeatures", def.getDisableFeatures(), null); + doWriteAttribute(jo, "contentTypeHeader", def.getContentTypeHeader(), "true"); + doWriteAttribute(jo, "maxStringLength", def.getMaxStringLength(), null); + return jo; + } + protected JsonObject doWriteJaxbDataFormat(JaxbDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "contextPath", def.getContextPath(), null); + doWriteAttribute(jo, "contextPathIsClassName", def.getContextPathIsClassName(), null); + doWriteAttribute(jo, "schema", def.getSchema(), null); + doWriteAttribute(jo, "schemaSeverityLevel", def.getSchemaSeverityLevel(), "0"); + doWriteAttribute(jo, "prettyPrint", def.getPrettyPrint(), "true"); + doWriteAttribute(jo, "objectFactory", def.getObjectFactory(), "true"); + doWriteAttribute(jo, "ignoreJAXBElement", def.getIgnoreJAXBElement(), "true"); + doWriteAttribute(jo, "mustBeJAXBElement", def.getMustBeJAXBElement(), null); + doWriteAttribute(jo, "filterNonXmlChars", def.getFilterNonXmlChars(), null); + doWriteAttribute(jo, "encoding", def.getEncoding(), null); + doWriteAttribute(jo, "fragment", def.getFragment(), null); + doWriteAttribute(jo, "partClass", def.getPartClass(), null); + doWriteAttribute(jo, "partNamespace", def.getPartNamespace(), null); + doWriteAttribute(jo, "namespacePrefix", def.getNamespacePrefix(), null); + doWriteAttribute(jo, "xmlStreamWriterWrapper", def.getXmlStreamWriterWrapper(), null); + doWriteAttribute(jo, "schemaLocation", def.getSchemaLocation(), null); + doWriteAttribute(jo, "noNamespaceSchemaLocation", def.getNoNamespaceSchemaLocation(), null); + doWriteAttribute(jo, "jaxbProviderProperties", def.getJaxbProviderProperties(), null); + doWriteAttribute(jo, "contentTypeHeader", def.getContentTypeHeader(), "true"); + doWriteAttribute(jo, "accessExternalSchemaProtocols", def.getAccessExternalSchemaProtocols(), null); + return jo; + } + protected JsonObject doWriteJsonApiDataFormat(JsonApiDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "dataFormatTypes", def.getDataFormatTypes(), null); + doWriteAttribute(jo, "mainFormatType", def.getMainFormatType(), null); + return jo; + } + protected JsonObject doWriteJsonDataFormat(JsonDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "collectionType", def.getCollectionTypeName(), null); + doWriteAttribute(jo, "jsonView", def.getJsonViewTypeName(), null); + doWriteAttribute(jo, "unmarshalType", def.getUnmarshalTypeName(), null); + doWriteAttribute(jo, "objectMapper", def.getObjectMapper(), null); + doWriteAttribute(jo, "useDefaultObjectMapper", def.getUseDefaultObjectMapper(), "true"); + doWriteAttribute(jo, "autoDiscoverObjectMapper", def.getAutoDiscoverObjectMapper(), "false"); + doWriteAttribute(jo, "prettyPrint", def.getPrettyPrint(), null); + doWriteAttribute(jo, "library", toString(def.getLibrary()), "Jackson"); + doWriteAttribute(jo, "combineUnicodeSurrogates", def.getCombineUnicodeSurrogates(), null); + doWriteAttribute(jo, "include", def.getInclude(), null); + doWriteAttribute(jo, "allowJmsType", def.getAllowJmsType(), null); + doWriteAttribute(jo, "useList", def.getUseList(), null); + doWriteAttribute(jo, "moduleClassNames", def.getModuleClassNames(), null); + doWriteAttribute(jo, "moduleRefs", def.getModuleRefs(), null); + doWriteAttribute(jo, "enableFeatures", def.getEnableFeatures(), null); + doWriteAttribute(jo, "disableFeatures", def.getDisableFeatures(), null); + doWriteAttribute(jo, "allowUnmarshallType", def.getAllowUnmarshallType(), null); + doWriteAttribute(jo, "timezone", def.getTimezone(), null); + doWriteAttribute(jo, "schemaResolver", def.getSchemaResolver(), null); + doWriteAttribute(jo, "autoDiscoverSchemaResolver", def.getAutoDiscoverSchemaResolver(), "true"); + doWriteAttribute(jo, "namingStrategy", def.getNamingStrategy(), null); + doWriteAttribute(jo, "contentTypeHeader", def.getContentTypeHeader(), "true"); + doWriteAttribute(jo, "dateFormatPattern", def.getDateFormatPattern(), null); + doWriteAttribute(jo, "maxStringLength", def.getMaxStringLength(), null); + return jo; + } + protected JsonObject doWriteLZFDataFormat(LZFDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "usingParallelCompression", def.getUsingParallelCompression(), null); + return jo; + } + protected JsonObject doWriteMimeMultipartDataFormat(MimeMultipartDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "multipartSubType", def.getMultipartSubType(), "mixed"); + doWriteAttribute(jo, "multipartWithoutAttachment", def.getMultipartWithoutAttachment(), null); + doWriteAttribute(jo, "headersInline", def.getHeadersInline(), null); + doWriteAttribute(jo, "includeHeaders", def.getIncludeHeaders(), null); + doWriteAttribute(jo, "binaryContent", def.getBinaryContent(), null); + return jo; + } + protected JsonObject doWriteOcsfDataFormat(OcsfDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "unmarshalType", def.getUnmarshalTypeName(), null); + doWriteAttribute(jo, "collectionType", def.getCollectionTypeName(), null); + doWriteAttribute(jo, "objectMapper", def.getObjectMapper(), null); + doWriteAttribute(jo, "useDefaultObjectMapper", def.getUseDefaultObjectMapper(), "true"); + doWriteAttribute(jo, "useList", def.getUseList(), "false"); + doWriteAttribute(jo, "allowUnmarshallType", def.getAllowUnmarshallType(), "false"); + doWriteAttribute(jo, "prettyPrint", def.getPrettyPrint(), "false"); + return jo; + } + protected JsonObject doWritePGPDataFormat(PGPDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "keyUserid", def.getKeyUserid(), null); + doWriteAttribute(jo, "signatureKeyUserid", def.getSignatureKeyUserid(), null); + doWriteAttribute(jo, "password", def.getPassword(), null); + doWriteAttribute(jo, "signaturePassword", def.getSignaturePassword(), null); + doWriteAttribute(jo, "keyFileName", def.getKeyFileName(), null); + doWriteAttribute(jo, "signatureKeyFileName", def.getSignatureKeyFileName(), null); + doWriteAttribute(jo, "signatureKeyRing", def.getSignatureKeyRing(), null); + doWriteAttribute(jo, "armored", def.getArmored(), "false"); + doWriteAttribute(jo, "integrity", def.getIntegrity(), "true"); + doWriteAttribute(jo, "provider", def.getProvider(), null); + doWriteAttribute(jo, "algorithm", def.getAlgorithm(), null); + doWriteAttribute(jo, "compressionAlgorithm", def.getCompressionAlgorithm(), null); + doWriteAttribute(jo, "hashAlgorithm", def.getHashAlgorithm(), null); + doWriteAttribute(jo, "signatureVerificationOption", def.getSignatureVerificationOption(), null); + return jo; + } + protected JsonObject doWritePQCDataFormat(PQCDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "keyEncapsulationAlgorithm", def.getKeyEncapsulationAlgorithm(), "MLKEM"); + doWriteAttribute(jo, "symmetricKeyAlgorithm", def.getSymmetricKeyAlgorithm(), "AES"); + doWriteAttribute(jo, "symmetricKeyLength", def.getSymmetricKeyLength(), "128"); + doWriteAttribute(jo, "keyPair", def.getKeyPair(), null); + doWriteAttribute(jo, "bufferSize", def.getBufferSize(), "4096"); + doWriteAttribute(jo, "provider", def.getProvider(), null); + doWriteAttribute(jo, "keyGenerator", def.getKeyGenerator(), null); + return jo; + } + protected JsonObject doWriteParquetAvroDataFormat(ParquetAvroDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "unmarshalType", def.getUnmarshalTypeName(), null); + doWriteAttribute(jo, "compressionCodecName", def.getCompressionCodecName(), "GZIP"); + doWriteAttribute(jo, "lazyLoad", def.getLazyLoad(), null); + return jo; + } + protected JsonObject doWriteProtobufDataFormat(ProtobufDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "collectionType", def.getCollectionTypeName(), null); + doWriteAttribute(jo, "jsonView", def.getJsonViewTypeName(), null); + doWriteAttribute(jo, "unmarshalType", def.getUnmarshalTypeName(), null); + doWriteAttribute(jo, "instanceClass", def.getInstanceClass(), null); + doWriteAttribute(jo, "objectMapper", def.getObjectMapper(), null); + doWriteAttribute(jo, "useDefaultObjectMapper", def.getUseDefaultObjectMapper(), "true"); + doWriteAttribute(jo, "autoDiscoverObjectMapper", def.getAutoDiscoverObjectMapper(), "false"); + doWriteAttribute(jo, "library", toString(def.getLibrary()), "GoogleProtobuf"); + doWriteAttribute(jo, "include", def.getInclude(), null); + doWriteAttribute(jo, "allowJmsType", def.getAllowJmsType(), null); + doWriteAttribute(jo, "useList", def.getUseList(), null); + doWriteAttribute(jo, "moduleClassNames", def.getModuleClassNames(), null); + doWriteAttribute(jo, "moduleRefs", def.getModuleRefs(), null); + doWriteAttribute(jo, "enableFeatures", def.getEnableFeatures(), null); + doWriteAttribute(jo, "disableFeatures", def.getDisableFeatures(), null); + doWriteAttribute(jo, "allowUnmarshallType", def.getAllowUnmarshallType(), null); + doWriteAttribute(jo, "timezone", def.getTimezone(), null); + doWriteAttribute(jo, "schemaResolver", def.getSchemaResolver(), null); + doWriteAttribute(jo, "autoDiscoverSchemaResolver", def.getAutoDiscoverSchemaResolver(), "true"); + doWriteAttribute(jo, "contentTypeFormat", def.getContentTypeFormat(), "native"); + doWriteAttribute(jo, "contentTypeHeader", def.getContentTypeHeader(), "true"); + return jo; + } + protected JsonObject doWriteRssDataFormat(RssDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + return jo; + } + protected JsonObject doWriteSmooksDataFormat(SmooksDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "smooksConfig", def.getSmooksConfig(), null); + return jo; + } + protected JsonObject doWriteSoapDataFormat(SoapDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "contextPath", def.getContextPath(), null); + doWriteAttribute(jo, "encoding", def.getEncoding(), null); + doWriteAttribute(jo, "elementNameStrategy", def.getElementNameStrategy(), null); + doWriteAttribute(jo, "version", def.getVersion(), "1.1"); + doWriteAttribute(jo, "namespacePrefix", def.getNamespacePrefix(), null); + doWriteAttribute(jo, "schema", def.getSchema(), null); + doWriteAttribute(jo, "ignoreUnmarshalledHeaders", def.getIgnoreUnmarshalledHeaders(), null); + return jo; + } + protected JsonObject doWriteSwiftMtDataFormat(SwiftMtDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "writeInJson", def.getWriteInJson(), null); + return jo; + } + protected JsonObject doWriteSwiftMxDataFormat(SwiftMxDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "writeInJson", def.getWriteInJson(), null); + doWriteAttribute(jo, "readMessageId", def.getReadMessageId(), null); + doWriteAttribute(jo, "readConfig", def.getReadConfig(), null); + doWriteAttribute(jo, "writeConfig", def.getWriteConfig(), null); + return jo; + } + protected JsonObject doWriteSyslogDataFormat(SyslogDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + return jo; + } + protected JsonObject doWriteTarFileDataFormat(TarFileDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "usingIterator", def.getUsingIterator(), null); + doWriteAttribute(jo, "allowEmptyDirectory", def.getAllowEmptyDirectory(), null); + doWriteAttribute(jo, "preservePathElements", def.getPreservePathElements(), null); + doWriteAttribute(jo, "maxDecompressedSize", def.getMaxDecompressedSize(), "1073741824"); + return jo; + } + protected JsonObject doWriteThriftDataFormat(ThriftDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "instanceClass", def.getInstanceClass(), null); + doWriteAttribute(jo, "contentTypeFormat", def.getContentTypeFormat(), "binary"); + doWriteAttribute(jo, "contentTypeHeader", def.getContentTypeHeader(), "true"); + return jo; + } + protected void doWriteUniVocityAbstractDataFormatAttributes(JsonObject jo, UniVocityAbstractDataFormat def) { + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "headerExtractionEnabled", def.getHeaderExtractionEnabled(), null); + doWriteAttribute(jo, "skipEmptyLines", def.getSkipEmptyLines(), "true"); + doWriteAttribute(jo, "asMap", def.getAsMap(), null); + doWriteAttribute(jo, "ignoreLeadingWhitespaces", def.getIgnoreLeadingWhitespaces(), "true"); + doWriteAttribute(jo, "lineSeparator", def.getLineSeparator(), null); + doWriteAttribute(jo, "ignoreTrailingWhitespaces", def.getIgnoreTrailingWhitespaces(), "true"); + doWriteAttribute(jo, "lazyLoad", def.getLazyLoad(), null); + doWriteAttribute(jo, "nullValue", def.getNullValue(), null); + doWriteAttribute(jo, "normalizedLineSeparator", def.getNormalizedLineSeparator(), null); + doWriteAttribute(jo, "emptyValue", def.getEmptyValue(), null); + doWriteAttribute(jo, "headersDisabled", def.getHeadersDisabled(), null); + doWriteAttribute(jo, "comment", def.getComment(), "#"); + doWriteAttribute(jo, "numberOfRecordsToRead", def.getNumberOfRecordsToRead(), null); + } + protected void doWriteUniVocityAbstractDataFormatElements(JsonObject jo, UniVocityAbstractDataFormat def) { + doWriteElementRefList(jo, null, def.getHeaders(), this::doWriteUniVocityHeaderRef); + } + protected JsonObject doWriteUniVocityAbstractDataFormat(UniVocityAbstractDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteUniVocityAbstractDataFormatAttributes(jo, def); + doWriteUniVocityAbstractDataFormatElements(jo, def); + return jo; + } + protected JsonObject doWriteUniVocityCsvDataFormat(UniVocityCsvDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteUniVocityAbstractDataFormatAttributes(jo, def); + doWriteAttribute(jo, "delimiter", def.getDelimiter(), ","); + doWriteAttribute(jo, "quoteAllFields", def.getQuoteAllFields(), null); + doWriteAttribute(jo, "quote", def.getQuote(), "\""); + doWriteAttribute(jo, "quoteEscape", def.getQuoteEscape(), "\""); + doWriteUniVocityAbstractDataFormatElements(jo, def); + return jo; + } + protected JsonObject doWriteUniVocityFixedDataFormat(UniVocityFixedDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteUniVocityAbstractDataFormatAttributes(jo, def); + doWriteAttribute(jo, "padding", def.getPadding(), null); + doWriteAttribute(jo, "skipTrailingCharsUntilNewline", def.getSkipTrailingCharsUntilNewline(), null); + doWriteAttribute(jo, "recordEndsOnNewline", def.getRecordEndsOnNewline(), null); + doWriteUniVocityAbstractDataFormatElements(jo, def); + return jo; + } + protected JsonObject doWriteUniVocityHeader(UniVocityHeader def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "length", def.getLength(), null); + doWriteValue(jo, def.getName()); + return jo; + } + protected JsonObject doWriteUniVocityTsvDataFormat(UniVocityTsvDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteUniVocityAbstractDataFormatAttributes(jo, def); + doWriteAttribute(jo, "escapeChar", def.getEscapeChar(), "\\"); + doWriteUniVocityAbstractDataFormatElements(jo, def); + return jo; + } + protected JsonObject doWriteXMLSecurityDataFormat(XMLSecurityDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "namespace", def.getNamespaceRef(), null); + doWriteAttribute(jo, "xmlCipherAlgorithm", def.getXmlCipherAlgorithm(), "AES-256-GCM"); + doWriteAttribute(jo, "passPhrase", def.getPassPhrase(), null); + doWriteAttribute(jo, "passPhraseByte", toString(def.getPassPhraseByte()), null); + doWriteAttribute(jo, "secureTag", def.getSecureTag(), null); + doWriteAttribute(jo, "secureTagContents", def.getSecureTagContents(), null); + doWriteAttribute(jo, "keyCipherAlgorithm", def.getKeyCipherAlgorithm(), "RSA_OAEP"); + doWriteAttribute(jo, "recipientKeyAlias", def.getRecipientKeyAlias(), null); + doWriteAttribute(jo, "keyOrTrustStoreParameters", def.getKeyOrTrustStoreParameters(), null); + doWriteAttribute(jo, "keyPassword", def.getKeyPassword(), null); + doWriteAttribute(jo, "digestAlgorithm", def.getDigestAlgorithm(), "SHA1"); + doWriteAttribute(jo, "mgfAlgorithm", def.getMgfAlgorithm(), "MGF1_SHA1"); + doWriteAttribute(jo, "addKeyValueForEncryptedKey", def.getAddKeyValueForEncryptedKey(), "true"); + return jo; + } + protected JsonObject doWriteYAMLDataFormat(YAMLDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "unmarshalType", def.getUnmarshalTypeName(), null); + doWriteAttribute(jo, "library", toString(def.getLibrary()), "SnakeYAML"); + doWriteAttribute(jo, "constructor", def.getConstructor(), null); + doWriteAttribute(jo, "representer", def.getRepresenter(), null); + doWriteAttribute(jo, "dumperOptions", def.getDumperOptions(), null); + doWriteAttribute(jo, "resolver", def.getResolver(), null); + doWriteAttribute(jo, "useApplicationContextClassLoader", def.getUseApplicationContextClassLoader(), "true"); + doWriteAttribute(jo, "prettyFlow", def.getPrettyFlow(), null); + doWriteAttribute(jo, "allowAnyType", def.getAllowAnyType(), null); + doWriteAttribute(jo, "typeFilter", def.getTypeFilter(), null); + doWriteAttribute(jo, "maxAliasesForCollections", def.getMaxAliasesForCollections(), "50"); + doWriteAttribute(jo, "allowRecursiveKeys", def.getAllowRecursiveKeys(), null); + return jo; + } + protected JsonObject doWriteZipDeflaterDataFormat(ZipDeflaterDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "compressionLevel", def.getCompressionLevel(), "-1"); + return jo; + } + protected JsonObject doWriteZipFileDataFormat(ZipFileDataFormat def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "usingIterator", def.getUsingIterator(), null); + doWriteAttribute(jo, "allowEmptyDirectory", def.getAllowEmptyDirectory(), null); + doWriteAttribute(jo, "preservePathElements", def.getPreservePathElements(), null); + doWriteAttribute(jo, "maxDecompressedSize", def.getMaxDecompressedSize(), "1073741824"); + return jo; + } + protected JsonObject doWriteDeadLetterChannelDefinition(DeadLetterChannelDefinition def) { + JsonObject jo = new JsonObject(); + doWriteDefaultErrorHandlerDefinitionAttributes(jo, def); + doWriteAttribute(jo, "deadLetterUri", def.getDeadLetterUri(), null); + doWriteAttribute(jo, "deadLetterHandleNewException", def.getDeadLetterHandleNewException(), "true"); + doWriteDefaultErrorHandlerDefinitionElements(jo, def); + return jo; + } + protected void doWriteDefaultErrorHandlerDefinitionAttributes(JsonObject jo, DefaultErrorHandlerDefinition def) { + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "useOriginalMessage", def.getUseOriginalMessage(), null); + doWriteAttribute(jo, "useOriginalBody", def.getUseOriginalBody(), null); + doWriteAttribute(jo, "redeliveryPolicyRef", def.getRedeliveryPolicyRef(), null); + doWriteAttribute(jo, "loggerRef", def.getLoggerRef(), null); + doWriteAttribute(jo, "level", def.getLevel(), "ERROR"); + doWriteAttribute(jo, "logName", def.getLogName(), null); + doWriteAttribute(jo, "onRedeliveryRef", def.getOnRedeliveryRef(), null); + doWriteAttribute(jo, "onExceptionOccurredRef", def.getOnExceptionOccurredRef(), null); + doWriteAttribute(jo, "onPrepareFailureRef", def.getOnPrepareFailureRef(), null); + doWriteAttribute(jo, "retryWhileRef", def.getRetryWhileRef(), null); + doWriteAttribute(jo, "executorServiceRef", def.getExecutorServiceRef(), null); + } + protected void doWriteDefaultErrorHandlerDefinitionElements(JsonObject jo, DefaultErrorHandlerDefinition def) { + doWriteChildElement(jo, "redeliveryPolicy", def.getRedeliveryPolicy(), this::doWriteRedeliveryPolicyDefinition); + } + protected JsonObject doWriteDefaultErrorHandlerDefinition(DefaultErrorHandlerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteDefaultErrorHandlerDefinitionAttributes(jo, def); + doWriteDefaultErrorHandlerDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteJtaTransactionErrorHandlerDefinition(JtaTransactionErrorHandlerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteTransactionErrorHandlerDefinitionAttributes(jo, def); + doWriteDefaultErrorHandlerDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteNoErrorHandlerDefinition(NoErrorHandlerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + return jo; + } + protected JsonObject doWriteRefErrorHandlerDefinition(RefErrorHandlerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + return jo; + } + protected JsonObject doWriteSpringTransactionErrorHandlerDefinition(SpringTransactionErrorHandlerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteTransactionErrorHandlerDefinitionAttributes(jo, def); + doWriteDefaultErrorHandlerDefinitionElements(jo, def); + return jo; + } + protected void doWriteTransactionErrorHandlerDefinitionAttributes(JsonObject jo, TransactionErrorHandlerDefinition def) { + doWriteDefaultErrorHandlerDefinitionAttributes(jo, def); + doWriteAttribute(jo, "rollbackLoggingLevel", def.getRollbackLoggingLevel(), "WARN"); + doWriteAttribute(jo, "transactedPolicyRef", def.getTransactedPolicyRef(), null); + } + protected JsonObject doWriteTransactionErrorHandlerDefinition(TransactionErrorHandlerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteTransactionErrorHandlerDefinitionAttributes(jo, def); + doWriteDefaultErrorHandlerDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteCSimpleExpression(CSimpleExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "trimResult", def.getTrimResult(), "false"); + doWriteAttribute(jo, "pretty", def.getPretty(), "false"); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteConstantExpression(ConstantExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteDatasonnetExpression(DatasonnetExpression def) { + JsonObject jo = new JsonObject(); + doWriteSingleInputTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "bodyMediaType", def.getBodyMediaType(), null); + doWriteAttribute(jo, "outputMediaType", def.getOutputMediaType(), null); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteExchangePropertyExpression(ExchangePropertyExpression def) { + JsonObject jo = new JsonObject(); + doWriteExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected void doWriteExpressionDefinitionAttributes(JsonObject jo, ExpressionDefinition def) { + doWriteAttribute(jo, "id", def.getId(), null); + doWriteAttribute(jo, "trim", def.getTrim(), "true"); + } + protected JsonObject doWriteExpressionDefinition(ExpressionDefinition def) { + JsonObject jo = new JsonObject(); + doWriteExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteGroovyExpression(GroovyExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteHeaderExpression(HeaderExpression def) { + JsonObject jo = new JsonObject(); + doWriteExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteHl7TerserExpression(Hl7TerserExpression def) { + JsonObject jo = new JsonObject(); + doWriteSingleInputTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteJavaExpression(JavaExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "preCompile", def.getPreCompile(), "true"); + doWriteAttribute(jo, "singleQuotes", def.getSingleQuotes(), "true"); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteJavaScriptExpression(JavaScriptExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteJoorExpression(JoorExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "preCompile", def.getPreCompile(), "true"); + doWriteAttribute(jo, "singleQuotes", def.getSingleQuotes(), "true"); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteJqExpression(JqExpression def) { + JsonObject jo = new JsonObject(); + doWriteSingleInputTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteJsonPathExpression(JsonPathExpression def) { + JsonObject jo = new JsonObject(); + doWriteSingleInputTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "suppressExceptions", def.getSuppressExceptions(), "false"); + doWriteAttribute(jo, "allowSimple", def.getAllowSimple(), "true"); + doWriteAttribute(jo, "allowEasyPredicate", def.getAllowEasyPredicate(), "true"); + doWriteAttribute(jo, "writeAsString", def.getWriteAsString(), "false"); + doWriteAttribute(jo, "unpackArray", def.getUnpackArray(), "false"); + doWriteAttribute(jo, "option", def.getOption(), null); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteLanguageExpression(LanguageExpression def) { + JsonObject jo = new JsonObject(); + doWriteExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "language", def.getLanguage(), null); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteMethodCallExpression(MethodCallExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "beanType", def.getBeanTypeName(), null); + doWriteAttribute(jo, "ref", def.getRef(), null); + doWriteAttribute(jo, "method", def.getMethod(), null); + doWriteAttribute(jo, "scope", def.getScope(), "Singleton"); + doWriteAttribute(jo, "validate", def.getValidate(), "true"); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteMvelExpression(MvelExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected void doWriteNamespaceAwareExpressionElements(JsonObject jo, NamespaceAwareExpression def) { + doWriteChildList(jo, null, "namespace", def.getNamespace(), this::doWritePropertyDefinition); + } + protected JsonObject doWriteNamespaceAwareExpression(NamespaceAwareExpression def) { + JsonObject jo = new JsonObject(); + doWriteSingleInputTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + doWriteNamespaceAwareExpressionElements(jo, def); + return jo; + } + protected JsonObject doWriteOgnlExpression(OgnlExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWritePythonExpression(PythonExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteRefExpression(RefExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteSimpleExpression(SimpleExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "trimResult", def.getTrimResult(), "false"); + doWriteAttribute(jo, "pretty", def.getPretty(), "false"); + doWriteAttribute(jo, "nested", def.getNested(), "false"); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected void doWriteSingleInputTypedExpressionDefinitionAttributes(JsonObject jo, SingleInputTypedExpressionDefinition def) { + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "source", def.getSource(), null); + } + protected JsonObject doWriteSingleInputTypedExpressionDefinition(SingleInputTypedExpressionDefinition def) { + JsonObject jo = new JsonObject(); + doWriteSingleInputTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteSpELExpression(SpELExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteTokenizerExpression(TokenizerExpression def) { + JsonObject jo = new JsonObject(); + doWriteSingleInputTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "token", def.getToken(), null); + doWriteAttribute(jo, "endToken", def.getEndToken(), null); + doWriteAttribute(jo, "inheritNamespaceTagName", def.getInheritNamespaceTagName(), null); + doWriteAttribute(jo, "regex", def.getRegex(), null); + doWriteAttribute(jo, "xml", def.getXml(), null); + doWriteAttribute(jo, "includeTokens", def.getIncludeTokens(), null); + doWriteAttribute(jo, "group", def.getGroup(), null); + doWriteAttribute(jo, "groupDelimiter", def.getGroupDelimiter(), null); + doWriteAttribute(jo, "skipFirst", def.getSkipFirst(), null); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected void doWriteTypedExpressionDefinitionAttributes(JsonObject jo, TypedExpressionDefinition def) { + doWriteExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "resultType", def.getResultTypeName(), null); + } + protected JsonObject doWriteTypedExpressionDefinition(TypedExpressionDefinition def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteVariableExpression(VariableExpression def) { + JsonObject jo = new JsonObject(); + doWriteExpressionDefinitionAttributes(jo, def); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteWasmExpression(WasmExpression def) { + JsonObject jo = new JsonObject(); + doWriteTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "module", def.getModule(), null); + doWriteValue(jo, def.getExpression()); + return jo; + } + protected JsonObject doWriteXMLTokenizerExpression(XMLTokenizerExpression def) { + JsonObject jo = new JsonObject(); + doWriteSingleInputTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "mode", def.getMode(), "i"); + doWriteAttribute(jo, "group", def.getGroup(), null); + doWriteValue(jo, def.getExpression()); + doWriteNamespaceAwareExpressionElements(jo, def); + return jo; + } + protected JsonObject doWriteXPathExpression(XPathExpression def) { + JsonObject jo = new JsonObject(); + doWriteSingleInputTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "documentType", def.getDocumentTypeName(), null); + doWriteAttribute(jo, "resultQName", def.getResultQName(), "NODESET"); + doWriteAttribute(jo, "saxon", def.getSaxon(), null); + doWriteAttribute(jo, "factoryRef", def.getFactoryRef(), null); + doWriteAttribute(jo, "objectModel", def.getObjectModel(), null); + doWriteAttribute(jo, "logNamespaces", def.getLogNamespaces(), null); + doWriteAttribute(jo, "threadSafety", def.getThreadSafety(), null); + doWriteAttribute(jo, "preCompile", def.getPreCompile(), "true"); + doWriteValue(jo, def.getExpression()); + doWriteNamespaceAwareExpressionElements(jo, def); + return jo; + } + protected JsonObject doWriteXQueryExpression(XQueryExpression def) { + JsonObject jo = new JsonObject(); + doWriteSingleInputTypedExpressionDefinitionAttributes(jo, def); + doWriteAttribute(jo, "configurationRef", def.getConfigurationRef(), null); + doWriteValue(jo, def.getExpression()); + doWriteNamespaceAwareExpressionElements(jo, def); + return jo; + } + protected JsonObject doWriteCustomLoadBalancerDefinition(CustomLoadBalancerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + return jo; + } + protected JsonObject doWriteFailoverLoadBalancerDefinition(FailoverLoadBalancerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "roundRobin", def.getRoundRobin(), null); + doWriteAttribute(jo, "sticky", def.getSticky(), null); + doWriteAttribute(jo, "maximumFailoverAttempts", def.getMaximumFailoverAttempts(), "-1"); + doWriteAttribute(jo, "inheritErrorHandler", toString(def.getInheritErrorHandler()), "true"); + doWriteStringList(jo, null, "exception", def.getExceptions()); + return jo; + } + protected JsonObject doWriteRandomLoadBalancerDefinition(RandomLoadBalancerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + return jo; + } + protected JsonObject doWriteRoundRobinLoadBalancerDefinition(RoundRobinLoadBalancerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + return jo; + } + protected JsonObject doWriteStickyLoadBalancerDefinition(StickyLoadBalancerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteChildElement(jo, "correlationExpression", def.getCorrelationExpression(), this::doWriteExpressionSubElementDefinition); + return jo; + } + protected JsonObject doWriteTopicLoadBalancerDefinition(TopicLoadBalancerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + return jo; + } + protected JsonObject doWriteWeightedLoadBalancerDefinition(WeightedLoadBalancerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "distributionRatio", def.getDistributionRatio(), null); + doWriteAttribute(jo, "distributionRatioDelimiter", def.getDistributionRatioDelimiter(), ","); + doWriteAttribute(jo, "roundRobin", def.getRoundRobin(), null); + return jo; + } + protected JsonObject doWriteApiKeyDefinition(ApiKeyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteRestSecurityDefinitionAttributes(jo, def); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteAttribute(jo, "inHeader", def.getInHeader(), null); + doWriteAttribute(jo, "inQuery", def.getInQuery(), null); + doWriteAttribute(jo, "inCookie", def.getInCookie(), null); + return jo; + } + protected JsonObject doWriteBasicAuthDefinition(BasicAuthDefinition def) { + JsonObject jo = new JsonObject(); + doWriteRestSecurityDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteBearerTokenDefinition(BearerTokenDefinition def) { + JsonObject jo = new JsonObject(); + doWriteRestSecurityDefinitionAttributes(jo, def); + doWriteAttribute(jo, "format", def.getFormat(), null); + return jo; + } + protected JsonObject doWriteDeleteDefinition(DeleteDefinition def) { + JsonObject jo = new JsonObject(); + doWriteVerbDefinitionAttributes(jo, def); + doWriteVerbDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteGetDefinition(GetDefinition def) { + JsonObject jo = new JsonObject(); + doWriteVerbDefinitionAttributes(jo, def); + doWriteVerbDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteHeadDefinition(HeadDefinition def) { + JsonObject jo = new JsonObject(); + doWriteVerbDefinitionAttributes(jo, def); + doWriteVerbDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteMutualTLSDefinition(MutualTLSDefinition def) { + JsonObject jo = new JsonObject(); + doWriteRestSecurityDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteOAuth2Definition(OAuth2Definition def) { + JsonObject jo = new JsonObject(); + doWriteRestSecurityDefinitionAttributes(jo, def); + doWriteAttribute(jo, "authorizationUrl", def.getAuthorizationUrl(), null); + doWriteAttribute(jo, "tokenUrl", def.getTokenUrl(), null); + doWriteAttribute(jo, "refreshUrl", def.getRefreshUrl(), null); + doWriteAttribute(jo, "flow", def.getFlow(), null); + doWriteChildList(jo, null, "scopes", def.getScopes(), this::doWriteRestPropertyDefinition); + return jo; + } + protected JsonObject doWriteOpenApiDefinition(OpenApiDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "disabled", def.getDisabled(), null); + doWriteAttribute(jo, "specification", def.getSpecification(), null); + doWriteAttribute(jo, "apiContextPath", def.getApiContextPath(), null); + doWriteAttribute(jo, "routeId", def.getRouteId(), null); + doWriteAttribute(jo, "missingOperation", def.getMissingOperation(), "fail"); + doWriteAttribute(jo, "mockIncludePattern", def.getMockIncludePattern(), "classpath:camel-mock/**"); + return jo; + } + protected JsonObject doWriteOpenIdConnectDefinition(OpenIdConnectDefinition def) { + JsonObject jo = new JsonObject(); + doWriteRestSecurityDefinitionAttributes(jo, def); + doWriteAttribute(jo, "url", def.getUrl(), null); + return jo; + } + protected JsonObject doWriteParamDefinition(ParamDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "description", def.getDescription(), null); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteAttribute(jo, "type", toString(def.getType()), "path"); + doWriteAttribute(jo, "defaultValue", def.getDefaultValue(), null); + doWriteAttribute(jo, "required", toString(def.getRequired()), "true"); + doWriteAttribute(jo, "collectionFormat", toString(def.getCollectionFormat()), "csv"); + doWriteAttribute(jo, "arrayType", def.getArrayType(), "string"); + doWriteAttribute(jo, "dataType", def.getDataType(), "string"); + doWriteAttribute(jo, "dataFormat", def.getDataFormat(), null); + doWriteChildList(jo, "allowableValues", "value", def.getAllowableValues(), this::doWriteValueDefinition); + doWriteChildList(jo, null, "examples", def.getExamples(), this::doWriteRestPropertyDefinition); + return jo; + } + protected JsonObject doWritePatchDefinition(PatchDefinition def) { + JsonObject jo = new JsonObject(); + doWriteVerbDefinitionAttributes(jo, def); + doWriteVerbDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWritePostDefinition(PostDefinition def) { + JsonObject jo = new JsonObject(); + doWriteVerbDefinitionAttributes(jo, def); + doWriteVerbDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWritePutDefinition(PutDefinition def) { + JsonObject jo = new JsonObject(); + doWriteVerbDefinitionAttributes(jo, def); + doWriteVerbDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteResponseHeaderDefinition(ResponseHeaderDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "description", def.getDescription(), null); + doWriteAttribute(jo, "name", def.getName(), null); + doWriteAttribute(jo, "collectionFormat", toString(def.getCollectionFormat()), "csv"); + doWriteAttribute(jo, "arrayType", def.getArrayType(), "string"); + doWriteAttribute(jo, "dataType", def.getDataType(), "string"); + doWriteAttribute(jo, "dataFormat", def.getDataFormat(), null); + doWriteAttribute(jo, "example", def.getExample(), null); + doWriteChildList(jo, "allowableValues", "value", def.getAllowableValues(), this::doWriteValueDefinition); + return jo; + } + protected JsonObject doWriteResponseMessageDefinition(ResponseMessageDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "code", def.getCode(), "200"); + doWriteAttribute(jo, "contentType", def.getContentType(), null); + doWriteAttribute(jo, "message", def.getMessage(), null); + doWriteAttribute(jo, "responseModel", def.getResponseModel(), null); + doWriteChildList(jo, null, "header", def.getHeaders(), this::doWriteResponseHeaderDefinition); + doWriteChildList(jo, null, "examples", def.getExamples(), this::doWriteRestPropertyDefinition); + return jo; + } + protected JsonObject doWriteRestBindingDefinition(RestBindingDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "consumes", def.getConsumes(), null); + doWriteAttribute(jo, "produces", def.getProduces(), null); + doWriteAttribute(jo, "bindingMode", def.getBindingMode(), "off"); + doWriteAttribute(jo, "type", def.getType(), null); + doWriteAttribute(jo, "outType", def.getOutType(), null); + doWriteAttribute(jo, "skipBindingOnErrorCode", def.getSkipBindingOnErrorCode(), "false"); + doWriteAttribute(jo, "clientRequestValidation", def.getClientRequestValidation(), "false"); + doWriteAttribute(jo, "clientResponseValidation", def.getClientResponseValidation(), "false"); + doWriteAttribute(jo, "enableCORS", def.getEnableCORS(), "false"); + doWriteAttribute(jo, "enableNoContentResponse", def.getEnableNoContentResponse(), "false"); + doWriteAttribute(jo, "component", def.getComponent(), null); + return jo; + } + protected JsonObject doWriteRestConfigurationDefinition(RestConfigurationDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "component", def.getComponent(), null); + doWriteAttribute(jo, "apiComponent", def.getApiComponent(), null); + doWriteAttribute(jo, "producerComponent", def.getProducerComponent(), null); + doWriteAttribute(jo, "scheme", def.getScheme(), null); + doWriteAttribute(jo, "host", def.getHost(), null); + doWriteAttribute(jo, "port", def.getPort(), null); + doWriteAttribute(jo, "apiHost", def.getApiHost(), null); + doWriteAttribute(jo, "useXForwardHeaders", def.getUseXForwardHeaders(), null); + doWriteAttribute(jo, "producerApiDoc", def.getProducerApiDoc(), null); + doWriteAttribute(jo, "contextPath", def.getContextPath(), null); + doWriteAttribute(jo, "apiContextPath", def.getApiContextPath(), null); + doWriteAttribute(jo, "apiContextRouteId", def.getApiContextRouteId(), null); + doWriteAttribute(jo, "apiVendorExtension", def.getApiVendorExtension(), "false"); + doWriteAttribute(jo, "hostNameResolver", toString(def.getHostNameResolver()), "allLocalIp"); + doWriteAttribute(jo, "bindingMode", toString(def.getBindingMode()), "off"); + doWriteAttribute(jo, "bindingPackageScan", def.getBindingPackageScan(), null); + doWriteAttribute(jo, "skipBindingOnErrorCode", def.getSkipBindingOnErrorCode(), "false"); + doWriteAttribute(jo, "clientRequestValidation", def.getClientRequestValidation(), "false"); + doWriteAttribute(jo, "clientResponseValidation", def.getClientResponseValidation(), "false"); + doWriteAttribute(jo, "enableCORS", def.getEnableCORS(), "false"); + doWriteAttribute(jo, "enableNoContentResponse", def.getEnableNoContentResponse(), "false"); + doWriteAttribute(jo, "inlineRoutes", def.getInlineRoutes(), "true"); + doWriteAttribute(jo, "jsonDataFormat", def.getJsonDataFormat(), "jackson"); + doWriteAttribute(jo, "xmlDataFormat", def.getXmlDataFormat(), "jaxb"); + doWriteChildList(jo, null, "consumerProperty", def.getConsumerProperties(), this::doWriteRestPropertyDefinition); + doWriteChildList(jo, null, "componentProperty", def.getComponentProperties(), this::doWriteRestPropertyDefinition); + doWriteChildList(jo, null, "apiProperty", def.getApiProperties(), this::doWriteRestPropertyDefinition); + doWriteChildList(jo, null, "endpointProperty", def.getEndpointProperties(), this::doWriteRestPropertyDefinition); + doWriteChildList(jo, null, "dataFormatProperty", def.getDataFormatProperties(), this::doWriteRestPropertyDefinition); + doWriteChildList(jo, null, "corsHeaders", def.getCorsHeaders(), this::doWriteRestPropertyDefinition); + doWriteChildList(jo, null, "validationLevels", def.getValidationLevels(), this::doWriteRestPropertyDefinition); + return jo; + } + protected JsonObject doWriteRestDefinition(RestDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "disabled", def.getDisabled(), null); + doWriteAttribute(jo, "path", def.getPath(), null); + doWriteAttribute(jo, "consumes", def.getConsumes(), null); + doWriteAttribute(jo, "produces", def.getProduces(), null); + doWriteAttribute(jo, "bindingMode", def.getBindingMode(), "off"); + doWriteAttribute(jo, "skipBindingOnErrorCode", def.getSkipBindingOnErrorCode(), "false"); + doWriteAttribute(jo, "clientRequestValidation", def.getClientRequestValidation(), "false"); + doWriteAttribute(jo, "clientResponseValidation", def.getClientResponseValidation(), "false"); + doWriteAttribute(jo, "enableCORS", def.getEnableCORS(), "false"); + doWriteAttribute(jo, "enableNoContentResponse", def.getEnableNoContentResponse(), "false"); + doWriteAttribute(jo, "apiDocs", def.getApiDocs(), "true"); + doWriteAttribute(jo, "tag", def.getTag(), null); + doWriteElementRefList(jo, null, def.getVerbs(), this::doWriteVerbDefinitionRef); + doWriteChildElement(jo, "openApi", def.getOpenApi(), this::doWriteOpenApiDefinition); + doWriteChildElement(jo, "securityDefinitions", def.getSecurityDefinitions(), this::doWriteRestSecuritiesDefinition); + doWriteChildList(jo, null, "securityRequirements", def.getSecurityRequirements(), this::doWriteSecurityDefinition); + return jo; + } + protected JsonObject doWriteRestPropertyDefinition(RestPropertyDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "key", def.getKey(), null); + doWriteAttribute(jo, "value", def.getValue(), null); + return jo; + } + protected JsonObject doWriteRestSecuritiesDefinition(RestSecuritiesDefinition def) { + JsonObject jo = new JsonObject(); + if (def.getSecurityDefinitions() != null) { + for (var item : def.getSecurityDefinitions()) { + switch (item.getClass().getSimpleName()) { + case "ApiKeyDefinition" -> doWriteChildElement(jo, "apiKey", (ApiKeyDefinition) item, this::doWriteApiKeyDefinition); + case "BasicAuthDefinition" -> doWriteChildElement(jo, "basicAuth", (BasicAuthDefinition) item, this::doWriteBasicAuthDefinition); + case "BearerTokenDefinition" -> doWriteChildElement(jo, "bearerToken", (BearerTokenDefinition) item, this::doWriteBearerTokenDefinition); + case "OAuth2Definition" -> doWriteChildElement(jo, "oauth2", (OAuth2Definition) item, this::doWriteOAuth2Definition); + case "OpenIdConnectDefinition" -> doWriteChildElement(jo, "openIdConnect", (OpenIdConnectDefinition) item, this::doWriteOpenIdConnectDefinition); + case "MutualTLSDefinition" -> doWriteChildElement(jo, "mutualTLS", (MutualTLSDefinition) item, this::doWriteMutualTLSDefinition); + } + } + } + return jo; + } + protected void doWriteRestSecurityDefinitionAttributes(JsonObject jo, RestSecurityDefinition def) { + doWriteAttribute(jo, "description", def.getDescription(), null); + doWriteAttribute(jo, "key", def.getKey(), null); + } + protected JsonObject doWriteRestSecurityDefinition(RestSecurityDefinition def) { + JsonObject jo = new JsonObject(); + doWriteRestSecurityDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteRestsDefinition(RestsDefinition def) { + JsonObject jo = new JsonObject(); + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteElementRefList(jo, null, def.getRests(), this::doWriteRestDefinitionRef); + return jo; + } + protected JsonObject doWriteSecurityDefinition(SecurityDefinition def) { + JsonObject jo = new JsonObject(); + doWriteAttribute(jo, "key", def.getKey(), null); + doWriteAttribute(jo, "scopes", def.getScopes(), null); + return jo; + } + protected void doWriteVerbDefinitionAttributes(JsonObject jo, VerbDefinition def) { + doWriteOptionalIdentifiedDefinitionAttributes(jo, def); + doWriteAttribute(jo, "enableCORS", def.getEnableCORS(), "false"); + doWriteAttribute(jo, "deprecated", def.getDeprecated(), "false"); + doWriteAttribute(jo, "streamCache", def.getStreamCache(), null); + doWriteAttribute(jo, "type", def.getType(), null); + doWriteAttribute(jo, "outType", def.getOutType(), null); + doWriteAttribute(jo, "clientResponseValidation", def.getClientResponseValidation(), "false"); + doWriteAttribute(jo, "path", def.getPath(), null); + doWriteAttribute(jo, "routeId", def.getRouteId(), null); + doWriteAttribute(jo, "bindingMode", def.getBindingMode(), "off"); + doWriteAttribute(jo, "apiDocs", def.getApiDocs(), "true"); + doWriteAttribute(jo, "enableNoContentResponse", def.getEnableNoContentResponse(), "false"); + doWriteAttribute(jo, "skipBindingOnErrorCode", def.getSkipBindingOnErrorCode(), "false"); + doWriteAttribute(jo, "clientRequestValidation", def.getClientRequestValidation(), "false"); + doWriteAttribute(jo, "produces", def.getProduces(), null); + doWriteAttribute(jo, "disabled", def.getDisabled(), null); + doWriteAttribute(jo, "consumes", def.getConsumes(), null); + } + protected void doWriteVerbDefinitionElements(JsonObject jo, VerbDefinition def) { + doWriteElementRefList(jo, null, def.getParams(), this::doWriteParamDefinitionRef); + doWriteElementRefList(jo, null, def.getSecurity(), this::doWriteSecurityDefinitionRef); + doWriteElementRefList(jo, null, def.getResponseMsgs(), this::doWriteResponseMessageDefinitionRef); + doWriteChildElement(jo, "to", def.getTo(), this::doWriteToDefinition); + } + protected JsonObject doWriteVerbDefinition(VerbDefinition def) { + JsonObject jo = new JsonObject(); + doWriteVerbDefinitionAttributes(jo, def); + doWriteVerbDefinitionElements(jo, def); + return jo; + } + protected JsonObject doWriteLangChain4jCharacterTokenizerDefinition(LangChain4jCharacterTokenizerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteLangChain4jTokenizerDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteLangChain4jLineTokenizerDefinition(LangChain4jLineTokenizerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteLangChain4jTokenizerDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteLangChain4jParagraphTokenizerDefinition(LangChain4jParagraphTokenizerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteLangChain4jTokenizerDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteLangChain4jSentenceTokenizerDefinition(LangChain4jSentenceTokenizerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteLangChain4jTokenizerDefinitionAttributes(jo, def); + return jo; + } + protected void doWriteLangChain4jTokenizerDefinitionAttributes(JsonObject jo, LangChain4jTokenizerDefinition def) { + doWriteIdentifiedTypeAttributes(jo, def); + doWriteAttribute(jo, "modelName", def.getModelName(), null); + doWriteAttribute(jo, "maxTokens", def.getMaxTokens(), null); + doWriteAttribute(jo, "tokenizerType", def.getTokenizerType(), null); + doWriteAttribute(jo, "maxOverlap", def.getMaxOverlap(), null); + } + protected JsonObject doWriteLangChain4jTokenizerDefinition(LangChain4jTokenizerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteLangChain4jTokenizerDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteLangChain4jWordTokenizerDefinition(LangChain4jWordTokenizerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteLangChain4jTokenizerDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteCustomTransformerDefinition(CustomTransformerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteTransformerDefinitionAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + doWriteAttribute(jo, "className", def.getClassName(), null); + return jo; + } + protected JsonObject doWriteDataFormatTransformerDefinition(DataFormatTransformerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteTransformerDefinitionAttributes(jo, def); + if (def.getDataFormatType() != null) { + switch (def.getDataFormatType().getClass().getSimpleName()) { + case "ASN1DataFormat" -> doWriteChildElement(jo, "asn1", (ASN1DataFormat) def.getDataFormatType(), this::doWriteASN1DataFormat); + case "AvroDataFormat" -> doWriteChildElement(jo, "avro", (AvroDataFormat) def.getDataFormatType(), this::doWriteAvroDataFormat); + case "BarcodeDataFormat" -> doWriteChildElement(jo, "barcode", (BarcodeDataFormat) def.getDataFormatType(), this::doWriteBarcodeDataFormat); + case "Base64DataFormat" -> doWriteChildElement(jo, "base64", (Base64DataFormat) def.getDataFormatType(), this::doWriteBase64DataFormat); + case "BeanioDataFormat" -> doWriteChildElement(jo, "beanio", (BeanioDataFormat) def.getDataFormatType(), this::doWriteBeanioDataFormat); + case "BindyDataFormat" -> doWriteChildElement(jo, "bindy", (BindyDataFormat) def.getDataFormatType(), this::doWriteBindyDataFormat); + case "CBORDataFormat" -> doWriteChildElement(jo, "cbor", (CBORDataFormat) def.getDataFormatType(), this::doWriteCBORDataFormat); + case "CryptoDataFormat" -> doWriteChildElement(jo, "crypto", (CryptoDataFormat) def.getDataFormatType(), this::doWriteCryptoDataFormat); + case "CsvDataFormat" -> doWriteChildElement(jo, "csv", (CsvDataFormat) def.getDataFormatType(), this::doWriteCsvDataFormat); + case "CustomDataFormat" -> doWriteChildElement(jo, "custom", (CustomDataFormat) def.getDataFormatType(), this::doWriteCustomDataFormat); + case "DfdlDataFormat" -> doWriteChildElement(jo, "dfdl", (DfdlDataFormat) def.getDataFormatType(), this::doWriteDfdlDataFormat); + case "FhirJsonDataFormat" -> doWriteChildElement(jo, "fhirJson", (FhirJsonDataFormat) def.getDataFormatType(), this::doWriteFhirJsonDataFormat); + case "FhirXmlDataFormat" -> doWriteChildElement(jo, "fhirXml", (FhirXmlDataFormat) def.getDataFormatType(), this::doWriteFhirXmlDataFormat); + case "FlatpackDataFormat" -> doWriteChildElement(jo, "flatpack", (FlatpackDataFormat) def.getDataFormatType(), this::doWriteFlatpackDataFormat); + case "ForyDataFormat" -> doWriteChildElement(jo, "fory", (ForyDataFormat) def.getDataFormatType(), this::doWriteForyDataFormat); + case "GrokDataFormat" -> doWriteChildElement(jo, "grok", (GrokDataFormat) def.getDataFormatType(), this::doWriteGrokDataFormat); + case "GroovyJSonDataFormat" -> doWriteChildElement(jo, "groovyJson", (GroovyJSonDataFormat) def.getDataFormatType(), this::doWriteGroovyJSonDataFormat); + case "GroovyXmlDataFormat" -> doWriteChildElement(jo, "groovyXml", (GroovyXmlDataFormat) def.getDataFormatType(), this::doWriteGroovyXmlDataFormat); + case "GzipDeflaterDataFormat" -> doWriteChildElement(jo, "gzipDeflater", (GzipDeflaterDataFormat) def.getDataFormatType(), this::doWriteGzipDeflaterDataFormat); + case "HL7DataFormat" -> doWriteChildElement(jo, "hl7", (HL7DataFormat) def.getDataFormatType(), this::doWriteHL7DataFormat); + case "IcalDataFormat" -> doWriteChildElement(jo, "ical", (IcalDataFormat) def.getDataFormatType(), this::doWriteIcalDataFormat); + case "Iso8583DataFormat" -> doWriteChildElement(jo, "iso8583", (Iso8583DataFormat) def.getDataFormatType(), this::doWriteIso8583DataFormat); + case "JacksonXMLDataFormat" -> doWriteChildElement(jo, "jacksonXml", (JacksonXMLDataFormat) def.getDataFormatType(), this::doWriteJacksonXMLDataFormat); + case "JaxbDataFormat" -> doWriteChildElement(jo, "jaxb", (JaxbDataFormat) def.getDataFormatType(), this::doWriteJaxbDataFormat); + case "JsonDataFormat" -> doWriteChildElement(jo, "json", (JsonDataFormat) def.getDataFormatType(), this::doWriteJsonDataFormat); + case "JsonApiDataFormat" -> doWriteChildElement(jo, "jsonApi", (JsonApiDataFormat) def.getDataFormatType(), this::doWriteJsonApiDataFormat); + case "LZFDataFormat" -> doWriteChildElement(jo, "lzf", (LZFDataFormat) def.getDataFormatType(), this::doWriteLZFDataFormat); + case "MimeMultipartDataFormat" -> doWriteChildElement(jo, "mimeMultipart", (MimeMultipartDataFormat) def.getDataFormatType(), this::doWriteMimeMultipartDataFormat); + case "OcsfDataFormat" -> doWriteChildElement(jo, "ocsf", (OcsfDataFormat) def.getDataFormatType(), this::doWriteOcsfDataFormat); + case "ParquetAvroDataFormat" -> doWriteChildElement(jo, "parquetAvro", (ParquetAvroDataFormat) def.getDataFormatType(), this::doWriteParquetAvroDataFormat); + case "PGPDataFormat" -> doWriteChildElement(jo, "pgp", (PGPDataFormat) def.getDataFormatType(), this::doWritePGPDataFormat); + case "PQCDataFormat" -> doWriteChildElement(jo, "pqc", (PQCDataFormat) def.getDataFormatType(), this::doWritePQCDataFormat); + case "ProtobufDataFormat" -> doWriteChildElement(jo, "protobuf", (ProtobufDataFormat) def.getDataFormatType(), this::doWriteProtobufDataFormat); + case "RssDataFormat" -> doWriteChildElement(jo, "rss", (RssDataFormat) def.getDataFormatType(), this::doWriteRssDataFormat); + case "SmooksDataFormat" -> doWriteChildElement(jo, "smooks", (SmooksDataFormat) def.getDataFormatType(), this::doWriteSmooksDataFormat); + case "SoapDataFormat" -> doWriteChildElement(jo, "soap", (SoapDataFormat) def.getDataFormatType(), this::doWriteSoapDataFormat); + case "SwiftMtDataFormat" -> doWriteChildElement(jo, "swiftMt", (SwiftMtDataFormat) def.getDataFormatType(), this::doWriteSwiftMtDataFormat); + case "SwiftMxDataFormat" -> doWriteChildElement(jo, "swiftMx", (SwiftMxDataFormat) def.getDataFormatType(), this::doWriteSwiftMxDataFormat); + case "SyslogDataFormat" -> doWriteChildElement(jo, "syslog", (SyslogDataFormat) def.getDataFormatType(), this::doWriteSyslogDataFormat); + case "TarFileDataFormat" -> doWriteChildElement(jo, "tarFile", (TarFileDataFormat) def.getDataFormatType(), this::doWriteTarFileDataFormat); + case "ThriftDataFormat" -> doWriteChildElement(jo, "thrift", (ThriftDataFormat) def.getDataFormatType(), this::doWriteThriftDataFormat); + case "UniVocityCsvDataFormat" -> doWriteChildElement(jo, "univocityCsv", (UniVocityCsvDataFormat) def.getDataFormatType(), this::doWriteUniVocityCsvDataFormat); + case "UniVocityFixedDataFormat" -> doWriteChildElement(jo, "univocityFixed", (UniVocityFixedDataFormat) def.getDataFormatType(), this::doWriteUniVocityFixedDataFormat); + case "UniVocityTsvDataFormat" -> doWriteChildElement(jo, "univocityTsv", (UniVocityTsvDataFormat) def.getDataFormatType(), this::doWriteUniVocityTsvDataFormat); + case "XMLSecurityDataFormat" -> doWriteChildElement(jo, "xmlSecurity", (XMLSecurityDataFormat) def.getDataFormatType(), this::doWriteXMLSecurityDataFormat); + case "YAMLDataFormat" -> doWriteChildElement(jo, "yaml", (YAMLDataFormat) def.getDataFormatType(), this::doWriteYAMLDataFormat); + case "ZipDeflaterDataFormat" -> doWriteChildElement(jo, "zipDeflater", (ZipDeflaterDataFormat) def.getDataFormatType(), this::doWriteZipDeflaterDataFormat); + case "ZipFileDataFormat" -> doWriteChildElement(jo, "zipFile", (ZipFileDataFormat) def.getDataFormatType(), this::doWriteZipFileDataFormat); + } + } + return jo; + } + protected JsonObject doWriteEndpointTransformerDefinition(EndpointTransformerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteTransformerDefinitionAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + doWriteAttribute(jo, "uri", def.getUri(), null); + return jo; + } + protected JsonObject doWriteLoadTransformerDefinition(LoadTransformerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteTransformerDefinitionAttributes(jo, def); + doWriteAttribute(jo, "packageScan", def.getPackageScan(), null); + doWriteAttribute(jo, "defaults", def.getDefaults(), "false"); + return jo; + } + protected void doWriteTransformerDefinitionAttributes(JsonObject jo, TransformerDefinition def) { + doWriteAttribute(jo, "toType", def.getToType(), null); + doWriteAttribute(jo, "fromType", def.getFromType(), null); + doWriteAttribute(jo, "scheme", def.getScheme(), null); + doWriteAttribute(jo, "name", def.getName(), null); + } + protected JsonObject doWriteTransformerDefinition(TransformerDefinition def) { + JsonObject jo = new JsonObject(); + doWriteTransformerDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteTransformersDefinition(TransformersDefinition def) { + JsonObject jo = new JsonObject(); + if (def.getTransformers() != null) { + for (var item : def.getTransformers()) { + switch (item.getClass().getSimpleName()) { + case "DataFormatTransformerDefinition" -> doWriteChildElement(jo, "dataFormatTransformer", (DataFormatTransformerDefinition) item, this::doWriteDataFormatTransformerDefinition); + case "EndpointTransformerDefinition" -> doWriteChildElement(jo, "endpointTransformer", (EndpointTransformerDefinition) item, this::doWriteEndpointTransformerDefinition); + case "LoadTransformerDefinition" -> doWriteChildElement(jo, "loadTransformer", (LoadTransformerDefinition) item, this::doWriteLoadTransformerDefinition); + case "CustomTransformerDefinition" -> doWriteChildElement(jo, "customTransformer", (CustomTransformerDefinition) item, this::doWriteCustomTransformerDefinition); + } + } + } + return jo; + } + protected JsonObject doWriteCustomValidatorDefinition(CustomValidatorDefinition def) { + JsonObject jo = new JsonObject(); + doWriteValidatorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + doWriteAttribute(jo, "className", def.getClassName(), null); + return jo; + } + protected JsonObject doWriteEndpointValidatorDefinition(EndpointValidatorDefinition def) { + JsonObject jo = new JsonObject(); + doWriteValidatorDefinitionAttributes(jo, def); + doWriteAttribute(jo, "ref", def.getRef(), null); + doWriteAttribute(jo, "uri", def.getUri(), null); + return jo; + } + protected JsonObject doWritePredicateValidatorDefinition(PredicateValidatorDefinition def) { + JsonObject jo = new JsonObject(); + doWriteValidatorDefinitionAttributes(jo, def); + doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + return jo; + } + protected void doWriteValidatorDefinitionAttributes(JsonObject jo, ValidatorDefinition def) { + doWriteAttribute(jo, "type", def.getType(), null); + } + protected JsonObject doWriteValidatorDefinition(ValidatorDefinition def) { + JsonObject jo = new JsonObject(); + doWriteValidatorDefinitionAttributes(jo, def); + return jo; + } + protected JsonObject doWriteValidatorsDefinition(ValidatorsDefinition def) { + JsonObject jo = new JsonObject(); + if (def.getValidators() != null) { + for (var item : def.getValidators()) { + switch (item.getClass().getSimpleName()) { + case "EndpointValidatorDefinition" -> doWriteChildElement(jo, "endpointValidator", (EndpointValidatorDefinition) item, this::doWriteEndpointValidatorDefinition); + case "PredicateValidatorDefinition" -> doWriteChildElement(jo, "predicateValidator", (PredicateValidatorDefinition) item, this::doWritePredicateValidatorDefinition); + case "CustomValidatorDefinition" -> doWriteChildElement(jo, "customValidator", (CustomValidatorDefinition) item, this::doWriteCustomValidatorDefinition); + } + } + } + return jo; + } + + protected JsonObject doWriteFromDefinitionRef(FromDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "FromDefinition" -> wrapNode("from", doWriteFromDefinition((FromDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteInputTypeDefinitionRef(InputTypeDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "InputTypeDefinition" -> wrapNode("inputType", doWriteInputTypeDefinition((InputTypeDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteOptionalIdentifiedDefinitionRef(OptionalIdentifiedDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "AggregateDefinition" -> wrapNode("aggregate", doWriteAggregateDefinition((AggregateDefinition) v)); + case "BeanDefinition" -> wrapNode("bean", doWriteBeanDefinition((BeanDefinition) v)); + case "CatchDefinition" -> wrapNode("doCatch", doWriteCatchDefinition((CatchDefinition) v)); + case "ChoiceDefinition" -> wrapNode("choice", doWriteChoiceDefinition((ChoiceDefinition) v)); + case "CircuitBreakerDefinition" -> wrapNode("circuitBreaker", doWriteCircuitBreakerDefinition((CircuitBreakerDefinition) v)); + case "ClaimCheckDefinition" -> wrapNode("claimCheck", doWriteClaimCheckDefinition((ClaimCheckDefinition) v)); + case "ConvertBodyDefinition" -> wrapNode("convertBodyTo", doWriteConvertBodyDefinition((ConvertBodyDefinition) v)); + case "ConvertHeaderDefinition" -> wrapNode("convertHeaderTo", doWriteConvertHeaderDefinition((ConvertHeaderDefinition) v)); + case "ConvertVariableDefinition" -> wrapNode("convertVariableTo", doWriteConvertVariableDefinition((ConvertVariableDefinition) v)); + case "DelayDefinition" -> wrapNode("delay", doWriteDelayDefinition((DelayDefinition) v)); + case "DynamicRouterDefinition" -> wrapNode("dynamicRouter", doWriteDynamicRouterDefinition((DynamicRouterDefinition) v)); + case "EnrichDefinition" -> wrapNode("enrich", doWriteEnrichDefinition((EnrichDefinition) v)); + case "FilterDefinition" -> wrapNode("filter", doWriteFilterDefinition((FilterDefinition) v)); + case "FinallyDefinition" -> wrapNode("doFinally", doWriteFinallyDefinition((FinallyDefinition) v)); + case "FromDefinition" -> wrapNode("from", doWriteFromDefinition((FromDefinition) v)); + case "IdempotentConsumerDefinition" -> wrapNode("idempotentConsumer", doWriteIdempotentConsumerDefinition((IdempotentConsumerDefinition) v)); + case "InputTypeDefinition" -> wrapNode("inputType", doWriteInputTypeDefinition((InputTypeDefinition) v)); + case "InterceptDefinition" -> wrapNode("intercept", doWriteInterceptDefinition((InterceptDefinition) v)); + case "InterceptFromDefinition" -> wrapNode("interceptFrom", doWriteInterceptFromDefinition((InterceptFromDefinition) v)); + case "InterceptSendToEndpointDefinition" -> wrapNode("interceptSendToEndpoint", doWriteInterceptSendToEndpointDefinition((InterceptSendToEndpointDefinition) v)); + case "KameletDefinition" -> wrapNode("kamelet", doWriteKameletDefinition((KameletDefinition) v)); + case "LoadBalanceDefinition" -> wrapNode("loadBalance", doWriteLoadBalanceDefinition((LoadBalanceDefinition) v)); + case "LogDefinition" -> wrapNode("log", doWriteLogDefinition((LogDefinition) v)); + case "LoopDefinition" -> wrapNode("loop", doWriteLoopDefinition((LoopDefinition) v)); + case "MarshalDefinition" -> wrapNode("marshal", doWriteMarshalDefinition((MarshalDefinition) v)); + case "MulticastDefinition" -> wrapNode("multicast", doWriteMulticastDefinition((MulticastDefinition) v)); + case "OnCompletionDefinition" -> wrapNode("onCompletion", doWriteOnCompletionDefinition((OnCompletionDefinition) v)); + case "OnExceptionDefinition" -> wrapNode("onException", doWriteOnExceptionDefinition((OnExceptionDefinition) v)); + case "OnFallbackDefinition" -> wrapNode("onFallback", doWriteOnFallbackDefinition((OnFallbackDefinition) v)); + case "OnWhenDefinition" -> wrapNode("onWhen", doWriteOnWhenDefinition((OnWhenDefinition) v)); + case "OtherwiseDefinition" -> wrapNode("otherwise", doWriteOtherwiseDefinition((OtherwiseDefinition) v)); + case "OutputTypeDefinition" -> wrapNode("outputType", doWriteOutputTypeDefinition((OutputTypeDefinition) v)); + case "PausableDefinition" -> wrapNode("pausable", doWritePausableDefinition((PausableDefinition) v)); + case "PipelineDefinition" -> wrapNode("pipeline", doWritePipelineDefinition((PipelineDefinition) v)); + case "PolicyDefinition" -> wrapNode("policy", doWritePolicyDefinition((PolicyDefinition) v)); + case "PollDefinition" -> wrapNode("poll", doWritePollDefinition((PollDefinition) v)); + case "PollEnrichDefinition" -> wrapNode("pollEnrich", doWritePollEnrichDefinition((PollEnrichDefinition) v)); + case "ProcessDefinition" -> wrapNode("process", doWriteProcessDefinition((ProcessDefinition) v)); + case "RecipientListDefinition" -> wrapNode("recipientList", doWriteRecipientListDefinition((RecipientListDefinition) v)); + case "RemoveHeaderDefinition" -> wrapNode("removeHeader", doWriteRemoveHeaderDefinition((RemoveHeaderDefinition) v)); + case "RemoveHeadersDefinition" -> wrapNode("removeHeaders", doWriteRemoveHeadersDefinition((RemoveHeadersDefinition) v)); + case "RemovePropertiesDefinition" -> wrapNode("removeProperties", doWriteRemovePropertiesDefinition((RemovePropertiesDefinition) v)); + case "RemovePropertyDefinition" -> wrapNode("removeProperty", doWriteRemovePropertyDefinition((RemovePropertyDefinition) v)); + case "RemoveVariableDefinition" -> wrapNode("removeVariable", doWriteRemoveVariableDefinition((RemoveVariableDefinition) v)); + case "ResequenceDefinition" -> wrapNode("resequence", doWriteResequenceDefinition((ResequenceDefinition) v)); + case "ResumableDefinition" -> wrapNode("resumable", doWriteResumableDefinition((ResumableDefinition) v)); + case "RollbackDefinition" -> wrapNode("rollback", doWriteRollbackDefinition((RollbackDefinition) v)); + case "RouteConfigurationDefinition" -> wrapNode("routeConfiguration", doWriteRouteConfigurationDefinition((RouteConfigurationDefinition) v)); + case "RouteConfigurationsDefinition" -> wrapNode("routeConfigurations", doWriteRouteConfigurationsDefinition((RouteConfigurationsDefinition) v)); + case "RouteDefinition" -> wrapNode("route", doWriteRouteDefinition((RouteDefinition) v)); + case "RouteTemplateDefinition" -> wrapNode("routeTemplate", doWriteRouteTemplateDefinition((RouteTemplateDefinition) v)); + case "RouteTemplatesDefinition" -> wrapNode("routeTemplates", doWriteRouteTemplatesDefinition((RouteTemplatesDefinition) v)); + case "RoutesDefinition" -> wrapNode("routes", doWriteRoutesDefinition((RoutesDefinition) v)); + case "RoutingSlipDefinition" -> wrapNode("routingSlip", doWriteRoutingSlipDefinition((RoutingSlipDefinition) v)); + case "SagaDefinition" -> wrapNode("saga", doWriteSagaDefinition((SagaDefinition) v)); + case "SamplingDefinition" -> wrapNode("sample", doWriteSamplingDefinition((SamplingDefinition) v)); + case "ScriptDefinition" -> wrapNode("script", doWriteScriptDefinition((ScriptDefinition) v)); + case "SetBodyDefinition" -> wrapNode("setBody", doWriteSetBodyDefinition((SetBodyDefinition) v)); + case "SetExchangePatternDefinition" -> wrapNode("setExchangePattern", doWriteSetExchangePatternDefinition((SetExchangePatternDefinition) v)); + case "SetHeaderDefinition" -> wrapNode("setHeader", doWriteSetHeaderDefinition((SetHeaderDefinition) v)); + case "SetHeadersDefinition" -> wrapNode("setHeaders", doWriteSetHeadersDefinition((SetHeadersDefinition) v)); + case "SetPropertyDefinition" -> wrapNode("setProperty", doWriteSetPropertyDefinition((SetPropertyDefinition) v)); + case "SetVariableDefinition" -> wrapNode("setVariable", doWriteSetVariableDefinition((SetVariableDefinition) v)); + case "SetVariablesDefinition" -> wrapNode("setVariables", doWriteSetVariablesDefinition((SetVariablesDefinition) v)); + case "SortDefinition" -> wrapNode("sort", doWriteSortDefinition((SortDefinition) v)); + case "SplitDefinition" -> wrapNode("split", doWriteSplitDefinition((SplitDefinition) v)); + case "StepDefinition" -> wrapNode("step", doWriteStepDefinition((StepDefinition) v)); + case "StopDefinition" -> wrapNode("stop", doWriteStopDefinition((StopDefinition) v)); + case "TemplatedRoutesDefinition" -> wrapNode("templatedRoutes", doWriteTemplatedRoutesDefinition((TemplatedRoutesDefinition) v)); + case "ThreadPoolProfileDefinition" -> wrapNode("threadPoolProfile", doWriteThreadPoolProfileDefinition((ThreadPoolProfileDefinition) v)); + case "ThreadsDefinition" -> wrapNode("threads", doWriteThreadsDefinition((ThreadsDefinition) v)); + case "ThrottleDefinition" -> wrapNode("throttle", doWriteThrottleDefinition((ThrottleDefinition) v)); + case "ThrowExceptionDefinition" -> wrapNode("throwException", doWriteThrowExceptionDefinition((ThrowExceptionDefinition) v)); + case "ToDefinition" -> wrapNode("to", doWriteToDefinition((ToDefinition) v)); + case "ToDynamicDefinition" -> wrapNode("toD", doWriteToDynamicDefinition((ToDynamicDefinition) v)); + case "TokenizerDefinition" -> wrapNode("tokenizer", doWriteTokenizerDefinition((TokenizerDefinition) v)); + case "TransactedDefinition" -> wrapNode("transacted", doWriteTransactedDefinition((TransactedDefinition) v)); + case "TransformDataTypeDefinition" -> wrapNode("transformDataType", doWriteTransformDataTypeDefinition((TransformDataTypeDefinition) v)); + case "TransformDefinition" -> wrapNode("transform", doWriteTransformDefinition((TransformDefinition) v)); + case "TryDefinition" -> wrapNode("doTry", doWriteTryDefinition((TryDefinition) v)); + case "UnmarshalDefinition" -> wrapNode("unmarshal", doWriteUnmarshalDefinition((UnmarshalDefinition) v)); + case "ValidateDefinition" -> wrapNode("validate", doWriteValidateDefinition((ValidateDefinition) v)); + case "WhenDefinition" -> wrapNode("when", doWriteWhenDefinition((WhenDefinition) v)); + case "WireTapDefinition" -> wrapNode("wireTap", doWriteWireTapDefinition((WireTapDefinition) v)); + case "DeleteDefinition" -> wrapNode("delete", doWriteDeleteDefinition((DeleteDefinition) v)); + case "GetDefinition" -> wrapNode("get", doWriteGetDefinition((GetDefinition) v)); + case "HeadDefinition" -> wrapNode("head", doWriteHeadDefinition((HeadDefinition) v)); + case "OpenApiDefinition" -> wrapNode("openApi", doWriteOpenApiDefinition((OpenApiDefinition) v)); + case "PatchDefinition" -> wrapNode("patch", doWritePatchDefinition((PatchDefinition) v)); + case "PostDefinition" -> wrapNode("post", doWritePostDefinition((PostDefinition) v)); + case "PutDefinition" -> wrapNode("put", doWritePutDefinition((PutDefinition) v)); + case "RestBindingDefinition" -> wrapNode("restBinding", doWriteRestBindingDefinition((RestBindingDefinition) v)); + case "RestDefinition" -> wrapNode("rest", doWriteRestDefinition((RestDefinition) v)); + case "RestsDefinition" -> wrapNode("rests", doWriteRestsDefinition((RestsDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteOutputTypeDefinitionRef(OutputTypeDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "OutputTypeDefinition" -> wrapNode("outputType", doWriteOutputTypeDefinition((OutputTypeDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteProcessorDefinitionRef(ProcessorDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "AggregateDefinition" -> wrapNode("aggregate", doWriteAggregateDefinition((AggregateDefinition) v)); + case "BeanDefinition" -> wrapNode("bean", doWriteBeanDefinition((BeanDefinition) v)); + case "CatchDefinition" -> wrapNode("doCatch", doWriteCatchDefinition((CatchDefinition) v)); + case "ChoiceDefinition" -> wrapNode("choice", doWriteChoiceDefinition((ChoiceDefinition) v)); + case "CircuitBreakerDefinition" -> wrapNode("circuitBreaker", doWriteCircuitBreakerDefinition((CircuitBreakerDefinition) v)); + case "ClaimCheckDefinition" -> wrapNode("claimCheck", doWriteClaimCheckDefinition((ClaimCheckDefinition) v)); + case "ConvertBodyDefinition" -> wrapNode("convertBodyTo", doWriteConvertBodyDefinition((ConvertBodyDefinition) v)); + case "ConvertHeaderDefinition" -> wrapNode("convertHeaderTo", doWriteConvertHeaderDefinition((ConvertHeaderDefinition) v)); + case "ConvertVariableDefinition" -> wrapNode("convertVariableTo", doWriteConvertVariableDefinition((ConvertVariableDefinition) v)); + case "DelayDefinition" -> wrapNode("delay", doWriteDelayDefinition((DelayDefinition) v)); + case "DynamicRouterDefinition" -> wrapNode("dynamicRouter", doWriteDynamicRouterDefinition((DynamicRouterDefinition) v)); + case "EnrichDefinition" -> wrapNode("enrich", doWriteEnrichDefinition((EnrichDefinition) v)); + case "FilterDefinition" -> wrapNode("filter", doWriteFilterDefinition((FilterDefinition) v)); + case "FinallyDefinition" -> wrapNode("doFinally", doWriteFinallyDefinition((FinallyDefinition) v)); + case "IdempotentConsumerDefinition" -> wrapNode("idempotentConsumer", doWriteIdempotentConsumerDefinition((IdempotentConsumerDefinition) v)); + case "InterceptDefinition" -> wrapNode("intercept", doWriteInterceptDefinition((InterceptDefinition) v)); + case "InterceptFromDefinition" -> wrapNode("interceptFrom", doWriteInterceptFromDefinition((InterceptFromDefinition) v)); + case "InterceptSendToEndpointDefinition" -> wrapNode("interceptSendToEndpoint", doWriteInterceptSendToEndpointDefinition((InterceptSendToEndpointDefinition) v)); + case "KameletDefinition" -> wrapNode("kamelet", doWriteKameletDefinition((KameletDefinition) v)); + case "LoadBalanceDefinition" -> wrapNode("loadBalance", doWriteLoadBalanceDefinition((LoadBalanceDefinition) v)); + case "LogDefinition" -> wrapNode("log", doWriteLogDefinition((LogDefinition) v)); + case "LoopDefinition" -> wrapNode("loop", doWriteLoopDefinition((LoopDefinition) v)); + case "MarshalDefinition" -> wrapNode("marshal", doWriteMarshalDefinition((MarshalDefinition) v)); + case "MulticastDefinition" -> wrapNode("multicast", doWriteMulticastDefinition((MulticastDefinition) v)); + case "OnCompletionDefinition" -> wrapNode("onCompletion", doWriteOnCompletionDefinition((OnCompletionDefinition) v)); + case "OnExceptionDefinition" -> wrapNode("onException", doWriteOnExceptionDefinition((OnExceptionDefinition) v)); + case "PausableDefinition" -> wrapNode("pausable", doWritePausableDefinition((PausableDefinition) v)); + case "PipelineDefinition" -> wrapNode("pipeline", doWritePipelineDefinition((PipelineDefinition) v)); + case "PolicyDefinition" -> wrapNode("policy", doWritePolicyDefinition((PolicyDefinition) v)); + case "PollDefinition" -> wrapNode("poll", doWritePollDefinition((PollDefinition) v)); + case "PollEnrichDefinition" -> wrapNode("pollEnrich", doWritePollEnrichDefinition((PollEnrichDefinition) v)); + case "ProcessDefinition" -> wrapNode("process", doWriteProcessDefinition((ProcessDefinition) v)); + case "RecipientListDefinition" -> wrapNode("recipientList", doWriteRecipientListDefinition((RecipientListDefinition) v)); + case "RemoveHeaderDefinition" -> wrapNode("removeHeader", doWriteRemoveHeaderDefinition((RemoveHeaderDefinition) v)); + case "RemoveHeadersDefinition" -> wrapNode("removeHeaders", doWriteRemoveHeadersDefinition((RemoveHeadersDefinition) v)); + case "RemovePropertiesDefinition" -> wrapNode("removeProperties", doWriteRemovePropertiesDefinition((RemovePropertiesDefinition) v)); + case "RemovePropertyDefinition" -> wrapNode("removeProperty", doWriteRemovePropertyDefinition((RemovePropertyDefinition) v)); + case "RemoveVariableDefinition" -> wrapNode("removeVariable", doWriteRemoveVariableDefinition((RemoveVariableDefinition) v)); + case "ResequenceDefinition" -> wrapNode("resequence", doWriteResequenceDefinition((ResequenceDefinition) v)); + case "ResumableDefinition" -> wrapNode("resumable", doWriteResumableDefinition((ResumableDefinition) v)); + case "RollbackDefinition" -> wrapNode("rollback", doWriteRollbackDefinition((RollbackDefinition) v)); + case "RouteDefinition" -> wrapNode("route", doWriteRouteDefinition((RouteDefinition) v)); + case "RoutingSlipDefinition" -> wrapNode("routingSlip", doWriteRoutingSlipDefinition((RoutingSlipDefinition) v)); + case "SagaDefinition" -> wrapNode("saga", doWriteSagaDefinition((SagaDefinition) v)); + case "SamplingDefinition" -> wrapNode("sample", doWriteSamplingDefinition((SamplingDefinition) v)); + case "ScriptDefinition" -> wrapNode("script", doWriteScriptDefinition((ScriptDefinition) v)); + case "SetBodyDefinition" -> wrapNode("setBody", doWriteSetBodyDefinition((SetBodyDefinition) v)); + case "SetExchangePatternDefinition" -> wrapNode("setExchangePattern", doWriteSetExchangePatternDefinition((SetExchangePatternDefinition) v)); + case "SetHeaderDefinition" -> wrapNode("setHeader", doWriteSetHeaderDefinition((SetHeaderDefinition) v)); + case "SetHeadersDefinition" -> wrapNode("setHeaders", doWriteSetHeadersDefinition((SetHeadersDefinition) v)); + case "SetPropertyDefinition" -> wrapNode("setProperty", doWriteSetPropertyDefinition((SetPropertyDefinition) v)); + case "SetVariableDefinition" -> wrapNode("setVariable", doWriteSetVariableDefinition((SetVariableDefinition) v)); + case "SetVariablesDefinition" -> wrapNode("setVariables", doWriteSetVariablesDefinition((SetVariablesDefinition) v)); + case "SortDefinition" -> wrapNode("sort", doWriteSortDefinition((SortDefinition) v)); + case "SplitDefinition" -> wrapNode("split", doWriteSplitDefinition((SplitDefinition) v)); + case "StepDefinition" -> wrapNode("step", doWriteStepDefinition((StepDefinition) v)); + case "StopDefinition" -> wrapNode("stop", doWriteStopDefinition((StopDefinition) v)); + case "ThreadsDefinition" -> wrapNode("threads", doWriteThreadsDefinition((ThreadsDefinition) v)); + case "ThrottleDefinition" -> wrapNode("throttle", doWriteThrottleDefinition((ThrottleDefinition) v)); + case "ThrowExceptionDefinition" -> wrapNode("throwException", doWriteThrowExceptionDefinition((ThrowExceptionDefinition) v)); + case "ToDefinition" -> wrapNode("to", doWriteToDefinition((ToDefinition) v)); + case "ToDynamicDefinition" -> wrapNode("toD", doWriteToDynamicDefinition((ToDynamicDefinition) v)); + case "TokenizerDefinition" -> wrapNode("tokenizer", doWriteTokenizerDefinition((TokenizerDefinition) v)); + case "TransactedDefinition" -> wrapNode("transacted", doWriteTransactedDefinition((TransactedDefinition) v)); + case "TransformDataTypeDefinition" -> wrapNode("transformDataType", doWriteTransformDataTypeDefinition((TransformDataTypeDefinition) v)); + case "TransformDefinition" -> wrapNode("transform", doWriteTransformDefinition((TransformDefinition) v)); + case "TryDefinition" -> wrapNode("doTry", doWriteTryDefinition((TryDefinition) v)); + case "UnmarshalDefinition" -> wrapNode("unmarshal", doWriteUnmarshalDefinition((UnmarshalDefinition) v)); + case "ValidateDefinition" -> wrapNode("validate", doWriteValidateDefinition((ValidateDefinition) v)); + case "WireTapDefinition" -> wrapNode("wireTap", doWriteWireTapDefinition((WireTapDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteRouteConfigurationDefinitionRef(RouteConfigurationDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "RouteConfigurationDefinition" -> wrapNode("routeConfiguration", doWriteRouteConfigurationDefinition((RouteConfigurationDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteRouteDefinitionRef(RouteDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "RouteDefinition" -> wrapNode("route", doWriteRouteDefinition((RouteDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteRouteTemplateDefinitionRef(RouteTemplateDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "RouteTemplateDefinition" -> wrapNode("routeTemplate", doWriteRouteTemplateDefinition((RouteTemplateDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteSetHeaderDefinitionRef(SetHeaderDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "SetHeaderDefinition" -> wrapNode("setHeader", doWriteSetHeaderDefinition((SetHeaderDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteSetVariableDefinitionRef(SetVariableDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "SetVariableDefinition" -> wrapNode("setVariable", doWriteSetVariableDefinition((SetVariableDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteTemplatedRouteDefinitionRef(TemplatedRouteDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "TemplatedRouteDefinition" -> wrapNode("templatedRoute", doWriteTemplatedRouteDefinition((TemplatedRouteDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteWhenDefinitionRef(WhenDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "WhenDefinition" -> wrapNode("when", doWriteWhenDefinition((WhenDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteUniVocityHeaderRef(UniVocityHeader v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "UniVocityHeader" -> wrapNode("univocityHeader", doWriteUniVocityHeader((UniVocityHeader) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteExpressionDefinitionRef(ExpressionDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "CSimpleExpression" -> wrapNode("csimple", doWriteCSimpleExpression((CSimpleExpression) v)); + case "ConstantExpression" -> wrapNode("constant", doWriteConstantExpression((ConstantExpression) v)); + case "DatasonnetExpression" -> wrapNode("datasonnet", doWriteDatasonnetExpression((DatasonnetExpression) v)); + case "ExchangePropertyExpression" -> wrapNode("exchangeProperty", doWriteExchangePropertyExpression((ExchangePropertyExpression) v)); + case "ExpressionDefinition" -> wrapNode("expressionDefinition", doWriteExpressionDefinition((ExpressionDefinition) v)); + case "GroovyExpression" -> wrapNode("groovy", doWriteGroovyExpression((GroovyExpression) v)); + case "HeaderExpression" -> wrapNode("header", doWriteHeaderExpression((HeaderExpression) v)); + case "Hl7TerserExpression" -> wrapNode("hl7terser", doWriteHl7TerserExpression((Hl7TerserExpression) v)); + case "JavaExpression" -> wrapNode("java", doWriteJavaExpression((JavaExpression) v)); + case "JavaScriptExpression" -> wrapNode("js", doWriteJavaScriptExpression((JavaScriptExpression) v)); + case "JoorExpression" -> wrapNode("joor", doWriteJoorExpression((JoorExpression) v)); + case "JqExpression" -> wrapNode("jq", doWriteJqExpression((JqExpression) v)); + case "JsonPathExpression" -> wrapNode("jsonpath", doWriteJsonPathExpression((JsonPathExpression) v)); + case "LanguageExpression" -> wrapNode("language", doWriteLanguageExpression((LanguageExpression) v)); + case "MethodCallExpression" -> wrapNode("method", doWriteMethodCallExpression((MethodCallExpression) v)); + case "MvelExpression" -> wrapNode("mvel", doWriteMvelExpression((MvelExpression) v)); + case "OgnlExpression" -> wrapNode("ognl", doWriteOgnlExpression((OgnlExpression) v)); + case "PythonExpression" -> wrapNode("python", doWritePythonExpression((PythonExpression) v)); + case "RefExpression" -> wrapNode("ref", doWriteRefExpression((RefExpression) v)); + case "SimpleExpression" -> wrapNode("simple", doWriteSimpleExpression((SimpleExpression) v)); + case "SpELExpression" -> wrapNode("spel", doWriteSpELExpression((SpELExpression) v)); + case "TokenizerExpression" -> wrapNode("tokenize", doWriteTokenizerExpression((TokenizerExpression) v)); + case "VariableExpression" -> wrapNode("variable", doWriteVariableExpression((VariableExpression) v)); + case "WasmExpression" -> wrapNode("wasm", doWriteWasmExpression((WasmExpression) v)); + case "XMLTokenizerExpression" -> wrapNode("xtokenize", doWriteXMLTokenizerExpression((XMLTokenizerExpression) v)); + case "XPathExpression" -> wrapNode("xpath", doWriteXPathExpression((XPathExpression) v)); + case "XQueryExpression" -> wrapNode("xquery", doWriteXQueryExpression((XQueryExpression) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteParamDefinitionRef(ParamDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "ParamDefinition" -> wrapNode("param", doWriteParamDefinition((ParamDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteResponseMessageDefinitionRef(ResponseMessageDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "ResponseMessageDefinition" -> wrapNode("responseMessage", doWriteResponseMessageDefinition((ResponseMessageDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteRestDefinitionRef(RestDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "RestDefinition" -> wrapNode("rest", doWriteRestDefinition((RestDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteSecurityDefinitionRef(SecurityDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "SecurityDefinition" -> wrapNode("security", doWriteSecurityDefinition((SecurityDefinition) v)); + default -> null; + }; + } + return null; + } + protected JsonObject doWriteVerbDefinitionRef(VerbDefinition v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + case "DeleteDefinition" -> wrapNode("delete", doWriteDeleteDefinition((DeleteDefinition) v)); + case "GetDefinition" -> wrapNode("get", doWriteGetDefinition((GetDefinition) v)); + case "HeadDefinition" -> wrapNode("head", doWriteHeadDefinition((HeadDefinition) v)); + case "PatchDefinition" -> wrapNode("patch", doWritePatchDefinition((PatchDefinition) v)); + case "PostDefinition" -> wrapNode("post", doWritePostDefinition((PostDefinition) v)); + case "PutDefinition" -> wrapNode("put", doWritePutDefinition((PutDefinition) v)); + default -> null; + }; + } + return null; + } +} diff --git a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/LwModelToYAMLDumper.java b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/LwModelToYAMLDumper.java index cb58001322c69..21d0ac6830fd7 100644 --- a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/LwModelToYAMLDumper.java +++ b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/LwModelToYAMLDumper.java @@ -16,7 +16,6 @@ */ package org.apache.camel.yaml; -import java.io.IOException; import java.io.StringWriter; import java.util.ArrayList; import java.util.Collection; @@ -37,6 +36,8 @@ import org.apache.camel.model.ExpressionNode; import org.apache.camel.model.FromDefinition; import org.apache.camel.model.OptionalIdentifiedDefinition; +import org.apache.camel.model.RouteConfigurationDefinition; +import org.apache.camel.model.RouteConfigurationsDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.RouteTemplateDefinition; import org.apache.camel.model.RouteTemplatesDefinition; @@ -45,16 +46,19 @@ import org.apache.camel.model.ToDynamicDefinition; import org.apache.camel.model.dataformat.DataFormatsDefinition; import org.apache.camel.model.language.ExpressionDefinition; +import org.apache.camel.model.rest.RestDefinition; +import org.apache.camel.model.rest.RestsDefinition; import org.apache.camel.spi.ModelToYAMLDumper; import org.apache.camel.spi.NamespaceAware; import org.apache.camel.spi.annotations.JdkService; import org.apache.camel.util.KeyValueHolder; -import org.apache.camel.yaml.out.ModelWriter; +import org.apache.camel.util.json.JsonObject; +import org.apache.camel.yaml.out.YamlModelWriter; import static org.apache.camel.model.ProcessorDefinitionHelper.filterTypeInOutputs; /** - * Lightweight {@link org.apache.camel.spi.ModelToYAMLDumper} based on the generated {@link ModelWriter}. + * Lightweight {@link org.apache.camel.spi.ModelToYAMLDumper} based on the generated {@link YamlModelWriter}. */ @JdkService(ModelToYAMLDumper.FACTORY) public class LwModelToYAMLDumper implements ModelToYAMLDumper { @@ -86,48 +90,53 @@ public String dumpModelAsYaml( } }; - StringWriter buffer = new StringWriter(); - ModelWriter writer = new ModelWriter(buffer) { - @Override - protected void doWriteOptionalIdentifiedDefinitionAttributes(OptionalIdentifiedDefinition def) - throws IOException { + // gather all namespaces from the routes or route which is stored on the expression nodes + if (definition instanceof RouteTemplatesDefinition templates) { + templates.getRouteTemplates().forEach(template -> extractor.accept(template.getRoute())); + } else if (definition instanceof RouteTemplateDefinition template) { + extractor.accept(template.getRoute()); + } else if (definition instanceof RoutesDefinition routes) { + routes.getRoutes().forEach(extractor); + } else if (definition instanceof RouteDefinition route) { + extractor.accept(route); + } + YamlModelWriter writer = new YamlModelWriter() { + @Override + protected void doWriteOptionalIdentifiedDefinitionAttributes( + JsonObject jo, OptionalIdentifiedDefinition def) { if (generatedIds || Boolean.TRUE.equals(def.getCustomId())) { - // write id - doWriteAttribute("id", def.getId()); + doWriteAttribute(jo, "id", def.getId(), null); } - // write location information + doWriteAttribute(jo, "description", def.getDescription(), null); if (sourceLocation || context.isDebugging()) { String loc = (def instanceof RouteDefinition rd1 ? rd1.getInput() : def).getLocation(); int line = (def instanceof RouteDefinition rd2 ? rd2.getInput() : def).getLineNumber(); if (line != -1) { - writer.addAttribute("sourceLineNumber", Integer.toString(line)); - writer.addAttribute("sourceLocation", loc); + doWriteAttribute(jo, "sourceLineNumber", Integer.toString(line), null); + doWriteAttribute(jo, "sourceLocation", loc, null); } } } @Override - protected void doWriteValue(String value) throws IOException { - if (value != null && !value.isEmpty()) { - super.doWriteValue(value); + protected void doWriteAttribute(JsonObject jo, String key, String value, String defaultValue) { + if (resolvePlaceholders && value != null) { + value = resolve(value, properties); } - } - - @Override - protected void text(String name, String text) throws IOException { - if (resolvePlaceholders) { - text = resolve(text, properties); + if ("uri".equals(key) && uriAsParameters) { + expandUri(jo, value); + return; } - super.text(name, text); + super.doWriteAttribute(jo, key, value, defaultValue); } @Override - protected void attribute(String name, Object value) throws IOException { + protected void doWriteValue(JsonObject jo, String value) { if (resolvePlaceholders && value != null) { - value = resolve(value.toString(), properties); + value = resolve(value, properties); } - super.attribute(name, value); + super.doWriteValue(jo, value); } String resolve(String value, Properties properties) { @@ -137,33 +146,46 @@ String resolve(String value, Properties properties) { } catch (Exception e) { return value; } finally { - // clear local after the route is dumped context.getPropertiesComponent().setLocalProperties(null); } } }; - - // gather all namespaces from the routes or route which is stored on the expression nodes - if (definition instanceof RouteTemplatesDefinition templates) { - templates.getRouteTemplates().forEach(template -> extractor.accept(template.getRoute())); - } else if (definition instanceof RouteTemplateDefinition template) { - extractor.accept(template.getRoute()); - } else if (definition instanceof RoutesDefinition routes) { - routes.getRoutes().forEach(extractor); - } else if (definition instanceof RouteDefinition route) { - extractor.accept(route); - } - writer.setUriAsParameters(uriAsParameters); writer.setCamelContext(context); - writer.start(); - try { - writer.writeOptionalIdentifiedDefinitionRef((OptionalIdentifiedDefinition) definition); - } finally { - writer.stop(); + + List roots = new ArrayList<>(); + if (definition instanceof RoutesDefinition rd) { + for (RouteDefinition route : rd.getRoutes()) { + roots.add(writer.writeRouteDefinition(route)); + } + } else if (definition instanceof RouteDefinition route) { + roots.add(writer.writeRouteDefinition(route)); + } else if (definition instanceof RouteTemplatesDefinition rtd) { + for (RouteTemplateDefinition template : rtd.getRouteTemplates()) { + roots.add(writer.writeRouteTemplateDefinition(template)); + } + } else if (definition instanceof RouteTemplateDefinition template) { + roots.add(writer.writeRouteTemplateDefinition(template)); + } else if (definition instanceof RestsDefinition rd) { + for (RestDefinition rest : rd.getRests()) { + roots.add(writer.writeRestDefinition(rest)); + } + } else if (definition instanceof RestDefinition rest) { + roots.add(writer.writeRestDefinition(rest)); + } else if (definition instanceof RouteConfigurationsDefinition rcd) { + for (RouteConfigurationDefinition config : rcd.getRouteConfigurations()) { + roots.add(writer.writeRouteConfigurationDefinition(config)); + } + } else if (definition instanceof RouteConfigurationDefinition config) { + roots.add(writer.writeRouteConfigurationDefinition(config)); + } else { + JsonObject jo = writer.writeOptionalIdentifiedDefinitionRef((OptionalIdentifiedDefinition) definition); + if (jo != null) { + roots.add(jo); + } } - return buffer.toString(); + return writer.printAsYaml(roots); } @Override @@ -421,7 +443,7 @@ public void stop() { // noop } - public void writeDataFormats(Map dataFormats) throws Exception { + public void writeDataFormats(Map dataFormats) { if (dataFormats.isEmpty()) { return; } @@ -431,16 +453,13 @@ public void writeDataFormats(Map dataFormats) thro DataFormatsDefinition def = new DataFormatsDefinition(); def.setDataFormats(new ArrayList<>(dataFormats.values())); - StringWriter tmp = new StringWriter(); - ModelWriter writer = new ModelWriter(tmp); + YamlModelWriter writer = new YamlModelWriter(); writer.setCamelContext(camelContext); - writer.start(); - try { - writer.writeDataFormatsDefinition(def); - } finally { - writer.stop(); - } - for (String line : tmp.toString().split("\n")) { + JsonObject jo = writer.writeDataFormatsDefinition(def); + List roots = new ArrayList<>(); + roots.add(jo); + String yaml = writer.printAsYaml(roots); + for (String line : yaml.split("\n")) { buffer.write(" "); buffer.write(line); buffer.write("\n"); diff --git a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/YamlModelWriterSupport.java b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/YamlModelWriterSupport.java new file mode 100644 index 0000000000000..aef2fd430c521 --- /dev/null +++ b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/YamlModelWriterSupport.java @@ -0,0 +1,235 @@ +/* + * 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.yaml.out; + +import java.util.Base64; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +import org.apache.camel.CamelContext; +import org.apache.camel.catalog.RuntimeCamelCatalog; +import org.apache.camel.util.URISupport; +import org.apache.camel.util.json.JsonArray; +import org.apache.camel.util.json.JsonObject; +import org.apache.camel.yaml.io.YamlPrinter; + +/** + * Base class for the generated {@link YamlModelWriter}. Provides helper methods for building {@link JsonObject} + * structures from model definitions. + */ +public abstract class YamlModelWriterSupport { + + protected boolean uriAsParameters; + protected CamelContext camelContext; + + public void setUriAsParameters(boolean uriAsParameters) { + this.uriAsParameters = uriAsParameters; + } + + public CamelContext getCamelContext() { + return camelContext; + } + + public void setCamelContext(CamelContext camelContext) { + this.camelContext = camelContext; + } + + protected void doWriteAttribute(JsonObject jo, String key, String value, String defaultValue) { + if (value != null && (defaultValue == null || !defaultValue.equals(value))) { + jo.put(key, parseValue(value)); + } + } + + protected void doWriteValue(JsonObject jo, String value) { + if (value != null && !value.isEmpty()) { + jo.put("expression", value); + } + } + + protected void doWriteChildElement(JsonObject jo, String key, T value, Function writer) { + if (value != null) { + JsonObject child = writer.apply(value); + if (child != null && !child.isEmpty()) { + jo.put(key, child); + } + } + } + + protected void doWriteElementRef(JsonObject jo, T value, Function writer) { + if (value != null) { + JsonObject result = writer.apply(value); + if (result != null) { + jo.putAll(result); + } + } + } + + protected void doWriteElementRefList(JsonObject jo, String key, List list, Function writer) { + if (list != null && !list.isEmpty()) { + JsonArray arr = new JsonArray(); + for (T item : list) { + JsonObject result = writer.apply(item); + if (result != null) { + arr.add(result); + } + } + if (!arr.isEmpty()) { + if (key != null) { + jo.put(key, arr); + } + } + } + } + + protected void doWriteOutputs(JsonObject jo, List list, Function writer) { + doWriteElementRefList(jo, "steps", list, writer); + } + + @SuppressWarnings("unchecked") + protected void doWriteChildList( + JsonObject jo, String wrapperKey, String itemKey, List list, Function writer) { + if (list != null && !list.isEmpty()) { + JsonArray arr = new JsonArray(); + for (T item : list) { + if (item instanceof String s) { + arr.add(s); + } else { + JsonObject child = writer.apply(item); + if (child != null) { + arr.add(child); + } + } + } + if (!arr.isEmpty()) { + String key = wrapperKey != null ? wrapperKey : itemKey; + jo.put(key, arr); + } + } + } + + @SuppressWarnings("unchecked") + protected void doWriteStringList(JsonObject jo, String wrapperKey, String itemKey, List list) { + if (list != null && !list.isEmpty()) { + JsonArray arr = new JsonArray(); + for (String s : list) { + if (s != null) { + arr.add(s); + } + } + if (!arr.isEmpty()) { + String key = wrapperKey != null ? wrapperKey : itemKey; + jo.put(key, arr); + } + } + } + + protected JsonObject wrapNode(String key, JsonObject value) { + JsonObject wrapper = new JsonObject(); + if (value != null) { + wrapper.put(key, value); + } + return wrapper; + } + + protected void expandUri(JsonObject jo, String uri) { + if (uri == null) { + return; + } + if (!uriAsParameters) { + jo.put("uri", uri); + return; + } + try { + Map params = null; + RuntimeCamelCatalog catalog + = camelContext != null + ? camelContext.getCamelContextExtension().getContextPlugin(RuntimeCamelCatalog.class) + : null; + if (catalog != null) { + params = catalog.endpointProperties(uri); + } + if (params == null || params.isEmpty()) { + Map raw = URISupport.parseQuery(URISupport.extractQuery(uri)); + params = new LinkedHashMap<>(); + for (Map.Entry e : raw.entrySet()) { + params.put(e.getKey(), e.getValue().toString()); + } + String base = URISupport.stripQuery(uri); + jo.put("uri", base); + } else { + String scheme = uri; + int idx = scheme.indexOf(':'); + if (idx != -1) { + scheme = scheme.substring(0, idx); + } + jo.put("uri", scheme); + } + if (params != null && !params.isEmpty()) { + JsonObject p = new JsonObject(); + params.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .forEach(e -> p.put(e.getKey(), parseValue(e.getValue()))); + jo.put("parameters", p); + } + } catch (Exception e) { + jo.put("uri", uri); + } + } + + protected Object parseValue(String value) { + if (value == null) { + return null; + } + if ("true".equals(value) || "false".equals(value)) { + return Boolean.parseBoolean(value); + } + try { + return Long.parseLong(value); + } catch (NumberFormatException e) { + // not a long + } + try { + return Double.parseDouble(value); + } catch (NumberFormatException e) { + // not a double + } + return value; + } + + public String printAsYaml(Collection roots) { + return YamlPrinter.print(roots); + } + + protected String toString(Boolean b) { + return b != null ? b.toString() : null; + } + + protected String toString(Enum e) { + return e != null ? e.name() : null; + } + + protected String toString(Number n) { + return n != null ? n.toString() : null; + } + + protected String toString(byte[] b) { + return b != null ? Base64.getEncoder().encodeToString(b) : null; + } +} diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelWriterGeneratorMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelWriterGeneratorMojo.java index 276208ad04618..dea58527d59d0 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelWriterGeneratorMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ModelWriterGeneratorMojo.java @@ -112,6 +112,10 @@ String getModelPackage() { abstract String getWriterPackage(); + protected String getTemplateName() { + return "velocity/model-writer.vm"; + } + protected String generateWriter() throws MojoExecutionException { try (DynamicClassLoader classLoader = DynamicClassLoader.createDynamicClassLoader(project.getCompileClasspathElements())) { @@ -170,7 +174,7 @@ private String doGenerateWriter(ClassLoader classLoader) throws MojoExecutionExc ctx.put("package", getWriterPackage()); ctx.put("model", model); ctx.put("mojo", this); - return velocity("velocity/model-writer.vm", ctx); + return velocity(getTemplateName(), ctx); } protected String postGenerateWriter(String writer) { diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlDirectModelWriterGeneratorMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlDirectModelWriterGeneratorMojo.java new file mode 100644 index 0000000000000..1aaac0a355565 --- /dev/null +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlDirectModelWriterGeneratorMojo.java @@ -0,0 +1,79 @@ +/* + * 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.maven.packaging; + +import java.io.File; +import java.nio.file.Path; + +import javax.inject.Inject; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectHelper; +import org.codehaus.plexus.build.BuildContext; + +/** + * Generate direct YAML Model Writer that builds JsonObject/JsonArray structures for YAML serialization without Jackson. + */ +@Mojo(name = "generate-yaml-direct-writer", threadSafe = true, + requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, + defaultPhase = LifecyclePhase.PROCESS_CLASSES) +public class YamlDirectModelWriterGeneratorMojo extends ModelWriterGeneratorMojo { + + public static final String WRITER_PACKAGE = "org.apache.camel.yaml.out"; + + @Parameter(defaultValue = "${camel-generate-yaml-direct-writer}") + protected boolean generateYamlDirectWriter; + + @Inject + public YamlDirectModelWriterGeneratorMojo(MavenProjectHelper projectHelper, BuildContext buildContext) { + super(projectHelper, buildContext); + } + + @Override + public void execute(MavenProject project) throws MojoFailureException, MojoExecutionException { + sourcesOutputDir = new File(project.getBasedir(), "src/generated/java"); + generateYamlDirectWriter + = Boolean.parseBoolean(project.getProperties().getProperty("camel-generate-yaml-direct-writer", "false")); + super.execute(project); + } + + @Override + public void execute() throws MojoExecutionException { + if (!generateYamlDirectWriter) { + return; + } + Path javaDir = sourcesOutputDir.toPath(); + String writer = generateWriter(); + updateResource(javaDir, (getWriterPackage() + ".YamlModelWriter").replace('.', '/') + ".java", writer); + } + + @Override + String getWriterPackage() { + return WRITER_PACKAGE; + } + + @Override + protected String getTemplateName() { + return "velocity/model-yaml-writer.vm"; + } +} diff --git a/tooling/maven/camel-package-maven-plugin/src/main/resources/velocity/model-yaml-writer.vm b/tooling/maven/camel-package-maven-plugin/src/main/resources/velocity/model-yaml-writer.vm new file mode 100644 index 0000000000000..5fa1a2ce8f700 --- /dev/null +++ b/tooling/maven/camel-package-maven-plugin/src/main/resources/velocity/model-yaml-writer.vm @@ -0,0 +1,298 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +#set( $default = "#[[##default]]#" ) +/* + * 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. + */ + +/** + * Generated by camel build tools - do NOT edit this file! + */ +package ${package}; + +import java.util.ArrayList; +import java.util.Base64; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import javax.annotation.processing.Generated; + +import org.apache.camel.util.json.JsonArray; +import org.apache.camel.util.json.JsonObject; + +#set( $pkgs = $mojo.newTreeSet() ) +#set( $mojoClassName = $mojo.getClass().getName() ) +#foreach( $clazz in $model ) + #set( $foo = $pkgs.add($clazz.getPackageName()) ) +#end +#foreach( $pkg in $pkgs ) +#if( $pkg != "java.lang" && $pkg != "org.apache.camel" ) +import ${pkg}.*; +#end +#end + +@Generated("${mojoClassName}") +@SuppressWarnings({"deprecation","rawtypes"}) +public class YamlModelWriter extends YamlModelWriterSupport { + +## ---- Public write methods for root elements ---- +#foreach( $clazz in $model ) + #if( $mojo.getXmlRootElement( $clazz ) ) + #set( $name = ${clazz.getSimpleName()} ) + #set( $element = $mojo.getXmlRootElement($clazz).name() ) + public JsonObject write${name}(${name} def) { + return wrapNode("${element}", doWrite${name}(def)); + } + #end +#end + + public JsonObject writeOptionalIdentifiedDefinitionRef(OptionalIdentifiedDefinition def) { + return doWriteOptionalIdentifiedDefinitionRef(def); + } + +## ---- Per-class doWrite methods ---- +#set( $elementRefs = $mojo.newClassTreeSet() ) +#foreach( $clazz in $model ) + #if( $clazz.simpleName == "OptionalIdentifiedDefinition" ) + #set( $foo = $elementRefs.add($clazz) ) + #end + #if( !$mojo.getXmlEnum($clazz) && !$clazz.isInterface() ) + #set( $hasDerived = false ) + #foreach( $c in $model ) + #if( $c.getSuperclass() == $clazz ) + #set( $hasDerived = true ) + #break + #end + #end + #set( $name = $clazz.simpleName ) + #set( $gname = $mojo.getGenericSimpleName($clazz) ) + #set( $members = $mojo.getProperties($clazz).toList() ) + #set( $thisAttributes = $mojo.getAttributes($clazz).toList() ) + #set( $superWithAttributes = false ) + #foreach( $cl in $mojo.getClassAndSuper($clazz.getSuperclass()).toList() ) + #if( $mojo.getAttributes($cl).findAny().isPresent() ) + #set( $superWithAttributes = $cl ) + #break + #end + #end + #set( $thisElements = $mojo.getElements($clazz).toList() ) + #set( $superWithElements = false ) + #foreach( $cl in $mojo.getClassAndSuper($clazz.getSuperclass()).toList() ) + #if( $mojo.getElements($cl).findAny().isPresent() ) + #set( $superWithElements = $cl ) + #break + #end + #end + #if( !$thisAttributes.isEmpty() || !$thisElements.isEmpty() || $mojo.getXmlRootElement($clazz) || $mojo.isReferenced($clazz, $model) ) +## ---- Macro: write attributes into JsonObject ---- + #macro( writeYamlAttrs ) + #if( $superWithAttributes ) + doWrite${superWithAttributes.getSimpleName()}Attributes(jo, def); + #end + #foreach( $member in $thisAttributes ) + #if( $member.type.getName() == "java.lang.String" ) + doWriteAttribute(jo, "${member.attributeName}", def.${member.getter}(), ${member.defaultValue}); + #else + doWriteAttribute(jo, "${member.attributeName}", toString(def.${member.getter}()), ${member.defaultValue}); + #end + #end + #end +## ---- Macro: write elements into JsonObject ---- + #macro( writeYamlElems ) + #if( $superWithElements ) + doWrite${superWithElements.getSimpleName()}Elements(jo, def); + #end + #foreach( $member in $thisElements ) + #set( $list = $member.genericType.rawClass.name == "java.util.List" ) + #if( $list ) + #set( $root = $member.genericType.getActualTypeArgument(0).rawClass ) + #else + #set( $root = $member.genericType.rawClass ) + #end + #if( $member.xmlElementRefs ) + // TODO: @XmlElementRefs: ${member} + #elseif( $member.xmlElementRef ) + #set( $foo = $elementRefs.add($root) ) + #if( $list ) + #if( $member.name == "outputs" ) + doWriteOutputs(jo, def.${member.getter}(), this::doWrite${root.simpleName}Ref); + #else + doWriteElementRefList(jo, null, def.${member.getter}(), this::doWrite${root.simpleName}Ref); + #end + #else + doWriteElementRef(jo, def.${member.getter}(), this::doWrite${root.simpleName}Ref); + #end + #elseif( $member.xmlElements ) + #if( $list ) + if (def.${member.getter}() != null) { + for (var item : def.${member.getter}()) { + switch (item.getClass().getSimpleName()) { + #foreach( $elem in $member.xmlElements.value() ) + #set( $t = $elem.type().simpleName ) + case "${t}" -> doWriteChildElement(jo, "${elem.name()}", (${t}) item, this::doWrite${t}); + #end + } + } + } + #else + if (def.${member.getter}() != null) { + switch (def.${member.getter}().getClass().getSimpleName()) { + #foreach( $elem in $member.xmlElements.value() ) + #set( $t = $elem.type().simpleName ) + case "${t}" -> doWriteChildElement(jo, "${elem.name()}", (${t}) def.${member.getter}(), this::doWrite${t}); + #end + } + } + #end + #elseif( $member.xmlElement ) + #set( $t = $root.simpleName ) + #set( $n = $member.xmlElement.name() ) + #if( $n == $default ) + #set( $n = ${member.name} ) + #end + #if( $list ) + #set( $w = false ) + #if( $member.xmlElementWrapper ) + #set( $w = $member.xmlElementWrapper.name() ) + #end + #if( $t == "String" ) + doWriteStringList(jo, #if($w)"${w}"#{else}null#end, "${n}", def.${member.getter}()); + #else + doWriteChildList(jo, #if($w)"${w}"#{else}null#end, "${n}", def.${member.getter}(), this::doWrite${t}); + #end + #else + #set( $adapter = $member.xmlJavaTypeAdapter ) + #if( $adapter ) + #set( $cl = $adapter.value() ) + #set( $actualType = false ) + #foreach( $m in $cl.declaredMethods ) + #if( $m.name == "marshal" && $m.returnType.simpleName != "Object" ) + #set( $actualType = $m.returnType ) + #break + #end + #end + #if( !$actualType ) + ERROR: Unable to determine property name for JAXB adapted member: ${member} + #end + doWriteChildElement(jo, "${n}", new ${cl.simpleName}().marshal(def.${member.getter}()), this::doWrite${actualType.simpleName}); + #else + #if( $t == "String" ) + if (def.${member.getter}() != null) { + jo.put("${n}", def.${member.getter}()); + } + #else + doWriteChildElement(jo, "${n}", def.${member.getter}(), this::doWrite${t}); + #end + #end + #end + #elseif( $member.xmlAnyElement ) + // @XmlAnyElement - not applicable for YAML + #else + #set( $t = $root.simpleName ) + #set( $n = $member.xmlRootElement.name() ) + #if( $n == $default ) + #set( $n = ${member.name} ) + #end + #if( $list ) + #if( $t == "String" ) + doWriteStringList(jo, null, "${n}", def.${member.getter}()); + #else + doWriteChildList(jo, null, "${n}", def.${member.getter}(), this::doWrite${t}); + #end + #else + #if( $t == "String" ) + if (def.${member.getter}() != null) { + jo.put("${n}", def.${member.getter}()); + } + #else + doWriteChildElement(jo, "${n}", def.${member.getter}(), this::doWrite${t}); + #end + #end + #end + #end + #end +## ---- Generate Attributes method (if class has derived classes) ---- + #if( $hasDerived && !$thisAttributes.isEmpty() ) + protected void doWrite${name}Attributes(JsonObject jo, ${gname} def) { + #writeYamlAttrs + } + #end +## ---- Generate Elements method (if class has derived classes) ---- + #if( $hasDerived && !$thisElements.isEmpty() ) + protected void doWrite${name}Elements(JsonObject jo, ${gname} def) { + #writeYamlElems + } + #end +## ---- Generate main doWrite method ---- + protected JsonObject doWrite${name}(${gname} def) { + JsonObject jo = new JsonObject(); + #if( $hasDerived && !$thisAttributes.isEmpty() ) + doWrite${name}Attributes(jo, def); + #else + #writeYamlAttrs + #end + #set( $value = $mojo.getValues($mojo.getClassAndSuper($clazz)).findFirst() ) + #if( $value.isPresent() ) + doWriteValue(jo, def.${value.get().getter}()); + #end + #if( $hasDerived && !$thisElements.isEmpty() ) + doWrite${name}Elements(jo, def); + #else + #writeYamlElems + #end + return jo; + } + #end + #end +#end + +## ---- Polymorphic dispatch methods ---- +#foreach( $clazz in $elementRefs ) + #set( $qname = $clazz.simpleName ) + protected JsonObject doWrite${qname}Ref(${qname} v) { + if (v != null) { + return switch (v.getClass().getSimpleName()) { + #foreach( $cl in $model ) + #if( $mojo.getXmlRootElement($cl) && $mojo.getClassAndSuper($cl).toList().contains($clazz) ) + #set( $t = $cl.simpleName ) + #set( $n = $mojo.getXmlRootElement($cl).name() ) + #if( $n == $default ) + #set( $n = $mojo.lowercase($t) ) + #end + case "${t}" -> wrapNode("${n}", doWrite${t}((${t}) v)); + #end + #end + default -> null; + }; + } + return null; + } +#end +} From 1bec44b370085ea7bbbc467bed5008fa21bc5266 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Thu, 21 May 2026 11:39:14 +0200 Subject: [PATCH 3/9] CAMEL-23596: camel-yaml-io - Fix structural issues and add YamlModelWriter tests Fix three structural issues in generated YamlModelWriter: - Move steps from route level into from child (doMoveStepsUnderFrom) - Add expression wrapper key for ExpressionNode refs (doWriteExpressionRef) - Quote YAML strings containing ${ and {{ sequences - Preserve empty child elements like csv: {} for data format type info - Use doWriteChildList for non-outputs @XmlElementRef lists (choice when) - Remove alphabetical sorting in expandUri to match catalog parameter order Add 24 YamlModelWriter tests covering: simple route, two routes, choice, transform, marshal/unmarshal, multicast, wireTap, split, circuitBreaker, routeConfiguration, routeTemplate, REST DSL, filter, loadBalance (round-robin and failover), dynamicRouter, routingSlip, recipientList, enrich/pollEnrich, delay, throttle, validate, idempotentConsumer, and onCompletion. Co-Authored-By: Claude Opus 4.6 --- .../camel/yaml/out/YamlModelWriter.java | 39 +- .../org/apache/camel/yaml/io/YamlPrinter.java | 6 + .../yaml/out/YamlModelWriterSupport.java | 25 +- .../camel/yaml/out/YamlModelWriterTest.java | 590 ++++++++++++++++++ .../src/test/resources/yaml-rest.yaml | 27 + .../src/test/resources/yaml-route-choice.yaml | 43 ++ .../resources/yaml-route-circuitbreaker.yaml | 32 + .../src/test/resources/yaml-route-delay.yaml | 29 + .../resources/yaml-route-dynamic-router.yaml | 28 + .../src/test/resources/yaml-route-enrich.yaml | 35 ++ .../src/test/resources/yaml-route-filter.yaml | 32 + .../test/resources/yaml-route-idempotent.yaml | 31 + .../yaml-route-loadbalance-failover.yaml | 32 + .../resources/yaml-route-loadbalance.yaml | 30 + .../test/resources/yaml-route-marshal.yaml | 29 + .../test/resources/yaml-route-multicast.yaml | 31 + .../resources/yaml-route-oncompletion.yaml | 32 + .../resources/yaml-route-recipient-list.yaml | 28 + .../resources/yaml-route-routing-slip.yaml | 29 + .../src/test/resources/yaml-route-simple.yaml | 27 + .../src/test/resources/yaml-route-split.yaml | 33 + .../test/resources/yaml-route-template.yaml | 32 + .../test/resources/yaml-route-throttle.yaml | 32 + .../test/resources/yaml-route-transform.yaml | 29 + .../src/test/resources/yaml-route-two.yaml | 35 ++ .../test/resources/yaml-route-validate.yaml | 29 + .../test/resources/yaml-route-wiretap.yaml | 27 + .../src/test/resources/yaml-routeconfig.yaml | 33 + .../resources/velocity/model-yaml-writer.vm | 14 +- 29 files changed, 1395 insertions(+), 24 deletions(-) create mode 100644 core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java create mode 100644 core/camel-yaml-io/src/test/resources/yaml-rest.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-choice.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-circuitbreaker.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-delay.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-dynamic-router.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-enrich.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-filter.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-idempotent.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-loadbalance-failover.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-loadbalance.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-marshal.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-multicast.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-oncompletion.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-recipient-list.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-routing-slip.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-simple.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-split.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-template.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-throttle.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-transform.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-two.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-validate.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-wiretap.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-routeconfig.yaml diff --git a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java index 7c78c711d7ec0..4693789f75955 100644 --- a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java +++ b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java @@ -797,7 +797,7 @@ protected JsonObject doWriteAggregateDefinition(AggregateDefinition def) { return jo; } protected void doWriteBasicExpressionNodeElements(JsonObject jo, BasicExpressionNode def) { - doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + doWriteExpressionRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); } protected JsonObject doWriteBasicExpressionNode(BasicExpressionNode def) { JsonObject jo = new JsonObject(); @@ -855,7 +855,7 @@ protected JsonObject doWriteChoiceDefinition(ChoiceDefinition def) { JsonObject jo = new JsonObject(); doWriteProcessorDefinitionAttributes(jo, def); doWriteAttribute(jo, "precondition", def.getPrecondition(), "false"); - doWriteElementRefList(jo, null, def.getWhenClauses(), this::doWriteWhenDefinitionRef); + doWriteChildList(jo, "when", "when", def.getWhenClauses(), this::doWriteWhenDefinition); doWriteChildElement(jo, "otherwise", def.getOtherwise(), this::doWriteOtherwiseDefinition); return jo; } @@ -971,7 +971,7 @@ protected JsonObject doWriteErrorHandlerDefinition(ErrorHandlerDefinition def) { return jo; } protected void doWriteExpressionNodeElements(JsonObject jo, ExpressionNode def) { - doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + doWriteExpressionRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); } protected JsonObject doWriteExpressionNode(ExpressionNode def) { JsonObject jo = new JsonObject(); @@ -1260,7 +1260,7 @@ protected JsonObject doWriteOnFallbackDefinition(OnFallbackDefinition def) { protected JsonObject doWriteOnWhenDefinition(OnWhenDefinition def) { JsonObject jo = new JsonObject(); doWriteOptionalIdentifiedDefinitionAttributes(jo, def); - doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + doWriteExpressionRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); return jo; } protected JsonObject doWriteOptimisticLockRetryPolicyDefinition(OptimisticLockRetryPolicyDefinition def) { @@ -1387,7 +1387,7 @@ protected JsonObject doWritePropertyDefinitions(PropertyDefinitions def) { protected JsonObject doWritePropertyExpressionDefinition(PropertyExpressionDefinition def) { JsonObject jo = new JsonObject(); doWriteAttribute(jo, "key", def.getKey(), null); - doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + doWriteExpressionRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); return jo; } protected JsonObject doWriteRecipientListDefinition(RecipientListDefinition def) { @@ -1475,7 +1475,7 @@ protected JsonObject doWriteRemoveVariableDefinition(RemoveVariableDefinition de protected JsonObject doWriteResequenceDefinition(ResequenceDefinition def) { JsonObject jo = new JsonObject(); doWriteProcessorDefinitionAttributes(jo, def); - doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + doWriteExpressionRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); if (def.getResequencerConfig() != null) { switch (def.getResequencerConfig().getClass().getSimpleName()) { case "BatchResequencerConfig" -> doWriteChildElement(jo, "batchConfig", (BatchResequencerConfig) def.getResequencerConfig(), this::doWriteBatchResequencerConfig); @@ -1572,7 +1572,7 @@ protected JsonObject doWriteRouteConfigurationDefinition(RouteConfigurationDefin protected JsonObject doWriteRouteConfigurationsDefinition(RouteConfigurationsDefinition def) { JsonObject jo = new JsonObject(); doWriteOptionalIdentifiedDefinitionAttributes(jo, def); - doWriteElementRefList(jo, null, def.getRouteConfigurations(), this::doWriteRouteConfigurationDefinitionRef); + doWriteChildList(jo, "routeConfigurations", "routeConfigurations", def.getRouteConfigurations(), this::doWriteRouteConfigurationDefinition); return jo; } protected JsonObject doWriteRouteContextRefDefinition(RouteContextRefDefinition def) { @@ -1607,6 +1607,7 @@ protected JsonObject doWriteRouteDefinition(RouteDefinition def) { doWriteElementRef(jo, def.getInputType(), this::doWriteInputTypeDefinitionRef); doWriteElementRef(jo, def.getOutputType(), this::doWriteOutputTypeDefinitionRef); doWriteOutputs(jo, def.getOutputs(), this::doWriteProcessorDefinitionRef); + doMoveStepsUnderFrom(jo); return jo; } protected JsonObject doWriteRouteTemplateContextRefDefinition(RouteTemplateContextRefDefinition def) { @@ -1633,13 +1634,13 @@ protected JsonObject doWriteRouteTemplateParameterDefinition(RouteTemplateParame protected JsonObject doWriteRouteTemplatesDefinition(RouteTemplatesDefinition def) { JsonObject jo = new JsonObject(); doWriteOptionalIdentifiedDefinitionAttributes(jo, def); - doWriteElementRefList(jo, null, def.getRouteTemplates(), this::doWriteRouteTemplateDefinitionRef); + doWriteChildList(jo, "routeTemplates", "routeTemplates", def.getRouteTemplates(), this::doWriteRouteTemplateDefinition); return jo; } protected JsonObject doWriteRoutesDefinition(RoutesDefinition def) { JsonObject jo = new JsonObject(); doWriteOptionalIdentifiedDefinitionAttributes(jo, def); - doWriteElementRefList(jo, null, def.getRoutes(), this::doWriteRouteDefinitionRef); + doWriteChildList(jo, "routes", "routes", def.getRoutes(), this::doWriteRouteDefinition); return jo; } protected JsonObject doWriteRoutingSlipDefinition(RoutingSlipDefinition def) { @@ -1708,7 +1709,7 @@ protected JsonObject doWriteSetHeaderDefinition(SetHeaderDefinition def) { protected JsonObject doWriteSetHeadersDefinition(SetHeadersDefinition def) { JsonObject jo = new JsonObject(); doWriteProcessorDefinitionAttributes(jo, def); - doWriteElementRefList(jo, null, def.getHeaders(), this::doWriteSetHeaderDefinitionRef); + doWriteChildList(jo, "headers", "headers", def.getHeaders(), this::doWriteSetHeaderDefinition); return jo; } protected JsonObject doWriteSetPropertyDefinition(SetPropertyDefinition def) { @@ -1728,7 +1729,7 @@ protected JsonObject doWriteSetVariableDefinition(SetVariableDefinition def) { protected JsonObject doWriteSetVariablesDefinition(SetVariablesDefinition def) { JsonObject jo = new JsonObject(); doWriteProcessorDefinitionAttributes(jo, def); - doWriteElementRefList(jo, null, def.getVariables(), this::doWriteSetVariableDefinitionRef); + doWriteChildList(jo, "variables", "variables", def.getVariables(), this::doWriteSetVariableDefinition); return jo; } protected JsonObject doWriteSortDefinition(SortDefinition def) { @@ -1787,7 +1788,7 @@ protected JsonObject doWriteTemplatedRouteParameterDefinition(TemplatedRoutePara protected JsonObject doWriteTemplatedRoutesDefinition(TemplatedRoutesDefinition def) { JsonObject jo = new JsonObject(); doWriteOptionalIdentifiedDefinitionAttributes(jo, def); - doWriteElementRefList(jo, null, def.getTemplatedRoutes(), this::doWriteTemplatedRouteDefinitionRef); + doWriteChildList(jo, "templatedRoutes", "templatedRoutes", def.getTemplatedRoutes(), this::doWriteTemplatedRouteDefinition); return jo; } protected JsonObject doWriteThreadPoolProfileDefinition(ThreadPoolProfileDefinition def) { @@ -2665,7 +2666,7 @@ protected void doWriteUniVocityAbstractDataFormatAttributes(JsonObject jo, UniVo doWriteAttribute(jo, "numberOfRecordsToRead", def.getNumberOfRecordsToRead(), null); } protected void doWriteUniVocityAbstractDataFormatElements(JsonObject jo, UniVocityAbstractDataFormat def) { - doWriteElementRefList(jo, null, def.getHeaders(), this::doWriteUniVocityHeaderRef); + doWriteChildList(jo, "headers", "headers", def.getHeaders(), this::doWriteUniVocityHeader); } protected JsonObject doWriteUniVocityAbstractDataFormat(UniVocityAbstractDataFormat def) { JsonObject jo = new JsonObject(); @@ -3299,7 +3300,7 @@ protected JsonObject doWriteRestDefinition(RestDefinition def) { doWriteAttribute(jo, "enableNoContentResponse", def.getEnableNoContentResponse(), "false"); doWriteAttribute(jo, "apiDocs", def.getApiDocs(), "true"); doWriteAttribute(jo, "tag", def.getTag(), null); - doWriteElementRefList(jo, null, def.getVerbs(), this::doWriteVerbDefinitionRef); + doWriteChildList(jo, "verbs", "verbs", def.getVerbs(), this::doWriteVerbDefinition); doWriteChildElement(jo, "openApi", def.getOpenApi(), this::doWriteOpenApiDefinition); doWriteChildElement(jo, "securityDefinitions", def.getSecurityDefinitions(), this::doWriteRestSecuritiesDefinition); doWriteChildList(jo, null, "securityRequirements", def.getSecurityRequirements(), this::doWriteSecurityDefinition); @@ -3339,7 +3340,7 @@ protected JsonObject doWriteRestSecurityDefinition(RestSecurityDefinition def) { protected JsonObject doWriteRestsDefinition(RestsDefinition def) { JsonObject jo = new JsonObject(); doWriteOptionalIdentifiedDefinitionAttributes(jo, def); - doWriteElementRefList(jo, null, def.getRests(), this::doWriteRestDefinitionRef); + doWriteChildList(jo, "rests", "rests", def.getRests(), this::doWriteRestDefinition); return jo; } protected JsonObject doWriteSecurityDefinition(SecurityDefinition def) { @@ -3368,9 +3369,9 @@ protected void doWriteVerbDefinitionAttributes(JsonObject jo, VerbDefinition def doWriteAttribute(jo, "consumes", def.getConsumes(), null); } protected void doWriteVerbDefinitionElements(JsonObject jo, VerbDefinition def) { - doWriteElementRefList(jo, null, def.getParams(), this::doWriteParamDefinitionRef); - doWriteElementRefList(jo, null, def.getSecurity(), this::doWriteSecurityDefinitionRef); - doWriteElementRefList(jo, null, def.getResponseMsgs(), this::doWriteResponseMessageDefinitionRef); + doWriteChildList(jo, "params", "params", def.getParams(), this::doWriteParamDefinition); + doWriteChildList(jo, "security", "security", def.getSecurity(), this::doWriteSecurityDefinition); + doWriteChildList(jo, "responseMsgs", "responseMsgs", def.getResponseMsgs(), this::doWriteResponseMessageDefinition); doWriteChildElement(jo, "to", def.getTo(), this::doWriteToDefinition); } protected JsonObject doWriteVerbDefinition(VerbDefinition def) { @@ -3536,7 +3537,7 @@ protected JsonObject doWriteEndpointValidatorDefinition(EndpointValidatorDefinit protected JsonObject doWritePredicateValidatorDefinition(PredicateValidatorDefinition def) { JsonObject jo = new JsonObject(); doWriteValidatorDefinitionAttributes(jo, def); - doWriteElementRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); + doWriteExpressionRef(jo, def.getExpression(), this::doWriteExpressionDefinitionRef); return jo; } protected void doWriteValidatorDefinitionAttributes(JsonObject jo, ValidatorDefinition def) { diff --git a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlPrinter.java b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlPrinter.java index cfaf60b8c5af1..d573d031aaa3d 100644 --- a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlPrinter.java +++ b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlPrinter.java @@ -159,6 +159,12 @@ static boolean needsQuoting(String s) { if (c == '#' && i > 0 && s.charAt(i - 1) == ' ') { return true; } + if (c == '$' && i + 1 < s.length() && s.charAt(i + 1) == '{') { + return true; + } + if (c == '{' && i + 1 < s.length() && s.charAt(i + 1) == '{') { + return true; + } if (c == '\n') { return true; } diff --git a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/YamlModelWriterSupport.java b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/YamlModelWriterSupport.java index aef2fd430c521..3c024975df00c 100644 --- a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/YamlModelWriterSupport.java +++ b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/YamlModelWriterSupport.java @@ -66,12 +66,31 @@ protected void doWriteValue(JsonObject jo, String value) { protected void doWriteChildElement(JsonObject jo, String key, T value, Function writer) { if (value != null) { JsonObject child = writer.apply(value); - if (child != null && !child.isEmpty()) { + if (child != null) { jo.put(key, child); } } } + protected void doWriteExpressionRef(JsonObject jo, T value, Function writer) { + if (value != null) { + JsonObject result = writer.apply(value); + if (result != null && !result.isEmpty()) { + jo.put("expression", result); + } + } + } + + protected void doMoveStepsUnderFrom(JsonObject jo) { + Object steps = jo.remove("steps"); + if (steps != null) { + JsonObject from = (JsonObject) jo.get("from"); + if (from != null) { + from.put("steps", steps); + } + } + } + protected void doWriteElementRef(JsonObject jo, T value, Function writer) { if (value != null) { JsonObject result = writer.apply(value); @@ -183,9 +202,7 @@ protected void expandUri(JsonObject jo, String uri) { } if (params != null && !params.isEmpty()) { JsonObject p = new JsonObject(); - params.entrySet().stream() - .sorted(Map.Entry.comparingByKey()) - .forEach(e -> p.put(e.getKey(), parseValue(e.getValue()))); + params.forEach((k, v) -> p.put(k, parseValue(v))); jo.put("parameters", p); } } catch (Exception e) { diff --git a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java new file mode 100644 index 0000000000000..8cba2733f67fc --- /dev/null +++ b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java @@ -0,0 +1,590 @@ +/* + * 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.yaml.out; + +import java.nio.file.Paths; +import java.util.List; + +import org.apache.camel.model.ChoiceDefinition; +import org.apache.camel.model.CircuitBreakerDefinition; +import org.apache.camel.model.DelayDefinition; +import org.apache.camel.model.DynamicRouterDefinition; +import org.apache.camel.model.EnrichDefinition; +import org.apache.camel.model.ExpressionSubElementDefinition; +import org.apache.camel.model.FilterDefinition; +import org.apache.camel.model.FromDefinition; +import org.apache.camel.model.IdempotentConsumerDefinition; +import org.apache.camel.model.InterceptDefinition; +import org.apache.camel.model.LoadBalanceDefinition; +import org.apache.camel.model.LogDefinition; +import org.apache.camel.model.MarshalDefinition; +import org.apache.camel.model.MulticastDefinition; +import org.apache.camel.model.OnCompletionDefinition; +import org.apache.camel.model.OnExceptionDefinition; +import org.apache.camel.model.OtherwiseDefinition; +import org.apache.camel.model.PollEnrichDefinition; +import org.apache.camel.model.RecipientListDefinition; +import org.apache.camel.model.Resilience4jConfigurationDefinition; +import org.apache.camel.model.RouteConfigurationDefinition; +import org.apache.camel.model.RouteDefinition; +import org.apache.camel.model.RouteTemplateDefinition; +import org.apache.camel.model.RoutingSlipDefinition; +import org.apache.camel.model.SplitDefinition; +import org.apache.camel.model.ThrottleDefinition; +import org.apache.camel.model.ToDefinition; +import org.apache.camel.model.TransformDefinition; +import org.apache.camel.model.UnmarshalDefinition; +import org.apache.camel.model.ValidateDefinition; +import org.apache.camel.model.WhenDefinition; +import org.apache.camel.model.WireTapDefinition; +import org.apache.camel.model.dataformat.CsvDataFormat; +import org.apache.camel.model.dataformat.JsonDataFormat; +import org.apache.camel.model.dataformat.JsonLibrary; +import org.apache.camel.model.language.ConstantExpression; +import org.apache.camel.model.language.HeaderExpression; +import org.apache.camel.model.language.SimpleExpression; +import org.apache.camel.model.loadbalancer.FailoverLoadBalancerDefinition; +import org.apache.camel.model.loadbalancer.RoundRobinLoadBalancerDefinition; +import org.apache.camel.model.rest.GetDefinition; +import org.apache.camel.model.rest.PostDefinition; +import org.apache.camel.model.rest.RestDefinition; +import org.apache.camel.util.json.JsonObject; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static org.apache.camel.util.IOHelper.stripLineComments; + +public class YamlModelWriterTest { + + @Test + public void testSimpleRoute() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + route.addOutput(new LogDefinition("${body}")); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-simple.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testTwoRoutes() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route1 = new RouteDefinition(); + route1.setId("route1"); + route1.setInput(new FromDefinition("direct:a")); + route1.addOutput(new ToDefinition("mock:a")); + + RouteDefinition route2 = new RouteDefinition(); + route2.setId("route2"); + route2.setInput(new FromDefinition("direct:b")); + route2.addOutput(new LogDefinition("${body}")); + route2.addOutput(new ToDefinition("mock:b")); + + List roots = List.of( + writer.writeRouteDefinition(route1), + writer.writeRouteDefinition(route2)); + String out = writer.printAsYaml(roots); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-two.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testChoice() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + ChoiceDefinition choice = new ChoiceDefinition(); + + WhenDefinition when1 = new WhenDefinition(); + when1.setExpression(new SimpleExpression("${header.type} == 'a'")); + when1.addOutput(new ToDefinition("mock:a")); + choice.getWhenClauses().add(when1); + + WhenDefinition when2 = new WhenDefinition(); + when2.setExpression(new SimpleExpression("${header.type} == 'b'")); + when2.addOutput(new ToDefinition("mock:b")); + choice.getWhenClauses().add(when2); + + OtherwiseDefinition ow = new OtherwiseDefinition(); + ow.addOutput(new ToDefinition("mock:other")); + choice.setOtherwise(ow); + + route.addOutput(choice); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-choice.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testTransformExpression() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + TransformDefinition transform = new TransformDefinition(); + transform.setExpression(new SimpleExpression("Hello ${body}")); + route.addOutput(transform); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-transform.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testMarshalUnmarshal() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + MarshalDefinition marshal = new MarshalDefinition(); + marshal.setDataFormatType(new CsvDataFormat()); + route.addOutput(marshal); + + UnmarshalDefinition unmarshal = new UnmarshalDefinition(); + JsonDataFormat jsonDf = new JsonDataFormat(); + jsonDf.setLibrary(JsonLibrary.Jackson); + unmarshal.setDataFormatType(jsonDf); + route.addOutput(unmarshal); + + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-marshal.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testMulticast() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + MulticastDefinition multicast = new MulticastDefinition(); + multicast.addOutput(new ToDefinition("mock:a")); + multicast.addOutput(new ToDefinition("mock:b")); + multicast.addOutput(new ToDefinition("mock:c")); + route.addOutput(multicast); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-multicast.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testWireTap() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + WireTapDefinition wt = new WireTapDefinition<>(); + wt.setUri("mock:tap"); + route.addOutput(wt); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-wiretap.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testSplit() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + SplitDefinition split = new SplitDefinition(); + split.setExpression(new SimpleExpression("${body}")); + split.setStreaming("true"); + split.addOutput(new ToDefinition("mock:split")); + route.addOutput(split); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-split.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testCircuitBreaker() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + CircuitBreakerDefinition cb = new CircuitBreakerDefinition(); + Resilience4jConfigurationDefinition r4j = new Resilience4jConfigurationDefinition(); + r4j.setMinimumNumberOfCalls("5"); + r4j.setFailureRateThreshold("70"); + cb.setResilience4jConfiguration(r4j); + cb.addOutput(new ToDefinition("mock:service")); + route.addOutput(cb); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-circuitbreaker.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testRouteConfiguration() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteConfigurationDefinition config = new RouteConfigurationDefinition(); + config.setId("myConfig"); + + OnExceptionDefinition onEx = new OnExceptionDefinition(); + onEx.getExceptions().add("java.lang.Exception"); + onEx.setHandled(new ExpressionSubElementDefinition(new ConstantExpression("true"))); + onEx.addOutput(new ToDefinition("mock:error")); + config.getOnExceptions().add(onEx); + + InterceptDefinition intercept = new InterceptDefinition(); + intercept.addOutput(new LogDefinition("intercepted")); + config.getIntercepts().add(intercept); + + JsonObject jo = writer.writeRouteConfigurationDefinition(config); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-routeconfig.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testRouteTemplate() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteTemplateDefinition template = new RouteTemplateDefinition(); + template.setId("myTemplate"); + template.templateParameter("foo", null, "the foo parameter"); + template.templateParameter("bar", "defaultBar", "the bar parameter"); + + RouteDefinition route = new RouteDefinition(); + route.setInput(new FromDefinition("direct:{{foo}}")); + route.addOutput(new ToDefinition("mock:{{bar}}")); + template.setRoute(route); + + JsonObject jo = writer.writeRouteTemplateDefinition(template); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-template.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testRestDsl() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RestDefinition rest = new RestDefinition(); + rest.setPath("/api"); + + GetDefinition get = new GetDefinition(); + get.setPath("/hello"); + get.setTo(new ToDefinition("direct:hello")); + rest.getVerbs().add(get); + + PostDefinition post = new PostDefinition(); + post.setPath("/bye"); + post.setConsumes("application/json"); + post.setTo(new ToDefinition("direct:bye")); + rest.getVerbs().add(post); + + JsonObject jo = writer.writeRestDefinition(rest); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-rest.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testFilter() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + FilterDefinition filter = new FilterDefinition(); + filter.setExpression(new SimpleExpression("${header.foo} == 'bar'")); + filter.addOutput(new ToDefinition("mock:filtered")); + route.addOutput(filter); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-filter.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testLoadBalanceRoundRobin() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + LoadBalanceDefinition lb = new LoadBalanceDefinition(); + lb.setLoadBalancerType(new RoundRobinLoadBalancerDefinition()); + lb.addOutput(new ToDefinition("mock:a")); + lb.addOutput(new ToDefinition("mock:b")); + route.addOutput(lb); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-loadbalance.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testLoadBalanceFailover() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + LoadBalanceDefinition lb = new LoadBalanceDefinition(); + FailoverLoadBalancerDefinition fo = new FailoverLoadBalancerDefinition(); + fo.setMaximumFailoverAttempts("3"); + fo.setRoundRobin("true"); + lb.setLoadBalancerType(fo); + lb.addOutput(new ToDefinition("mock:a")); + lb.addOutput(new ToDefinition("mock:b")); + route.addOutput(lb); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-loadbalance-failover.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testDynamicRouter() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + DynamicRouterDefinition dr = new DynamicRouterDefinition<>(); + dr.setExpression(new SimpleExpression("${header.route}")); + dr.setUriDelimiter(","); + dr.setIgnoreInvalidEndpoints("true"); + route.addOutput(dr); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-dynamic-router.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testRoutingSlip() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + RoutingSlipDefinition rs = new RoutingSlipDefinition<>(); + rs.setExpression(new HeaderExpression("mySlip")); + rs.setUriDelimiter(","); + route.addOutput(rs); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-routing-slip.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testRecipientList() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + RecipientListDefinition rl = new RecipientListDefinition<>(); + rl.setExpression(new HeaderExpression("recipients")); + rl.setDelimiter(","); + rl.setParallelProcessing("true"); + route.addOutput(rl); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-recipient-list.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testEnrichPollEnrich() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + EnrichDefinition enrich = new EnrichDefinition(); + enrich.setExpression(new ConstantExpression("direct:resource")); + enrich.setAggregationStrategy("#myStrategy"); + route.addOutput(enrich); + + PollEnrichDefinition pollEnrich = new PollEnrichDefinition(); + pollEnrich.setExpression(new ConstantExpression("file:inbox")); + pollEnrich.setTimeout("5000"); + route.addOutput(pollEnrich); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-enrich.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testDelay() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + DelayDefinition delay = new DelayDefinition(); + delay.setExpression(new ConstantExpression("1000")); + delay.setAsyncDelayed("true"); + route.addOutput(delay); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-delay.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testThrottle() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + ThrottleDefinition throttle = new ThrottleDefinition(); + throttle.setExpression(new ConstantExpression("10")); + throttle.setTimePeriodMillis("1000"); + throttle.setCorrelationExpression(new ExpressionSubElementDefinition(new HeaderExpression("clientId"))); + route.addOutput(throttle); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-throttle.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testValidate() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + ValidateDefinition validate = new ValidateDefinition(); + validate.setExpression(new SimpleExpression("${body} != null")); + route.addOutput(validate); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-validate.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testIdempotentConsumer() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + IdempotentConsumerDefinition ic = new IdempotentConsumerDefinition(); + ic.setExpression(new HeaderExpression("messageId")); + ic.setIdempotentRepository("#myRepo"); + ic.setEager("true"); + ic.setSkipDuplicate("true"); + ic.addOutput(new ToDefinition("mock:result")); + route.addOutput(ic); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-idempotent.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testOnCompletion() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + OnCompletionDefinition oc = new OnCompletionDefinition(); + oc.setOnCompleteOnly("true"); + oc.addOutput(new LogDefinition("completed")); + oc.addOutput(new ToDefinition("mock:done")); + route.addOutput(oc); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-oncompletion.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } +} diff --git a/core/camel-yaml-io/src/test/resources/yaml-rest.yaml b/core/camel-yaml-io/src/test/resources/yaml-rest.yaml new file mode 100644 index 0000000000000..fee9da12aaaaa --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-rest.yaml @@ -0,0 +1,27 @@ +# +# 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. +# + +- rest: + path: /api + verbs: + - path: /hello + to: + uri: direct:hello + - path: /bye + consumes: application/json + to: + uri: direct:bye diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-choice.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-choice.yaml new file mode 100644 index 0000000000000..976b4230125c9 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-choice.yaml @@ -0,0 +1,43 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - choice: + when: + - expression: + simple: + expression: "${header.type} == 'a'" + steps: + - to: + uri: mock:a + - expression: + simple: + expression: "${header.type} == 'b'" + steps: + - to: + uri: mock:b + otherwise: + steps: + - to: + uri: mock:other + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-circuitbreaker.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-circuitbreaker.yaml new file mode 100644 index 0000000000000..02493c6fe4f8e --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-circuitbreaker.yaml @@ -0,0 +1,32 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - circuitBreaker: + resilience4jConfiguration: + failureRateThreshold: 70 + minimumNumberOfCalls: 5 + steps: + - to: + uri: mock:service + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-delay.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-delay.yaml new file mode 100644 index 0000000000000..206bd1569c19b --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-delay.yaml @@ -0,0 +1,29 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - delay: + expression: + constant: + expression: "1000" + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-dynamic-router.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-dynamic-router.yaml new file mode 100644 index 0000000000000..be900c87a263d --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-dynamic-router.yaml @@ -0,0 +1,28 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - dynamicRouter: + ignoreInvalidEndpoints: true + expression: + simple: + expression: "${header.route}" diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-enrich.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-enrich.yaml new file mode 100644 index 0000000000000..c8299281272e3 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-enrich.yaml @@ -0,0 +1,35 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - enrich: + aggregationStrategy: "#myStrategy" + expression: + constant: + expression: direct:resource + - pollEnrich: + timeout: 5000 + expression: + constant: + expression: file:inbox + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-filter.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-filter.yaml new file mode 100644 index 0000000000000..c1687cfea2ecb --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-filter.yaml @@ -0,0 +1,32 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - filter: + expression: + simple: + expression: "${header.foo} == 'bar'" + steps: + - to: + uri: mock:filtered + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-idempotent.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-idempotent.yaml new file mode 100644 index 0000000000000..08e87d37ecb73 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-idempotent.yaml @@ -0,0 +1,31 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - idempotentConsumer: + idempotentRepository: "#myRepo" + expression: + header: + expression: messageId + steps: + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-loadbalance-failover.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-loadbalance-failover.yaml new file mode 100644 index 0000000000000..e31f81109da0b --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-loadbalance-failover.yaml @@ -0,0 +1,32 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - loadBalance: + failoverLoadBalancer: + roundRobin: true + maximumFailoverAttempts: 3 + steps: + - to: + uri: mock:a + - to: + uri: mock:b diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-loadbalance.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-loadbalance.yaml new file mode 100644 index 0000000000000..49cda78b09203 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-loadbalance.yaml @@ -0,0 +1,30 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - loadBalance: + roundRobinLoadBalancer: {} + steps: + - to: + uri: mock:a + - to: + uri: mock:b diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-marshal.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-marshal.yaml new file mode 100644 index 0000000000000..eb6e20312c169 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-marshal.yaml @@ -0,0 +1,29 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - marshal: + csv: {} + - unmarshal: + json: {} + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-multicast.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-multicast.yaml new file mode 100644 index 0000000000000..52f7d3c15fe05 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-multicast.yaml @@ -0,0 +1,31 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - multicast: + steps: + - to: + uri: mock:a + - to: + uri: mock:b + - to: + uri: mock:c diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-oncompletion.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-oncompletion.yaml new file mode 100644 index 0000000000000..2683ebdd85ddf --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-oncompletion.yaml @@ -0,0 +1,32 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - onCompletion: + onCompleteOnly: true + steps: + - log: + message: completed + - to: + uri: mock:done + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-recipient-list.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-recipient-list.yaml new file mode 100644 index 0000000000000..5bb77af13e8e0 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-recipient-list.yaml @@ -0,0 +1,28 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - recipientList: + parallelProcessing: true + expression: + header: + expression: recipients diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-routing-slip.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-routing-slip.yaml new file mode 100644 index 0000000000000..642ca6a143896 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-routing-slip.yaml @@ -0,0 +1,29 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - routingSlip: + expression: + header: + expression: mySlip + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-simple.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-simple.yaml new file mode 100644 index 0000000000000..5e05df08076c6 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-simple.yaml @@ -0,0 +1,27 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - log: + message: "${body}" + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-split.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-split.yaml new file mode 100644 index 0000000000000..92b0b1062ba98 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-split.yaml @@ -0,0 +1,33 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - split: + streaming: true + expression: + simple: + expression: "${body}" + steps: + - to: + uri: mock:split + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-template.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-template.yaml new file mode 100644 index 0000000000000..a1ad10bd8c38b --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-template.yaml @@ -0,0 +1,32 @@ +# +# 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. +# + +- routeTemplate: + customId: true + id: myTemplate + templateParameter: + - description: the foo parameter + name: foo + - description: the bar parameter + name: bar + defaultValue: defaultBar + route: + from: + uri: "direct:{{foo}}" + steps: + - to: + uri: "mock:{{bar}}" diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-throttle.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-throttle.yaml new file mode 100644 index 0000000000000..b800d7f5a415b --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-throttle.yaml @@ -0,0 +1,32 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - throttle: + expression: + constant: + expression: "10" + correlationExpression: + header: + expression: clientId + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-transform.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-transform.yaml new file mode 100644 index 0000000000000..f2c8246b74182 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-transform.yaml @@ -0,0 +1,29 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - transform: + expression: + simple: + expression: "Hello ${body}" + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-two.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-two.yaml new file mode 100644 index 0000000000000..8dfbdd4e8c469 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-two.yaml @@ -0,0 +1,35 @@ +# +# 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. +# + +- route: + customId: true + id: route1 + from: + uri: direct:a + steps: + - to: + uri: mock:a +- route: + customId: true + id: route2 + from: + uri: direct:b + steps: + - log: + message: "${body}" + - to: + uri: mock:b diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-validate.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-validate.yaml new file mode 100644 index 0000000000000..6d2ab80917312 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-validate.yaml @@ -0,0 +1,29 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - validate: + expression: + simple: + expression: "${body} != null" + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-wiretap.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-wiretap.yaml new file mode 100644 index 0000000000000..2ea07b1272d65 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-wiretap.yaml @@ -0,0 +1,27 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - wireTap: + uri: mock:tap + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-routeconfig.yaml b/core/camel-yaml-io/src/test/resources/yaml-routeconfig.yaml new file mode 100644 index 0000000000000..daeb77d2ddc2b --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-routeconfig.yaml @@ -0,0 +1,33 @@ +# +# 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. +# + +- routeConfiguration: + customId: true + id: myConfig + onException: + - exception: + - java.lang.Exception + handled: + constant: + expression: "true" + steps: + - to: + uri: mock:error + intercept: + - steps: + - log: + message: intercepted diff --git a/tooling/maven/camel-package-maven-plugin/src/main/resources/velocity/model-yaml-writer.vm b/tooling/maven/camel-package-maven-plugin/src/main/resources/velocity/model-yaml-writer.vm index 5fa1a2ce8f700..8b3da44d0e4ce 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/resources/velocity/model-yaml-writer.vm +++ b/tooling/maven/camel-package-maven-plugin/src/main/resources/velocity/model-yaml-writer.vm @@ -144,10 +144,19 @@ public class YamlModelWriter extends YamlModelWriterSupport { #if( $member.name == "outputs" ) doWriteOutputs(jo, def.${member.getter}(), this::doWrite${root.simpleName}Ref); #else - doWriteElementRefList(jo, null, def.${member.getter}(), this::doWrite${root.simpleName}Ref); + #set( $refName = $member.xmlElementRef.name() ) + #if( $refName && $refName != $default && $refName != "" ) + doWriteChildList(jo, "${refName}", "${refName}", def.${member.getter}(), this::doWrite${root.simpleName}); + #else + doWriteChildList(jo, "${member.name}", "${member.name}", def.${member.getter}(), this::doWrite${root.simpleName}); + #end #end #else + #if( $member.name == "expression" && $root.simpleName == "ExpressionDefinition" ) + doWriteExpressionRef(jo, def.${member.getter}(), this::doWrite${root.simpleName}Ref); + #else doWriteElementRef(jo, def.${member.getter}(), this::doWrite${root.simpleName}Ref); + #end #end #elseif( $member.xmlElements ) #if( $list ) @@ -267,6 +276,9 @@ public class YamlModelWriter extends YamlModelWriterSupport { #else #writeYamlElems #end + #if( $name == "RouteDefinition" ) + doMoveStepsUnderFrom(jo); + #end return jo; } #end From 196c5386f70aad91b5f8245a5694d11016d432dc Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Thu, 21 May 2026 11:53:23 +0200 Subject: [PATCH 4/9] CAMEL-23596: camel-yaml-io - Add more YamlModelWriter tests for medium-priority EIPs Add 15 additional tests covering: try/catch/finally, saga, setVariable, setProperty, removeHeader/Property/Variable, convertBody/Header, loop, step, pipeline, toDynamic, process, bean, resequence, claimCheck, sampling, threads, sort, script, rollback, stop, throwException, onException (standalone with redeliveryPolicy), and poll. Total YamlModelWriter tests: 39, exercising 73 model types. Co-Authored-By: Claude Opus 4.6 --- .../camel/yaml/out/YamlModelWriterTest.java | 394 ++++++++++++++++++ .../test/resources/yaml-route-claimcheck.yaml | 33 ++ .../resources/yaml-route-convertbody.yaml | 31 ++ .../src/test/resources/yaml-route-loop.yaml | 33 ++ .../src/test/resources/yaml-route-misc.yaml | 38 ++ .../resources/yaml-route-onexception.yaml | 36 ++ .../test/resources/yaml-route-pipeline.yaml | 31 ++ .../src/test/resources/yaml-route-poll.yaml | 28 ++ .../resources/yaml-route-processbean.yaml | 30 ++ .../test/resources/yaml-route-resequence.yaml | 30 ++ .../src/test/resources/yaml-route-saga.yaml | 32 ++ .../resources/yaml-route-setvariable.yaml | 41 ++ .../src/test/resources/yaml-route-step.yaml | 33 ++ .../src/test/resources/yaml-route-stop.yaml | 29 ++ .../test/resources/yaml-route-todynamic.yaml | 28 ++ .../test/resources/yaml-route-trycatch.yaml | 37 ++ 16 files changed, 884 insertions(+) create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-claimcheck.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-convertbody.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-loop.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-misc.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-onexception.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-pipeline.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-poll.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-processbean.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-resequence.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-saga.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-setvariable.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-step.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-stop.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-todynamic.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-trycatch.yaml diff --git a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java index 8cba2733f67fc..32d34178ea176 100644 --- a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java +++ b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java @@ -19,38 +19,67 @@ import java.nio.file.Paths; import java.util.List; +import org.apache.camel.model.BeanDefinition; +import org.apache.camel.model.CatchDefinition; import org.apache.camel.model.ChoiceDefinition; import org.apache.camel.model.CircuitBreakerDefinition; +import org.apache.camel.model.ClaimCheckDefinition; +import org.apache.camel.model.ConvertBodyDefinition; +import org.apache.camel.model.ConvertHeaderDefinition; import org.apache.camel.model.DelayDefinition; import org.apache.camel.model.DynamicRouterDefinition; import org.apache.camel.model.EnrichDefinition; import org.apache.camel.model.ExpressionSubElementDefinition; import org.apache.camel.model.FilterDefinition; +import org.apache.camel.model.FinallyDefinition; import org.apache.camel.model.FromDefinition; import org.apache.camel.model.IdempotentConsumerDefinition; import org.apache.camel.model.InterceptDefinition; import org.apache.camel.model.LoadBalanceDefinition; import org.apache.camel.model.LogDefinition; +import org.apache.camel.model.LoopDefinition; import org.apache.camel.model.MarshalDefinition; import org.apache.camel.model.MulticastDefinition; import org.apache.camel.model.OnCompletionDefinition; import org.apache.camel.model.OnExceptionDefinition; import org.apache.camel.model.OtherwiseDefinition; +import org.apache.camel.model.PipelineDefinition; +import org.apache.camel.model.PollDefinition; import org.apache.camel.model.PollEnrichDefinition; +import org.apache.camel.model.ProcessDefinition; import org.apache.camel.model.RecipientListDefinition; +import org.apache.camel.model.RedeliveryPolicyDefinition; +import org.apache.camel.model.RemoveHeaderDefinition; +import org.apache.camel.model.RemovePropertyDefinition; +import org.apache.camel.model.RemoveVariableDefinition; +import org.apache.camel.model.ResequenceDefinition; import org.apache.camel.model.Resilience4jConfigurationDefinition; +import org.apache.camel.model.RollbackDefinition; import org.apache.camel.model.RouteConfigurationDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.RouteTemplateDefinition; import org.apache.camel.model.RoutingSlipDefinition; +import org.apache.camel.model.SagaDefinition; +import org.apache.camel.model.SamplingDefinition; +import org.apache.camel.model.ScriptDefinition; +import org.apache.camel.model.SetPropertyDefinition; +import org.apache.camel.model.SetVariableDefinition; +import org.apache.camel.model.SortDefinition; import org.apache.camel.model.SplitDefinition; +import org.apache.camel.model.StepDefinition; +import org.apache.camel.model.StopDefinition; +import org.apache.camel.model.ThreadsDefinition; import org.apache.camel.model.ThrottleDefinition; +import org.apache.camel.model.ThrowExceptionDefinition; import org.apache.camel.model.ToDefinition; +import org.apache.camel.model.ToDynamicDefinition; import org.apache.camel.model.TransformDefinition; +import org.apache.camel.model.TryDefinition; import org.apache.camel.model.UnmarshalDefinition; import org.apache.camel.model.ValidateDefinition; import org.apache.camel.model.WhenDefinition; import org.apache.camel.model.WireTapDefinition; +import org.apache.camel.model.config.BatchResequencerConfig; import org.apache.camel.model.dataformat.CsvDataFormat; import org.apache.camel.model.dataformat.JsonDataFormat; import org.apache.camel.model.dataformat.JsonLibrary; @@ -587,4 +616,369 @@ public void testOnCompletion() throws Exception { String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-oncompletion.yaml"), "#", true); Assertions.assertEquals(expected, out); } + + @Test + public void testTryCatchFinally() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + TryDefinition tryDef = new TryDefinition(); + tryDef.addOutput(new ToDefinition("mock:try")); + + CatchDefinition catchDef = new CatchDefinition(); + catchDef.getExceptions().add("java.io.IOException"); + catchDef.addOutput(new ToDefinition("mock:catch")); + tryDef.addOutput(catchDef); + + FinallyDefinition finallyDef = new FinallyDefinition(); + finallyDef.addOutput(new ToDefinition("mock:finally")); + tryDef.addOutput(finallyDef); + + route.addOutput(tryDef); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-trycatch.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testSaga() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + SagaDefinition saga = new SagaDefinition(); + saga.setCompensation("direct:compensate"); + saga.setCompletion("direct:complete"); + saga.setPropagation("MANDATORY"); + saga.addOutput(new ToDefinition("mock:saga")); + route.addOutput(saga); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-saga.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testSetVariableRemoveHeader() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + SetVariableDefinition sv = new SetVariableDefinition(); + sv.setName("myVar"); + sv.setExpression(new SimpleExpression("${body}")); + route.addOutput(sv); + + SetPropertyDefinition sp = new SetPropertyDefinition(); + sp.setName("myProp"); + sp.setExpression(new ConstantExpression("propValue")); + route.addOutput(sp); + + route.addOutput(new RemoveHeaderDefinition("foo")); + route.addOutput(new RemovePropertyDefinition("bar")); + route.addOutput(new RemoveVariableDefinition("myVar")); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-setvariable.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testConvertBodyHeader() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + ConvertBodyDefinition cb = new ConvertBodyDefinition("java.lang.String"); + cb.setCharset("UTF-8"); + route.addOutput(cb); + + ConvertHeaderDefinition ch = new ConvertHeaderDefinition(); + ch.setName("myHeader"); + ch.setType("java.lang.Integer"); + route.addOutput(ch); + + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-convertbody.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testLoop() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + LoopDefinition loop = new LoopDefinition(); + loop.setExpression(new ConstantExpression("3")); + loop.setCopy("true"); + loop.addOutput(new ToDefinition("mock:loop")); + route.addOutput(loop); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-loop.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testStep() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + StepDefinition step = new StepDefinition(); + step.setId("myStep"); + step.addOutput(new LogDefinition("step log")); + step.addOutput(new ToDefinition("mock:step")); + route.addOutput(step); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-step.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testPipeline() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + PipelineDefinition pipeline = new PipelineDefinition(); + pipeline.addOutput(new ToDefinition("direct:a")); + pipeline.addOutput(new ToDefinition("direct:b")); + pipeline.addOutput(new ToDefinition("direct:c")); + route.addOutput(pipeline); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-pipeline.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testToDynamic() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + ToDynamicDefinition toD = new ToDynamicDefinition(); + toD.setUri("${header.destination}"); + toD.setCacheSize("100"); + route.addOutput(toD); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-todynamic.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testProcessBean() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + ProcessDefinition process = new ProcessDefinition(); + process.setRef("#myProcessor"); + route.addOutput(process); + + BeanDefinition bean = new BeanDefinition(); + bean.setRef("#myBean"); + bean.setMethod("transform"); + route.addOutput(bean); + + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-processbean.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testResequence() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + ResequenceDefinition reseq = new ResequenceDefinition(); + reseq.setExpression(new SimpleExpression("${header.seqNum}")); + BatchResequencerConfig batchConfig = new BatchResequencerConfig(); + batchConfig.setBatchSize("100"); + batchConfig.setBatchTimeout("2000"); + reseq.setBatchConfig(batchConfig); + reseq.addOutput(new ToDefinition("mock:result")); + route.addOutput(reseq); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-resequence.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testClaimCheck() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + ClaimCheckDefinition push = new ClaimCheckDefinition(); + push.setOperation("Push"); + push.setKey("myKey"); + route.addOutput(push); + + route.addOutput(new ToDefinition("mock:process")); + + ClaimCheckDefinition pop = new ClaimCheckDefinition(); + pop.setOperation("Pop"); + pop.setKey("myKey"); + route.addOutput(pop); + + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-claimcheck.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testSamplingThreadsSortScript() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + SamplingDefinition sampling = new SamplingDefinition(); + sampling.setMessageFrequency("5"); + route.addOutput(sampling); + + ThreadsDefinition threads = new ThreadsDefinition(); + threads.setPoolSize("5"); + threads.setMaxPoolSize("10"); + route.addOutput(threads); + + SortDefinition sort = new SortDefinition<>(); + sort.setExpression(new SimpleExpression("${body}")); + route.addOutput(sort); + + ScriptDefinition script = new ScriptDefinition(); + script.setExpression(new SimpleExpression("log.info('hello')")); + route.addOutput(script); + + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-misc.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testRollbackStopThrowException() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + route.addOutput(new StopDefinition()); + + RollbackDefinition rollback = new RollbackDefinition(); + rollback.setMessage("forced rollback"); + route.addOutput(rollback); + + ThrowExceptionDefinition throwEx = new ThrowExceptionDefinition(); + throwEx.setExceptionType("java.lang.IllegalArgumentException"); + throwEx.setMessage("bad input"); + route.addOutput(throwEx); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-stop.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testOnExceptionStandalone() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + OnExceptionDefinition onEx = new OnExceptionDefinition(); + onEx.getExceptions().add("java.io.IOException"); + onEx.setHandled(new ExpressionSubElementDefinition(new ConstantExpression("true"))); + RedeliveryPolicyDefinition redelivery = new RedeliveryPolicyDefinition(); + redelivery.setMaximumRedeliveries("3"); + onEx.setRedeliveryPolicyType(redelivery); + onEx.addOutput(new ToDefinition("mock:error")); + route.addOutput(onEx); + + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-onexception.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testPoll() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + PollDefinition poll = new PollDefinition(); + poll.setUri("file:inbox"); + poll.setTimeout("5000"); + route.addOutput(poll); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-poll.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } } diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-claimcheck.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-claimcheck.yaml new file mode 100644 index 0000000000000..b0fcb0078e8ef --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-claimcheck.yaml @@ -0,0 +1,33 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - claimCheck: + operation: Push + key: myKey + - to: + uri: mock:process + - claimCheck: + operation: Pop + key: myKey + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-convertbody.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-convertbody.yaml new file mode 100644 index 0000000000000..a338f961c817e --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-convertbody.yaml @@ -0,0 +1,31 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - convertBodyTo: + type: java.lang.String + charset: UTF-8 + - convertHeaderTo: + name: myHeader + type: java.lang.Integer + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-loop.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-loop.yaml new file mode 100644 index 0000000000000..3f14e5c155dc4 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-loop.yaml @@ -0,0 +1,33 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - loop: + copy: true + expression: + constant: + expression: "3" + steps: + - to: + uri: mock:loop + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-misc.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-misc.yaml new file mode 100644 index 0000000000000..d3649a4294e7d --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-misc.yaml @@ -0,0 +1,38 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - sample: + messageFrequency: 5 + - threads: + poolSize: 5 + maxPoolSize: 10 + - sort: + expression: + simple: + expression: "${body}" + - script: + expression: + simple: + expression: log.info('hello') + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-onexception.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-onexception.yaml new file mode 100644 index 0000000000000..0d7cb2a35ba20 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-onexception.yaml @@ -0,0 +1,36 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - onException: + exception: + - java.io.IOException + redeliveryPolicy: + maximumRedeliveries: 3 + handled: + constant: + expression: "true" + steps: + - to: + uri: mock:error + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-pipeline.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-pipeline.yaml new file mode 100644 index 0000000000000..567281a9fd534 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-pipeline.yaml @@ -0,0 +1,31 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - pipeline: + steps: + - to: + uri: direct:a + - to: + uri: direct:b + - to: + uri: direct:c diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-poll.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-poll.yaml new file mode 100644 index 0000000000000..234a21b60df86 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-poll.yaml @@ -0,0 +1,28 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - poll: + uri: file:inbox + timeout: 5000 + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-processbean.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-processbean.yaml new file mode 100644 index 0000000000000..6fb0f30152517 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-processbean.yaml @@ -0,0 +1,30 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - process: + ref: "#myProcessor" + - bean: + ref: "#myBean" + method: transform + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-resequence.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-resequence.yaml new file mode 100644 index 0000000000000..f0ce0a1d1d099 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-resequence.yaml @@ -0,0 +1,30 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - resequence: + expression: + simple: + expression: "${header.seqNum}" + steps: + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-saga.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-saga.yaml new file mode 100644 index 0000000000000..bfe938644ce03 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-saga.yaml @@ -0,0 +1,32 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - saga: + propagation: MANDATORY + compensation: direct:compensate + completion: direct:complete + steps: + - to: + uri: mock:saga + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-setvariable.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-setvariable.yaml new file mode 100644 index 0000000000000..30d0fc5549e63 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-setvariable.yaml @@ -0,0 +1,41 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - setVariable: + name: myVar + expression: + simple: + expression: "${body}" + - setProperty: + name: myProp + expression: + constant: + expression: propValue + - removeHeader: + name: foo + - removeProperty: + name: bar + - removeVariable: + name: myVar + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-step.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-step.yaml new file mode 100644 index 0000000000000..c6e1e2d8d2c7d --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-step.yaml @@ -0,0 +1,33 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - step: + customId: true + id: myStep + steps: + - log: + message: step log + - to: + uri: mock:step + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-stop.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-stop.yaml new file mode 100644 index 0000000000000..ed76cb77b304e --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-stop.yaml @@ -0,0 +1,29 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - stop: {} + - rollback: + message: forced rollback + - throwException: + message: bad input + exceptionType: java.lang.IllegalArgumentException diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-todynamic.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-todynamic.yaml new file mode 100644 index 0000000000000..372d10e814438 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-todynamic.yaml @@ -0,0 +1,28 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - toD: + uri: "${header.destination}" + cacheSize: 100 + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-trycatch.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-trycatch.yaml new file mode 100644 index 0000000000000..64c5c590d979a --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-trycatch.yaml @@ -0,0 +1,37 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - doTry: + steps: + - to: + uri: mock:try + - doCatch: + exception: + - java.io.IOException + steps: + - to: + uri: mock:catch + - doFinally: + steps: + - to: + uri: mock:finally From abefd3aaedeb812e8cd1e661178363faa8b4ee1d Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Thu, 21 May 2026 11:57:39 +0200 Subject: [PATCH 5/9] CAMEL-23596: camel-yaml-io - Add tests for errorHandler, restConfig, transformers, validators, kamelet, transacted Add 7 additional YamlModelWriter tests covering: - ErrorHandler: DeadLetterChannel with redeliveryPolicy, DefaultErrorHandler - RestConfiguration: component, host, port, bindingMode, contextPath - Transformers: EndpointTransformerDefinition with fromType/toType - Validators: EndpointValidatorDefinition with type - Kamelet: kamelet EIP with name and nested steps - Transacted: transacted EIP with ref and nested steps Total YamlModelWriter tests: 46. Co-Authored-By: Claude Opus 4.6 --- .../camel/yaml/out/YamlModelWriterTest.java | 145 ++++++++++++++++++ .../resources/yaml-errorhandler-default.yaml | 22 +++ .../test/resources/yaml-errorhandler-dlc.yaml | 23 +++ .../resources/yaml-restconfiguration.yaml | 23 +++ .../test/resources/yaml-route-kamelet.yaml | 30 ++++ .../test/resources/yaml-route-transacted.yaml | 30 ++++ .../src/test/resources/yaml-transformers.yaml | 22 +++ .../src/test/resources/yaml-validators.yaml | 21 +++ 8 files changed, 316 insertions(+) create mode 100644 core/camel-yaml-io/src/test/resources/yaml-errorhandler-default.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-errorhandler-dlc.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-restconfiguration.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-kamelet.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-route-transacted.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-transformers.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-validators.yaml diff --git a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java index 32d34178ea176..08446fd2ed587 100644 --- a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java +++ b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java @@ -17,6 +17,7 @@ package org.apache.camel.yaml.out; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.List; import org.apache.camel.model.BeanDefinition; @@ -29,12 +30,14 @@ import org.apache.camel.model.DelayDefinition; import org.apache.camel.model.DynamicRouterDefinition; import org.apache.camel.model.EnrichDefinition; +import org.apache.camel.model.ErrorHandlerDefinition; import org.apache.camel.model.ExpressionSubElementDefinition; import org.apache.camel.model.FilterDefinition; import org.apache.camel.model.FinallyDefinition; import org.apache.camel.model.FromDefinition; import org.apache.camel.model.IdempotentConsumerDefinition; import org.apache.camel.model.InterceptDefinition; +import org.apache.camel.model.KameletDefinition; import org.apache.camel.model.LoadBalanceDefinition; import org.apache.camel.model.LogDefinition; import org.apache.camel.model.LoopDefinition; @@ -73,6 +76,7 @@ import org.apache.camel.model.ThrowExceptionDefinition; import org.apache.camel.model.ToDefinition; import org.apache.camel.model.ToDynamicDefinition; +import org.apache.camel.model.TransactedDefinition; import org.apache.camel.model.TransformDefinition; import org.apache.camel.model.TryDefinition; import org.apache.camel.model.UnmarshalDefinition; @@ -83,6 +87,8 @@ import org.apache.camel.model.dataformat.CsvDataFormat; import org.apache.camel.model.dataformat.JsonDataFormat; import org.apache.camel.model.dataformat.JsonLibrary; +import org.apache.camel.model.errorhandler.DeadLetterChannelDefinition; +import org.apache.camel.model.errorhandler.DefaultErrorHandlerDefinition; import org.apache.camel.model.language.ConstantExpression; import org.apache.camel.model.language.HeaderExpression; import org.apache.camel.model.language.SimpleExpression; @@ -90,7 +96,15 @@ import org.apache.camel.model.loadbalancer.RoundRobinLoadBalancerDefinition; import org.apache.camel.model.rest.GetDefinition; import org.apache.camel.model.rest.PostDefinition; +import org.apache.camel.model.rest.RestBindingMode; +import org.apache.camel.model.rest.RestConfigurationDefinition; import org.apache.camel.model.rest.RestDefinition; +import org.apache.camel.model.transformer.EndpointTransformerDefinition; +import org.apache.camel.model.transformer.TransformerDefinition; +import org.apache.camel.model.transformer.TransformersDefinition; +import org.apache.camel.model.validator.EndpointValidatorDefinition; +import org.apache.camel.model.validator.ValidatorDefinition; +import org.apache.camel.model.validator.ValidatorsDefinition; import org.apache.camel.util.json.JsonObject; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -981,4 +995,135 @@ public void testPoll() throws Exception { String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-poll.yaml"), "#", true); Assertions.assertEquals(expected, out); } + + @Test + public void testErrorHandlerDeadLetterChannel() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + ErrorHandlerDefinition ehDef = new ErrorHandlerDefinition(); + DeadLetterChannelDefinition dlc = new DeadLetterChannelDefinition(); + dlc.setDeadLetterUri("mock:dead"); + RedeliveryPolicyDefinition rp = new RedeliveryPolicyDefinition(); + rp.setMaximumRedeliveries("3"); + rp.setRedeliveryDelay("2000"); + dlc.setRedeliveryPolicy(rp); + ehDef.setErrorHandlerType(dlc); + + JsonObject jo = writer.writeErrorHandlerDefinition(ehDef); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-errorhandler-dlc.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testErrorHandlerDefault() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + ErrorHandlerDefinition ehDef = new ErrorHandlerDefinition(); + DefaultErrorHandlerDefinition deh = new DefaultErrorHandlerDefinition(); + deh.setLevel("WARN"); + RedeliveryPolicyDefinition rp = new RedeliveryPolicyDefinition(); + rp.setMaximumRedeliveries("5"); + deh.setRedeliveryPolicy(rp); + ehDef.setErrorHandlerType(deh); + + JsonObject jo = writer.writeErrorHandlerDefinition(ehDef); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-errorhandler-default.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testRestConfiguration() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RestConfigurationDefinition rc = new RestConfigurationDefinition(); + rc.setComponent("platform-http"); + rc.setHost("localhost"); + rc.setPort("8080"); + rc.setBindingMode(RestBindingMode.json); + rc.setContextPath("/api"); + + JsonObject jo = writer.writeRestConfigurationDefinition(rc); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-restconfiguration.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testTransformers() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + TransformersDefinition transformers = new TransformersDefinition(); + EndpointTransformerDefinition et = new EndpointTransformerDefinition(); + et.setFromType("xml"); + et.setToType("json"); + et.setUri("direct:transform"); + List tList = new ArrayList<>(); + tList.add(et); + transformers.setTransformers(tList); + + JsonObject jo = writer.writeTransformersDefinition(transformers); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-transformers.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testValidators() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + ValidatorsDefinition validators = new ValidatorsDefinition(); + EndpointValidatorDefinition ev = new EndpointValidatorDefinition(); + ev.setType("json"); + ev.setUri("direct:validate"); + List vList = new ArrayList<>(); + vList.add(ev); + validators.setValidators(vList); + + JsonObject jo = writer.writeValidatorsDefinition(validators); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-validators.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testKamelet() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + KameletDefinition kamelet = new KameletDefinition(); + kamelet.setName("my-kamelet"); + kamelet.addOutput(new ToDefinition("mock:kamelet")); + route.addOutput(kamelet); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-kamelet.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testTransacted() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + + TransactedDefinition transacted = new TransactedDefinition(); + transacted.setRef("myTransactionPolicy"); + transacted.addOutput(new ToDefinition("mock:transacted")); + route.addOutput(transacted); + route.addOutput(new ToDefinition("mock:result")); + + JsonObject jo = writer.writeRouteDefinition(route); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-transacted.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } } diff --git a/core/camel-yaml-io/src/test/resources/yaml-errorhandler-default.yaml b/core/camel-yaml-io/src/test/resources/yaml-errorhandler-default.yaml new file mode 100644 index 0000000000000..86d7638e35d66 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-errorhandler-default.yaml @@ -0,0 +1,22 @@ +# +# 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. +# + +- errorHandler: + defaultErrorHandler: + level: WARN + redeliveryPolicy: + maximumRedeliveries: 5 diff --git a/core/camel-yaml-io/src/test/resources/yaml-errorhandler-dlc.yaml b/core/camel-yaml-io/src/test/resources/yaml-errorhandler-dlc.yaml new file mode 100644 index 0000000000000..514fd49bf99c0 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-errorhandler-dlc.yaml @@ -0,0 +1,23 @@ +# +# 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. +# + +- errorHandler: + deadLetterChannel: + deadLetterUri: mock:dead + redeliveryPolicy: + maximumRedeliveries: 3 + redeliveryDelay: 2000 diff --git a/core/camel-yaml-io/src/test/resources/yaml-restconfiguration.yaml b/core/camel-yaml-io/src/test/resources/yaml-restconfiguration.yaml new file mode 100644 index 0000000000000..bcfe1c7b78305 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-restconfiguration.yaml @@ -0,0 +1,23 @@ +# +# 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. +# + +- restConfiguration: + component: platform-http + host: localhost + port: 8080 + contextPath: /api + bindingMode: json diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-kamelet.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-kamelet.yaml new file mode 100644 index 0000000000000..b52a8f7985285 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-kamelet.yaml @@ -0,0 +1,30 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - kamelet: + name: my-kamelet + steps: + - to: + uri: mock:kamelet + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-route-transacted.yaml b/core/camel-yaml-io/src/test/resources/yaml-route-transacted.yaml new file mode 100644 index 0000000000000..304a0c38fc0db --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-route-transacted.yaml @@ -0,0 +1,30 @@ +# +# 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. +# + +- route: + customId: true + id: myRoute + from: + uri: direct:start + steps: + - transacted: + ref: myTransactionPolicy + steps: + - to: + uri: mock:transacted + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-transformers.yaml b/core/camel-yaml-io/src/test/resources/yaml-transformers.yaml new file mode 100644 index 0000000000000..94dd4e94fa7ef --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-transformers.yaml @@ -0,0 +1,22 @@ +# +# 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. +# + +- transformers: + endpointTransformer: + toType: json + fromType: xml + uri: direct:transform diff --git a/core/camel-yaml-io/src/test/resources/yaml-validators.yaml b/core/camel-yaml-io/src/test/resources/yaml-validators.yaml new file mode 100644 index 0000000000000..40e17dadb305c --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-validators.yaml @@ -0,0 +1,21 @@ +# +# 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. +# + +- validators: + endpointValidator: + type: json + uri: direct:validate From 61e1091f26d6a934f48d5fe44ef249fe1d3d9b1a Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Thu, 21 May 2026 12:03:04 +0200 Subject: [PATCH 6/9] CAMEL-23596: camel-yaml-io - Add tests for beans (BeanFactoryDefinition and BeansDefinition) Add 2 tests for bean definitions: - testBeans: BeanFactoryDefinition with properties, factoryMethod, init/destroy - testBeansWithRoute: BeansDefinition container with bean + route Total YamlModelWriter tests: 48. Co-Authored-By: Claude Opus 4.6 --- .../camel/yaml/out/YamlModelWriterTest.java | 60 +++++++++++++++++++ .../test/resources/yaml-beans-with-route.yaml | 35 +++++++++++ .../src/test/resources/yaml-beans.yaml | 32 ++++++++++ 3 files changed, 127 insertions(+) create mode 100644 core/camel-yaml-io/src/test/resources/yaml-beans-with-route.yaml create mode 100644 core/camel-yaml-io/src/test/resources/yaml-beans.yaml diff --git a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java index 08446fd2ed587..2cd54da8e1d27 100644 --- a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java +++ b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/YamlModelWriterTest.java @@ -18,9 +18,12 @@ import java.nio.file.Paths; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.apache.camel.model.BeanDefinition; +import org.apache.camel.model.BeanFactoryDefinition; import org.apache.camel.model.CatchDefinition; import org.apache.camel.model.ChoiceDefinition; import org.apache.camel.model.CircuitBreakerDefinition; @@ -83,6 +86,7 @@ import org.apache.camel.model.ValidateDefinition; import org.apache.camel.model.WhenDefinition; import org.apache.camel.model.WireTapDefinition; +import org.apache.camel.model.app.BeansDefinition; import org.apache.camel.model.config.BatchResequencerConfig; import org.apache.camel.model.dataformat.CsvDataFormat; import org.apache.camel.model.dataformat.JsonDataFormat; @@ -1126,4 +1130,60 @@ public void testTransacted() throws Exception { String expected = stripLineComments(Paths.get("src/test/resources/yaml-route-transacted.yaml"), "#", true); Assertions.assertEquals(expected, out); } + + @Test + public void testBeans() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + BeanFactoryDefinition bean1 = new BeanFactoryDefinition<>(); + bean1.setName("myBean"); + bean1.setType("com.example.MyBean"); + Map props = new LinkedHashMap<>(); + props.put("greeting", "Hello"); + props.put("count", "5"); + bean1.setProperties(props); + + BeanFactoryDefinition bean2 = new BeanFactoryDefinition<>(); + bean2.setName("myFactory"); + bean2.setType("com.example.MyFactory"); + bean2.setFactoryMethod("create"); + bean2.setInitMethod("init"); + bean2.setDestroyMethod("cleanup"); + + List result = new ArrayList<>(); + result.add(writer.writeBeanFactoryDefinition(bean1)); + result.add(writer.writeBeanFactoryDefinition(bean2)); + String out = writer.printAsYaml(result); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-beans.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } + + @Test + public void testBeansWithRoute() throws Exception { + YamlModelWriter writer = new YamlModelWriter(); + + BeansDefinition beansContainer = new BeansDefinition(); + + BeanFactoryDefinition bean = new BeanFactoryDefinition<>(); + bean.setName("myService"); + bean.setType("com.example.MyService"); + Map props = new LinkedHashMap<>(); + props.put("url", "http://localhost:8080"); + bean.setProperties(props); + List beanList = new ArrayList<>(); + beanList.add(bean); + beansContainer.setBeans(beanList); + + RouteDefinition route = new RouteDefinition(); + route.setId("myRoute"); + route.setInput(new FromDefinition("direct:start")); + route.addOutput(new LogDefinition("${body}")); + route.addOutput(new ToDefinition("mock:result")); + beansContainer.setRoutes(List.of(route)); + + JsonObject jo = writer.writeBeansDefinition(beansContainer); + String out = writer.printAsYaml(List.of(jo)); + String expected = stripLineComments(Paths.get("src/test/resources/yaml-beans-with-route.yaml"), "#", true); + Assertions.assertEquals(expected, out); + } } diff --git a/core/camel-yaml-io/src/test/resources/yaml-beans-with-route.yaml b/core/camel-yaml-io/src/test/resources/yaml-beans-with-route.yaml new file mode 100644 index 0000000000000..64db76b553c75 --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-beans-with-route.yaml @@ -0,0 +1,35 @@ +# +# 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. +# + +- beans: + bean: + - name: myService + type: com.example.MyService + properties: + property: + - key: url + value: http://localhost:8080 + route: + - customId: true + id: myRoute + from: + uri: direct:start + steps: + - log: + message: "${body}" + - to: + uri: mock:result diff --git a/core/camel-yaml-io/src/test/resources/yaml-beans.yaml b/core/camel-yaml-io/src/test/resources/yaml-beans.yaml new file mode 100644 index 0000000000000..3e50198f4fdcf --- /dev/null +++ b/core/camel-yaml-io/src/test/resources/yaml-beans.yaml @@ -0,0 +1,32 @@ +# +# 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. +# + +- beanFactory: + name: myBean + type: com.example.MyBean + properties: + property: + - key: greeting + value: Hello + - key: count + value: 5 +- beanFactory: + name: myFactory + type: com.example.MyFactory + initMethod: init + destroyMethod: cleanup + factoryMethod: create From 0e33df860aeb072a6a2cbd3e32e680389a31592d Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Thu, 21 May 2026 12:22:34 +0200 Subject: [PATCH 7/9] CAMEL-23596: camel-yaml-io - Remove old ModelWriter, BaseWriter, YamlWriter and generator The old YAML writer stack (ModelWriter extending BaseWriter using YamlWriter) is fully replaced by the new generated YamlModelWriter. Remove the old code and migrate remaining consumers (TransformTools, XmlToYamlTest, XPathNamespacesTest). Co-Authored-By: Claude Opus 4.6 --- core/camel-yaml-io/pom.xml | 2 - .../apache/camel/yaml/out/ModelWriter.java | 3960 ----------------- .../org/apache/camel/yaml/io/YamlWriter.java | 599 --- .../org/apache/camel/yaml/out/BaseWriter.java | 104 - .../camel/yaml/out/ModelWriterTest.java | 465 -- .../out/ModelWriterUriAsParametersTest.java | 356 -- .../camel/yaml/out/XPathNamespacesTest.java | 50 +- .../apache/camel/yaml/out/XmlToYamlTest.java | 15 +- .../core/commands/mcp/TransformTools.java | 12 +- .../YamlModelWriterGeneratorMojo.java | 74 - 10 files changed, 54 insertions(+), 5583 deletions(-) delete mode 100644 core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java delete mode 100644 core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java delete mode 100644 core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/BaseWriter.java delete mode 100644 core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/ModelWriterTest.java delete mode 100644 core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/ModelWriterUriAsParametersTest.java delete mode 100644 tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlModelWriterGeneratorMojo.java diff --git a/core/camel-yaml-io/pom.xml b/core/camel-yaml-io/pom.xml index 8616b7446245b..6cf99fe9b1cdf 100644 --- a/core/camel-yaml-io/pom.xml +++ b/core/camel-yaml-io/pom.xml @@ -33,7 +33,6 @@ 4.0.0 - true true @@ -100,7 +99,6 @@ generate-sources generate-sources - generate-yaml-writer generate-yaml-direct-writer diff --git a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java deleted file mode 100644 index 89d86e909dee4..0000000000000 --- a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java +++ /dev/null @@ -1,3960 +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. - */ - -/** - * Generated by camel build tools - do NOT edit this file! - */ -package org.apache.camel.yaml.out; - -import java.io.IOException; -import java.io.Writer; -import java.util.Base64; -import java.util.List; -import javax.annotation.processing.Generated; - -import org.apache.camel.model.*; -import org.apache.camel.model.app.*; -import org.apache.camel.model.config.*; -import org.apache.camel.model.dataformat.*; -import org.apache.camel.model.errorhandler.*; -import org.apache.camel.model.language.*; -import org.apache.camel.model.loadbalancer.*; -import org.apache.camel.model.rest.*; -import org.apache.camel.model.tokenizer.*; -import org.apache.camel.model.transformer.*; -import org.apache.camel.model.validator.*; - -@Generated("org.apache.camel.maven.packaging.YamlModelWriterGeneratorMojo") -// The model automatically scan all classes, also those one deprecated. They will be dropped when removed from core model. -// In the while we confirm this exception by suppressing the compiler warning. -// It allows usage of raw types as it is an autogenerated class used internally by the framework. -@SuppressWarnings({"deprecation","rawtypes"}) -public class ModelWriter extends BaseWriter { - - public ModelWriter(Writer writer, String namespace) throws IOException { - super(writer, namespace); - } - - public ModelWriter(Writer writer) throws IOException { - super(writer, null); - } - - public void writeAggregateDefinition(AggregateDefinition def) throws IOException { - doWriteAggregateDefinition("aggregate", def); - } - public void writeBeanDefinition(BeanDefinition def) throws IOException { - doWriteBeanDefinition("bean", def); - } - public void writeBeanFactoryDefinition(BeanFactoryDefinition def) throws IOException { - doWriteBeanFactoryDefinition("beanFactory", def); - } - public void writeCatchDefinition(CatchDefinition def) throws IOException { - doWriteCatchDefinition("doCatch", def); - } - public void writeChoiceDefinition(ChoiceDefinition def) throws IOException { - doWriteChoiceDefinition("choice", def); - } - public void writeCircuitBreakerDefinition(CircuitBreakerDefinition def) throws IOException { - doWriteCircuitBreakerDefinition("circuitBreaker", def); - } - public void writeClaimCheckDefinition(ClaimCheckDefinition def) throws IOException { - doWriteClaimCheckDefinition("claimCheck", def); - } - public void writeContextScanDefinition(ContextScanDefinition def) throws IOException { - doWriteContextScanDefinition("contextScan", def); - } - public void writeConvertBodyDefinition(ConvertBodyDefinition def) throws IOException { - doWriteConvertBodyDefinition("convertBodyTo", def); - } - public void writeConvertHeaderDefinition(ConvertHeaderDefinition def) throws IOException { - doWriteConvertHeaderDefinition("convertHeaderTo", def); - } - public void writeConvertVariableDefinition(ConvertVariableDefinition def) throws IOException { - doWriteConvertVariableDefinition("convertVariableTo", def); - } - public void writeDelayDefinition(DelayDefinition def) throws IOException { - doWriteDelayDefinition("delay", def); - } - public void writeDynamicRouterDefinition(DynamicRouterDefinition def) throws IOException { - doWriteDynamicRouterDefinition("dynamicRouter", def); - } - public void writeEnrichDefinition(EnrichDefinition def) throws IOException { - doWriteEnrichDefinition("enrich", def); - } - public void writeErrorHandlerDefinition(ErrorHandlerDefinition def) throws IOException { - doWriteErrorHandlerDefinition("errorHandler", def); - } - public void writeExpressionSubElementDefinition(ExpressionSubElementDefinition def) throws IOException { - doWriteExpressionSubElementDefinition("expression", def); - } - public void writeFaultToleranceConfigurationDefinition(FaultToleranceConfigurationDefinition def) throws IOException { - doWriteFaultToleranceConfigurationDefinition("faultToleranceConfiguration", def); - } - public void writeFilterDefinition(FilterDefinition def) throws IOException { - doWriteFilterDefinition("filter", def); - } - public void writeFinallyDefinition(FinallyDefinition def) throws IOException { - doWriteFinallyDefinition("doFinally", def); - } - public void writeFromDefinition(FromDefinition def) throws IOException { - doWriteFromDefinition("from", def); - } - public void writeGlobalOptionDefinition(GlobalOptionDefinition def) throws IOException { - doWriteGlobalOptionDefinition("globalOption", def); - } - public void writeGlobalOptionsDefinition(GlobalOptionsDefinition def) throws IOException { - doWriteGlobalOptionsDefinition("globalOptions", def); - } - public void writeIdempotentConsumerDefinition(IdempotentConsumerDefinition def) throws IOException { - doWriteIdempotentConsumerDefinition("idempotentConsumer", def); - } - public void writeInputTypeDefinition(InputTypeDefinition def) throws IOException { - doWriteInputTypeDefinition("inputType", def); - } - public void writeInterceptDefinition(InterceptDefinition def) throws IOException { - doWriteInterceptDefinition("intercept", def); - } - public void writeInterceptFromDefinition(InterceptFromDefinition def) throws IOException { - doWriteInterceptFromDefinition("interceptFrom", def); - } - public void writeInterceptSendToEndpointDefinition(InterceptSendToEndpointDefinition def) throws IOException { - doWriteInterceptSendToEndpointDefinition("interceptSendToEndpoint", def); - } - public void writeKameletDefinition(KameletDefinition def) throws IOException { - doWriteKameletDefinition("kamelet", def); - } - public void writeLoadBalanceDefinition(LoadBalanceDefinition def) throws IOException { - doWriteLoadBalanceDefinition("loadBalance", def); - } - public void writeLogDefinition(LogDefinition def) throws IOException { - doWriteLogDefinition("log", def); - } - public void writeLoopDefinition(LoopDefinition def) throws IOException { - doWriteLoopDefinition("loop", def); - } - public void writeMarshalDefinition(MarshalDefinition def) throws IOException { - doWriteMarshalDefinition("marshal", def); - } - public void writeMulticastDefinition(MulticastDefinition def) throws IOException { - doWriteMulticastDefinition("multicast", def); - } - public void writeOnCompletionDefinition(OnCompletionDefinition def) throws IOException { - doWriteOnCompletionDefinition("onCompletion", def); - } - public void writeOnExceptionDefinition(OnExceptionDefinition def) throws IOException { - doWriteOnExceptionDefinition("onException", def); - } - public void writeOnFallbackDefinition(OnFallbackDefinition def) throws IOException { - doWriteOnFallbackDefinition("onFallback", def); - } - public void writeOnWhenDefinition(OnWhenDefinition def) throws IOException { - doWriteOnWhenDefinition("onWhen", def); - } - public void writeOptimisticLockRetryPolicyDefinition(OptimisticLockRetryPolicyDefinition def) throws IOException { - doWriteOptimisticLockRetryPolicyDefinition("optimisticLockRetryPolicy", def); - } - public void writeOtherwiseDefinition(OtherwiseDefinition def) throws IOException { - doWriteOtherwiseDefinition("otherwise", def); - } - public void writeOutputTypeDefinition(OutputTypeDefinition def) throws IOException { - doWriteOutputTypeDefinition("outputType", def); - } - public void writePackageScanDefinition(PackageScanDefinition def) throws IOException { - doWritePackageScanDefinition("packageScan", def); - } - public void writePausableDefinition(PausableDefinition def) throws IOException { - doWritePausableDefinition("pausable", def); - } - public void writePipelineDefinition(PipelineDefinition def) throws IOException { - doWritePipelineDefinition("pipeline", def); - } - public void writePolicyDefinition(PolicyDefinition def) throws IOException { - doWritePolicyDefinition("policy", def); - } - public void writePollDefinition(PollDefinition def) throws IOException { - doWritePollDefinition("poll", def); - } - public void writePollEnrichDefinition(PollEnrichDefinition def) throws IOException { - doWritePollEnrichDefinition("pollEnrich", def); - } - public void writeProcessDefinition(ProcessDefinition def) throws IOException { - doWriteProcessDefinition("process", def); - } - public void writePropertyDefinition(PropertyDefinition def) throws IOException { - doWritePropertyDefinition("property", def); - } - public void writePropertyExpressionDefinition(PropertyExpressionDefinition def) throws IOException { - doWritePropertyExpressionDefinition("propertyExpression", def); - } - public void writeRecipientListDefinition(RecipientListDefinition def) throws IOException { - doWriteRecipientListDefinition("recipientList", def); - } - public void writeRedeliveryPolicyDefinition(RedeliveryPolicyDefinition def) throws IOException { - doWriteRedeliveryPolicyDefinition("redeliveryPolicy", def); - } - public void writeRemoveHeaderDefinition(RemoveHeaderDefinition def) throws IOException { - doWriteRemoveHeaderDefinition("removeHeader", def); - } - public void writeRemoveHeadersDefinition(RemoveHeadersDefinition def) throws IOException { - doWriteRemoveHeadersDefinition("removeHeaders", def); - } - public void writeRemovePropertiesDefinition(RemovePropertiesDefinition def) throws IOException { - doWriteRemovePropertiesDefinition("removeProperties", def); - } - public void writeRemovePropertyDefinition(RemovePropertyDefinition def) throws IOException { - doWriteRemovePropertyDefinition("removeProperty", def); - } - public void writeRemoveVariableDefinition(RemoveVariableDefinition def) throws IOException { - doWriteRemoveVariableDefinition("removeVariable", def); - } - public void writeResequenceDefinition(ResequenceDefinition def) throws IOException { - doWriteResequenceDefinition("resequence", def); - } - public void writeResilience4jConfigurationDefinition(Resilience4jConfigurationDefinition def) throws IOException { - doWriteResilience4jConfigurationDefinition("resilience4jConfiguration", def); - } - public void writeRestContextRefDefinition(RestContextRefDefinition def) throws IOException { - doWriteRestContextRefDefinition("restContextRef", def); - } - public void writeResumableDefinition(ResumableDefinition def) throws IOException { - doWriteResumableDefinition("resumable", def); - } - public void writeRollbackDefinition(RollbackDefinition def) throws IOException { - doWriteRollbackDefinition("rollback", def); - } - public void writeRouteBuilderDefinition(RouteBuilderDefinition def) throws IOException { - doWriteRouteBuilderDefinition("routeBuilder", def); - } - public void writeRouteConfigurationContextRefDefinition(RouteConfigurationContextRefDefinition def) throws IOException { - doWriteRouteConfigurationContextRefDefinition("routeConfigurationContextRef", def); - } - public void writeRouteConfigurationDefinition(RouteConfigurationDefinition def) throws IOException { - doWriteRouteConfigurationDefinition("routeConfiguration", def); - } - public void writeRouteConfigurationsDefinition(RouteConfigurationsDefinition def) throws IOException { - doWriteRouteConfigurationsDefinition("routeConfigurations", def); - } - public void writeRouteContextRefDefinition(RouteContextRefDefinition def) throws IOException { - doWriteRouteContextRefDefinition("routeContextRef", def); - } - public void writeRouteDefinition(RouteDefinition def) throws IOException { - doWriteRouteDefinition("route", def); - } - public void writeRouteTemplateContextRefDefinition(RouteTemplateContextRefDefinition def) throws IOException { - doWriteRouteTemplateContextRefDefinition("routeTemplateContextRef", def); - } - public void writeRouteTemplateDefinition(RouteTemplateDefinition def) throws IOException { - doWriteRouteTemplateDefinition("routeTemplate", def); - } - public void writeRouteTemplateParameterDefinition(RouteTemplateParameterDefinition def) throws IOException { - doWriteRouteTemplateParameterDefinition("templateParameter", def); - } - public void writeRouteTemplatesDefinition(RouteTemplatesDefinition def) throws IOException { - doWriteRouteTemplatesDefinition("routeTemplates", def); - } - public void writeRoutesDefinition(RoutesDefinition def) throws IOException { - doWriteRoutesDefinition("routes", def); - } - public void writeRoutingSlipDefinition(RoutingSlipDefinition def) throws IOException { - doWriteRoutingSlipDefinition("routingSlip", def); - } - public void writeSagaDefinition(SagaDefinition def) throws IOException { - doWriteSagaDefinition("saga", def); - } - public void writeSamplingDefinition(SamplingDefinition def) throws IOException { - doWriteSamplingDefinition("sample", def); - } - public void writeScriptDefinition(ScriptDefinition def) throws IOException { - doWriteScriptDefinition("script", def); - } - public void writeSetBodyDefinition(SetBodyDefinition def) throws IOException { - doWriteSetBodyDefinition("setBody", def); - } - public void writeSetExchangePatternDefinition(SetExchangePatternDefinition def) throws IOException { - doWriteSetExchangePatternDefinition("setExchangePattern", def); - } - public void writeSetHeaderDefinition(SetHeaderDefinition def) throws IOException { - doWriteSetHeaderDefinition("setHeader", def); - } - public void writeSetHeadersDefinition(SetHeadersDefinition def) throws IOException { - doWriteSetHeadersDefinition("setHeaders", def); - } - public void writeSetPropertyDefinition(SetPropertyDefinition def) throws IOException { - doWriteSetPropertyDefinition("setProperty", def); - } - public void writeSetVariableDefinition(SetVariableDefinition def) throws IOException { - doWriteSetVariableDefinition("setVariable", def); - } - public void writeSetVariablesDefinition(SetVariablesDefinition def) throws IOException { - doWriteSetVariablesDefinition("setVariables", def); - } - public void writeSortDefinition(SortDefinition def) throws IOException { - doWriteSortDefinition("sort", def); - } - public void writeSplitDefinition(SplitDefinition def) throws IOException { - doWriteSplitDefinition("split", def); - } - public void writeStepDefinition(StepDefinition def) throws IOException { - doWriteStepDefinition("step", def); - } - public void writeStopDefinition(StopDefinition def) throws IOException { - doWriteStopDefinition("stop", def); - } - public void writeTemplatedRouteDefinition(TemplatedRouteDefinition def) throws IOException { - doWriteTemplatedRouteDefinition("templatedRoute", def); - } - public void writeTemplatedRouteParameterDefinition(TemplatedRouteParameterDefinition def) throws IOException { - doWriteTemplatedRouteParameterDefinition("templatedRouteParameter", def); - } - public void writeTemplatedRoutesDefinition(TemplatedRoutesDefinition def) throws IOException { - doWriteTemplatedRoutesDefinition("templatedRoutes", def); - } - public void writeThreadPoolProfileDefinition(ThreadPoolProfileDefinition def) throws IOException { - doWriteThreadPoolProfileDefinition("threadPoolProfile", def); - } - public void writeThreadsDefinition(ThreadsDefinition def) throws IOException { - doWriteThreadsDefinition("threads", def); - } - public void writeThrottleDefinition(ThrottleDefinition def) throws IOException { - doWriteThrottleDefinition("throttle", def); - } - public void writeThrowExceptionDefinition(ThrowExceptionDefinition def) throws IOException { - doWriteThrowExceptionDefinition("throwException", def); - } - public void writeToDefinition(ToDefinition def) throws IOException { - doWriteToDefinition("to", def); - } - public void writeToDynamicDefinition(ToDynamicDefinition def) throws IOException { - doWriteToDynamicDefinition("toD", def); - } - public void writeTokenizerDefinition(TokenizerDefinition def) throws IOException { - doWriteTokenizerDefinition("tokenizer", def); - } - public void writeTransactedDefinition(TransactedDefinition def) throws IOException { - doWriteTransactedDefinition("transacted", def); - } - public void writeTransformDataTypeDefinition(TransformDataTypeDefinition def) throws IOException { - doWriteTransformDataTypeDefinition("transformDataType", def); - } - public void writeTransformDefinition(TransformDefinition def) throws IOException { - doWriteTransformDefinition("transform", def); - } - public void writeTryDefinition(TryDefinition def) throws IOException { - doWriteTryDefinition("doTry", def); - } - public void writeUnmarshalDefinition(UnmarshalDefinition def) throws IOException { - doWriteUnmarshalDefinition("unmarshal", def); - } - public void writeValidateDefinition(ValidateDefinition def) throws IOException { - doWriteValidateDefinition("validate", def); - } - public void writeValueDefinition(ValueDefinition def) throws IOException { - doWriteValueDefinition("value", def); - } - public void writeWhenDefinition(WhenDefinition def) throws IOException { - doWriteWhenDefinition("when", def); - } - public void writeWireTapDefinition(WireTapDefinition def) throws IOException { - doWriteWireTapDefinition("wireTap", def); - } - public void writeApplicationDefinition(ApplicationDefinition def) throws IOException { - doWriteApplicationDefinition("camel", def); - } - public void writeBeansDefinition(BeansDefinition def) throws IOException { - doWriteBeansDefinition("beans", def); - } - public void writeBatchResequencerConfig(BatchResequencerConfig def) throws IOException { - doWriteBatchResequencerConfig("batchConfig", def); - } - public void writeStreamResequencerConfig(StreamResequencerConfig def) throws IOException { - doWriteStreamResequencerConfig("streamConfig", def); - } - public void writeASN1DataFormat(ASN1DataFormat def) throws IOException { - doWriteASN1DataFormat("asn1", def); - } - public void writeAvroDataFormat(AvroDataFormat def) throws IOException { - doWriteAvroDataFormat("avro", def); - } - public void writeBarcodeDataFormat(BarcodeDataFormat def) throws IOException { - doWriteBarcodeDataFormat("barcode", def); - } - public void writeBase64DataFormat(Base64DataFormat def) throws IOException { - doWriteBase64DataFormat("base64", def); - } - public void writeBeanioDataFormat(BeanioDataFormat def) throws IOException { - doWriteBeanioDataFormat("beanio", def); - } - public void writeBindyDataFormat(BindyDataFormat def) throws IOException { - doWriteBindyDataFormat("bindy", def); - } - public void writeCBORDataFormat(CBORDataFormat def) throws IOException { - doWriteCBORDataFormat("cbor", def); - } - public void writeCryptoDataFormat(CryptoDataFormat def) throws IOException { - doWriteCryptoDataFormat("crypto", def); - } - public void writeCsvDataFormat(CsvDataFormat def) throws IOException { - doWriteCsvDataFormat("csv", def); - } - public void writeCustomDataFormat(CustomDataFormat def) throws IOException { - doWriteCustomDataFormat("custom", def); - } - public void writeDataFormatsDefinition(DataFormatsDefinition def) throws IOException { - doWriteDataFormatsDefinition("dataFormats", def); - } - public void writeDfdlDataFormat(DfdlDataFormat def) throws IOException { - doWriteDfdlDataFormat("dfdl", def); - } - public void writeFhirJsonDataFormat(FhirJsonDataFormat def) throws IOException { - doWriteFhirJsonDataFormat("fhirJson", def); - } - public void writeFhirXmlDataFormat(FhirXmlDataFormat def) throws IOException { - doWriteFhirXmlDataFormat("fhirXml", def); - } - public void writeFlatpackDataFormat(FlatpackDataFormat def) throws IOException { - doWriteFlatpackDataFormat("flatpack", def); - } - public void writeForyDataFormat(ForyDataFormat def) throws IOException { - doWriteForyDataFormat("fory", def); - } - public void writeGrokDataFormat(GrokDataFormat def) throws IOException { - doWriteGrokDataFormat("grok", def); - } - public void writeGroovyJSonDataFormat(GroovyJSonDataFormat def) throws IOException { - doWriteGroovyJSonDataFormat("groovyJson", def); - } - public void writeGroovyXmlDataFormat(GroovyXmlDataFormat def) throws IOException { - doWriteGroovyXmlDataFormat("groovyXml", def); - } - public void writeGzipDeflaterDataFormat(GzipDeflaterDataFormat def) throws IOException { - doWriteGzipDeflaterDataFormat("gzipDeflater", def); - } - public void writeHL7DataFormat(HL7DataFormat def) throws IOException { - doWriteHL7DataFormat("hl7", def); - } - public void writeIcalDataFormat(IcalDataFormat def) throws IOException { - doWriteIcalDataFormat("ical", def); - } - public void writeIso8583DataFormat(Iso8583DataFormat def) throws IOException { - doWriteIso8583DataFormat("iso8583", def); - } - public void writeJacksonXMLDataFormat(JacksonXMLDataFormat def) throws IOException { - doWriteJacksonXMLDataFormat("jacksonXml", def); - } - public void writeJaxbDataFormat(JaxbDataFormat def) throws IOException { - doWriteJaxbDataFormat("jaxb", def); - } - public void writeJsonApiDataFormat(JsonApiDataFormat def) throws IOException { - doWriteJsonApiDataFormat("jsonApi", def); - } - public void writeJsonDataFormat(JsonDataFormat def) throws IOException { - doWriteJsonDataFormat("json", def); - } - public void writeLZFDataFormat(LZFDataFormat def) throws IOException { - doWriteLZFDataFormat("lzf", def); - } - public void writeMimeMultipartDataFormat(MimeMultipartDataFormat def) throws IOException { - doWriteMimeMultipartDataFormat("mimeMultipart", def); - } - public void writeOcsfDataFormat(OcsfDataFormat def) throws IOException { - doWriteOcsfDataFormat("ocsf", def); - } - public void writePGPDataFormat(PGPDataFormat def) throws IOException { - doWritePGPDataFormat("pgp", def); - } - public void writePQCDataFormat(PQCDataFormat def) throws IOException { - doWritePQCDataFormat("pqc", def); - } - public void writeParquetAvroDataFormat(ParquetAvroDataFormat def) throws IOException { - doWriteParquetAvroDataFormat("parquetAvro", def); - } - public void writeProtobufDataFormat(ProtobufDataFormat def) throws IOException { - doWriteProtobufDataFormat("protobuf", def); - } - public void writeRssDataFormat(RssDataFormat def) throws IOException { - doWriteRssDataFormat("rss", def); - } - public void writeSmooksDataFormat(SmooksDataFormat def) throws IOException { - doWriteSmooksDataFormat("smooks", def); - } - public void writeSoapDataFormat(SoapDataFormat def) throws IOException { - doWriteSoapDataFormat("soap", def); - } - public void writeSwiftMtDataFormat(SwiftMtDataFormat def) throws IOException { - doWriteSwiftMtDataFormat("swiftMt", def); - } - public void writeSwiftMxDataFormat(SwiftMxDataFormat def) throws IOException { - doWriteSwiftMxDataFormat("swiftMx", def); - } - public void writeSyslogDataFormat(SyslogDataFormat def) throws IOException { - doWriteSyslogDataFormat("syslog", def); - } - public void writeTarFileDataFormat(TarFileDataFormat def) throws IOException { - doWriteTarFileDataFormat("tarFile", def); - } - public void writeThriftDataFormat(ThriftDataFormat def) throws IOException { - doWriteThriftDataFormat("thrift", def); - } - public void writeUniVocityCsvDataFormat(UniVocityCsvDataFormat def) throws IOException { - doWriteUniVocityCsvDataFormat("univocityCsv", def); - } - public void writeUniVocityFixedDataFormat(UniVocityFixedDataFormat def) throws IOException { - doWriteUniVocityFixedDataFormat("univocityFixed", def); - } - public void writeUniVocityHeader(UniVocityHeader def) throws IOException { - doWriteUniVocityHeader("univocityHeader", def); - } - public void writeUniVocityTsvDataFormat(UniVocityTsvDataFormat def) throws IOException { - doWriteUniVocityTsvDataFormat("univocityTsv", def); - } - public void writeXMLSecurityDataFormat(XMLSecurityDataFormat def) throws IOException { - doWriteXMLSecurityDataFormat("xmlSecurity", def); - } - public void writeYAMLDataFormat(YAMLDataFormat def) throws IOException { - doWriteYAMLDataFormat("yaml", def); - } - public void writeZipDeflaterDataFormat(ZipDeflaterDataFormat def) throws IOException { - doWriteZipDeflaterDataFormat("zipDeflater", def); - } - public void writeZipFileDataFormat(ZipFileDataFormat def) throws IOException { - doWriteZipFileDataFormat("zipFile", def); - } - public void writeDeadLetterChannelDefinition(DeadLetterChannelDefinition def) throws IOException { - doWriteDeadLetterChannelDefinition("deadLetterChannel", def); - } - public void writeDefaultErrorHandlerDefinition(DefaultErrorHandlerDefinition def) throws IOException { - doWriteDefaultErrorHandlerDefinition("defaultErrorHandler", def); - } - public void writeJtaTransactionErrorHandlerDefinition(JtaTransactionErrorHandlerDefinition def) throws IOException { - doWriteJtaTransactionErrorHandlerDefinition("jtaTransactionErrorHandler", def); - } - public void writeNoErrorHandlerDefinition(NoErrorHandlerDefinition def) throws IOException { - doWriteNoErrorHandlerDefinition("noErrorHandler", def); - } - public void writeRefErrorHandlerDefinition(RefErrorHandlerDefinition def) throws IOException { - doWriteRefErrorHandlerDefinition("refErrorHandler", def); - } - public void writeSpringTransactionErrorHandlerDefinition(SpringTransactionErrorHandlerDefinition def) throws IOException { - doWriteSpringTransactionErrorHandlerDefinition("springTransactionErrorHandler", def); - } - public void writeCSimpleExpression(CSimpleExpression def) throws IOException { - doWriteCSimpleExpression("csimple", def); - } - public void writeConstantExpression(ConstantExpression def) throws IOException { - doWriteConstantExpression("constant", def); - } - public void writeDatasonnetExpression(DatasonnetExpression def) throws IOException { - doWriteDatasonnetExpression("datasonnet", def); - } - public void writeExchangePropertyExpression(ExchangePropertyExpression def) throws IOException { - doWriteExchangePropertyExpression("exchangeProperty", def); - } - public void writeExpressionDefinition(ExpressionDefinition def) throws IOException { - doWriteExpressionDefinition("##default", def); - } - public void writeGroovyExpression(GroovyExpression def) throws IOException { - doWriteGroovyExpression("groovy", def); - } - public void writeHeaderExpression(HeaderExpression def) throws IOException { - doWriteHeaderExpression("header", def); - } - public void writeHl7TerserExpression(Hl7TerserExpression def) throws IOException { - doWriteHl7TerserExpression("hl7terser", def); - } - public void writeJavaExpression(JavaExpression def) throws IOException { - doWriteJavaExpression("java", def); - } - public void writeJavaScriptExpression(JavaScriptExpression def) throws IOException { - doWriteJavaScriptExpression("js", def); - } - public void writeJoorExpression(JoorExpression def) throws IOException { - doWriteJoorExpression("joor", def); - } - public void writeJqExpression(JqExpression def) throws IOException { - doWriteJqExpression("jq", def); - } - public void writeJsonPathExpression(JsonPathExpression def) throws IOException { - doWriteJsonPathExpression("jsonpath", def); - } - public void writeLanguageExpression(LanguageExpression def) throws IOException { - doWriteLanguageExpression("language", def); - } - public void writeMethodCallExpression(MethodCallExpression def) throws IOException { - doWriteMethodCallExpression("method", def); - } - public void writeMvelExpression(MvelExpression def) throws IOException { - doWriteMvelExpression("mvel", def); - } - public void writeOgnlExpression(OgnlExpression def) throws IOException { - doWriteOgnlExpression("ognl", def); - } - public void writePythonExpression(PythonExpression def) throws IOException { - doWritePythonExpression("python", def); - } - public void writeRefExpression(RefExpression def) throws IOException { - doWriteRefExpression("ref", def); - } - public void writeSimpleExpression(SimpleExpression def) throws IOException { - doWriteSimpleExpression("simple", def); - } - public void writeSpELExpression(SpELExpression def) throws IOException { - doWriteSpELExpression("spel", def); - } - public void writeTokenizerExpression(TokenizerExpression def) throws IOException { - doWriteTokenizerExpression("tokenize", def); - } - public void writeVariableExpression(VariableExpression def) throws IOException { - doWriteVariableExpression("variable", def); - } - public void writeWasmExpression(WasmExpression def) throws IOException { - doWriteWasmExpression("wasm", def); - } - public void writeXMLTokenizerExpression(XMLTokenizerExpression def) throws IOException { - doWriteXMLTokenizerExpression("xtokenize", def); - } - public void writeXPathExpression(XPathExpression def) throws IOException { - doWriteXPathExpression("xpath", def); - } - public void writeXQueryExpression(XQueryExpression def) throws IOException { - doWriteXQueryExpression("xquery", def); - } - public void writeCustomLoadBalancerDefinition(CustomLoadBalancerDefinition def) throws IOException { - doWriteCustomLoadBalancerDefinition("customLoadBalancer", def); - } - public void writeFailoverLoadBalancerDefinition(FailoverLoadBalancerDefinition def) throws IOException { - doWriteFailoverLoadBalancerDefinition("failoverLoadBalancer", def); - } - public void writeRandomLoadBalancerDefinition(RandomLoadBalancerDefinition def) throws IOException { - doWriteRandomLoadBalancerDefinition("randomLoadBalancer", def); - } - public void writeRoundRobinLoadBalancerDefinition(RoundRobinLoadBalancerDefinition def) throws IOException { - doWriteRoundRobinLoadBalancerDefinition("roundRobinLoadBalancer", def); - } - public void writeStickyLoadBalancerDefinition(StickyLoadBalancerDefinition def) throws IOException { - doWriteStickyLoadBalancerDefinition("stickyLoadBalancer", def); - } - public void writeTopicLoadBalancerDefinition(TopicLoadBalancerDefinition def) throws IOException { - doWriteTopicLoadBalancerDefinition("topicLoadBalancer", def); - } - public void writeWeightedLoadBalancerDefinition(WeightedLoadBalancerDefinition def) throws IOException { - doWriteWeightedLoadBalancerDefinition("weightedLoadBalancer", def); - } - public void writeApiKeyDefinition(ApiKeyDefinition def) throws IOException { - doWriteApiKeyDefinition("apiKey", def); - } - public void writeBasicAuthDefinition(BasicAuthDefinition def) throws IOException { - doWriteBasicAuthDefinition("basicAuth", def); - } - public void writeBearerTokenDefinition(BearerTokenDefinition def) throws IOException { - doWriteBearerTokenDefinition("bearerToken", def); - } - public void writeDeleteDefinition(DeleteDefinition def) throws IOException { - doWriteDeleteDefinition("delete", def); - } - public void writeGetDefinition(GetDefinition def) throws IOException { - doWriteGetDefinition("get", def); - } - public void writeHeadDefinition(HeadDefinition def) throws IOException { - doWriteHeadDefinition("head", def); - } - public void writeMutualTLSDefinition(MutualTLSDefinition def) throws IOException { - doWriteMutualTLSDefinition("mutualTLS", def); - } - public void writeOAuth2Definition(OAuth2Definition def) throws IOException { - doWriteOAuth2Definition("oauth2", def); - } - public void writeOpenApiDefinition(OpenApiDefinition def) throws IOException { - doWriteOpenApiDefinition("openApi", def); - } - public void writeOpenIdConnectDefinition(OpenIdConnectDefinition def) throws IOException { - doWriteOpenIdConnectDefinition("openIdConnect", def); - } - public void writeParamDefinition(ParamDefinition def) throws IOException { - doWriteParamDefinition("param", def); - } - public void writePatchDefinition(PatchDefinition def) throws IOException { - doWritePatchDefinition("patch", def); - } - public void writePostDefinition(PostDefinition def) throws IOException { - doWritePostDefinition("post", def); - } - public void writePutDefinition(PutDefinition def) throws IOException { - doWritePutDefinition("put", def); - } - public void writeResponseHeaderDefinition(ResponseHeaderDefinition def) throws IOException { - doWriteResponseHeaderDefinition("responseHeader", def); - } - public void writeResponseMessageDefinition(ResponseMessageDefinition def) throws IOException { - doWriteResponseMessageDefinition("responseMessage", def); - } - public void writeRestBindingDefinition(RestBindingDefinition def) throws IOException { - doWriteRestBindingDefinition("restBinding", def); - } - public void writeRestConfigurationDefinition(RestConfigurationDefinition def) throws IOException { - doWriteRestConfigurationDefinition("restConfiguration", def); - } - public void writeRestDefinition(RestDefinition def) throws IOException { - doWriteRestDefinition("rest", def); - } - public void writeRestPropertyDefinition(RestPropertyDefinition def) throws IOException { - doWriteRestPropertyDefinition("restProperty", def); - } - public void writeRestSecuritiesDefinition(RestSecuritiesDefinition def) throws IOException { - doWriteRestSecuritiesDefinition("securityDefinitions", def); - } - public void writeRestsDefinition(RestsDefinition def) throws IOException { - doWriteRestsDefinition("rests", def); - } - public void writeSecurityDefinition(SecurityDefinition def) throws IOException { - doWriteSecurityDefinition("security", def); - } - public void writeLangChain4jCharacterTokenizerDefinition(LangChain4jCharacterTokenizerDefinition def) throws IOException { - doWriteLangChain4jCharacterTokenizerDefinition("langChain4jCharacterTokenizer", def); - } - public void writeLangChain4jLineTokenizerDefinition(LangChain4jLineTokenizerDefinition def) throws IOException { - doWriteLangChain4jLineTokenizerDefinition("langChain4jLineTokenizer", def); - } - public void writeLangChain4jParagraphTokenizerDefinition(LangChain4jParagraphTokenizerDefinition def) throws IOException { - doWriteLangChain4jParagraphTokenizerDefinition("langChain4jParagraphTokenizer", def); - } - public void writeLangChain4jSentenceTokenizerDefinition(LangChain4jSentenceTokenizerDefinition def) throws IOException { - doWriteLangChain4jSentenceTokenizerDefinition("langChain4jSentenceTokenizer", def); - } - public void writeLangChain4jWordTokenizerDefinition(LangChain4jWordTokenizerDefinition def) throws IOException { - doWriteLangChain4jWordTokenizerDefinition("langChain4jWordTokenizer", def); - } - public void writeCustomTransformerDefinition(CustomTransformerDefinition def) throws IOException { - doWriteCustomTransformerDefinition("customTransformer", def); - } - public void writeDataFormatTransformerDefinition(DataFormatTransformerDefinition def) throws IOException { - doWriteDataFormatTransformerDefinition("dataFormatTransformer", def); - } - public void writeEndpointTransformerDefinition(EndpointTransformerDefinition def) throws IOException { - doWriteEndpointTransformerDefinition("endpointTransformer", def); - } - public void writeLoadTransformerDefinition(LoadTransformerDefinition def) throws IOException { - doWriteLoadTransformerDefinition("loadTransformer", def); - } - public void writeTransformersDefinition(TransformersDefinition def) throws IOException { - doWriteTransformersDefinition("transformers", def); - } - public void writeCustomValidatorDefinition(CustomValidatorDefinition def) throws IOException { - doWriteCustomValidatorDefinition("customValidator", def); - } - public void writeEndpointValidatorDefinition(EndpointValidatorDefinition def) throws IOException { - doWriteEndpointValidatorDefinition("endpointValidator", def); - } - public void writePredicateValidatorDefinition(PredicateValidatorDefinition def) throws IOException { - doWritePredicateValidatorDefinition("predicateValidator", def); - } - public void writeValidatorsDefinition(ValidatorsDefinition def) throws IOException { - doWriteValidatorsDefinition("validators", def); - } - - public void writeOptionalIdentifiedDefinitionRef(OptionalIdentifiedDefinition def) throws IOException { - doWriteOptionalIdentifiedDefinitionRef(null, def); - } - - protected void doWriteAggregateDefinition(String name, AggregateDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("parallelProcessing", def.getParallelProcessing(), null); - doWriteAttribute("optimisticLocking", def.getOptimisticLocking(), null); - doWriteAttribute("optimisticLockingSyncRetry", def.getOptimisticLockingSyncRetry(), "false"); - doWriteAttribute("executorService", def.getExecutorService(), null); - doWriteAttribute("timeoutCheckerExecutorService", def.getTimeoutCheckerExecutorService(), null); - doWriteAttribute("aggregateController", def.getAggregateController(), null); - doWriteAttribute("aggregationRepository", def.getAggregationRepository(), null); - doWriteAttribute("aggregationStrategy", def.getAggregationStrategy(), null); - doWriteAttribute("aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); - doWriteAttribute("aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); - doWriteAttribute("completionSize", def.getCompletionSize(), null); - doWriteAttribute("completionInterval", def.getCompletionInterval(), null); - doWriteAttribute("completionTimeout", def.getCompletionTimeout(), null); - doWriteAttribute("completionTimeoutCheckerInterval", def.getCompletionTimeoutCheckerInterval(), "1000"); - doWriteAttribute("completionFromBatchConsumer", def.getCompletionFromBatchConsumer(), null); - doWriteAttribute("completionOnNewCorrelationGroup", def.getCompletionOnNewCorrelationGroup(), null); - doWriteAttribute("eagerCheckCompletion", def.getEagerCheckCompletion(), null); - doWriteAttribute("ignoreInvalidCorrelationKeys", def.getIgnoreInvalidCorrelationKeys(), null); - doWriteAttribute("closeCorrelationKeyOnCompletion", def.getCloseCorrelationKeyOnCompletion(), null); - doWriteAttribute("discardOnCompletionTimeout", def.getDiscardOnCompletionTimeout(), null); - doWriteAttribute("discardOnAggregationFailure", def.getDiscardOnAggregationFailure(), null); - doWriteAttribute("forceCompletionOnStop", def.getForceCompletionOnStop(), null); - doWriteAttribute("completeAllOnStop", def.getCompleteAllOnStop(), null); - doWriteElement("optimisticLockRetryPolicy", def.getOptimisticLockRetryPolicyDefinition(), this::doWriteOptimisticLockRetryPolicyDefinition); - doWriteElement("correlationExpression", def.getCorrelationExpression(), this::doWriteExpressionSubElementDefinition); - doWriteElement("completionPredicate", def.getCompletionPredicate(), this::doWriteExpressionSubElementDefinition); - doWriteElement("completionTimeoutExpression", def.getCompletionTimeoutExpression(), this::doWriteExpressionSubElementDefinition); - doWriteElement("completionSizeExpression", def.getCompletionSizeExpression(), this::doWriteExpressionSubElementDefinition); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteBasicExpressionNodeElements(BasicExpressionNode def) throws IOException { - doWriteElement(null, def.getExpression(), this::doWriteExpressionDefinitionRef); - } - protected void doWriteBasicExpressionNode(String name, BasicExpressionNode def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteBasicExpressionNodeElements(def); - endElement(name); - } - protected void doWriteBasicOutputExpressionNodeElements(BasicOutputExpressionNode def) throws IOException { - doWriteBasicExpressionNodeElements(def); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - } - protected void doWriteBasicOutputExpressionNode(String name, BasicOutputExpressionNode def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteBasicOutputExpressionNodeElements(def); - endElement(name); - } - protected void doWriteBeanDefinition(String name, BeanDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - doWriteAttribute("method", def.getMethod(), null); - doWriteAttribute("beanType", def.getBeanType(), null); - doWriteAttribute("scope", def.getScope(), "Singleton"); - endElement(name); - } - protected void doWriteBeanFactoryDefinition(String name, BeanFactoryDefinition def) throws IOException { - startElement(name); - doWriteAttribute("name", def.getName(), null); - doWriteAttribute("type", def.getType(), null); - doWriteAttribute("initMethod", def.getInitMethod(), null); - doWriteAttribute("destroyMethod", def.getDestroyMethod(), null); - doWriteAttribute("factoryMethod", def.getFactoryMethod(), null); - doWriteAttribute("factoryBean", def.getFactoryBean(), null); - doWriteAttribute("builderClass", def.getBuilderClass(), null); - doWriteAttribute("builderMethod", def.getBuilderMethod(), "build"); - doWriteAttribute("scriptLanguage", def.getScriptLanguage(), null); - doWriteAttribute("scriptPropertyPlaceholders", def.getScriptPropertyPlaceholders(), "true"); - doWriteElement("constructors", new BeanConstructorsAdapter().marshal(def.getConstructors()), this::doWriteBeanConstructorsDefinition); - doWriteElement("properties", new BeanPropertiesAdapter().marshal(def.getProperties()), this::doWriteBeanPropertiesDefinition); - doWriteElement("script", def.getScript(), this::doWriteString); - endElement(name); - } - protected void doWriteCatchDefinition(String name, CatchDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteList(null, "exception", def.getExceptions(), this::doWriteString); - doWriteElement("onWhen", def.getOnWhen(), this::doWriteOnWhenDefinition); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteChoiceDefinition(String name, ChoiceDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("precondition", def.getPrecondition(), "false"); - doWriteList(null, null, def.getWhenClauses(), this::doWriteWhenDefinitionRef); - doWriteElement("otherwise", def.getOtherwise(), this::doWriteOtherwiseDefinition); - endElement(name); - } - protected void doWriteCircuitBreakerDefinition(String name, CircuitBreakerDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("configuration", def.getConfiguration(), null); - doWriteAttribute("inheritErrorHandler", toString(def.getInheritErrorHandler()), "false"); - doWriteElement("resilience4jConfiguration", def.getResilience4jConfiguration(), this::doWriteResilience4jConfigurationDefinition); - doWriteElement("faultToleranceConfiguration", def.getFaultToleranceConfiguration(), this::doWriteFaultToleranceConfigurationDefinition); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - doWriteElement("onFallback", def.getOnFallback(), this::doWriteOnFallbackDefinition); - endElement(name); - } - protected void doWriteClaimCheckDefinition(String name, ClaimCheckDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("operation", def.getOperation(), null); - doWriteAttribute("key", def.getKey(), null); - doWriteAttribute("filter", def.getFilter(), null); - doWriteAttribute("aggregationStrategy", def.getAggregationStrategy(), null); - doWriteAttribute("aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); - endElement(name); - } - protected void doWriteContextScanDefinition(String name, ContextScanDefinition def) throws IOException { - startElement(name); - doWriteAttribute("includeNonSingletons", def.getIncludeNonSingletons(), null); - doWriteList(null, "excludes", def.getExcludes(), this::doWriteString); - doWriteList(null, "includes", def.getIncludes(), this::doWriteString); - endElement(name); - } - protected void doWriteConvertBodyDefinition(String name, ConvertBodyDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("type", def.getType(), null); - doWriteAttribute("mandatory", def.getMandatory(), "true"); - doWriteAttribute("charset", def.getCharset(), null); - endElement(name); - } - protected void doWriteConvertHeaderDefinition(String name, ConvertHeaderDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("name", def.getName(), null); - doWriteAttribute("type", def.getType(), null); - doWriteAttribute("toName", def.getToName(), null); - doWriteAttribute("mandatory", def.getMandatory(), "true"); - doWriteAttribute("charset", def.getCharset(), null); - endElement(name); - } - protected void doWriteConvertVariableDefinition(String name, ConvertVariableDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("name", def.getName(), null); - doWriteAttribute("type", def.getType(), null); - doWriteAttribute("toName", def.getToName(), null); - doWriteAttribute("mandatory", def.getMandatory(), "true"); - doWriteAttribute("charset", def.getCharset(), null); - endElement(name); - } - protected void doWriteDataFormatDefinition(String name, DataFormatDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - endElement(name); - } - protected void doWriteDelayDefinition(String name, DelayDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("asyncDelayed", def.getAsyncDelayed(), "true"); - doWriteAttribute("callerRunsWhenRejected", def.getCallerRunsWhenRejected(), "true"); - doWriteAttribute("executorService", def.getExecutorService(), null); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteDynamicRouterDefinition(String name, DynamicRouterDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("uriDelimiter", def.getUriDelimiter(), ","); - doWriteAttribute("ignoreInvalidEndpoints", def.getIgnoreInvalidEndpoints(), null); - doWriteAttribute("cacheSize", def.getCacheSize(), null); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteEnrichDefinition(String name, EnrichDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("variableSend", def.getVariableSend(), null); - doWriteAttribute("variableReceive", def.getVariableReceive(), null); - doWriteAttribute("aggregationStrategy", def.getAggregationStrategy(), null); - doWriteAttribute("aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); - doWriteAttribute("aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); - doWriteAttribute("aggregateOnException", def.getAggregateOnException(), null); - doWriteAttribute("shareUnitOfWork", def.getShareUnitOfWork(), null); - doWriteAttribute("cacheSize", def.getCacheSize(), null); - doWriteAttribute("ignoreInvalidEndpoint", def.getIgnoreInvalidEndpoint(), null); - doWriteAttribute("allowOptimisedComponents", def.getAllowOptimisedComponents(), "true"); - doWriteAttribute("autoStartComponents", def.getAutoStartComponents(), "true"); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteErrorHandlerDefinition(String name, ErrorHandlerDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteElement(null, def.getErrorHandlerType(), (n, v) -> { - switch (v.getClass().getSimpleName()) { - case "DeadLetterChannelDefinition" -> doWriteDeadLetterChannelDefinition("deadLetterChannel", (DeadLetterChannelDefinition) v); - case "DefaultErrorHandlerDefinition" -> doWriteDefaultErrorHandlerDefinition("defaultErrorHandler", (DefaultErrorHandlerDefinition) v); - case "NoErrorHandlerDefinition" -> doWriteNoErrorHandlerDefinition("noErrorHandler", (NoErrorHandlerDefinition) v); - case "RefErrorHandlerDefinition" -> doWriteRefErrorHandlerDefinition("refErrorHandler", (RefErrorHandlerDefinition) v); - case "JtaTransactionErrorHandlerDefinition" -> doWriteJtaTransactionErrorHandlerDefinition("jtaTransactionErrorHandler", (JtaTransactionErrorHandlerDefinition) v); - case "SpringTransactionErrorHandlerDefinition" -> doWriteSpringTransactionErrorHandlerDefinition("springTransactionErrorHandler", (SpringTransactionErrorHandlerDefinition) v); - } - }); - endElement(name); - } - protected void doWriteExpressionNodeElements(ExpressionNode def) throws IOException { - doWriteElement(null, def.getExpression(), this::doWriteExpressionDefinitionRef); - } - protected void doWriteExpressionNode(String name, ExpressionNode def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteExpressionSubElementDefinition(String name, ExpressionSubElementDefinition def) throws IOException { - startExpressionElement(name); - doWriteElement(null, def.getExpressionType(), this::doWriteExpressionDefinitionRef); - endExpressionElement(name); - } - protected void doWriteFaultToleranceConfigurationCommonAttributes(FaultToleranceConfigurationCommon def) throws IOException { - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("delay", def.getDelay(), "5000"); - doWriteAttribute("bulkheadWaitingTaskQueue", def.getBulkheadWaitingTaskQueue(), "10"); - doWriteAttribute("typedGuard", def.getTypedGuard(), null); - doWriteAttribute("failureRatio", def.getFailureRatio(), "50"); - doWriteAttribute("timeoutDuration", def.getTimeoutDuration(), "1000"); - doWriteAttribute("timeoutEnabled", def.getTimeoutEnabled(), "false"); - doWriteAttribute("timeoutPoolSize", def.getTimeoutPoolSize(), "10"); - doWriteAttribute("successThreshold", def.getSuccessThreshold(), "1"); - doWriteAttribute("requestVolumeThreshold", def.getRequestVolumeThreshold(), "20"); - doWriteAttribute("bulkheadMaxConcurrentCalls", def.getBulkheadMaxConcurrentCalls(), "10"); - doWriteAttribute("threadOffloadExecutorService", def.getThreadOffloadExecutorService(), null); - doWriteAttribute("bulkheadEnabled", def.getBulkheadEnabled(), "false"); - } - protected void doWriteFaultToleranceConfigurationCommon(String name, FaultToleranceConfigurationCommon def) throws IOException { - startElement(name); - doWriteFaultToleranceConfigurationCommonAttributes(def); - endElement(name); - } - protected void doWriteFaultToleranceConfigurationDefinition(String name, FaultToleranceConfigurationDefinition def) throws IOException { - startElement(name); - doWriteFaultToleranceConfigurationCommonAttributes(def); - endElement(name); - } - protected void doWriteFilterDefinition(String name, FilterDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("statusPropertyName", def.getStatusPropertyName(), null); - doWriteOutputExpressionNodeElements(def); - endElement(name); - } - protected void doWriteFinallyDefinition(String name, FinallyDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteFromDefinition(String name, FromDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("uri", def.getUri(), null); - doWriteAttribute("variableReceive", def.getVariableReceive(), null); - endElement(name); - } - protected void doWriteGlobalOptionDefinition(String name, GlobalOptionDefinition def) throws IOException { - startElement(name); - doWriteAttribute("key", def.getKey(), null); - doWriteAttribute("value", def.getValue(), null); - endElement(name); - } - protected void doWriteGlobalOptionsDefinition(String name, GlobalOptionsDefinition def) throws IOException { - startElement(name); - doWriteList(null, "globalOption", def.getGlobalOptions(), this::doWriteGlobalOptionDefinition); - endElement(name); - } - protected void doWriteIdempotentConsumerDefinition(String name, IdempotentConsumerDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("idempotentRepository", def.getIdempotentRepository(), null); - doWriteAttribute("eager", def.getEager(), "true"); - doWriteAttribute("completionEager", def.getCompletionEager(), "false"); - doWriteAttribute("skipDuplicate", def.getSkipDuplicate(), "true"); - doWriteAttribute("removeOnFailure", def.getRemoveOnFailure(), "true"); - doWriteOutputExpressionNodeElements(def); - endElement(name); - } - protected void doWriteIdentifiedTypeAttributes(IdentifiedType def) throws IOException { - doWriteAttribute("id", def.getId(), null); - } - protected void doWriteIdentifiedType(String name, IdentifiedType def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - endElement(name); - } - protected void doWriteInputTypeDefinition(String name, InputTypeDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("urn", def.getUrn(), null); - doWriteAttribute("validate", def.getValidate(), "false"); - endElement(name); - } - protected void doWriteInterceptDefinitionElements(InterceptDefinition def) throws IOException { - doWriteElement("onWhen", def.getOnWhen(), this::doWriteOnWhenDefinition); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - } - protected void doWriteInterceptDefinition(String name, InterceptDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteInterceptDefinitionElements(def); - endElement(name); - } - protected void doWriteInterceptFromDefinition(String name, InterceptFromDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("uri", def.getUri(), null); - doWriteInterceptDefinitionElements(def); - endElement(name); - } - protected void doWriteInterceptSendToEndpointDefinition(String name, InterceptSendToEndpointDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("uri", def.getUri(), null); - doWriteAttribute("skipSendToOriginalEndpoint", def.getSkipSendToOriginalEndpoint(), null); - doWriteAttribute("afterUri", def.getAfterUri(), null); - doWriteElement("onWhen", def.getOnWhen(), this::doWriteOnWhenDefinition); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteKameletDefinition(String name, KameletDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("name", def.getName(), null); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteLoadBalanceDefinition(String name, LoadBalanceDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteElement(null, def.getLoadBalancerType(), (n, v) -> { - switch (v.getClass().getSimpleName()) { - case "CustomLoadBalancerDefinition" -> doWriteCustomLoadBalancerDefinition("customLoadBalancer", (CustomLoadBalancerDefinition) v); - case "FailoverLoadBalancerDefinition" -> doWriteFailoverLoadBalancerDefinition("failoverLoadBalancer", (FailoverLoadBalancerDefinition) v); - case "RandomLoadBalancerDefinition" -> doWriteRandomLoadBalancerDefinition("randomLoadBalancer", (RandomLoadBalancerDefinition) v); - case "RoundRobinLoadBalancerDefinition" -> doWriteRoundRobinLoadBalancerDefinition("roundRobinLoadBalancer", (RoundRobinLoadBalancerDefinition) v); - case "StickyLoadBalancerDefinition" -> doWriteStickyLoadBalancerDefinition("stickyLoadBalancer", (StickyLoadBalancerDefinition) v); - case "TopicLoadBalancerDefinition" -> doWriteTopicLoadBalancerDefinition("topicLoadBalancer", (TopicLoadBalancerDefinition) v); - case "WeightedLoadBalancerDefinition" -> doWriteWeightedLoadBalancerDefinition("weightedLoadBalancer", (WeightedLoadBalancerDefinition) v); - } - }); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteLoadBalancerDefinition(String name, LoadBalancerDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - endElement(name); - } - protected void doWriteLogDefinition(String name, LogDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("message", def.getMessage(), null); - doWriteAttribute("loggingLevel", def.getLoggingLevel(), "INFO"); - doWriteAttribute("logName", def.getLogName(), null); - doWriteAttribute("marker", def.getMarker(), null); - doWriteAttribute("logger", def.getLogger(), null); - doWriteAttribute("logLanguage", def.getLogLanguage(), null); - endElement(name); - } - protected void doWriteLoopDefinition(String name, LoopDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("copy", def.getCopy(), null); - doWriteAttribute("doWhile", def.getDoWhile(), null); - doWriteAttribute("breakOnShutdown", def.getBreakOnShutdown(), null); - doWriteAttribute("onPrepare", def.getOnPrepare(), null); - doWriteOutputExpressionNodeElements(def); - endElement(name); - } - protected void doWriteMarshalDefinition(String name, MarshalDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("variableSend", def.getVariableSend(), null); - doWriteAttribute("variableReceive", def.getVariableReceive(), null); - doWriteElement(null, def.getDataFormatType(), (n, v) -> { - switch (v.getClass().getSimpleName()) { - case "ASN1DataFormat" -> doWriteASN1DataFormat("asn1", (ASN1DataFormat) v); - case "AvroDataFormat" -> doWriteAvroDataFormat("avro", (AvroDataFormat) v); - case "BarcodeDataFormat" -> doWriteBarcodeDataFormat("barcode", (BarcodeDataFormat) v); - case "Base64DataFormat" -> doWriteBase64DataFormat("base64", (Base64DataFormat) v); - case "BeanioDataFormat" -> doWriteBeanioDataFormat("beanio", (BeanioDataFormat) v); - case "BindyDataFormat" -> doWriteBindyDataFormat("bindy", (BindyDataFormat) v); - case "CBORDataFormat" -> doWriteCBORDataFormat("cbor", (CBORDataFormat) v); - case "CryptoDataFormat" -> doWriteCryptoDataFormat("crypto", (CryptoDataFormat) v); - case "CsvDataFormat" -> doWriteCsvDataFormat("csv", (CsvDataFormat) v); - case "CustomDataFormat" -> doWriteCustomDataFormat("custom", (CustomDataFormat) v); - case "DfdlDataFormat" -> doWriteDfdlDataFormat("dfdl", (DfdlDataFormat) v); - case "FhirJsonDataFormat" -> doWriteFhirJsonDataFormat("fhirJson", (FhirJsonDataFormat) v); - case "FhirXmlDataFormat" -> doWriteFhirXmlDataFormat("fhirXml", (FhirXmlDataFormat) v); - case "FlatpackDataFormat" -> doWriteFlatpackDataFormat("flatpack", (FlatpackDataFormat) v); - case "ForyDataFormat" -> doWriteForyDataFormat("fory", (ForyDataFormat) v); - case "GrokDataFormat" -> doWriteGrokDataFormat("grok", (GrokDataFormat) v); - case "GroovyJSonDataFormat" -> doWriteGroovyJSonDataFormat("groovyJson", (GroovyJSonDataFormat) v); - case "GroovyXmlDataFormat" -> doWriteGroovyXmlDataFormat("groovyXml", (GroovyXmlDataFormat) v); - case "GzipDeflaterDataFormat" -> doWriteGzipDeflaterDataFormat("gzipDeflater", (GzipDeflaterDataFormat) v); - case "HL7DataFormat" -> doWriteHL7DataFormat("hl7", (HL7DataFormat) v); - case "IcalDataFormat" -> doWriteIcalDataFormat("ical", (IcalDataFormat) v); - case "Iso8583DataFormat" -> doWriteIso8583DataFormat("iso8583", (Iso8583DataFormat) v); - case "JacksonXMLDataFormat" -> doWriteJacksonXMLDataFormat("jacksonXml", (JacksonXMLDataFormat) v); - case "JaxbDataFormat" -> doWriteJaxbDataFormat("jaxb", (JaxbDataFormat) v); - case "JsonDataFormat" -> doWriteJsonDataFormat("json", (JsonDataFormat) v); - case "JsonApiDataFormat" -> doWriteJsonApiDataFormat("jsonApi", (JsonApiDataFormat) v); - case "LZFDataFormat" -> doWriteLZFDataFormat("lzf", (LZFDataFormat) v); - case "MimeMultipartDataFormat" -> doWriteMimeMultipartDataFormat("mimeMultipart", (MimeMultipartDataFormat) v); - case "OcsfDataFormat" -> doWriteOcsfDataFormat("ocsf", (OcsfDataFormat) v); - case "ParquetAvroDataFormat" -> doWriteParquetAvroDataFormat("parquetAvro", (ParquetAvroDataFormat) v); - case "PGPDataFormat" -> doWritePGPDataFormat("pgp", (PGPDataFormat) v); - case "PQCDataFormat" -> doWritePQCDataFormat("pqc", (PQCDataFormat) v); - case "ProtobufDataFormat" -> doWriteProtobufDataFormat("protobuf", (ProtobufDataFormat) v); - case "RssDataFormat" -> doWriteRssDataFormat("rss", (RssDataFormat) v); - case "SmooksDataFormat" -> doWriteSmooksDataFormat("smooks", (SmooksDataFormat) v); - case "SoapDataFormat" -> doWriteSoapDataFormat("soap", (SoapDataFormat) v); - case "SwiftMtDataFormat" -> doWriteSwiftMtDataFormat("swiftMt", (SwiftMtDataFormat) v); - case "SwiftMxDataFormat" -> doWriteSwiftMxDataFormat("swiftMx", (SwiftMxDataFormat) v); - case "SyslogDataFormat" -> doWriteSyslogDataFormat("syslog", (SyslogDataFormat) v); - case "TarFileDataFormat" -> doWriteTarFileDataFormat("tarFile", (TarFileDataFormat) v); - case "ThriftDataFormat" -> doWriteThriftDataFormat("thrift", (ThriftDataFormat) v); - case "UniVocityCsvDataFormat" -> doWriteUniVocityCsvDataFormat("univocityCsv", (UniVocityCsvDataFormat) v); - case "UniVocityFixedDataFormat" -> doWriteUniVocityFixedDataFormat("univocityFixed", (UniVocityFixedDataFormat) v); - case "UniVocityTsvDataFormat" -> doWriteUniVocityTsvDataFormat("univocityTsv", (UniVocityTsvDataFormat) v); - case "XMLSecurityDataFormat" -> doWriteXMLSecurityDataFormat("xmlSecurity", (XMLSecurityDataFormat) v); - case "YAMLDataFormat" -> doWriteYAMLDataFormat("yaml", (YAMLDataFormat) v); - case "ZipDeflaterDataFormat" -> doWriteZipDeflaterDataFormat("zipDeflater", (ZipDeflaterDataFormat) v); - case "ZipFileDataFormat" -> doWriteZipFileDataFormat("zipFile", (ZipFileDataFormat) v); - } - }); - endElement(name); - } - protected void doWriteMulticastDefinition(String name, MulticastDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("aggregationStrategy", def.getAggregationStrategy(), null); - doWriteAttribute("aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); - doWriteAttribute("aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); - doWriteAttribute("parallelAggregate", def.getParallelAggregate(), null); - doWriteAttribute("parallelProcessing", def.getParallelProcessing(), null); - doWriteAttribute("synchronous", def.getSynchronous(), null); - doWriteAttribute("streaming", def.getStreaming(), null); - doWriteAttribute("stopOnException", def.getStopOnException(), null); - doWriteAttribute("timeout", def.getTimeout(), "0"); - doWriteAttribute("executorService", def.getExecutorService(), null); - doWriteAttribute("onPrepare", def.getOnPrepare(), null); - doWriteAttribute("shareUnitOfWork", def.getShareUnitOfWork(), null); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteOnCompletionDefinition(String name, OnCompletionDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("mode", def.getMode(), "AfterConsumer"); - doWriteAttribute("onCompleteOnly", def.getOnCompleteOnly(), null); - doWriteAttribute("onFailureOnly", def.getOnFailureOnly(), null); - doWriteAttribute("parallelProcessing", def.getParallelProcessing(), null); - doWriteAttribute("executorService", def.getExecutorService(), null); - doWriteAttribute("useOriginalMessage", def.getUseOriginalMessage(), null); - doWriteElement("onWhen", def.getOnWhen(), this::doWriteOnWhenDefinition); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteOnExceptionDefinition(String name, OnExceptionDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("redeliveryPolicyRef", def.getRedeliveryPolicyRef(), null); - doWriteAttribute("onRedeliveryRef", def.getOnRedeliveryRef(), null); - doWriteAttribute("onExceptionOccurredRef", def.getOnExceptionOccurredRef(), null); - doWriteAttribute("useOriginalMessage", def.getUseOriginalMessage(), null); - doWriteAttribute("useOriginalBody", def.getUseOriginalBody(), null); - doWriteList(null, "exception", def.getExceptions(), this::doWriteString); - doWriteElement("redeliveryPolicy", def.getRedeliveryPolicyType(), this::doWriteRedeliveryPolicyDefinition); - doWriteElement("onWhen", def.getOnWhen(), this::doWriteOnWhenDefinition); - doWriteElement("retryWhile", def.getRetryWhile(), this::doWriteExpressionSubElementDefinition); - doWriteElement("handled", def.getHandled(), this::doWriteExpressionSubElementDefinition); - doWriteElement("continued", def.getContinued(), this::doWriteExpressionSubElementDefinition); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteOnFallbackDefinition(String name, OnFallbackDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("fallbackViaNetwork", def.getFallbackViaNetwork(), "false"); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteOnWhenDefinition(String name, OnWhenDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteElement(null, def.getExpression(), this::doWriteExpressionDefinitionRef); - endElement(name); - } - protected void doWriteOptimisticLockRetryPolicyDefinition(String name, OptimisticLockRetryPolicyDefinition def) throws IOException { - startElement(name); - doWriteAttribute("maximumRetries", def.getMaximumRetries(), null); - doWriteAttribute("retryDelay", def.getRetryDelay(), "50"); - doWriteAttribute("maximumRetryDelay", def.getMaximumRetryDelay(), "1000"); - doWriteAttribute("exponentialBackOff", def.getExponentialBackOff(), "true"); - doWriteAttribute("randomBackOff", def.getRandomBackOff(), null); - endElement(name); - } - protected void doWriteOptionalIdentifiedDefinitionAttributes(OptionalIdentifiedDefinition def) throws IOException { - doWriteAttribute("customId", toString(def.getCustomId()), null); - doWriteAttribute("id", def.getId(), null); - doWriteAttribute("note", def.getNote(), null); - doWriteAttribute("description", def.getDescription(), null); - } - protected void doWriteOptionalIdentifiedDefinition(String name, OptionalIdentifiedDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - endElement(name); - } - protected void doWriteOtherwiseDefinition(String name, OtherwiseDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("disabled", def.getDisabled(), null); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteOutputExpressionNodeElements(OutputExpressionNode def) throws IOException { - doWriteExpressionNodeElements(def); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - } - protected void doWriteOutputExpressionNode(String name, OutputExpressionNode def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteOutputExpressionNodeElements(def); - endElement(name); - } - protected void doWriteOutputTypeDefinition(String name, OutputTypeDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("urn", def.getUrn(), null); - doWriteAttribute("validate", def.getValidate(), "false"); - endElement(name); - } - protected void doWritePackageScanDefinition(String name, PackageScanDefinition def) throws IOException { - startElement(name); - doWriteList(null, "package", def.getPackages(), this::doWriteString); - doWriteList(null, "excludes", def.getExcludes(), this::doWriteString); - doWriteList(null, "includes", def.getIncludes(), this::doWriteString); - endElement(name); - } - protected void doWritePausableDefinition(String name, PausableDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("consumerListener", def.getConsumerListener(), null); - doWriteAttribute("untilCheck", def.getUntilCheck(), null); - endElement(name); - } - protected void doWritePipelineDefinition(String name, PipelineDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWritePolicyDefinition(String name, PolicyDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWritePollDefinition(String name, PollDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("variableReceive", def.getVariableReceive(), null); - doWriteAttribute("uri", def.getUri(), null); - doWriteAttribute("timeout", def.getTimeout(), "20000"); - endElement(name); - } - protected void doWritePollEnrichDefinition(String name, PollEnrichDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("variableReceive", def.getVariableReceive(), null); - doWriteAttribute("aggregationStrategy", def.getAggregationStrategy(), null); - doWriteAttribute("aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); - doWriteAttribute("aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); - doWriteAttribute("aggregateOnException", def.getAggregateOnException(), null); - doWriteAttribute("timeout", def.getTimeout(), "-1"); - doWriteAttribute("cacheSize", def.getCacheSize(), null); - doWriteAttribute("ignoreInvalidEndpoint", def.getIgnoreInvalidEndpoint(), null); - doWriteAttribute("allowOptimisedComponents", def.getAllowOptimisedComponents(), "true"); - doWriteAttribute("autoStartComponents", def.getAutoStartComponents(), "true"); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteProcessDefinition(String name, ProcessDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - endElement(name); - } - protected void doWriteProcessorDefinitionAttributes(ProcessorDefinition def) throws IOException { - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("disabled", def.getDisabled(), null); - } - protected void doWriteProcessorDefinition(String name, ProcessorDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - endElement(name); - } - protected void doWritePropertyDefinition(String name, PropertyDefinition def) throws IOException { - startElement(name); - doWriteAttribute("key", def.getKey(), null); - doWriteAttribute("value", def.getValue(), null); - endElement(name); - } - protected void doWritePropertyDefinitions(String name, PropertyDefinitions def) throws IOException { - startElement(name); - doWriteList(null, "property", def.getProperties(), this::doWritePropertyDefinition); - endElement(name); - } - protected void doWritePropertyExpressionDefinition(String name, PropertyExpressionDefinition def) throws IOException { - startElement(name); - doWriteAttribute("key", def.getKey(), null); - doWriteElement(null, def.getExpression(), this::doWriteExpressionDefinitionRef); - endElement(name); - } - protected void doWriteRecipientListDefinition(String name, RecipientListDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("delimiter", def.getDelimiter(), ","); - doWriteAttribute("aggregationStrategy", def.getAggregationStrategy(), null); - doWriteAttribute("aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); - doWriteAttribute("aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); - doWriteAttribute("parallelAggregate", def.getParallelAggregate(), null); - doWriteAttribute("parallelProcessing", def.getParallelProcessing(), null); - doWriteAttribute("synchronous", def.getSynchronous(), null); - doWriteAttribute("timeout", def.getTimeout(), "0"); - doWriteAttribute("executorService", def.getExecutorService(), null); - doWriteAttribute("stopOnException", def.getStopOnException(), null); - doWriteAttribute("ignoreInvalidEndpoints", def.getIgnoreInvalidEndpoints(), null); - doWriteAttribute("streaming", def.getStreaming(), null); - doWriteAttribute("onPrepare", def.getOnPrepare(), null); - doWriteAttribute("cacheSize", def.getCacheSize(), null); - doWriteAttribute("shareUnitOfWork", def.getShareUnitOfWork(), null); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteRedeliveryPolicyDefinition(String name, RedeliveryPolicyDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("maximumRedeliveries", def.getMaximumRedeliveries(), null); - doWriteAttribute("redeliveryDelay", def.getRedeliveryDelay(), "1000"); - doWriteAttribute("asyncDelayedRedelivery", def.getAsyncDelayedRedelivery(), null); - doWriteAttribute("backOffMultiplier", def.getBackOffMultiplier(), "2.0"); - doWriteAttribute("useExponentialBackOff", def.getUseExponentialBackOff(), null); - doWriteAttribute("collisionAvoidanceFactor", def.getCollisionAvoidanceFactor(), "0.15"); - doWriteAttribute("useCollisionAvoidance", def.getUseCollisionAvoidance(), null); - doWriteAttribute("maximumRedeliveryDelay", def.getMaximumRedeliveryDelay(), "60000"); - doWriteAttribute("retriesExhaustedLogLevel", def.getRetriesExhaustedLogLevel(), "ERROR"); - doWriteAttribute("retryAttemptedLogLevel", def.getRetryAttemptedLogLevel(), "DEBUG"); - doWriteAttribute("retryAttemptedLogInterval", def.getRetryAttemptedLogInterval(), "1"); - doWriteAttribute("logRetryAttempted", def.getLogRetryAttempted(), "true"); - doWriteAttribute("logStackTrace", def.getLogStackTrace(), "true"); - doWriteAttribute("logRetryStackTrace", def.getLogRetryStackTrace(), null); - doWriteAttribute("logHandled", def.getLogHandled(), null); - doWriteAttribute("logNewException", def.getLogNewException(), "true"); - doWriteAttribute("logContinued", def.getLogContinued(), null); - doWriteAttribute("logExhausted", def.getLogExhausted(), "true"); - doWriteAttribute("logExhaustedMessageHistory", def.getLogExhaustedMessageHistory(), null); - doWriteAttribute("logExhaustedMessageBody", def.getLogExhaustedMessageBody(), null); - doWriteAttribute("disableRedelivery", def.getDisableRedelivery(), null); - doWriteAttribute("delayPattern", def.getDelayPattern(), null); - doWriteAttribute("allowRedeliveryWhileStopping", def.getAllowRedeliveryWhileStopping(), "true"); - doWriteAttribute("exchangeFormatterRef", def.getExchangeFormatterRef(), null); - endElement(name); - } - protected void doWriteRemoveHeaderDefinition(String name, RemoveHeaderDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("name", def.getName(), null); - endElement(name); - } - protected void doWriteRemoveHeadersDefinition(String name, RemoveHeadersDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("pattern", def.getPattern(), null); - doWriteAttribute("excludePattern", def.getExcludePattern(), null); - endElement(name); - } - protected void doWriteRemovePropertiesDefinition(String name, RemovePropertiesDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("pattern", def.getPattern(), null); - doWriteAttribute("excludePattern", def.getExcludePattern(), null); - endElement(name); - } - protected void doWriteRemovePropertyDefinition(String name, RemovePropertyDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("name", def.getName(), null); - endElement(name); - } - protected void doWriteRemoveVariableDefinition(String name, RemoveVariableDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("name", def.getName(), null); - endElement(name); - } - protected void doWriteResequenceDefinition(String name, ResequenceDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteElement(null, def.getExpression(), this::doWriteExpressionDefinitionRef); - doWriteElement(null, def.getResequencerConfig(), (n, v) -> { - switch (v.getClass().getSimpleName()) { - case "BatchResequencerConfig" -> doWriteBatchResequencerConfig("batchConfig", (BatchResequencerConfig) v); - case "StreamResequencerConfig" -> doWriteStreamResequencerConfig("streamConfig", (StreamResequencerConfig) v); - } - }); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteResilience4jConfigurationCommonAttributes(Resilience4jConfigurationCommon def) throws IOException { - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("failureRateThreshold", def.getFailureRateThreshold(), "50"); - doWriteAttribute("bulkheadMaxWaitDuration", def.getBulkheadMaxWaitDuration(), "0"); - doWriteAttribute("slowCallDurationThreshold", def.getSlowCallDurationThreshold(), "60"); - doWriteAttribute("timeoutCancelRunningFuture", def.getTimeoutCancelRunningFuture(), "true"); - doWriteAttribute("minimumNumberOfCalls", def.getMinimumNumberOfCalls(), "100"); - doWriteAttribute("timeoutDuration", def.getTimeoutDuration(), "1000"); - doWriteAttribute("timeoutEnabled", def.getTimeoutEnabled(), "false"); - doWriteAttribute("timeoutExecutorService", def.getTimeoutExecutorService(), null); - doWriteAttribute("permittedNumberOfCallsInHalfOpenState", def.getPermittedNumberOfCallsInHalfOpenState(), "10"); - doWriteAttribute("throwExceptionWhenHalfOpenOrOpenState", def.getThrowExceptionWhenHalfOpenOrOpenState(), "false"); - doWriteAttribute("slowCallRateThreshold", def.getSlowCallRateThreshold(), "100"); - doWriteAttribute("micrometerEnabled", def.getMicrometerEnabled(), "false"); - doWriteAttribute("writableStackTraceEnabled", def.getWritableStackTraceEnabled(), "true"); - doWriteAttribute("automaticTransitionFromOpenToHalfOpenEnabled", def.getAutomaticTransitionFromOpenToHalfOpenEnabled(), "false"); - doWriteAttribute("circuitBreaker", def.getCircuitBreaker(), null); - doWriteAttribute("slidingWindowSize", def.getSlidingWindowSize(), "100"); - doWriteAttribute("config", def.getConfig(), null); - doWriteAttribute("bulkheadMaxConcurrentCalls", def.getBulkheadMaxConcurrentCalls(), "25"); - doWriteAttribute("slidingWindowType", def.getSlidingWindowType(), "COUNT_BASED"); - doWriteAttribute("bulkheadEnabled", def.getBulkheadEnabled(), "false"); - doWriteAttribute("waitDurationInOpenState", def.getWaitDurationInOpenState(), "60"); - } - protected void doWriteResilience4jConfigurationCommonElements(Resilience4jConfigurationCommon def) throws IOException { - doWriteList(null, "ignoreException", def.getIgnoreExceptions(), this::doWriteString); - doWriteList(null, "recordException", def.getRecordExceptions(), this::doWriteString); - } - protected void doWriteResilience4jConfigurationCommon(String name, Resilience4jConfigurationCommon def) throws IOException { - startElement(name); - doWriteResilience4jConfigurationCommonAttributes(def); - doWriteResilience4jConfigurationCommonElements(def); - endElement(name); - } - protected void doWriteResilience4jConfigurationDefinition(String name, Resilience4jConfigurationDefinition def) throws IOException { - startElement(name); - doWriteResilience4jConfigurationCommonAttributes(def); - doWriteResilience4jConfigurationCommonElements(def); - endElement(name); - } - protected void doWriteRestContextRefDefinition(String name, RestContextRefDefinition def) throws IOException { - startElement(name); - doWriteAttribute("ref", def.getRef(), null); - endElement(name); - } - protected void doWriteResumableDefinition(String name, ResumableDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("resumeStrategy", def.getResumeStrategy(), null); - doWriteAttribute("loggingLevel", def.getLoggingLevel(), "ERROR"); - doWriteAttribute("intermittent", def.getIntermittent(), "false"); - endElement(name); - } - protected void doWriteRollbackDefinition(String name, RollbackDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("message", def.getMessage(), null); - doWriteAttribute("markRollbackOnly", def.getMarkRollbackOnly(), null); - doWriteAttribute("markRollbackOnlyLast", def.getMarkRollbackOnlyLast(), null); - endElement(name); - } - protected void doWriteRouteBuilderDefinition(String name, RouteBuilderDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - endElement(name); - } - protected void doWriteRouteConfigurationContextRefDefinition(String name, RouteConfigurationContextRefDefinition def) throws IOException { - startElement(name); - doWriteAttribute("ref", def.getRef(), null); - endElement(name); - } - protected void doWriteRouteConfigurationDefinition(String name, RouteConfigurationDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("precondition", def.getPrecondition(), null); - doWriteList(null, "onException", def.getOnExceptions(), this::doWriteOnExceptionDefinition); - doWriteList(null, "onCompletion", def.getOnCompletions(), this::doWriteOnCompletionDefinition); - doWriteList(null, "interceptSendToEndpoint", def.getInterceptSendTos(), this::doWriteInterceptSendToEndpointDefinition); - doWriteList(null, "interceptFrom", def.getInterceptFroms(), this::doWriteInterceptFromDefinition); - doWriteList(null, "intercept", def.getIntercepts(), this::doWriteInterceptDefinition); - doWriteElement("errorHandler", def.getErrorHandler(), this::doWriteErrorHandlerDefinition); - endElement(name); - } - protected void doWriteRouteConfigurationsDefinition(String name, RouteConfigurationsDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteList(null, null, def.getRouteConfigurations(), this::doWriteRouteConfigurationDefinitionRef); - endElement(name); - } - protected void doWriteRouteContextRefDefinition(String name, RouteContextRefDefinition def) throws IOException { - startElement(name); - doWriteAttribute("ref", def.getRef(), null); - endElement(name); - } - protected void doWriteRouteDefinition(String name, RouteDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("template", toString(def.isTemplate()), null); - doWriteAttribute("kamelet", toString(def.isKamelet()), null); - doWriteAttribute("rest", toString(def.isRest()), null); - doWriteAttribute("group", def.getGroup(), null); - doWriteAttribute("nodePrefixId", def.getNodePrefixId(), null); - doWriteAttribute("routeConfigurationId", def.getRouteConfigurationId(), null); - doWriteAttribute("autoStartup", def.getAutoStartup(), "true"); - doWriteAttribute("startupOrder", toString(def.getStartupOrder()), null); - doWriteAttribute("streamCache", def.getStreamCache(), null); - doWriteAttribute("trace", def.getTrace(), null); - doWriteAttribute("messageHistory", def.getMessageHistory(), null); - doWriteAttribute("logMask", def.getLogMask(), null); - doWriteAttribute("delayer", def.getDelayer(), null); - doWriteAttribute("errorHandlerRef", def.getErrorHandlerRef(), null); - doWriteAttribute("routePolicyRef", def.getRoutePolicyRef(), null); - doWriteAttribute("shutdownRoute", def.getShutdownRoute(), "Default"); - doWriteAttribute("shutdownRunningTask", def.getShutdownRunningTask(), "CompleteCurrentTaskOnly"); - doWriteAttribute("precondition", def.getPrecondition(), null); - doWriteList(null, "routeProperty", def.getRouteProperties(), this::doWritePropertyDefinition); - doWriteElement("errorHandler", def.getErrorHandler(), this::doWriteErrorHandlerDefinition); - doWriteElement(null, def.getInput(), this::doWriteFromDefinitionRef); - doWriteElement(null, def.getInputType(), this::doWriteInputTypeDefinitionRef); - doWriteElement(null, def.getOutputType(), this::doWriteOutputTypeDefinitionRef); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteRouteTemplateContextRefDefinition(String name, RouteTemplateContextRefDefinition def) throws IOException { - startElement(name); - doWriteAttribute("ref", def.getRef(), null); - endElement(name); - } - protected void doWriteRouteTemplateDefinition(String name, RouteTemplateDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteList(null, "templateParameter", def.getTemplateParameters(), this::doWriteRouteTemplateParameterDefinition); - doWriteList(null, "templateBean", def.getTemplateBeans(), this::doWriteBeanFactoryDefinition); - doWriteElement("route", def.getRoute(), this::doWriteRouteDefinition); - endElement(name); - } - protected void doWriteRouteTemplateParameterDefinition(String name, RouteTemplateParameterDefinition def) throws IOException { - startElement(name); - doWriteAttribute("description", def.getDescription(), null); - doWriteAttribute("name", def.getName(), null); - doWriteAttribute("required", toString(def.getRequired()), null); - doWriteAttribute("defaultValue", def.getDefaultValue(), null); - endElement(name); - } - protected void doWriteRouteTemplatesDefinition(String name, RouteTemplatesDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteList(null, null, def.getRouteTemplates(), this::doWriteRouteTemplateDefinitionRef); - endElement(name); - } - protected void doWriteRoutesDefinition(String name, RoutesDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteList(null, null, def.getRoutes(), this::doWriteRouteDefinitionRef); - endElement(name); - } - protected void doWriteRoutingSlipDefinition(String name, RoutingSlipDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("uriDelimiter", def.getUriDelimiter(), ","); - doWriteAttribute("ignoreInvalidEndpoints", def.getIgnoreInvalidEndpoints(), null); - doWriteAttribute("cacheSize", def.getCacheSize(), null); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteSagaDefinition(String name, SagaDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("sagaService", def.getSagaService(), null); - doWriteAttribute("propagation", def.getPropagation(), "REQUIRED"); - doWriteAttribute("completionMode", def.getCompletionMode(), "AUTO"); - doWriteAttribute("timeout", def.getTimeout(), null); - doWriteAttribute("compensation", def.getCompensation(), null); - doWriteAttribute("completion", def.getCompletion(), null); - doWriteList(null, "option", def.getOptions(), this::doWritePropertyExpressionDefinition); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteSamplingDefinition(String name, SamplingDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("samplePeriod", def.getSamplePeriod(), "1000"); - doWriteAttribute("messageFrequency", def.getMessageFrequency(), null); - endElement(name); - } - protected void doWriteScriptDefinition(String name, ScriptDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteSendDefinitionAttributes(SendDefinition def) throws IOException { - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("uri", def.getUri(), null); - } - protected void doWriteSendDefinition(String name, SendDefinition def) throws IOException { - startElement(name); - doWriteSendDefinitionAttributes(def); - endElement(name); - } - protected void doWriteSetBodyDefinition(String name, SetBodyDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteSetExchangePatternDefinition(String name, SetExchangePatternDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("pattern", def.getPattern(), null); - endElement(name); - } - protected void doWriteSetHeaderDefinition(String name, SetHeaderDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("name", def.getName(), null); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteSetHeadersDefinition(String name, SetHeadersDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteList(null, null, def.getHeaders(), this::doWriteSetHeaderDefinitionRef); - endElement(name); - } - protected void doWriteSetPropertyDefinition(String name, SetPropertyDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("name", def.getName(), null); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteSetVariableDefinition(String name, SetVariableDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("name", def.getName(), null); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteSetVariablesDefinition(String name, SetVariablesDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteList(null, null, def.getVariables(), this::doWriteSetVariableDefinitionRef); - endElement(name); - } - protected void doWriteSortDefinition(String name, SortDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("comparator", def.getComparator(), null); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteSplitDefinition(String name, SplitDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("delimiter", def.getDelimiter(), ","); - doWriteAttribute("aggregationStrategy", def.getAggregationStrategy(), null); - doWriteAttribute("aggregationStrategyMethodName", def.getAggregationStrategyMethodName(), null); - doWriteAttribute("aggregationStrategyMethodAllowNull", def.getAggregationStrategyMethodAllowNull(), null); - doWriteAttribute("parallelAggregate", def.getParallelAggregate(), null); - doWriteAttribute("parallelProcessing", def.getParallelProcessing(), null); - doWriteAttribute("synchronous", def.getSynchronous(), null); - doWriteAttribute("streaming", def.getStreaming(), null); - doWriteAttribute("stopOnException", def.getStopOnException(), null); - doWriteAttribute("timeout", def.getTimeout(), "0"); - doWriteAttribute("executorService", def.getExecutorService(), null); - doWriteAttribute("onPrepare", def.getOnPrepare(), null); - doWriteAttribute("shareUnitOfWork", def.getShareUnitOfWork(), null); - doWriteOutputExpressionNodeElements(def); - endElement(name); - } - protected void doWriteStepDefinition(String name, StepDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteStopDefinition(String name, StopDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - endElement(name); - } - protected void doWriteTemplatedRouteDefinition(String name, TemplatedRouteDefinition def) throws IOException { - startElement(name); - doWriteAttribute("routeTemplateRef", def.getRouteTemplateRef(), null); - doWriteAttribute("routeId", def.getRouteId(), null); - doWriteAttribute("prefixId", def.getPrefixId(), null); - doWriteAttribute("group", def.getGroup(), null); - doWriteList(null, "parameter", def.getParameters(), this::doWriteTemplatedRouteParameterDefinition); - doWriteList(null, "bean", def.getBeans(), this::doWriteBeanFactoryDefinition); - endElement(name); - } - protected void doWriteTemplatedRouteParameterDefinition(String name, TemplatedRouteParameterDefinition def) throws IOException { - startElement(name); - doWriteAttribute("name", def.getName(), null); - doWriteAttribute("value", def.getValue(), null); - endElement(name); - } - protected void doWriteTemplatedRoutesDefinition(String name, TemplatedRoutesDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteList(null, null, def.getTemplatedRoutes(), this::doWriteTemplatedRouteDefinitionRef); - endElement(name); - } - protected void doWriteThreadPoolProfileDefinition(String name, ThreadPoolProfileDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("defaultProfile", def.getDefaultProfile(), null); - doWriteAttribute("poolSize", def.getPoolSize(), null); - doWriteAttribute("maxPoolSize", def.getMaxPoolSize(), null); - doWriteAttribute("keepAliveTime", def.getKeepAliveTime(), null); - doWriteAttribute("timeUnit", def.getTimeUnit(), null); - doWriteAttribute("maxQueueSize", def.getMaxQueueSize(), null); - doWriteAttribute("allowCoreThreadTimeOut", def.getAllowCoreThreadTimeOut(), null); - doWriteAttribute("rejectedPolicy", def.getRejectedPolicy(), null); - endElement(name); - } - protected void doWriteThreadsDefinition(String name, ThreadsDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("executorService", def.getExecutorService(), null); - doWriteAttribute("poolSize", def.getPoolSize(), null); - doWriteAttribute("maxPoolSize", def.getMaxPoolSize(), null); - doWriteAttribute("keepAliveTime", def.getKeepAliveTime(), null); - doWriteAttribute("timeUnit", def.getTimeUnit(), null); - doWriteAttribute("maxQueueSize", def.getMaxQueueSize(), null); - doWriteAttribute("allowCoreThreadTimeOut", def.getAllowCoreThreadTimeOut(), null); - doWriteAttribute("threadName", def.getThreadName(), "Threads"); - doWriteAttribute("rejectedPolicy", def.getRejectedPolicy(), null); - doWriteAttribute("callerRunsWhenRejected", def.getCallerRunsWhenRejected(), "true"); - endElement(name); - } - protected void doWriteThrottleDefinition(String name, ThrottleDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("mode", def.getMode(), "TotalRequests"); - doWriteAttribute("executorService", def.getExecutorService(), null); - doWriteAttribute("asyncDelayed", def.getAsyncDelayed(), null); - doWriteAttribute("callerRunsWhenRejected", def.getCallerRunsWhenRejected(), "true"); - doWriteAttribute("rejectExecution", def.getRejectExecution(), null); - doWriteAttribute("timePeriodMillis", def.getTimePeriodMillis(), "1000"); - doWriteExpressionNodeElements(def); - doWriteElement("correlationExpression", def.getCorrelationExpression(), this::doWriteExpressionSubElementDefinition); - endElement(name); - } - protected void doWriteThrowExceptionDefinition(String name, ThrowExceptionDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("message", def.getMessage(), null); - doWriteAttribute("exceptionType", def.getExceptionType(), null); - doWriteAttribute("ref", def.getRef(), null); - endElement(name); - } - protected void doWriteToDefinition(String name, ToDefinition def) throws IOException { - startElement(name); - doWriteSendDefinitionAttributes(def); - doWriteAttribute("variableSend", def.getVariableSend(), null); - doWriteAttribute("variableReceive", def.getVariableReceive(), null); - doWriteAttribute("pattern", def.getPattern(), null); - endElement(name); - } - protected void doWriteToDynamicDefinitionAttributes(ToDynamicDefinition def) throws IOException { - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("uri", def.getUri(), null); - doWriteAttribute("variableSend", def.getVariableSend(), null); - doWriteAttribute("variableReceive", def.getVariableReceive(), null); - doWriteAttribute("pattern", def.getPattern(), null); - doWriteAttribute("cacheSize", def.getCacheSize(), null); - doWriteAttribute("ignoreInvalidEndpoint", def.getIgnoreInvalidEndpoint(), null); - doWriteAttribute("allowOptimisedComponents", def.getAllowOptimisedComponents(), "true"); - doWriteAttribute("autoStartComponents", def.getAutoStartComponents(), "true"); - } - protected void doWriteToDynamicDefinition(String name, ToDynamicDefinition def) throws IOException { - startElement(name); - doWriteToDynamicDefinitionAttributes(def); - endElement(name); - } - protected void doWriteTokenizerDefinition(String name, TokenizerDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteElement(null, def.getTokenizerImplementation(), (n, v) -> { - switch (v.getClass().getSimpleName()) { - case "LangChain4jCharacterTokenizerDefinition" -> doWriteLangChain4jCharacterTokenizerDefinition("langChain4jCharacterTokenizer", (LangChain4jCharacterTokenizerDefinition) v); - case "LangChain4jLineTokenizerDefinition" -> doWriteLangChain4jLineTokenizerDefinition("langChain4jLineTokenizer", (LangChain4jLineTokenizerDefinition) v); - case "LangChain4jParagraphTokenizerDefinition" -> doWriteLangChain4jParagraphTokenizerDefinition("langChain4jParagraphTokenizer", (LangChain4jParagraphTokenizerDefinition) v); - case "LangChain4jSentenceTokenizerDefinition" -> doWriteLangChain4jSentenceTokenizerDefinition("langChain4jSentenceTokenizer", (LangChain4jSentenceTokenizerDefinition) v); - case "LangChain4jWordTokenizerDefinition" -> doWriteLangChain4jWordTokenizerDefinition("langChain4jWordTokenizer", (LangChain4jWordTokenizerDefinition) v); - } - }); - endElement(name); - } - protected void doWriteTokenizerImplementationDefinition(String name, TokenizerImplementationDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - endElement(name); - } - protected void doWriteTransactedDefinition(String name, TransactedDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteTransformDataTypeDefinition(String name, TransformDataTypeDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("fromType", def.getFromType(), null); - doWriteAttribute("toType", def.getToType(), null); - endElement(name); - } - protected void doWriteTransformDefinition(String name, TransformDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteTryDefinition(String name, TryDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef); - endElement(name); - } - protected void doWriteUnmarshalDefinition(String name, UnmarshalDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("variableSend", def.getVariableSend(), null); - doWriteAttribute("variableReceive", def.getVariableReceive(), null); - doWriteAttribute("allowNullBody", def.getAllowNullBody(), "false"); - doWriteElement(null, def.getDataFormatType(), (n, v) -> { - switch (v.getClass().getSimpleName()) { - case "ASN1DataFormat" -> doWriteASN1DataFormat("asn1", (ASN1DataFormat) v); - case "AvroDataFormat" -> doWriteAvroDataFormat("avro", (AvroDataFormat) v); - case "BarcodeDataFormat" -> doWriteBarcodeDataFormat("barcode", (BarcodeDataFormat) v); - case "Base64DataFormat" -> doWriteBase64DataFormat("base64", (Base64DataFormat) v); - case "BeanioDataFormat" -> doWriteBeanioDataFormat("beanio", (BeanioDataFormat) v); - case "BindyDataFormat" -> doWriteBindyDataFormat("bindy", (BindyDataFormat) v); - case "CBORDataFormat" -> doWriteCBORDataFormat("cbor", (CBORDataFormat) v); - case "CryptoDataFormat" -> doWriteCryptoDataFormat("crypto", (CryptoDataFormat) v); - case "CsvDataFormat" -> doWriteCsvDataFormat("csv", (CsvDataFormat) v); - case "CustomDataFormat" -> doWriteCustomDataFormat("custom", (CustomDataFormat) v); - case "DfdlDataFormat" -> doWriteDfdlDataFormat("dfdl", (DfdlDataFormat) v); - case "FhirJsonDataFormat" -> doWriteFhirJsonDataFormat("fhirJson", (FhirJsonDataFormat) v); - case "FhirXmlDataFormat" -> doWriteFhirXmlDataFormat("fhirXml", (FhirXmlDataFormat) v); - case "FlatpackDataFormat" -> doWriteFlatpackDataFormat("flatpack", (FlatpackDataFormat) v); - case "ForyDataFormat" -> doWriteForyDataFormat("fory", (ForyDataFormat) v); - case "GrokDataFormat" -> doWriteGrokDataFormat("grok", (GrokDataFormat) v); - case "GroovyJSonDataFormat" -> doWriteGroovyJSonDataFormat("groovyJson", (GroovyJSonDataFormat) v); - case "GroovyXmlDataFormat" -> doWriteGroovyXmlDataFormat("groovyXml", (GroovyXmlDataFormat) v); - case "GzipDeflaterDataFormat" -> doWriteGzipDeflaterDataFormat("gzipDeflater", (GzipDeflaterDataFormat) v); - case "HL7DataFormat" -> doWriteHL7DataFormat("hl7", (HL7DataFormat) v); - case "IcalDataFormat" -> doWriteIcalDataFormat("ical", (IcalDataFormat) v); - case "Iso8583DataFormat" -> doWriteIso8583DataFormat("iso8583", (Iso8583DataFormat) v); - case "JacksonXMLDataFormat" -> doWriteJacksonXMLDataFormat("jacksonXml", (JacksonXMLDataFormat) v); - case "JaxbDataFormat" -> doWriteJaxbDataFormat("jaxb", (JaxbDataFormat) v); - case "JsonDataFormat" -> doWriteJsonDataFormat("json", (JsonDataFormat) v); - case "JsonApiDataFormat" -> doWriteJsonApiDataFormat("jsonApi", (JsonApiDataFormat) v); - case "LZFDataFormat" -> doWriteLZFDataFormat("lzf", (LZFDataFormat) v); - case "MimeMultipartDataFormat" -> doWriteMimeMultipartDataFormat("mimeMultipart", (MimeMultipartDataFormat) v); - case "OcsfDataFormat" -> doWriteOcsfDataFormat("ocsf", (OcsfDataFormat) v); - case "ParquetAvroDataFormat" -> doWriteParquetAvroDataFormat("parquetAvro", (ParquetAvroDataFormat) v); - case "PGPDataFormat" -> doWritePGPDataFormat("pgp", (PGPDataFormat) v); - case "PQCDataFormat" -> doWritePQCDataFormat("pqc", (PQCDataFormat) v); - case "ProtobufDataFormat" -> doWriteProtobufDataFormat("protobuf", (ProtobufDataFormat) v); - case "RssDataFormat" -> doWriteRssDataFormat("rss", (RssDataFormat) v); - case "SmooksDataFormat" -> doWriteSmooksDataFormat("smooks", (SmooksDataFormat) v); - case "SoapDataFormat" -> doWriteSoapDataFormat("soap", (SoapDataFormat) v); - case "SwiftMtDataFormat" -> doWriteSwiftMtDataFormat("swiftMt", (SwiftMtDataFormat) v); - case "SwiftMxDataFormat" -> doWriteSwiftMxDataFormat("swiftMx", (SwiftMxDataFormat) v); - case "SyslogDataFormat" -> doWriteSyslogDataFormat("syslog", (SyslogDataFormat) v); - case "TarFileDataFormat" -> doWriteTarFileDataFormat("tarFile", (TarFileDataFormat) v); - case "ThriftDataFormat" -> doWriteThriftDataFormat("thrift", (ThriftDataFormat) v); - case "UniVocityCsvDataFormat" -> doWriteUniVocityCsvDataFormat("univocityCsv", (UniVocityCsvDataFormat) v); - case "UniVocityFixedDataFormat" -> doWriteUniVocityFixedDataFormat("univocityFixed", (UniVocityFixedDataFormat) v); - case "UniVocityTsvDataFormat" -> doWriteUniVocityTsvDataFormat("univocityTsv", (UniVocityTsvDataFormat) v); - case "XMLSecurityDataFormat" -> doWriteXMLSecurityDataFormat("xmlSecurity", (XMLSecurityDataFormat) v); - case "YAMLDataFormat" -> doWriteYAMLDataFormat("yaml", (YAMLDataFormat) v); - case "ZipDeflaterDataFormat" -> doWriteZipDeflaterDataFormat("zipDeflater", (ZipDeflaterDataFormat) v); - case "ZipFileDataFormat" -> doWriteZipFileDataFormat("zipFile", (ZipFileDataFormat) v); - } - }); - endElement(name); - } - protected void doWriteValidateDefinition(String name, ValidateDefinition def) throws IOException { - startElement(name); - doWriteProcessorDefinitionAttributes(def); - doWriteAttribute("predicateExceptionFactory", def.getPredicateExceptionFactory(), null); - doWriteExpressionNodeElements(def); - endElement(name); - } - protected void doWriteValueDefinition(String name, ValueDefinition def) throws IOException { - startElement(name); - doWriteValue(def.getValue()); - endElement(name); - } - protected void doWriteWhenDefinition(String name, WhenDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("disabled", def.getDisabled(), null); - doWriteBasicOutputExpressionNodeElements(def); - endElement(name); - } - protected void doWriteWireTapDefinition(String name, WireTapDefinition def) throws IOException { - startElement(name); - doWriteToDynamicDefinitionAttributes(def); - doWriteAttribute("copy", def.getCopy(), "true"); - doWriteAttribute("dynamicUri", def.getDynamicUri(), "true"); - doWriteAttribute("onPrepare", def.getOnPrepare(), null); - doWriteAttribute("executorService", def.getExecutorService(), null); - endElement(name); - } - protected void doWriteApplicationDefinition(String name, ApplicationDefinition def) throws IOException { - startElement(name); - doWriteBeansDefinitionElements(def); - endElement(name); - } - protected void doWriteBeanConstructorDefinition(String name, BeanConstructorDefinition def) throws IOException { - startElement(name); - doWriteAttribute("index", toString(def.getIndex()), null); - doWriteAttribute("value", def.getValue(), null); - endElement(name); - } - protected void doWriteBeanConstructorsDefinition(String name, BeanConstructorsDefinition def) throws IOException { - startElement(name); - doWriteList(null, "constructor", def.getConstructors(), this::doWriteBeanConstructorDefinition); - endElement(name); - } - protected void doWriteBeanPropertiesDefinition(String name, BeanPropertiesDefinition def) throws IOException { - startElement(name); - doWriteList(null, "property", def.getProperties(), this::doWriteBeanPropertyDefinition); - endElement(name); - } - protected void doWriteBeanPropertyDefinition(String name, BeanPropertyDefinition def) throws IOException { - startElement(name); - doWriteAttribute("key", def.getKey(), null); - doWriteAttribute("value", def.getValue(), null); - doWriteElement("properties", def.getProperties(), this::doWriteBeanPropertiesDefinition); - endElement(name); - } - protected void doWriteBeansDefinitionElements(BeansDefinition def) throws IOException { - doWriteList(null, "component-scan", def.getComponentScanning(), this::doWriteComponentScanDefinition); - doWriteList(null, "bean", def.getBeans(), this::doWriteBeanFactoryDefinition); - domElements(def.getSpringOrBlueprintBeans()); - doWriteList(null, "sslContextParameters", def.getSslContextParameters(), this::doWriteSSLContextParametersDefinition); - doWriteList("dataFormats", "dataFormat", def.getDataFormats(), this::doWriteDataFormatDefinition); - doWriteList(null, "restConfiguration", def.getRestConfigurations(), this::doWriteRestConfigurationDefinition); - doWriteList(null, "rest", def.getRests(), this::doWriteRestDefinition); - doWriteList(null, "routeConfiguration", def.getRouteConfigurations(), this::doWriteRouteConfigurationDefinition); - doWriteList(null, "routeTemplate", def.getRouteTemplates(), this::doWriteRouteTemplateDefinition); - doWriteList(null, "templatedRoute", def.getTemplatedRoutes(), this::doWriteTemplatedRouteDefinition); - doWriteList(null, "route", def.getRoutes(), this::doWriteRouteDefinition); - } - protected void doWriteBeansDefinition(String name, BeansDefinition def) throws IOException { - startElement(name); - doWriteBeansDefinitionElements(def); - endElement(name); - } - protected void doWriteComponentScanDefinition(String name, ComponentScanDefinition def) throws IOException { - startElement(name); - doWriteAttribute("base-package", def.getBasePackage(), null); - endElement(name); - } - protected void doWriteSSLContextParametersDefinition(String name, SSLContextParametersDefinition def) throws IOException { - startElement(name); - doWriteAttribute("id", def.getId(), null); - doWriteAttribute("provider", def.getProvider(), null); - doWriteAttribute("secureSocketProtocol", def.getSecureSocketProtocol(), "TLSv1.3"); - doWriteAttribute("certAlias", def.getCertAlias(), null); - doWriteAttribute("sessionTimeout", def.getSessionTimeout(), "86400"); - doWriteAttribute("cipherSuites", def.getCipherSuites(), null); - doWriteAttribute("cipherSuitesInclude", def.getCipherSuitesInclude(), null); - doWriteAttribute("cipherSuitesExclude", def.getCipherSuitesExclude(), null); - doWriteAttribute("namedGroups", def.getNamedGroups(), null); - doWriteAttribute("namedGroupsInclude", def.getNamedGroupsInclude(), null); - doWriteAttribute("namedGroupsExclude", def.getNamedGroupsExclude(), null); - doWriteAttribute("signatureSchemes", def.getSignatureSchemes(), null); - doWriteAttribute("signatureSchemesInclude", def.getSignatureSchemesInclude(), null); - doWriteAttribute("signatureSchemesExclude", def.getSignatureSchemesExclude(), null); - doWriteAttribute("keyStore", def.getKeyStore(), null); - doWriteAttribute("keyStoreType", def.getKeyStoreType(), null); - doWriteAttribute("keyStoreProvider", def.getKeyStoreProvider(), null); - doWriteAttribute("keystorePassword", def.getKeystorePassword(), null); - doWriteAttribute("trustStore", def.getTrustStore(), null); - doWriteAttribute("trustStorePassword", def.getTrustStorePassword(), null); - doWriteAttribute("trustAllCertificates", def.getTrustAllCertificates(), null); - doWriteAttribute("keyManagerAlgorithm", def.getKeyManagerAlgorithm(), null); - doWriteAttribute("keyManagerProvider", def.getKeyManagerProvider(), null); - doWriteAttribute("secureRandomAlgorithm", def.getSecureRandomAlgorithm(), null); - doWriteAttribute("secureRandomProvider", def.getSecureRandomProvider(), null); - doWriteAttribute("clientAuthentication", def.getClientAuthentication(), "NONE"); - endElement(name); - } - protected void doWriteBatchResequencerConfig(String name, BatchResequencerConfig def) throws IOException { - startElement(name); - doWriteAttribute("batchSize", def.getBatchSize(), "100"); - doWriteAttribute("batchTimeout", def.getBatchTimeout(), "1000"); - doWriteAttribute("allowDuplicates", def.getAllowDuplicates(), null); - doWriteAttribute("reverse", def.getReverse(), null); - doWriteAttribute("ignoreInvalidExchanges", def.getIgnoreInvalidExchanges(), null); - endElement(name); - } - protected void doWriteResequencerConfig(String name, ResequencerConfig def) throws IOException { - startElement(name); - endElement(name); - } - protected void doWriteStreamResequencerConfig(String name, StreamResequencerConfig def) throws IOException { - startElement(name); - doWriteAttribute("capacity", def.getCapacity(), "1000"); - doWriteAttribute("timeout", def.getTimeout(), "1000"); - doWriteAttribute("deliveryAttemptInterval", def.getDeliveryAttemptInterval(), "1000"); - doWriteAttribute("ignoreInvalidExchanges", def.getIgnoreInvalidExchanges(), null); - doWriteAttribute("rejectOld", def.getRejectOld(), null); - doWriteAttribute("comparator", def.getComparator(), null); - endElement(name); - } - protected void doWriteASN1DataFormat(String name, ASN1DataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("unmarshalType", def.getUnmarshalTypeName(), null); - doWriteAttribute("usingIterator", def.getUsingIterator(), null); - endElement(name); - } - protected void doWriteAvroDataFormat(String name, AvroDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("unmarshalType", def.getUnmarshalTypeName(), null); - doWriteAttribute("collectionType", def.getCollectionTypeName(), null); - doWriteAttribute("jsonView", def.getJsonViewTypeName(), null); - doWriteAttribute("instanceClassName", def.getInstanceClassName(), null); - doWriteAttribute("library", toString(def.getLibrary()), "avroJackson"); - doWriteAttribute("objectMapper", def.getObjectMapper(), null); - doWriteAttribute("useDefaultObjectMapper", def.getUseDefaultObjectMapper(), "true"); - doWriteAttribute("include", def.getInclude(), null); - doWriteAttribute("allowJmsType", def.getAllowJmsType(), null); - doWriteAttribute("useList", def.getUseList(), null); - doWriteAttribute("moduleClassNames", def.getModuleClassNames(), null); - doWriteAttribute("moduleRefs", def.getModuleRefs(), null); - doWriteAttribute("enableFeatures", def.getEnableFeatures(), null); - doWriteAttribute("disableFeatures", def.getDisableFeatures(), null); - doWriteAttribute("allowUnmarshallType", def.getAllowUnmarshallType(), null); - doWriteAttribute("timezone", def.getTimezone(), null); - doWriteAttribute("autoDiscoverObjectMapper", def.getAutoDiscoverObjectMapper(), null); - doWriteAttribute("contentTypeHeader", def.getContentTypeHeader(), "true"); - doWriteAttribute("schemaResolver", def.getSchemaResolver(), null); - doWriteAttribute("autoDiscoverSchemaResolver", def.getAutoDiscoverSchemaResolver(), "true"); - endElement(name); - } - protected void doWriteBarcodeDataFormat(String name, BarcodeDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("barcodeFormat", def.getBarcodeFormat(), "QR_CODE"); - doWriteAttribute("imageType", def.getImageType(), "PNG"); - doWriteAttribute("width", def.getWidth(), "100"); - doWriteAttribute("height", def.getHeight(), "100"); - endElement(name); - } - protected void doWriteBase64DataFormat(String name, Base64DataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("lineLength", def.getLineLength(), "76"); - doWriteAttribute("lineSeparator", def.getLineSeparator(), null); - doWriteAttribute("urlSafe", def.getUrlSafe(), null); - endElement(name); - } - protected void doWriteBeanioDataFormat(String name, BeanioDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("mapping", def.getMapping(), null); - doWriteAttribute("streamName", def.getStreamName(), null); - doWriteAttribute("ignoreUnidentifiedRecords", def.getIgnoreUnidentifiedRecords(), null); - doWriteAttribute("ignoreUnexpectedRecords", def.getIgnoreUnexpectedRecords(), null); - doWriteAttribute("ignoreInvalidRecords", def.getIgnoreInvalidRecords(), null); - doWriteAttribute("encoding", def.getEncoding(), null); - doWriteAttribute("beanReaderErrorHandlerType", def.getBeanReaderErrorHandlerType(), null); - doWriteAttribute("unmarshalSingleObject", def.getUnmarshalSingleObject(), null); - endElement(name); - } - protected void doWriteBindyDataFormat(String name, BindyDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("classType", def.getClassTypeAsString(), null); - doWriteAttribute("type", def.getType(), null); - doWriteAttribute("defaultValueStringAsNull", def.getDefaultValueStringAsNull(), null); - doWriteAttribute("allowEmptyStream", def.getAllowEmptyStream(), "false"); - doWriteAttribute("unwrapSingleInstance", def.getUnwrapSingleInstance(), "true"); - doWriteAttribute("locale", def.getLocale(), null); - endElement(name); - } - protected void doWriteCBORDataFormat(String name, CBORDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("unmarshalType", def.getUnmarshalTypeName(), null); - doWriteAttribute("collectionType", def.getCollectionTypeName(), null); - doWriteAttribute("objectMapper", def.getObjectMapper(), null); - doWriteAttribute("useDefaultObjectMapper", def.getUseDefaultObjectMapper(), "true"); - doWriteAttribute("useList", def.getUseList(), "false"); - doWriteAttribute("allowUnmarshallType", def.getAllowUnmarshallType(), "false"); - doWriteAttribute("prettyPrint", def.getPrettyPrint(), "false"); - doWriteAttribute("allowJmsType", def.getAllowJmsType(), "false"); - doWriteAttribute("enableFeatures", def.getEnableFeatures(), null); - doWriteAttribute("disableFeatures", def.getDisableFeatures(), null); - endElement(name); - } - protected void doWriteCryptoDataFormat(String name, CryptoDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("algorithm", def.getAlgorithm(), null); - doWriteAttribute("key", def.getKey(), null); - doWriteAttribute("cryptoProvider", def.getCryptoProvider(), null); - doWriteAttribute("initVector", def.getInitVector(), null); - doWriteAttribute("algorithmParameterSpec", def.getAlgorithmParameterSpec(), null); - doWriteAttribute("bufferSize", def.getBufferSize(), "4096"); - doWriteAttribute("macAlgorithm", def.getMacAlgorithm(), "HmacSHA1"); - doWriteAttribute("shouldAppendHMAC", def.getShouldAppendHMAC(), "true"); - doWriteAttribute("inline", def.getInline(), "false"); - endElement(name); - } - protected void doWriteCsvDataFormat(String name, CsvDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("format", def.getFormat(), "DEFAULT"); - doWriteAttribute("commentMarkerDisabled", def.getCommentMarkerDisabled(), null); - doWriteAttribute("commentMarker", def.getCommentMarker(), null); - doWriteAttribute("delimiter", def.getDelimiter(), null); - doWriteAttribute("escapeDisabled", def.getEscapeDisabled(), null); - doWriteAttribute("escape", def.getEscape(), null); - doWriteAttribute("headerDisabled", def.getHeaderDisabled(), null); - doWriteAttribute("header", def.getHeader(), null); - doWriteAttribute("allowMissingColumnNames", def.getAllowMissingColumnNames(), null); - doWriteAttribute("ignoreEmptyLines", def.getIgnoreEmptyLines(), null); - doWriteAttribute("ignoreSurroundingSpaces", def.getIgnoreSurroundingSpaces(), null); - doWriteAttribute("nullStringDisabled", def.getNullStringDisabled(), null); - doWriteAttribute("nullString", def.getNullString(), null); - doWriteAttribute("quoteDisabled", def.getQuoteDisabled(), null); - doWriteAttribute("quote", def.getQuote(), null); - doWriteAttribute("recordSeparatorDisabled", def.getRecordSeparatorDisabled(), null); - doWriteAttribute("recordSeparator", def.getRecordSeparator(), null); - doWriteAttribute("skipHeaderRecord", def.getSkipHeaderRecord(), null); - doWriteAttribute("quoteMode", def.getQuoteMode(), null); - doWriteAttribute("ignoreHeaderCase", def.getIgnoreHeaderCase(), null); - doWriteAttribute("trim", def.getTrim(), null); - doWriteAttribute("trailingDelimiter", def.getTrailingDelimiter(), null); - doWriteAttribute("marshallerFactoryRef", def.getMarshallerFactoryRef(), null); - doWriteAttribute("lazyLoad", def.getLazyLoad(), null); - doWriteAttribute("useMaps", def.getUseMaps(), null); - doWriteAttribute("useOrderedMaps", def.getUseOrderedMaps(), null); - doWriteAttribute("recordConverterRef", def.getRecordConverterRef(), null); - doWriteAttribute("captureHeaderRecord", def.getCaptureHeaderRecord(), null); - endElement(name); - } - protected void doWriteCustomDataFormat(String name, CustomDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - endElement(name); - } - protected void doWriteDataFormatsDefinition(String name, DataFormatsDefinition def) throws IOException { - startElement(name); - doWriteList(null, null, def.getDataFormats(), (n, v) -> { - switch (v.getClass().getSimpleName()) { - case "ASN1DataFormat" -> doWriteASN1DataFormat("asn1", (ASN1DataFormat) v); - case "AvroDataFormat" -> doWriteAvroDataFormat("avro", (AvroDataFormat) v); - case "BarcodeDataFormat" -> doWriteBarcodeDataFormat("barcode", (BarcodeDataFormat) v); - case "Base64DataFormat" -> doWriteBase64DataFormat("base64", (Base64DataFormat) v); - case "BeanioDataFormat" -> doWriteBeanioDataFormat("beanio", (BeanioDataFormat) v); - case "BindyDataFormat" -> doWriteBindyDataFormat("bindy", (BindyDataFormat) v); - case "CBORDataFormat" -> doWriteCBORDataFormat("cbor", (CBORDataFormat) v); - case "CryptoDataFormat" -> doWriteCryptoDataFormat("crypto", (CryptoDataFormat) v); - case "CsvDataFormat" -> doWriteCsvDataFormat("csv", (CsvDataFormat) v); - case "CustomDataFormat" -> doWriteCustomDataFormat("custom", (CustomDataFormat) v); - case "DfdlDataFormat" -> doWriteDfdlDataFormat("dfdl", (DfdlDataFormat) v); - case "FhirJsonDataFormat" -> doWriteFhirJsonDataFormat("fhirJson", (FhirJsonDataFormat) v); - case "FhirXmlDataFormat" -> doWriteFhirXmlDataFormat("fhirXml", (FhirXmlDataFormat) v); - case "FlatpackDataFormat" -> doWriteFlatpackDataFormat("flatpack", (FlatpackDataFormat) v); - case "ForyDataFormat" -> doWriteForyDataFormat("fory", (ForyDataFormat) v); - case "GrokDataFormat" -> doWriteGrokDataFormat("grok", (GrokDataFormat) v); - case "GroovyJSonDataFormat" -> doWriteGroovyJSonDataFormat("groovyJson", (GroovyJSonDataFormat) v); - case "GroovyXmlDataFormat" -> doWriteGroovyXmlDataFormat("groovyXml", (GroovyXmlDataFormat) v); - case "GzipDeflaterDataFormat" -> doWriteGzipDeflaterDataFormat("gzipDeflater", (GzipDeflaterDataFormat) v); - case "HL7DataFormat" -> doWriteHL7DataFormat("hl7", (HL7DataFormat) v); - case "IcalDataFormat" -> doWriteIcalDataFormat("ical", (IcalDataFormat) v); - case "Iso8583DataFormat" -> doWriteIso8583DataFormat("iso8583", (Iso8583DataFormat) v); - case "JacksonXMLDataFormat" -> doWriteJacksonXMLDataFormat("jacksonXml", (JacksonXMLDataFormat) v); - case "JaxbDataFormat" -> doWriteJaxbDataFormat("jaxb", (JaxbDataFormat) v); - case "JsonDataFormat" -> doWriteJsonDataFormat("json", (JsonDataFormat) v); - case "JsonApiDataFormat" -> doWriteJsonApiDataFormat("jsonApi", (JsonApiDataFormat) v); - case "LZFDataFormat" -> doWriteLZFDataFormat("lzf", (LZFDataFormat) v); - case "MimeMultipartDataFormat" -> doWriteMimeMultipartDataFormat("mimeMultipart", (MimeMultipartDataFormat) v); - case "OcsfDataFormat" -> doWriteOcsfDataFormat("ocsf", (OcsfDataFormat) v); - case "ParquetAvroDataFormat" -> doWriteParquetAvroDataFormat("parquetAvro", (ParquetAvroDataFormat) v); - case "PGPDataFormat" -> doWritePGPDataFormat("pgp", (PGPDataFormat) v); - case "PQCDataFormat" -> doWritePQCDataFormat("pqc", (PQCDataFormat) v); - case "ProtobufDataFormat" -> doWriteProtobufDataFormat("protobuf", (ProtobufDataFormat) v); - case "RssDataFormat" -> doWriteRssDataFormat("rss", (RssDataFormat) v); - case "SmooksDataFormat" -> doWriteSmooksDataFormat("smooks", (SmooksDataFormat) v); - case "SoapDataFormat" -> doWriteSoapDataFormat("soap", (SoapDataFormat) v); - case "SwiftMtDataFormat" -> doWriteSwiftMtDataFormat("swiftMt", (SwiftMtDataFormat) v); - case "SwiftMxDataFormat" -> doWriteSwiftMxDataFormat("swiftMx", (SwiftMxDataFormat) v); - case "SyslogDataFormat" -> doWriteSyslogDataFormat("syslog", (SyslogDataFormat) v); - case "TarFileDataFormat" -> doWriteTarFileDataFormat("tarFile", (TarFileDataFormat) v); - case "ThriftDataFormat" -> doWriteThriftDataFormat("thrift", (ThriftDataFormat) v); - case "UniVocityCsvDataFormat" -> doWriteUniVocityCsvDataFormat("univocityCsv", (UniVocityCsvDataFormat) v); - case "UniVocityFixedDataFormat" -> doWriteUniVocityFixedDataFormat("univocityFixed", (UniVocityFixedDataFormat) v); - case "UniVocityTsvDataFormat" -> doWriteUniVocityTsvDataFormat("univocityTsv", (UniVocityTsvDataFormat) v); - case "XMLSecurityDataFormat" -> doWriteXMLSecurityDataFormat("xmlSecurity", (XMLSecurityDataFormat) v); - case "YAMLDataFormat" -> doWriteYAMLDataFormat("yaml", (YAMLDataFormat) v); - case "ZipDeflaterDataFormat" -> doWriteZipDeflaterDataFormat("zipDeflater", (ZipDeflaterDataFormat) v); - case "ZipFileDataFormat" -> doWriteZipFileDataFormat("zipFile", (ZipFileDataFormat) v); - } - }); - endElement(name); - } - protected void doWriteDfdlDataFormat(String name, DfdlDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("schemaUri", def.getSchemaUri(), null); - doWriteAttribute("rootElement", def.getRootElement(), null); - doWriteAttribute("rootNamespace", def.getRootNamespace(), null); - endElement(name); - } - protected void doWriteFhirDataformatAttributes(FhirDataformat def) throws IOException { - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("contentTypeHeader", def.getContentTypeHeader(), "true"); - doWriteAttribute("dontStripVersionsFromReferencesAtPaths", def.getDontStripVersionsFromReferencesAtPaths(), null); - doWriteAttribute("parserOptions", def.getParserOptions(), null); - doWriteAttribute("prettyPrint", def.getPrettyPrint(), null); - doWriteAttribute("dontEncodeElements", def.getDontEncodeElements(), null); - doWriteAttribute("summaryMode", def.getSummaryMode(), null); - doWriteAttribute("forceResourceId", def.getForceResourceId(), null); - doWriteAttribute("encodeElementsAppliesToChildResourcesOnly", def.getEncodeElementsAppliesToChildResourcesOnly(), null); - doWriteAttribute("parserErrorHandler", def.getParserErrorHandler(), null); - doWriteAttribute("serverBaseUrl", def.getServerBaseUrl(), null); - doWriteAttribute("fhirVersion", def.getFhirVersion(), "R4"); - doWriteAttribute("suppressNarratives", def.getSuppressNarratives(), null); - doWriteAttribute("fhirContext", def.getFhirContext(), null); - doWriteAttribute("stripVersionsFromReferences", def.getStripVersionsFromReferences(), null); - doWriteAttribute("encodeElements", def.getEncodeElements(), null); - doWriteAttribute("preferTypes", def.getPreferTypes(), null); - doWriteAttribute("overrideResourceIdWithBundleEntryFullUrl", def.getOverrideResourceIdWithBundleEntryFullUrl(), null); - doWriteAttribute("omitResourceId", def.getOmitResourceId(), null); - } - protected void doWriteFhirDataformat(String name, FhirDataformat def) throws IOException { - startElement(name); - doWriteFhirDataformatAttributes(def); - endElement(name); - } - protected void doWriteFhirJsonDataFormat(String name, FhirJsonDataFormat def) throws IOException { - startElement(name); - doWriteFhirDataformatAttributes(def); - endElement(name); - } - protected void doWriteFhirXmlDataFormat(String name, FhirXmlDataFormat def) throws IOException { - startElement(name); - doWriteFhirDataformatAttributes(def); - endElement(name); - } - protected void doWriteFlatpackDataFormat(String name, FlatpackDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("definition", def.getDefinition(), null); - doWriteAttribute("fixed", def.getFixed(), null); - doWriteAttribute("delimiter", def.getDelimiter(), ","); - doWriteAttribute("ignoreFirstRecord", def.getIgnoreFirstRecord(), "true"); - doWriteAttribute("allowShortLines", def.getAllowShortLines(), null); - doWriteAttribute("ignoreExtraColumns", def.getIgnoreExtraColumns(), null); - doWriteAttribute("textQualifier", def.getTextQualifier(), null); - doWriteAttribute("parserFactory", def.getParserFactory(), null); - endElement(name); - } - protected void doWriteForyDataFormat(String name, ForyDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("unmarshalType", def.getUnmarshalTypeName(), null); - doWriteAttribute("requireClassRegistration", def.getRequireClassRegistration(), "true"); - doWriteAttribute("threadSafe", def.getThreadSafe(), "true"); - doWriteAttribute("allowAutoWiredFory", def.getAllowAutoWiredFory(), "true"); - endElement(name); - } - protected void doWriteGrokDataFormat(String name, GrokDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("pattern", def.getPattern(), null); - doWriteAttribute("flattened", def.getFlattened(), null); - doWriteAttribute("allowMultipleMatchesPerLine", def.getAllowMultipleMatchesPerLine(), "true"); - doWriteAttribute("namedOnly", def.getNamedOnly(), null); - endElement(name); - } - protected void doWriteGroovyJSonDataFormat(String name, GroovyJSonDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("prettyPrint", def.getPrettyPrint(), "true"); - endElement(name); - } - protected void doWriteGroovyXmlDataFormat(String name, GroovyXmlDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("attributeMapping", def.getAttributeMapping(), "true"); - endElement(name); - } - protected void doWriteGzipDeflaterDataFormat(String name, GzipDeflaterDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - endElement(name); - } - protected void doWriteHL7DataFormat(String name, HL7DataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("parser", def.getParser(), null); - doWriteAttribute("validate", def.getValidate(), "true"); - endElement(name); - } - protected void doWriteIcalDataFormat(String name, IcalDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("validating", def.getValidating(), null); - endElement(name); - } - protected void doWriteIso8583DataFormat(String name, Iso8583DataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("configFile", def.getConfigFile(), "j8583-config.xml"); - doWriteAttribute("isoType", def.getIsoType(), null); - doWriteAttribute("allowAutoWiredMessageFormat", def.getAllowAutoWiredMessageFormat(), "true"); - endElement(name); - } - protected void doWriteJacksonXMLDataFormat(String name, JacksonXMLDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("unmarshalType", def.getUnmarshalTypeName(), null); - doWriteAttribute("collectionType", def.getCollectionTypeName(), null); - doWriteAttribute("jsonView", def.getJsonViewTypeName(), null); - doWriteAttribute("xmlMapper", def.getXmlMapper(), null); - doWriteAttribute("prettyPrint", def.getPrettyPrint(), null); - doWriteAttribute("allowUnmarshallType", def.getAllowUnmarshallType(), null); - doWriteAttribute("include", def.getInclude(), null); - doWriteAttribute("allowJmsType", def.getAllowJmsType(), null); - doWriteAttribute("useList", def.getUseList(), null); - doWriteAttribute("timezone", def.getTimezone(), null); - doWriteAttribute("enableJaxbAnnotationModule", def.getEnableJaxbAnnotationModule(), null); - doWriteAttribute("moduleClassNames", def.getModuleClassNames(), null); - doWriteAttribute("moduleRefs", def.getModuleRefs(), null); - doWriteAttribute("enableFeatures", def.getEnableFeatures(), null); - doWriteAttribute("disableFeatures", def.getDisableFeatures(), null); - doWriteAttribute("contentTypeHeader", def.getContentTypeHeader(), "true"); - doWriteAttribute("maxStringLength", def.getMaxStringLength(), null); - endElement(name); - } - protected void doWriteJaxbDataFormat(String name, JaxbDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("contextPath", def.getContextPath(), null); - doWriteAttribute("contextPathIsClassName", def.getContextPathIsClassName(), null); - doWriteAttribute("schema", def.getSchema(), null); - doWriteAttribute("schemaSeverityLevel", def.getSchemaSeverityLevel(), "0"); - doWriteAttribute("prettyPrint", def.getPrettyPrint(), "true"); - doWriteAttribute("objectFactory", def.getObjectFactory(), "true"); - doWriteAttribute("ignoreJAXBElement", def.getIgnoreJAXBElement(), "true"); - doWriteAttribute("mustBeJAXBElement", def.getMustBeJAXBElement(), null); - doWriteAttribute("filterNonXmlChars", def.getFilterNonXmlChars(), null); - doWriteAttribute("encoding", def.getEncoding(), null); - doWriteAttribute("fragment", def.getFragment(), null); - doWriteAttribute("partClass", def.getPartClass(), null); - doWriteAttribute("partNamespace", def.getPartNamespace(), null); - doWriteAttribute("namespacePrefix", def.getNamespacePrefix(), null); - doWriteAttribute("xmlStreamWriterWrapper", def.getXmlStreamWriterWrapper(), null); - doWriteAttribute("schemaLocation", def.getSchemaLocation(), null); - doWriteAttribute("noNamespaceSchemaLocation", def.getNoNamespaceSchemaLocation(), null); - doWriteAttribute("jaxbProviderProperties", def.getJaxbProviderProperties(), null); - doWriteAttribute("contentTypeHeader", def.getContentTypeHeader(), "true"); - doWriteAttribute("accessExternalSchemaProtocols", def.getAccessExternalSchemaProtocols(), null); - endElement(name); - } - protected void doWriteJsonApiDataFormat(String name, JsonApiDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("dataFormatTypes", def.getDataFormatTypes(), null); - doWriteAttribute("mainFormatType", def.getMainFormatType(), null); - endElement(name); - } - protected void doWriteJsonDataFormat(String name, JsonDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("collectionType", def.getCollectionTypeName(), null); - doWriteAttribute("jsonView", def.getJsonViewTypeName(), null); - doWriteAttribute("unmarshalType", def.getUnmarshalTypeName(), null); - doWriteAttribute("objectMapper", def.getObjectMapper(), null); - doWriteAttribute("useDefaultObjectMapper", def.getUseDefaultObjectMapper(), "true"); - doWriteAttribute("autoDiscoverObjectMapper", def.getAutoDiscoverObjectMapper(), "false"); - doWriteAttribute("prettyPrint", def.getPrettyPrint(), null); - doWriteAttribute("library", toString(def.getLibrary()), "Jackson"); - doWriteAttribute("combineUnicodeSurrogates", def.getCombineUnicodeSurrogates(), null); - doWriteAttribute("include", def.getInclude(), null); - doWriteAttribute("allowJmsType", def.getAllowJmsType(), null); - doWriteAttribute("useList", def.getUseList(), null); - doWriteAttribute("moduleClassNames", def.getModuleClassNames(), null); - doWriteAttribute("moduleRefs", def.getModuleRefs(), null); - doWriteAttribute("enableFeatures", def.getEnableFeatures(), null); - doWriteAttribute("disableFeatures", def.getDisableFeatures(), null); - doWriteAttribute("allowUnmarshallType", def.getAllowUnmarshallType(), null); - doWriteAttribute("timezone", def.getTimezone(), null); - doWriteAttribute("schemaResolver", def.getSchemaResolver(), null); - doWriteAttribute("autoDiscoverSchemaResolver", def.getAutoDiscoverSchemaResolver(), "true"); - doWriteAttribute("namingStrategy", def.getNamingStrategy(), null); - doWriteAttribute("contentTypeHeader", def.getContentTypeHeader(), "true"); - doWriteAttribute("dateFormatPattern", def.getDateFormatPattern(), null); - doWriteAttribute("maxStringLength", def.getMaxStringLength(), null); - endElement(name); - } - protected void doWriteLZFDataFormat(String name, LZFDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("usingParallelCompression", def.getUsingParallelCompression(), null); - endElement(name); - } - protected void doWriteMimeMultipartDataFormat(String name, MimeMultipartDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("multipartSubType", def.getMultipartSubType(), "mixed"); - doWriteAttribute("multipartWithoutAttachment", def.getMultipartWithoutAttachment(), null); - doWriteAttribute("headersInline", def.getHeadersInline(), null); - doWriteAttribute("includeHeaders", def.getIncludeHeaders(), null); - doWriteAttribute("binaryContent", def.getBinaryContent(), null); - endElement(name); - } - protected void doWriteOcsfDataFormat(String name, OcsfDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("unmarshalType", def.getUnmarshalTypeName(), null); - doWriteAttribute("collectionType", def.getCollectionTypeName(), null); - doWriteAttribute("objectMapper", def.getObjectMapper(), null); - doWriteAttribute("useDefaultObjectMapper", def.getUseDefaultObjectMapper(), "true"); - doWriteAttribute("useList", def.getUseList(), "false"); - doWriteAttribute("allowUnmarshallType", def.getAllowUnmarshallType(), "false"); - doWriteAttribute("prettyPrint", def.getPrettyPrint(), "false"); - endElement(name); - } - protected void doWritePGPDataFormat(String name, PGPDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("keyUserid", def.getKeyUserid(), null); - doWriteAttribute("signatureKeyUserid", def.getSignatureKeyUserid(), null); - doWriteAttribute("password", def.getPassword(), null); - doWriteAttribute("signaturePassword", def.getSignaturePassword(), null); - doWriteAttribute("keyFileName", def.getKeyFileName(), null); - doWriteAttribute("signatureKeyFileName", def.getSignatureKeyFileName(), null); - doWriteAttribute("signatureKeyRing", def.getSignatureKeyRing(), null); - doWriteAttribute("armored", def.getArmored(), "false"); - doWriteAttribute("integrity", def.getIntegrity(), "true"); - doWriteAttribute("provider", def.getProvider(), null); - doWriteAttribute("algorithm", def.getAlgorithm(), null); - doWriteAttribute("compressionAlgorithm", def.getCompressionAlgorithm(), null); - doWriteAttribute("hashAlgorithm", def.getHashAlgorithm(), null); - doWriteAttribute("signatureVerificationOption", def.getSignatureVerificationOption(), null); - endElement(name); - } - protected void doWritePQCDataFormat(String name, PQCDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("keyEncapsulationAlgorithm", def.getKeyEncapsulationAlgorithm(), "MLKEM"); - doWriteAttribute("symmetricKeyAlgorithm", def.getSymmetricKeyAlgorithm(), "AES"); - doWriteAttribute("symmetricKeyLength", def.getSymmetricKeyLength(), "128"); - doWriteAttribute("keyPair", def.getKeyPair(), null); - doWriteAttribute("bufferSize", def.getBufferSize(), "4096"); - doWriteAttribute("provider", def.getProvider(), null); - doWriteAttribute("keyGenerator", def.getKeyGenerator(), null); - endElement(name); - } - protected void doWriteParquetAvroDataFormat(String name, ParquetAvroDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("unmarshalType", def.getUnmarshalTypeName(), null); - doWriteAttribute("compressionCodecName", def.getCompressionCodecName(), "GZIP"); - doWriteAttribute("lazyLoad", def.getLazyLoad(), null); - endElement(name); - } - protected void doWriteProtobufDataFormat(String name, ProtobufDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("collectionType", def.getCollectionTypeName(), null); - doWriteAttribute("jsonView", def.getJsonViewTypeName(), null); - doWriteAttribute("unmarshalType", def.getUnmarshalTypeName(), null); - doWriteAttribute("instanceClass", def.getInstanceClass(), null); - doWriteAttribute("objectMapper", def.getObjectMapper(), null); - doWriteAttribute("useDefaultObjectMapper", def.getUseDefaultObjectMapper(), "true"); - doWriteAttribute("autoDiscoverObjectMapper", def.getAutoDiscoverObjectMapper(), "false"); - doWriteAttribute("library", toString(def.getLibrary()), "GoogleProtobuf"); - doWriteAttribute("include", def.getInclude(), null); - doWriteAttribute("allowJmsType", def.getAllowJmsType(), null); - doWriteAttribute("useList", def.getUseList(), null); - doWriteAttribute("moduleClassNames", def.getModuleClassNames(), null); - doWriteAttribute("moduleRefs", def.getModuleRefs(), null); - doWriteAttribute("enableFeatures", def.getEnableFeatures(), null); - doWriteAttribute("disableFeatures", def.getDisableFeatures(), null); - doWriteAttribute("allowUnmarshallType", def.getAllowUnmarshallType(), null); - doWriteAttribute("timezone", def.getTimezone(), null); - doWriteAttribute("schemaResolver", def.getSchemaResolver(), null); - doWriteAttribute("autoDiscoverSchemaResolver", def.getAutoDiscoverSchemaResolver(), "true"); - doWriteAttribute("contentTypeFormat", def.getContentTypeFormat(), "native"); - doWriteAttribute("contentTypeHeader", def.getContentTypeHeader(), "true"); - endElement(name); - } - protected void doWriteRssDataFormat(String name, RssDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - endElement(name); - } - protected void doWriteSmooksDataFormat(String name, SmooksDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("smooksConfig", def.getSmooksConfig(), null); - endElement(name); - } - protected void doWriteSoapDataFormat(String name, SoapDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("contextPath", def.getContextPath(), null); - doWriteAttribute("encoding", def.getEncoding(), null); - doWriteAttribute("elementNameStrategy", def.getElementNameStrategy(), null); - doWriteAttribute("version", def.getVersion(), "1.1"); - doWriteAttribute("namespacePrefix", def.getNamespacePrefix(), null); - doWriteAttribute("schema", def.getSchema(), null); - doWriteAttribute("ignoreUnmarshalledHeaders", def.getIgnoreUnmarshalledHeaders(), null); - endElement(name); - } - protected void doWriteSwiftMtDataFormat(String name, SwiftMtDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("writeInJson", def.getWriteInJson(), null); - endElement(name); - } - protected void doWriteSwiftMxDataFormat(String name, SwiftMxDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("writeInJson", def.getWriteInJson(), null); - doWriteAttribute("readMessageId", def.getReadMessageId(), null); - doWriteAttribute("readConfig", def.getReadConfig(), null); - doWriteAttribute("writeConfig", def.getWriteConfig(), null); - endElement(name); - } - protected void doWriteSyslogDataFormat(String name, SyslogDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - endElement(name); - } - protected void doWriteTarFileDataFormat(String name, TarFileDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("usingIterator", def.getUsingIterator(), null); - doWriteAttribute("allowEmptyDirectory", def.getAllowEmptyDirectory(), null); - doWriteAttribute("preservePathElements", def.getPreservePathElements(), null); - doWriteAttribute("maxDecompressedSize", def.getMaxDecompressedSize(), "1073741824"); - endElement(name); - } - protected void doWriteThriftDataFormat(String name, ThriftDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("instanceClass", def.getInstanceClass(), null); - doWriteAttribute("contentTypeFormat", def.getContentTypeFormat(), "binary"); - doWriteAttribute("contentTypeHeader", def.getContentTypeHeader(), "true"); - endElement(name); - } - protected void doWriteUniVocityAbstractDataFormatAttributes(UniVocityAbstractDataFormat def) throws IOException { - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("headerExtractionEnabled", def.getHeaderExtractionEnabled(), null); - doWriteAttribute("skipEmptyLines", def.getSkipEmptyLines(), "true"); - doWriteAttribute("asMap", def.getAsMap(), null); - doWriteAttribute("ignoreLeadingWhitespaces", def.getIgnoreLeadingWhitespaces(), "true"); - doWriteAttribute("lineSeparator", def.getLineSeparator(), null); - doWriteAttribute("ignoreTrailingWhitespaces", def.getIgnoreTrailingWhitespaces(), "true"); - doWriteAttribute("lazyLoad", def.getLazyLoad(), null); - doWriteAttribute("nullValue", def.getNullValue(), null); - doWriteAttribute("normalizedLineSeparator", def.getNormalizedLineSeparator(), null); - doWriteAttribute("emptyValue", def.getEmptyValue(), null); - doWriteAttribute("headersDisabled", def.getHeadersDisabled(), null); - doWriteAttribute("comment", def.getComment(), "#"); - doWriteAttribute("numberOfRecordsToRead", def.getNumberOfRecordsToRead(), null); - } - protected void doWriteUniVocityAbstractDataFormatElements(UniVocityAbstractDataFormat def) throws IOException { - doWriteList(null, null, def.getHeaders(), this::doWriteUniVocityHeaderRef); - } - protected void doWriteUniVocityAbstractDataFormat(String name, UniVocityAbstractDataFormat def) throws IOException { - startElement(name); - doWriteUniVocityAbstractDataFormatAttributes(def); - doWriteUniVocityAbstractDataFormatElements(def); - endElement(name); - } - protected void doWriteUniVocityCsvDataFormat(String name, UniVocityCsvDataFormat def) throws IOException { - startElement(name); - doWriteUniVocityAbstractDataFormatAttributes(def); - doWriteAttribute("delimiter", def.getDelimiter(), ","); - doWriteAttribute("quoteAllFields", def.getQuoteAllFields(), null); - doWriteAttribute("quote", def.getQuote(), "\""); - doWriteAttribute("quoteEscape", def.getQuoteEscape(), "\""); - doWriteUniVocityAbstractDataFormatElements(def); - endElement(name); - } - protected void doWriteUniVocityFixedDataFormat(String name, UniVocityFixedDataFormat def) throws IOException { - startElement(name); - doWriteUniVocityAbstractDataFormatAttributes(def); - doWriteAttribute("padding", def.getPadding(), null); - doWriteAttribute("skipTrailingCharsUntilNewline", def.getSkipTrailingCharsUntilNewline(), null); - doWriteAttribute("recordEndsOnNewline", def.getRecordEndsOnNewline(), null); - doWriteUniVocityAbstractDataFormatElements(def); - endElement(name); - } - protected void doWriteUniVocityHeader(String name, UniVocityHeader def) throws IOException { - startElement(name); - doWriteAttribute("length", def.getLength(), null); - doWriteValue(def.getName()); - endElement(name); - } - protected void doWriteUniVocityTsvDataFormat(String name, UniVocityTsvDataFormat def) throws IOException { - startElement(name); - doWriteUniVocityAbstractDataFormatAttributes(def); - doWriteAttribute("escapeChar", def.getEscapeChar(), "\\"); - doWriteUniVocityAbstractDataFormatElements(def); - endElement(name); - } - protected void doWriteXMLSecurityDataFormat(String name, XMLSecurityDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("namespace", def.getNamespaceRef(), null); - doWriteAttribute("xmlCipherAlgorithm", def.getXmlCipherAlgorithm(), "AES-256-GCM"); - doWriteAttribute("passPhrase", def.getPassPhrase(), null); - doWriteAttribute("passPhraseByte", toString(def.getPassPhraseByte()), null); - doWriteAttribute("secureTag", def.getSecureTag(), null); - doWriteAttribute("secureTagContents", def.getSecureTagContents(), null); - doWriteAttribute("keyCipherAlgorithm", def.getKeyCipherAlgorithm(), "RSA_OAEP"); - doWriteAttribute("recipientKeyAlias", def.getRecipientKeyAlias(), null); - doWriteAttribute("keyOrTrustStoreParameters", def.getKeyOrTrustStoreParameters(), null); - doWriteAttribute("keyPassword", def.getKeyPassword(), null); - doWriteAttribute("digestAlgorithm", def.getDigestAlgorithm(), "SHA1"); - doWriteAttribute("mgfAlgorithm", def.getMgfAlgorithm(), "MGF1_SHA1"); - doWriteAttribute("addKeyValueForEncryptedKey", def.getAddKeyValueForEncryptedKey(), "true"); - endElement(name); - } - protected void doWriteYAMLDataFormat(String name, YAMLDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("unmarshalType", def.getUnmarshalTypeName(), null); - doWriteAttribute("library", toString(def.getLibrary()), "SnakeYAML"); - doWriteAttribute("constructor", def.getConstructor(), null); - doWriteAttribute("representer", def.getRepresenter(), null); - doWriteAttribute("dumperOptions", def.getDumperOptions(), null); - doWriteAttribute("resolver", def.getResolver(), null); - doWriteAttribute("useApplicationContextClassLoader", def.getUseApplicationContextClassLoader(), "true"); - doWriteAttribute("prettyFlow", def.getPrettyFlow(), null); - doWriteAttribute("allowAnyType", def.getAllowAnyType(), null); - doWriteAttribute("typeFilter", def.getTypeFilter(), null); - doWriteAttribute("maxAliasesForCollections", def.getMaxAliasesForCollections(), "50"); - doWriteAttribute("allowRecursiveKeys", def.getAllowRecursiveKeys(), null); - endElement(name); - } - protected void doWriteZipDeflaterDataFormat(String name, ZipDeflaterDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("compressionLevel", def.getCompressionLevel(), "-1"); - endElement(name); - } - protected void doWriteZipFileDataFormat(String name, ZipFileDataFormat def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("usingIterator", def.getUsingIterator(), null); - doWriteAttribute("allowEmptyDirectory", def.getAllowEmptyDirectory(), null); - doWriteAttribute("preservePathElements", def.getPreservePathElements(), null); - doWriteAttribute("maxDecompressedSize", def.getMaxDecompressedSize(), "1073741824"); - endElement(name); - } - protected void doWriteDeadLetterChannelDefinition(String name, DeadLetterChannelDefinition def) throws IOException { - startElement(name); - doWriteDefaultErrorHandlerDefinitionAttributes(def); - doWriteAttribute("deadLetterUri", def.getDeadLetterUri(), null); - doWriteAttribute("deadLetterHandleNewException", def.getDeadLetterHandleNewException(), "true"); - doWriteDefaultErrorHandlerDefinitionElements(def); - endElement(name); - } - protected void doWriteDefaultErrorHandlerDefinitionAttributes(DefaultErrorHandlerDefinition def) throws IOException { - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("useOriginalMessage", def.getUseOriginalMessage(), null); - doWriteAttribute("useOriginalBody", def.getUseOriginalBody(), null); - doWriteAttribute("redeliveryPolicyRef", def.getRedeliveryPolicyRef(), null); - doWriteAttribute("loggerRef", def.getLoggerRef(), null); - doWriteAttribute("level", def.getLevel(), "ERROR"); - doWriteAttribute("logName", def.getLogName(), null); - doWriteAttribute("onRedeliveryRef", def.getOnRedeliveryRef(), null); - doWriteAttribute("onExceptionOccurredRef", def.getOnExceptionOccurredRef(), null); - doWriteAttribute("onPrepareFailureRef", def.getOnPrepareFailureRef(), null); - doWriteAttribute("retryWhileRef", def.getRetryWhileRef(), null); - doWriteAttribute("executorServiceRef", def.getExecutorServiceRef(), null); - } - protected void doWriteDefaultErrorHandlerDefinitionElements(DefaultErrorHandlerDefinition def) throws IOException { - doWriteElement("redeliveryPolicy", def.getRedeliveryPolicy(), this::doWriteRedeliveryPolicyDefinition); - } - protected void doWriteDefaultErrorHandlerDefinition(String name, DefaultErrorHandlerDefinition def) throws IOException { - startElement(name); - doWriteDefaultErrorHandlerDefinitionAttributes(def); - doWriteDefaultErrorHandlerDefinitionElements(def); - endElement(name); - } - protected void doWriteJtaTransactionErrorHandlerDefinition(String name, JtaTransactionErrorHandlerDefinition def) throws IOException { - startElement(name); - doWriteTransactionErrorHandlerDefinitionAttributes(def); - doWriteDefaultErrorHandlerDefinitionElements(def); - endElement(name); - } - protected void doWriteNoErrorHandlerDefinition(String name, NoErrorHandlerDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - endElement(name); - } - protected void doWriteRefErrorHandlerDefinition(String name, RefErrorHandlerDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - endElement(name); - } - protected void doWriteSpringTransactionErrorHandlerDefinition(String name, SpringTransactionErrorHandlerDefinition def) throws IOException { - startElement(name); - doWriteTransactionErrorHandlerDefinitionAttributes(def); - doWriteDefaultErrorHandlerDefinitionElements(def); - endElement(name); - } - protected void doWriteTransactionErrorHandlerDefinitionAttributes(TransactionErrorHandlerDefinition def) throws IOException { - doWriteDefaultErrorHandlerDefinitionAttributes(def); - doWriteAttribute("rollbackLoggingLevel", def.getRollbackLoggingLevel(), "WARN"); - doWriteAttribute("transactedPolicyRef", def.getTransactedPolicyRef(), null); - } - protected void doWriteTransactionErrorHandlerDefinition(String name, TransactionErrorHandlerDefinition def) throws IOException { - startElement(name); - doWriteTransactionErrorHandlerDefinitionAttributes(def); - doWriteDefaultErrorHandlerDefinitionElements(def); - endElement(name); - } - protected void doWriteCSimpleExpression(String name, CSimpleExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteAttribute("trimResult", def.getTrimResult(), "false"); - doWriteAttribute("pretty", def.getPretty(), "false"); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteConstantExpression(String name, ConstantExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteDatasonnetExpression(String name, DatasonnetExpression def) throws IOException { - startElement(name); - doWriteSingleInputTypedExpressionDefinitionAttributes(def); - doWriteAttribute("bodyMediaType", def.getBodyMediaType(), null); - doWriteAttribute("outputMediaType", def.getOutputMediaType(), null); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteExchangePropertyExpression(String name, ExchangePropertyExpression def) throws IOException { - startElement(name); - doWriteExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteExpressionDefinitionAttributes(ExpressionDefinition def) throws IOException { - doWriteAttribute("id", def.getId(), null); - doWriteAttribute("trim", def.getTrim(), "true"); - } - protected void doWriteExpressionDefinition(String name, ExpressionDefinition def) throws IOException { - startElement(name); - doWriteExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteGroovyExpression(String name, GroovyExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteHeaderExpression(String name, HeaderExpression def) throws IOException { - startElement(name); - doWriteExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteHl7TerserExpression(String name, Hl7TerserExpression def) throws IOException { - startElement(name); - doWriteSingleInputTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteJavaExpression(String name, JavaExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteAttribute("preCompile", def.getPreCompile(), "true"); - doWriteAttribute("singleQuotes", def.getSingleQuotes(), "true"); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteJavaScriptExpression(String name, JavaScriptExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteJoorExpression(String name, JoorExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteAttribute("preCompile", def.getPreCompile(), "true"); - doWriteAttribute("singleQuotes", def.getSingleQuotes(), "true"); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteJqExpression(String name, JqExpression def) throws IOException { - startElement(name); - doWriteSingleInputTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteJsonPathExpression(String name, JsonPathExpression def) throws IOException { - startElement(name); - doWriteSingleInputTypedExpressionDefinitionAttributes(def); - doWriteAttribute("suppressExceptions", def.getSuppressExceptions(), "false"); - doWriteAttribute("allowSimple", def.getAllowSimple(), "true"); - doWriteAttribute("allowEasyPredicate", def.getAllowEasyPredicate(), "true"); - doWriteAttribute("writeAsString", def.getWriteAsString(), "false"); - doWriteAttribute("unpackArray", def.getUnpackArray(), "false"); - doWriteAttribute("option", def.getOption(), null); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteLanguageExpression(String name, LanguageExpression def) throws IOException { - startElement(name); - doWriteExpressionDefinitionAttributes(def); - doWriteAttribute("language", def.getLanguage(), null); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteMethodCallExpression(String name, MethodCallExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteAttribute("beanType", def.getBeanTypeName(), null); - doWriteAttribute("ref", def.getRef(), null); - doWriteAttribute("method", def.getMethod(), null); - doWriteAttribute("scope", def.getScope(), "Singleton"); - doWriteAttribute("validate", def.getValidate(), "true"); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteMvelExpression(String name, MvelExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteNamespaceAwareExpressionElements(NamespaceAwareExpression def) throws IOException { - doWriteList(null, "namespace", def.getNamespace(), this::doWritePropertyDefinition); - } - protected void doWriteNamespaceAwareExpression(String name, NamespaceAwareExpression def) throws IOException { - startElement(name); - doWriteSingleInputTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - doWriteNamespaceAwareExpressionElements(def); - endElement(name); - } - protected void doWriteOgnlExpression(String name, OgnlExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWritePythonExpression(String name, PythonExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteRefExpression(String name, RefExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteSimpleExpression(String name, SimpleExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteAttribute("trimResult", def.getTrimResult(), "false"); - doWriteAttribute("pretty", def.getPretty(), "false"); - doWriteAttribute("nested", def.getNested(), "false"); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteSingleInputTypedExpressionDefinitionAttributes(SingleInputTypedExpressionDefinition def) throws IOException { - doWriteTypedExpressionDefinitionAttributes(def); - doWriteAttribute("source", def.getSource(), null); - } - protected void doWriteSingleInputTypedExpressionDefinition(String name, SingleInputTypedExpressionDefinition def) throws IOException { - startElement(name); - doWriteSingleInputTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteSpELExpression(String name, SpELExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteTokenizerExpression(String name, TokenizerExpression def) throws IOException { - startElement(name); - doWriteSingleInputTypedExpressionDefinitionAttributes(def); - doWriteAttribute("token", def.getToken(), null); - doWriteAttribute("endToken", def.getEndToken(), null); - doWriteAttribute("inheritNamespaceTagName", def.getInheritNamespaceTagName(), null); - doWriteAttribute("regex", def.getRegex(), null); - doWriteAttribute("xml", def.getXml(), null); - doWriteAttribute("includeTokens", def.getIncludeTokens(), null); - doWriteAttribute("group", def.getGroup(), null); - doWriteAttribute("groupDelimiter", def.getGroupDelimiter(), null); - doWriteAttribute("skipFirst", def.getSkipFirst(), null); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteTypedExpressionDefinitionAttributes(TypedExpressionDefinition def) throws IOException { - doWriteExpressionDefinitionAttributes(def); - doWriteAttribute("resultType", def.getResultTypeName(), null); - } - protected void doWriteTypedExpressionDefinition(String name, TypedExpressionDefinition def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteVariableExpression(String name, VariableExpression def) throws IOException { - startElement(name); - doWriteExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteWasmExpression(String name, WasmExpression def) throws IOException { - startElement(name); - doWriteTypedExpressionDefinitionAttributes(def); - doWriteAttribute("module", def.getModule(), null); - doWriteValue(def.getExpression()); - endElement(name); - } - protected void doWriteXMLTokenizerExpression(String name, XMLTokenizerExpression def) throws IOException { - startElement(name); - doWriteSingleInputTypedExpressionDefinitionAttributes(def); - doWriteAttribute("mode", def.getMode(), "i"); - doWriteAttribute("group", def.getGroup(), null); - doWriteValue(def.getExpression()); - doWriteNamespaceAwareExpressionElements(def); - endElement(name); - } - protected void doWriteXPathExpression(String name, XPathExpression def) throws IOException { - startElement(name); - doWriteSingleInputTypedExpressionDefinitionAttributes(def); - doWriteAttribute("documentType", def.getDocumentTypeName(), null); - doWriteAttribute("resultQName", def.getResultQName(), "NODESET"); - doWriteAttribute("saxon", def.getSaxon(), null); - doWriteAttribute("factoryRef", def.getFactoryRef(), null); - doWriteAttribute("objectModel", def.getObjectModel(), null); - doWriteAttribute("logNamespaces", def.getLogNamespaces(), null); - doWriteAttribute("threadSafety", def.getThreadSafety(), null); - doWriteAttribute("preCompile", def.getPreCompile(), "true"); - doWriteValue(def.getExpression()); - doWriteNamespaceAwareExpressionElements(def); - endElement(name); - } - protected void doWriteXQueryExpression(String name, XQueryExpression def) throws IOException { - startElement(name); - doWriteSingleInputTypedExpressionDefinitionAttributes(def); - doWriteAttribute("configurationRef", def.getConfigurationRef(), null); - doWriteValue(def.getExpression()); - doWriteNamespaceAwareExpressionElements(def); - endElement(name); - } - protected void doWriteCustomLoadBalancerDefinition(String name, CustomLoadBalancerDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - endElement(name); - } - protected void doWriteFailoverLoadBalancerDefinition(String name, FailoverLoadBalancerDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("roundRobin", def.getRoundRobin(), null); - doWriteAttribute("sticky", def.getSticky(), null); - doWriteAttribute("maximumFailoverAttempts", def.getMaximumFailoverAttempts(), "-1"); - doWriteAttribute("inheritErrorHandler", toString(def.getInheritErrorHandler()), "true"); - doWriteList(null, "exception", def.getExceptions(), this::doWriteString); - endElement(name); - } - protected void doWriteRandomLoadBalancerDefinition(String name, RandomLoadBalancerDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - endElement(name); - } - protected void doWriteRoundRobinLoadBalancerDefinition(String name, RoundRobinLoadBalancerDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - endElement(name); - } - protected void doWriteStickyLoadBalancerDefinition(String name, StickyLoadBalancerDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteElement("correlationExpression", def.getCorrelationExpression(), this::doWriteExpressionSubElementDefinition); - endElement(name); - } - protected void doWriteTopicLoadBalancerDefinition(String name, TopicLoadBalancerDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - endElement(name); - } - protected void doWriteWeightedLoadBalancerDefinition(String name, WeightedLoadBalancerDefinition def) throws IOException { - startElement(name); - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("distributionRatio", def.getDistributionRatio(), null); - doWriteAttribute("distributionRatioDelimiter", def.getDistributionRatioDelimiter(), ","); - doWriteAttribute("roundRobin", def.getRoundRobin(), null); - endElement(name); - } - protected void doWriteApiKeyDefinition(String name, ApiKeyDefinition def) throws IOException { - startElement(name); - doWriteRestSecurityDefinitionAttributes(def); - doWriteAttribute("name", def.getName(), null); - doWriteAttribute("inHeader", def.getInHeader(), null); - doWriteAttribute("inQuery", def.getInQuery(), null); - doWriteAttribute("inCookie", def.getInCookie(), null); - endElement(name); - } - protected void doWriteBasicAuthDefinition(String name, BasicAuthDefinition def) throws IOException { - startElement(name); - doWriteRestSecurityDefinitionAttributes(def); - endElement(name); - } - protected void doWriteBearerTokenDefinition(String name, BearerTokenDefinition def) throws IOException { - startElement(name); - doWriteRestSecurityDefinitionAttributes(def); - doWriteAttribute("format", def.getFormat(), null); - endElement(name); - } - protected void doWriteDeleteDefinition(String name, DeleteDefinition def) throws IOException { - startElement(name); - doWriteVerbDefinitionAttributes(def); - doWriteVerbDefinitionElements(def); - endElement(name); - } - protected void doWriteGetDefinition(String name, GetDefinition def) throws IOException { - startElement(name); - doWriteVerbDefinitionAttributes(def); - doWriteVerbDefinitionElements(def); - endElement(name); - } - protected void doWriteHeadDefinition(String name, HeadDefinition def) throws IOException { - startElement(name); - doWriteVerbDefinitionAttributes(def); - doWriteVerbDefinitionElements(def); - endElement(name); - } - protected void doWriteMutualTLSDefinition(String name, MutualTLSDefinition def) throws IOException { - startElement(name); - doWriteRestSecurityDefinitionAttributes(def); - endElement(name); - } - protected void doWriteOAuth2Definition(String name, OAuth2Definition def) throws IOException { - startElement(name); - doWriteRestSecurityDefinitionAttributes(def); - doWriteAttribute("authorizationUrl", def.getAuthorizationUrl(), null); - doWriteAttribute("tokenUrl", def.getTokenUrl(), null); - doWriteAttribute("refreshUrl", def.getRefreshUrl(), null); - doWriteAttribute("flow", def.getFlow(), null); - doWriteList(null, "scopes", def.getScopes(), this::doWriteRestPropertyDefinition); - endElement(name); - } - protected void doWriteOpenApiDefinition(String name, OpenApiDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("disabled", def.getDisabled(), null); - doWriteAttribute("specification", def.getSpecification(), null); - doWriteAttribute("apiContextPath", def.getApiContextPath(), null); - doWriteAttribute("routeId", def.getRouteId(), null); - doWriteAttribute("missingOperation", def.getMissingOperation(), "fail"); - doWriteAttribute("mockIncludePattern", def.getMockIncludePattern(), "classpath:camel-mock/**"); - endElement(name); - } - protected void doWriteOpenIdConnectDefinition(String name, OpenIdConnectDefinition def) throws IOException { - startElement(name); - doWriteRestSecurityDefinitionAttributes(def); - doWriteAttribute("url", def.getUrl(), null); - endElement(name); - } - protected void doWriteParamDefinition(String name, ParamDefinition def) throws IOException { - startElement(name); - doWriteAttribute("description", def.getDescription(), null); - doWriteAttribute("name", def.getName(), null); - doWriteAttribute("type", toString(def.getType()), "path"); - doWriteAttribute("defaultValue", def.getDefaultValue(), null); - doWriteAttribute("required", toString(def.getRequired()), "true"); - doWriteAttribute("collectionFormat", toString(def.getCollectionFormat()), "csv"); - doWriteAttribute("arrayType", def.getArrayType(), "string"); - doWriteAttribute("dataType", def.getDataType(), "string"); - doWriteAttribute("dataFormat", def.getDataFormat(), null); - doWriteList("allowableValues", "value", def.getAllowableValues(), this::doWriteValueDefinition); - doWriteList(null, "examples", def.getExamples(), this::doWriteRestPropertyDefinition); - endElement(name); - } - protected void doWritePatchDefinition(String name, PatchDefinition def) throws IOException { - startElement(name); - doWriteVerbDefinitionAttributes(def); - doWriteVerbDefinitionElements(def); - endElement(name); - } - protected void doWritePostDefinition(String name, PostDefinition def) throws IOException { - startElement(name); - doWriteVerbDefinitionAttributes(def); - doWriteVerbDefinitionElements(def); - endElement(name); - } - protected void doWritePutDefinition(String name, PutDefinition def) throws IOException { - startElement(name); - doWriteVerbDefinitionAttributes(def); - doWriteVerbDefinitionElements(def); - endElement(name); - } - protected void doWriteResponseHeaderDefinition(String name, ResponseHeaderDefinition def) throws IOException { - startElement(name); - doWriteAttribute("description", def.getDescription(), null); - doWriteAttribute("name", def.getName(), null); - doWriteAttribute("collectionFormat", toString(def.getCollectionFormat()), "csv"); - doWriteAttribute("arrayType", def.getArrayType(), "string"); - doWriteAttribute("dataType", def.getDataType(), "string"); - doWriteAttribute("dataFormat", def.getDataFormat(), null); - doWriteAttribute("example", def.getExample(), null); - doWriteList("allowableValues", "value", def.getAllowableValues(), this::doWriteValueDefinition); - endElement(name); - } - protected void doWriteResponseMessageDefinition(String name, ResponseMessageDefinition def) throws IOException { - startElement(name); - doWriteAttribute("code", def.getCode(), "200"); - doWriteAttribute("contentType", def.getContentType(), null); - doWriteAttribute("message", def.getMessage(), null); - doWriteAttribute("responseModel", def.getResponseModel(), null); - doWriteList(null, "header", def.getHeaders(), this::doWriteResponseHeaderDefinition); - doWriteList(null, "examples", def.getExamples(), this::doWriteRestPropertyDefinition); - endElement(name); - } - protected void doWriteRestBindingDefinition(String name, RestBindingDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("consumes", def.getConsumes(), null); - doWriteAttribute("produces", def.getProduces(), null); - doWriteAttribute("bindingMode", def.getBindingMode(), "off"); - doWriteAttribute("type", def.getType(), null); - doWriteAttribute("outType", def.getOutType(), null); - doWriteAttribute("skipBindingOnErrorCode", def.getSkipBindingOnErrorCode(), "false"); - doWriteAttribute("clientRequestValidation", def.getClientRequestValidation(), "false"); - doWriteAttribute("clientResponseValidation", def.getClientResponseValidation(), "false"); - doWriteAttribute("enableCORS", def.getEnableCORS(), "false"); - doWriteAttribute("enableNoContentResponse", def.getEnableNoContentResponse(), "false"); - doWriteAttribute("component", def.getComponent(), null); - endElement(name); - } - protected void doWriteRestConfigurationDefinition(String name, RestConfigurationDefinition def) throws IOException { - startElement(name); - doWriteAttribute("component", def.getComponent(), null); - doWriteAttribute("apiComponent", def.getApiComponent(), null); - doWriteAttribute("producerComponent", def.getProducerComponent(), null); - doWriteAttribute("scheme", def.getScheme(), null); - doWriteAttribute("host", def.getHost(), null); - doWriteAttribute("port", def.getPort(), null); - doWriteAttribute("apiHost", def.getApiHost(), null); - doWriteAttribute("useXForwardHeaders", def.getUseXForwardHeaders(), null); - doWriteAttribute("producerApiDoc", def.getProducerApiDoc(), null); - doWriteAttribute("contextPath", def.getContextPath(), null); - doWriteAttribute("apiContextPath", def.getApiContextPath(), null); - doWriteAttribute("apiContextRouteId", def.getApiContextRouteId(), null); - doWriteAttribute("apiVendorExtension", def.getApiVendorExtension(), "false"); - doWriteAttribute("hostNameResolver", toString(def.getHostNameResolver()), "allLocalIp"); - doWriteAttribute("bindingMode", toString(def.getBindingMode()), "off"); - doWriteAttribute("bindingPackageScan", def.getBindingPackageScan(), null); - doWriteAttribute("skipBindingOnErrorCode", def.getSkipBindingOnErrorCode(), "false"); - doWriteAttribute("clientRequestValidation", def.getClientRequestValidation(), "false"); - doWriteAttribute("clientResponseValidation", def.getClientResponseValidation(), "false"); - doWriteAttribute("enableCORS", def.getEnableCORS(), "false"); - doWriteAttribute("enableNoContentResponse", def.getEnableNoContentResponse(), "false"); - doWriteAttribute("inlineRoutes", def.getInlineRoutes(), "true"); - doWriteAttribute("jsonDataFormat", def.getJsonDataFormat(), "jackson"); - doWriteAttribute("xmlDataFormat", def.getXmlDataFormat(), "jaxb"); - doWriteList(null, "consumerProperty", def.getConsumerProperties(), this::doWriteRestPropertyDefinition); - doWriteList(null, "componentProperty", def.getComponentProperties(), this::doWriteRestPropertyDefinition); - doWriteList(null, "apiProperty", def.getApiProperties(), this::doWriteRestPropertyDefinition); - doWriteList(null, "endpointProperty", def.getEndpointProperties(), this::doWriteRestPropertyDefinition); - doWriteList(null, "dataFormatProperty", def.getDataFormatProperties(), this::doWriteRestPropertyDefinition); - doWriteList(null, "corsHeaders", def.getCorsHeaders(), this::doWriteRestPropertyDefinition); - doWriteList(null, "validationLevels", def.getValidationLevels(), this::doWriteRestPropertyDefinition); - endElement(name); - } - protected void doWriteRestDefinition(String name, RestDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("disabled", def.getDisabled(), null); - doWriteAttribute("path", def.getPath(), null); - doWriteAttribute("consumes", def.getConsumes(), null); - doWriteAttribute("produces", def.getProduces(), null); - doWriteAttribute("bindingMode", def.getBindingMode(), "off"); - doWriteAttribute("skipBindingOnErrorCode", def.getSkipBindingOnErrorCode(), "false"); - doWriteAttribute("clientRequestValidation", def.getClientRequestValidation(), "false"); - doWriteAttribute("clientResponseValidation", def.getClientResponseValidation(), "false"); - doWriteAttribute("enableCORS", def.getEnableCORS(), "false"); - doWriteAttribute("enableNoContentResponse", def.getEnableNoContentResponse(), "false"); - doWriteAttribute("apiDocs", def.getApiDocs(), "true"); - doWriteAttribute("tag", def.getTag(), null); - doWriteList(null, null, def.getVerbs(), this::doWriteVerbDefinitionRef); - doWriteElement("openApi", def.getOpenApi(), this::doWriteOpenApiDefinition); - doWriteElement("securityDefinitions", def.getSecurityDefinitions(), this::doWriteRestSecuritiesDefinition); - doWriteList(null, "securityRequirements", def.getSecurityRequirements(), this::doWriteSecurityDefinition); - endElement(name); - } - protected void doWriteRestPropertyDefinition(String name, RestPropertyDefinition def) throws IOException { - startElement(name); - doWriteAttribute("key", def.getKey(), null); - doWriteAttribute("value", def.getValue(), null); - endElement(name); - } - protected void doWriteRestSecuritiesDefinition(String name, RestSecuritiesDefinition def) throws IOException { - startElement(name); - doWriteList(null, null, def.getSecurityDefinitions(), (n, v) -> { - switch (v.getClass().getSimpleName()) { - case "ApiKeyDefinition" -> doWriteApiKeyDefinition("apiKey", (ApiKeyDefinition) v); - case "BasicAuthDefinition" -> doWriteBasicAuthDefinition("basicAuth", (BasicAuthDefinition) v); - case "BearerTokenDefinition" -> doWriteBearerTokenDefinition("bearerToken", (BearerTokenDefinition) v); - case "OAuth2Definition" -> doWriteOAuth2Definition("oauth2", (OAuth2Definition) v); - case "OpenIdConnectDefinition" -> doWriteOpenIdConnectDefinition("openIdConnect", (OpenIdConnectDefinition) v); - case "MutualTLSDefinition" -> doWriteMutualTLSDefinition("mutualTLS", (MutualTLSDefinition) v); - } - }); - endElement(name); - } - protected void doWriteRestSecurityDefinitionAttributes(RestSecurityDefinition def) throws IOException { - doWriteAttribute("description", def.getDescription(), null); - doWriteAttribute("key", def.getKey(), null); - } - protected void doWriteRestSecurityDefinition(String name, RestSecurityDefinition def) throws IOException { - startElement(name); - doWriteRestSecurityDefinitionAttributes(def); - endElement(name); - } - protected void doWriteRestsDefinition(String name, RestsDefinition def) throws IOException { - startElement(name); - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteList(null, null, def.getRests(), this::doWriteRestDefinitionRef); - endElement(name); - } - protected void doWriteSecurityDefinition(String name, SecurityDefinition def) throws IOException { - startElement(name); - doWriteAttribute("key", def.getKey(), null); - doWriteAttribute("scopes", def.getScopes(), null); - endElement(name); - } - protected void doWriteVerbDefinitionAttributes(VerbDefinition def) throws IOException { - doWriteOptionalIdentifiedDefinitionAttributes(def); - doWriteAttribute("enableCORS", def.getEnableCORS(), "false"); - doWriteAttribute("deprecated", def.getDeprecated(), "false"); - doWriteAttribute("streamCache", def.getStreamCache(), null); - doWriteAttribute("type", def.getType(), null); - doWriteAttribute("outType", def.getOutType(), null); - doWriteAttribute("clientResponseValidation", def.getClientResponseValidation(), "false"); - doWriteAttribute("path", def.getPath(), null); - doWriteAttribute("routeId", def.getRouteId(), null); - doWriteAttribute("bindingMode", def.getBindingMode(), "off"); - doWriteAttribute("apiDocs", def.getApiDocs(), "true"); - doWriteAttribute("enableNoContentResponse", def.getEnableNoContentResponse(), "false"); - doWriteAttribute("skipBindingOnErrorCode", def.getSkipBindingOnErrorCode(), "false"); - doWriteAttribute("clientRequestValidation", def.getClientRequestValidation(), "false"); - doWriteAttribute("produces", def.getProduces(), null); - doWriteAttribute("disabled", def.getDisabled(), null); - doWriteAttribute("consumes", def.getConsumes(), null); - } - protected void doWriteVerbDefinitionElements(VerbDefinition def) throws IOException { - doWriteList(null, null, def.getParams(), this::doWriteParamDefinitionRef); - doWriteList(null, null, def.getSecurity(), this::doWriteSecurityDefinitionRef); - doWriteList(null, null, def.getResponseMsgs(), this::doWriteResponseMessageDefinitionRef); - doWriteElement("to", def.getTo(), this::doWriteToDefinition); - } - protected void doWriteVerbDefinition(String name, VerbDefinition def) throws IOException { - startElement(name); - doWriteVerbDefinitionAttributes(def); - doWriteVerbDefinitionElements(def); - endElement(name); - } - protected void doWriteLangChain4jCharacterTokenizerDefinition(String name, LangChain4jCharacterTokenizerDefinition def) throws IOException { - startElement(name); - doWriteLangChain4jTokenizerDefinitionAttributes(def); - endElement(name); - } - protected void doWriteLangChain4jLineTokenizerDefinition(String name, LangChain4jLineTokenizerDefinition def) throws IOException { - startElement(name); - doWriteLangChain4jTokenizerDefinitionAttributes(def); - endElement(name); - } - protected void doWriteLangChain4jParagraphTokenizerDefinition(String name, LangChain4jParagraphTokenizerDefinition def) throws IOException { - startElement(name); - doWriteLangChain4jTokenizerDefinitionAttributes(def); - endElement(name); - } - protected void doWriteLangChain4jSentenceTokenizerDefinition(String name, LangChain4jSentenceTokenizerDefinition def) throws IOException { - startElement(name); - doWriteLangChain4jTokenizerDefinitionAttributes(def); - endElement(name); - } - protected void doWriteLangChain4jTokenizerDefinitionAttributes(LangChain4jTokenizerDefinition def) throws IOException { - doWriteIdentifiedTypeAttributes(def); - doWriteAttribute("modelName", def.getModelName(), null); - doWriteAttribute("maxTokens", def.getMaxTokens(), null); - doWriteAttribute("tokenizerType", def.getTokenizerType(), null); - doWriteAttribute("maxOverlap", def.getMaxOverlap(), null); - } - protected void doWriteLangChain4jTokenizerDefinition(String name, LangChain4jTokenizerDefinition def) throws IOException { - startElement(name); - doWriteLangChain4jTokenizerDefinitionAttributes(def); - endElement(name); - } - protected void doWriteLangChain4jWordTokenizerDefinition(String name, LangChain4jWordTokenizerDefinition def) throws IOException { - startElement(name); - doWriteLangChain4jTokenizerDefinitionAttributes(def); - endElement(name); - } - protected void doWriteCustomTransformerDefinition(String name, CustomTransformerDefinition def) throws IOException { - startElement(name); - doWriteTransformerDefinitionAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - doWriteAttribute("className", def.getClassName(), null); - endElement(name); - } - protected void doWriteDataFormatTransformerDefinition(String name, DataFormatTransformerDefinition def) throws IOException { - startElement(name); - doWriteTransformerDefinitionAttributes(def); - doWriteElement(null, def.getDataFormatType(), (n, v) -> { - switch (v.getClass().getSimpleName()) { - case "ASN1DataFormat" -> doWriteASN1DataFormat("asn1", (ASN1DataFormat) v); - case "AvroDataFormat" -> doWriteAvroDataFormat("avro", (AvroDataFormat) v); - case "BarcodeDataFormat" -> doWriteBarcodeDataFormat("barcode", (BarcodeDataFormat) v); - case "Base64DataFormat" -> doWriteBase64DataFormat("base64", (Base64DataFormat) v); - case "BeanioDataFormat" -> doWriteBeanioDataFormat("beanio", (BeanioDataFormat) v); - case "BindyDataFormat" -> doWriteBindyDataFormat("bindy", (BindyDataFormat) v); - case "CBORDataFormat" -> doWriteCBORDataFormat("cbor", (CBORDataFormat) v); - case "CryptoDataFormat" -> doWriteCryptoDataFormat("crypto", (CryptoDataFormat) v); - case "CsvDataFormat" -> doWriteCsvDataFormat("csv", (CsvDataFormat) v); - case "CustomDataFormat" -> doWriteCustomDataFormat("custom", (CustomDataFormat) v); - case "DfdlDataFormat" -> doWriteDfdlDataFormat("dfdl", (DfdlDataFormat) v); - case "FhirJsonDataFormat" -> doWriteFhirJsonDataFormat("fhirJson", (FhirJsonDataFormat) v); - case "FhirXmlDataFormat" -> doWriteFhirXmlDataFormat("fhirXml", (FhirXmlDataFormat) v); - case "FlatpackDataFormat" -> doWriteFlatpackDataFormat("flatpack", (FlatpackDataFormat) v); - case "ForyDataFormat" -> doWriteForyDataFormat("fory", (ForyDataFormat) v); - case "GrokDataFormat" -> doWriteGrokDataFormat("grok", (GrokDataFormat) v); - case "GroovyJSonDataFormat" -> doWriteGroovyJSonDataFormat("groovyJson", (GroovyJSonDataFormat) v); - case "GroovyXmlDataFormat" -> doWriteGroovyXmlDataFormat("groovyXml", (GroovyXmlDataFormat) v); - case "GzipDeflaterDataFormat" -> doWriteGzipDeflaterDataFormat("gzipDeflater", (GzipDeflaterDataFormat) v); - case "HL7DataFormat" -> doWriteHL7DataFormat("hl7", (HL7DataFormat) v); - case "IcalDataFormat" -> doWriteIcalDataFormat("ical", (IcalDataFormat) v); - case "Iso8583DataFormat" -> doWriteIso8583DataFormat("iso8583", (Iso8583DataFormat) v); - case "JacksonXMLDataFormat" -> doWriteJacksonXMLDataFormat("jacksonXml", (JacksonXMLDataFormat) v); - case "JaxbDataFormat" -> doWriteJaxbDataFormat("jaxb", (JaxbDataFormat) v); - case "JsonDataFormat" -> doWriteJsonDataFormat("json", (JsonDataFormat) v); - case "JsonApiDataFormat" -> doWriteJsonApiDataFormat("jsonApi", (JsonApiDataFormat) v); - case "LZFDataFormat" -> doWriteLZFDataFormat("lzf", (LZFDataFormat) v); - case "MimeMultipartDataFormat" -> doWriteMimeMultipartDataFormat("mimeMultipart", (MimeMultipartDataFormat) v); - case "OcsfDataFormat" -> doWriteOcsfDataFormat("ocsf", (OcsfDataFormat) v); - case "ParquetAvroDataFormat" -> doWriteParquetAvroDataFormat("parquetAvro", (ParquetAvroDataFormat) v); - case "PGPDataFormat" -> doWritePGPDataFormat("pgp", (PGPDataFormat) v); - case "PQCDataFormat" -> doWritePQCDataFormat("pqc", (PQCDataFormat) v); - case "ProtobufDataFormat" -> doWriteProtobufDataFormat("protobuf", (ProtobufDataFormat) v); - case "RssDataFormat" -> doWriteRssDataFormat("rss", (RssDataFormat) v); - case "SmooksDataFormat" -> doWriteSmooksDataFormat("smooks", (SmooksDataFormat) v); - case "SoapDataFormat" -> doWriteSoapDataFormat("soap", (SoapDataFormat) v); - case "SwiftMtDataFormat" -> doWriteSwiftMtDataFormat("swiftMt", (SwiftMtDataFormat) v); - case "SwiftMxDataFormat" -> doWriteSwiftMxDataFormat("swiftMx", (SwiftMxDataFormat) v); - case "SyslogDataFormat" -> doWriteSyslogDataFormat("syslog", (SyslogDataFormat) v); - case "TarFileDataFormat" -> doWriteTarFileDataFormat("tarFile", (TarFileDataFormat) v); - case "ThriftDataFormat" -> doWriteThriftDataFormat("thrift", (ThriftDataFormat) v); - case "UniVocityCsvDataFormat" -> doWriteUniVocityCsvDataFormat("univocityCsv", (UniVocityCsvDataFormat) v); - case "UniVocityFixedDataFormat" -> doWriteUniVocityFixedDataFormat("univocityFixed", (UniVocityFixedDataFormat) v); - case "UniVocityTsvDataFormat" -> doWriteUniVocityTsvDataFormat("univocityTsv", (UniVocityTsvDataFormat) v); - case "XMLSecurityDataFormat" -> doWriteXMLSecurityDataFormat("xmlSecurity", (XMLSecurityDataFormat) v); - case "YAMLDataFormat" -> doWriteYAMLDataFormat("yaml", (YAMLDataFormat) v); - case "ZipDeflaterDataFormat" -> doWriteZipDeflaterDataFormat("zipDeflater", (ZipDeflaterDataFormat) v); - case "ZipFileDataFormat" -> doWriteZipFileDataFormat("zipFile", (ZipFileDataFormat) v); - } - }); - endElement(name); - } - protected void doWriteEndpointTransformerDefinition(String name, EndpointTransformerDefinition def) throws IOException { - startElement(name); - doWriteTransformerDefinitionAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - doWriteAttribute("uri", def.getUri(), null); - endElement(name); - } - protected void doWriteLoadTransformerDefinition(String name, LoadTransformerDefinition def) throws IOException { - startElement(name); - doWriteTransformerDefinitionAttributes(def); - doWriteAttribute("packageScan", def.getPackageScan(), null); - doWriteAttribute("defaults", def.getDefaults(), "false"); - endElement(name); - } - protected void doWriteTransformerDefinitionAttributes(TransformerDefinition def) throws IOException { - doWriteAttribute("toType", def.getToType(), null); - doWriteAttribute("fromType", def.getFromType(), null); - doWriteAttribute("scheme", def.getScheme(), null); - doWriteAttribute("name", def.getName(), null); - } - protected void doWriteTransformerDefinition(String name, TransformerDefinition def) throws IOException { - startElement(name); - doWriteTransformerDefinitionAttributes(def); - endElement(name); - } - protected void doWriteTransformersDefinition(String name, TransformersDefinition def) throws IOException { - startElement(name); - doWriteList(null, null, def.getTransformers(), (n, v) -> { - switch (v.getClass().getSimpleName()) { - case "DataFormatTransformerDefinition" -> doWriteDataFormatTransformerDefinition("dataFormatTransformer", (DataFormatTransformerDefinition) v); - case "EndpointTransformerDefinition" -> doWriteEndpointTransformerDefinition("endpointTransformer", (EndpointTransformerDefinition) v); - case "LoadTransformerDefinition" -> doWriteLoadTransformerDefinition("loadTransformer", (LoadTransformerDefinition) v); - case "CustomTransformerDefinition" -> doWriteCustomTransformerDefinition("customTransformer", (CustomTransformerDefinition) v); - } - }); - endElement(name); - } - protected void doWriteCustomValidatorDefinition(String name, CustomValidatorDefinition def) throws IOException { - startElement(name); - doWriteValidatorDefinitionAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - doWriteAttribute("className", def.getClassName(), null); - endElement(name); - } - protected void doWriteEndpointValidatorDefinition(String name, EndpointValidatorDefinition def) throws IOException { - startElement(name); - doWriteValidatorDefinitionAttributes(def); - doWriteAttribute("ref", def.getRef(), null); - doWriteAttribute("uri", def.getUri(), null); - endElement(name); - } - protected void doWritePredicateValidatorDefinition(String name, PredicateValidatorDefinition def) throws IOException { - startElement(name); - doWriteValidatorDefinitionAttributes(def); - doWriteElement(null, def.getExpression(), this::doWriteExpressionDefinitionRef); - endElement(name); - } - protected void doWriteValidatorDefinitionAttributes(ValidatorDefinition def) throws IOException { - doWriteAttribute("type", def.getType(), null); - } - protected void doWriteValidatorDefinition(String name, ValidatorDefinition def) throws IOException { - startElement(name); - doWriteValidatorDefinitionAttributes(def); - endElement(name); - } - protected void doWriteValidatorsDefinition(String name, ValidatorsDefinition def) throws IOException { - startElement(name); - doWriteList(null, null, def.getValidators(), (n, v) -> { - switch (v.getClass().getSimpleName()) { - case "EndpointValidatorDefinition" -> doWriteEndpointValidatorDefinition("endpointValidator", (EndpointValidatorDefinition) v); - case "PredicateValidatorDefinition" -> doWritePredicateValidatorDefinition("predicateValidator", (PredicateValidatorDefinition) v); - case "CustomValidatorDefinition" -> doWriteCustomValidatorDefinition("customValidator", (CustomValidatorDefinition) v); - } - }); - endElement(name); - } - - protected void doWriteFromDefinitionRef(String n, FromDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "FromDefinition" -> doWriteFromDefinition("from", (FromDefinition) v); - } - } - } - protected void doWriteInputTypeDefinitionRef(String n, InputTypeDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "InputTypeDefinition" -> doWriteInputTypeDefinition("inputType", (InputTypeDefinition) v); - } - } - } - protected void doWriteOptionalIdentifiedDefinitionRef(String n, OptionalIdentifiedDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "AggregateDefinition" -> doWriteAggregateDefinition("aggregate", (AggregateDefinition) v); - case "BeanDefinition" -> doWriteBeanDefinition("bean", (BeanDefinition) v); - case "CatchDefinition" -> doWriteCatchDefinition("doCatch", (CatchDefinition) v); - case "ChoiceDefinition" -> doWriteChoiceDefinition("choice", (ChoiceDefinition) v); - case "CircuitBreakerDefinition" -> doWriteCircuitBreakerDefinition("circuitBreaker", (CircuitBreakerDefinition) v); - case "ClaimCheckDefinition" -> doWriteClaimCheckDefinition("claimCheck", (ClaimCheckDefinition) v); - case "ConvertBodyDefinition" -> doWriteConvertBodyDefinition("convertBodyTo", (ConvertBodyDefinition) v); - case "ConvertHeaderDefinition" -> doWriteConvertHeaderDefinition("convertHeaderTo", (ConvertHeaderDefinition) v); - case "ConvertVariableDefinition" -> doWriteConvertVariableDefinition("convertVariableTo", (ConvertVariableDefinition) v); - case "DelayDefinition" -> doWriteDelayDefinition("delay", (DelayDefinition) v); - case "DynamicRouterDefinition" -> doWriteDynamicRouterDefinition("dynamicRouter", (DynamicRouterDefinition) v); - case "EnrichDefinition" -> doWriteEnrichDefinition("enrich", (EnrichDefinition) v); - case "FilterDefinition" -> doWriteFilterDefinition("filter", (FilterDefinition) v); - case "FinallyDefinition" -> doWriteFinallyDefinition("doFinally", (FinallyDefinition) v); - case "FromDefinition" -> doWriteFromDefinition("from", (FromDefinition) v); - case "IdempotentConsumerDefinition" -> doWriteIdempotentConsumerDefinition("idempotentConsumer", (IdempotentConsumerDefinition) v); - case "InputTypeDefinition" -> doWriteInputTypeDefinition("inputType", (InputTypeDefinition) v); - case "InterceptDefinition" -> doWriteInterceptDefinition("intercept", (InterceptDefinition) v); - case "InterceptFromDefinition" -> doWriteInterceptFromDefinition("interceptFrom", (InterceptFromDefinition) v); - case "InterceptSendToEndpointDefinition" -> doWriteInterceptSendToEndpointDefinition("interceptSendToEndpoint", (InterceptSendToEndpointDefinition) v); - case "KameletDefinition" -> doWriteKameletDefinition("kamelet", (KameletDefinition) v); - case "LoadBalanceDefinition" -> doWriteLoadBalanceDefinition("loadBalance", (LoadBalanceDefinition) v); - case "LogDefinition" -> doWriteLogDefinition("log", (LogDefinition) v); - case "LoopDefinition" -> doWriteLoopDefinition("loop", (LoopDefinition) v); - case "MarshalDefinition" -> doWriteMarshalDefinition("marshal", (MarshalDefinition) v); - case "MulticastDefinition" -> doWriteMulticastDefinition("multicast", (MulticastDefinition) v); - case "OnCompletionDefinition" -> doWriteOnCompletionDefinition("onCompletion", (OnCompletionDefinition) v); - case "OnExceptionDefinition" -> doWriteOnExceptionDefinition("onException", (OnExceptionDefinition) v); - case "OnFallbackDefinition" -> doWriteOnFallbackDefinition("onFallback", (OnFallbackDefinition) v); - case "OnWhenDefinition" -> doWriteOnWhenDefinition("onWhen", (OnWhenDefinition) v); - case "OtherwiseDefinition" -> doWriteOtherwiseDefinition("otherwise", (OtherwiseDefinition) v); - case "OutputTypeDefinition" -> doWriteOutputTypeDefinition("outputType", (OutputTypeDefinition) v); - case "PausableDefinition" -> doWritePausableDefinition("pausable", (PausableDefinition) v); - case "PipelineDefinition" -> doWritePipelineDefinition("pipeline", (PipelineDefinition) v); - case "PolicyDefinition" -> doWritePolicyDefinition("policy", (PolicyDefinition) v); - case "PollDefinition" -> doWritePollDefinition("poll", (PollDefinition) v); - case "PollEnrichDefinition" -> doWritePollEnrichDefinition("pollEnrich", (PollEnrichDefinition) v); - case "ProcessDefinition" -> doWriteProcessDefinition("process", (ProcessDefinition) v); - case "RecipientListDefinition" -> doWriteRecipientListDefinition("recipientList", (RecipientListDefinition) v); - case "RemoveHeaderDefinition" -> doWriteRemoveHeaderDefinition("removeHeader", (RemoveHeaderDefinition) v); - case "RemoveHeadersDefinition" -> doWriteRemoveHeadersDefinition("removeHeaders", (RemoveHeadersDefinition) v); - case "RemovePropertiesDefinition" -> doWriteRemovePropertiesDefinition("removeProperties", (RemovePropertiesDefinition) v); - case "RemovePropertyDefinition" -> doWriteRemovePropertyDefinition("removeProperty", (RemovePropertyDefinition) v); - case "RemoveVariableDefinition" -> doWriteRemoveVariableDefinition("removeVariable", (RemoveVariableDefinition) v); - case "ResequenceDefinition" -> doWriteResequenceDefinition("resequence", (ResequenceDefinition) v); - case "ResumableDefinition" -> doWriteResumableDefinition("resumable", (ResumableDefinition) v); - case "RollbackDefinition" -> doWriteRollbackDefinition("rollback", (RollbackDefinition) v); - case "RouteConfigurationDefinition" -> doWriteRouteConfigurationDefinition("routeConfiguration", (RouteConfigurationDefinition) v); - case "RouteConfigurationsDefinition" -> doWriteRouteConfigurationsDefinition("routeConfigurations", (RouteConfigurationsDefinition) v); - case "RouteDefinition" -> doWriteRouteDefinition("route", (RouteDefinition) v); - case "RouteTemplateDefinition" -> doWriteRouteTemplateDefinition("routeTemplate", (RouteTemplateDefinition) v); - case "RouteTemplatesDefinition" -> doWriteRouteTemplatesDefinition("routeTemplates", (RouteTemplatesDefinition) v); - case "RoutesDefinition" -> doWriteRoutesDefinition("routes", (RoutesDefinition) v); - case "RoutingSlipDefinition" -> doWriteRoutingSlipDefinition("routingSlip", (RoutingSlipDefinition) v); - case "SagaDefinition" -> doWriteSagaDefinition("saga", (SagaDefinition) v); - case "SamplingDefinition" -> doWriteSamplingDefinition("sample", (SamplingDefinition) v); - case "ScriptDefinition" -> doWriteScriptDefinition("script", (ScriptDefinition) v); - case "SetBodyDefinition" -> doWriteSetBodyDefinition("setBody", (SetBodyDefinition) v); - case "SetExchangePatternDefinition" -> doWriteSetExchangePatternDefinition("setExchangePattern", (SetExchangePatternDefinition) v); - case "SetHeaderDefinition" -> doWriteSetHeaderDefinition("setHeader", (SetHeaderDefinition) v); - case "SetHeadersDefinition" -> doWriteSetHeadersDefinition("setHeaders", (SetHeadersDefinition) v); - case "SetPropertyDefinition" -> doWriteSetPropertyDefinition("setProperty", (SetPropertyDefinition) v); - case "SetVariableDefinition" -> doWriteSetVariableDefinition("setVariable", (SetVariableDefinition) v); - case "SetVariablesDefinition" -> doWriteSetVariablesDefinition("setVariables", (SetVariablesDefinition) v); - case "SortDefinition" -> doWriteSortDefinition("sort", (SortDefinition) v); - case "SplitDefinition" -> doWriteSplitDefinition("split", (SplitDefinition) v); - case "StepDefinition" -> doWriteStepDefinition("step", (StepDefinition) v); - case "StopDefinition" -> doWriteStopDefinition("stop", (StopDefinition) v); - case "TemplatedRoutesDefinition" -> doWriteTemplatedRoutesDefinition("templatedRoutes", (TemplatedRoutesDefinition) v); - case "ThreadPoolProfileDefinition" -> doWriteThreadPoolProfileDefinition("threadPoolProfile", (ThreadPoolProfileDefinition) v); - case "ThreadsDefinition" -> doWriteThreadsDefinition("threads", (ThreadsDefinition) v); - case "ThrottleDefinition" -> doWriteThrottleDefinition("throttle", (ThrottleDefinition) v); - case "ThrowExceptionDefinition" -> doWriteThrowExceptionDefinition("throwException", (ThrowExceptionDefinition) v); - case "ToDefinition" -> doWriteToDefinition("to", (ToDefinition) v); - case "ToDynamicDefinition" -> doWriteToDynamicDefinition("toD", (ToDynamicDefinition) v); - case "TokenizerDefinition" -> doWriteTokenizerDefinition("tokenizer", (TokenizerDefinition) v); - case "TransactedDefinition" -> doWriteTransactedDefinition("transacted", (TransactedDefinition) v); - case "TransformDataTypeDefinition" -> doWriteTransformDataTypeDefinition("transformDataType", (TransformDataTypeDefinition) v); - case "TransformDefinition" -> doWriteTransformDefinition("transform", (TransformDefinition) v); - case "TryDefinition" -> doWriteTryDefinition("doTry", (TryDefinition) v); - case "UnmarshalDefinition" -> doWriteUnmarshalDefinition("unmarshal", (UnmarshalDefinition) v); - case "ValidateDefinition" -> doWriteValidateDefinition("validate", (ValidateDefinition) v); - case "WhenDefinition" -> doWriteWhenDefinition("when", (WhenDefinition) v); - case "WireTapDefinition" -> doWriteWireTapDefinition("wireTap", (WireTapDefinition) v); - case "DeleteDefinition" -> doWriteDeleteDefinition("delete", (DeleteDefinition) v); - case "GetDefinition" -> doWriteGetDefinition("get", (GetDefinition) v); - case "HeadDefinition" -> doWriteHeadDefinition("head", (HeadDefinition) v); - case "OpenApiDefinition" -> doWriteOpenApiDefinition("openApi", (OpenApiDefinition) v); - case "PatchDefinition" -> doWritePatchDefinition("patch", (PatchDefinition) v); - case "PostDefinition" -> doWritePostDefinition("post", (PostDefinition) v); - case "PutDefinition" -> doWritePutDefinition("put", (PutDefinition) v); - case "RestBindingDefinition" -> doWriteRestBindingDefinition("restBinding", (RestBindingDefinition) v); - case "RestDefinition" -> doWriteRestDefinition("rest", (RestDefinition) v); - case "RestsDefinition" -> doWriteRestsDefinition("rests", (RestsDefinition) v); - } - } - } - protected void doWriteOutputTypeDefinitionRef(String n, OutputTypeDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "OutputTypeDefinition" -> doWriteOutputTypeDefinition("outputType", (OutputTypeDefinition) v); - } - } - } - protected void doWriteProcessorDefinitionRef(String n, ProcessorDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "AggregateDefinition" -> doWriteAggregateDefinition("aggregate", (AggregateDefinition) v); - case "BeanDefinition" -> doWriteBeanDefinition("bean", (BeanDefinition) v); - case "CatchDefinition" -> doWriteCatchDefinition("doCatch", (CatchDefinition) v); - case "ChoiceDefinition" -> doWriteChoiceDefinition("choice", (ChoiceDefinition) v); - case "CircuitBreakerDefinition" -> doWriteCircuitBreakerDefinition("circuitBreaker", (CircuitBreakerDefinition) v); - case "ClaimCheckDefinition" -> doWriteClaimCheckDefinition("claimCheck", (ClaimCheckDefinition) v); - case "ConvertBodyDefinition" -> doWriteConvertBodyDefinition("convertBodyTo", (ConvertBodyDefinition) v); - case "ConvertHeaderDefinition" -> doWriteConvertHeaderDefinition("convertHeaderTo", (ConvertHeaderDefinition) v); - case "ConvertVariableDefinition" -> doWriteConvertVariableDefinition("convertVariableTo", (ConvertVariableDefinition) v); - case "DelayDefinition" -> doWriteDelayDefinition("delay", (DelayDefinition) v); - case "DynamicRouterDefinition" -> doWriteDynamicRouterDefinition("dynamicRouter", (DynamicRouterDefinition) v); - case "EnrichDefinition" -> doWriteEnrichDefinition("enrich", (EnrichDefinition) v); - case "FilterDefinition" -> doWriteFilterDefinition("filter", (FilterDefinition) v); - case "FinallyDefinition" -> doWriteFinallyDefinition("doFinally", (FinallyDefinition) v); - case "IdempotentConsumerDefinition" -> doWriteIdempotentConsumerDefinition("idempotentConsumer", (IdempotentConsumerDefinition) v); - case "InterceptDefinition" -> doWriteInterceptDefinition("intercept", (InterceptDefinition) v); - case "InterceptFromDefinition" -> doWriteInterceptFromDefinition("interceptFrom", (InterceptFromDefinition) v); - case "InterceptSendToEndpointDefinition" -> doWriteInterceptSendToEndpointDefinition("interceptSendToEndpoint", (InterceptSendToEndpointDefinition) v); - case "KameletDefinition" -> doWriteKameletDefinition("kamelet", (KameletDefinition) v); - case "LoadBalanceDefinition" -> doWriteLoadBalanceDefinition("loadBalance", (LoadBalanceDefinition) v); - case "LogDefinition" -> doWriteLogDefinition("log", (LogDefinition) v); - case "LoopDefinition" -> doWriteLoopDefinition("loop", (LoopDefinition) v); - case "MarshalDefinition" -> doWriteMarshalDefinition("marshal", (MarshalDefinition) v); - case "MulticastDefinition" -> doWriteMulticastDefinition("multicast", (MulticastDefinition) v); - case "OnCompletionDefinition" -> doWriteOnCompletionDefinition("onCompletion", (OnCompletionDefinition) v); - case "OnExceptionDefinition" -> doWriteOnExceptionDefinition("onException", (OnExceptionDefinition) v); - case "PausableDefinition" -> doWritePausableDefinition("pausable", (PausableDefinition) v); - case "PipelineDefinition" -> doWritePipelineDefinition("pipeline", (PipelineDefinition) v); - case "PolicyDefinition" -> doWritePolicyDefinition("policy", (PolicyDefinition) v); - case "PollDefinition" -> doWritePollDefinition("poll", (PollDefinition) v); - case "PollEnrichDefinition" -> doWritePollEnrichDefinition("pollEnrich", (PollEnrichDefinition) v); - case "ProcessDefinition" -> doWriteProcessDefinition("process", (ProcessDefinition) v); - case "RecipientListDefinition" -> doWriteRecipientListDefinition("recipientList", (RecipientListDefinition) v); - case "RemoveHeaderDefinition" -> doWriteRemoveHeaderDefinition("removeHeader", (RemoveHeaderDefinition) v); - case "RemoveHeadersDefinition" -> doWriteRemoveHeadersDefinition("removeHeaders", (RemoveHeadersDefinition) v); - case "RemovePropertiesDefinition" -> doWriteRemovePropertiesDefinition("removeProperties", (RemovePropertiesDefinition) v); - case "RemovePropertyDefinition" -> doWriteRemovePropertyDefinition("removeProperty", (RemovePropertyDefinition) v); - case "RemoveVariableDefinition" -> doWriteRemoveVariableDefinition("removeVariable", (RemoveVariableDefinition) v); - case "ResequenceDefinition" -> doWriteResequenceDefinition("resequence", (ResequenceDefinition) v); - case "ResumableDefinition" -> doWriteResumableDefinition("resumable", (ResumableDefinition) v); - case "RollbackDefinition" -> doWriteRollbackDefinition("rollback", (RollbackDefinition) v); - case "RouteDefinition" -> doWriteRouteDefinition("route", (RouteDefinition) v); - case "RoutingSlipDefinition" -> doWriteRoutingSlipDefinition("routingSlip", (RoutingSlipDefinition) v); - case "SagaDefinition" -> doWriteSagaDefinition("saga", (SagaDefinition) v); - case "SamplingDefinition" -> doWriteSamplingDefinition("sample", (SamplingDefinition) v); - case "ScriptDefinition" -> doWriteScriptDefinition("script", (ScriptDefinition) v); - case "SetBodyDefinition" -> doWriteSetBodyDefinition("setBody", (SetBodyDefinition) v); - case "SetExchangePatternDefinition" -> doWriteSetExchangePatternDefinition("setExchangePattern", (SetExchangePatternDefinition) v); - case "SetHeaderDefinition" -> doWriteSetHeaderDefinition("setHeader", (SetHeaderDefinition) v); - case "SetHeadersDefinition" -> doWriteSetHeadersDefinition("setHeaders", (SetHeadersDefinition) v); - case "SetPropertyDefinition" -> doWriteSetPropertyDefinition("setProperty", (SetPropertyDefinition) v); - case "SetVariableDefinition" -> doWriteSetVariableDefinition("setVariable", (SetVariableDefinition) v); - case "SetVariablesDefinition" -> doWriteSetVariablesDefinition("setVariables", (SetVariablesDefinition) v); - case "SortDefinition" -> doWriteSortDefinition("sort", (SortDefinition) v); - case "SplitDefinition" -> doWriteSplitDefinition("split", (SplitDefinition) v); - case "StepDefinition" -> doWriteStepDefinition("step", (StepDefinition) v); - case "StopDefinition" -> doWriteStopDefinition("stop", (StopDefinition) v); - case "ThreadsDefinition" -> doWriteThreadsDefinition("threads", (ThreadsDefinition) v); - case "ThrottleDefinition" -> doWriteThrottleDefinition("throttle", (ThrottleDefinition) v); - case "ThrowExceptionDefinition" -> doWriteThrowExceptionDefinition("throwException", (ThrowExceptionDefinition) v); - case "ToDefinition" -> doWriteToDefinition("to", (ToDefinition) v); - case "ToDynamicDefinition" -> doWriteToDynamicDefinition("toD", (ToDynamicDefinition) v); - case "TokenizerDefinition" -> doWriteTokenizerDefinition("tokenizer", (TokenizerDefinition) v); - case "TransactedDefinition" -> doWriteTransactedDefinition("transacted", (TransactedDefinition) v); - case "TransformDataTypeDefinition" -> doWriteTransformDataTypeDefinition("transformDataType", (TransformDataTypeDefinition) v); - case "TransformDefinition" -> doWriteTransformDefinition("transform", (TransformDefinition) v); - case "TryDefinition" -> doWriteTryDefinition("doTry", (TryDefinition) v); - case "UnmarshalDefinition" -> doWriteUnmarshalDefinition("unmarshal", (UnmarshalDefinition) v); - case "ValidateDefinition" -> doWriteValidateDefinition("validate", (ValidateDefinition) v); - case "WireTapDefinition" -> doWriteWireTapDefinition("wireTap", (WireTapDefinition) v); - } - } - } - protected void doWriteRouteConfigurationDefinitionRef(String n, RouteConfigurationDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "RouteConfigurationDefinition" -> doWriteRouteConfigurationDefinition("routeConfiguration", (RouteConfigurationDefinition) v); - } - } - } - protected void doWriteRouteDefinitionRef(String n, RouteDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "RouteDefinition" -> doWriteRouteDefinition("route", (RouteDefinition) v); - } - } - } - protected void doWriteRouteTemplateDefinitionRef(String n, RouteTemplateDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "RouteTemplateDefinition" -> doWriteRouteTemplateDefinition("routeTemplate", (RouteTemplateDefinition) v); - } - } - } - protected void doWriteSetHeaderDefinitionRef(String n, SetHeaderDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "SetHeaderDefinition" -> doWriteSetHeaderDefinition("setHeader", (SetHeaderDefinition) v); - } - } - } - protected void doWriteSetVariableDefinitionRef(String n, SetVariableDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "SetVariableDefinition" -> doWriteSetVariableDefinition("setVariable", (SetVariableDefinition) v); - } - } - } - protected void doWriteTemplatedRouteDefinitionRef(String n, TemplatedRouteDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "TemplatedRouteDefinition" -> doWriteTemplatedRouteDefinition("templatedRoute", (TemplatedRouteDefinition) v); - } - } - } - protected void doWriteWhenDefinitionRef(String n, WhenDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "WhenDefinition" -> doWriteWhenDefinition("when", (WhenDefinition) v); - } - } - } - protected void doWriteUniVocityHeaderRef(String n, UniVocityHeader v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "UniVocityHeader" -> doWriteUniVocityHeader("univocityHeader", (UniVocityHeader) v); - } - } - } - protected void doWriteExpressionDefinitionRef(String n, ExpressionDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "CSimpleExpression" -> doWriteCSimpleExpression("csimple", (CSimpleExpression) v); - case "ConstantExpression" -> doWriteConstantExpression("constant", (ConstantExpression) v); - case "DatasonnetExpression" -> doWriteDatasonnetExpression("datasonnet", (DatasonnetExpression) v); - case "ExchangePropertyExpression" -> doWriteExchangePropertyExpression("exchangeProperty", (ExchangePropertyExpression) v); - case "ExpressionDefinition" -> doWriteExpressionDefinition("expressionDefinition", (ExpressionDefinition) v); - case "GroovyExpression" -> doWriteGroovyExpression("groovy", (GroovyExpression) v); - case "HeaderExpression" -> doWriteHeaderExpression("header", (HeaderExpression) v); - case "Hl7TerserExpression" -> doWriteHl7TerserExpression("hl7terser", (Hl7TerserExpression) v); - case "JavaExpression" -> doWriteJavaExpression("java", (JavaExpression) v); - case "JavaScriptExpression" -> doWriteJavaScriptExpression("js", (JavaScriptExpression) v); - case "JoorExpression" -> doWriteJoorExpression("joor", (JoorExpression) v); - case "JqExpression" -> doWriteJqExpression("jq", (JqExpression) v); - case "JsonPathExpression" -> doWriteJsonPathExpression("jsonpath", (JsonPathExpression) v); - case "LanguageExpression" -> doWriteLanguageExpression("language", (LanguageExpression) v); - case "MethodCallExpression" -> doWriteMethodCallExpression("method", (MethodCallExpression) v); - case "MvelExpression" -> doWriteMvelExpression("mvel", (MvelExpression) v); - case "OgnlExpression" -> doWriteOgnlExpression("ognl", (OgnlExpression) v); - case "PythonExpression" -> doWritePythonExpression("python", (PythonExpression) v); - case "RefExpression" -> doWriteRefExpression("ref", (RefExpression) v); - case "SimpleExpression" -> doWriteSimpleExpression("simple", (SimpleExpression) v); - case "SpELExpression" -> doWriteSpELExpression("spel", (SpELExpression) v); - case "TokenizerExpression" -> doWriteTokenizerExpression("tokenize", (TokenizerExpression) v); - case "VariableExpression" -> doWriteVariableExpression("variable", (VariableExpression) v); - case "WasmExpression" -> doWriteWasmExpression("wasm", (WasmExpression) v); - case "XMLTokenizerExpression" -> doWriteXMLTokenizerExpression("xtokenize", (XMLTokenizerExpression) v); - case "XPathExpression" -> doWriteXPathExpression("xpath", (XPathExpression) v); - case "XQueryExpression" -> doWriteXQueryExpression("xquery", (XQueryExpression) v); - } - } - } - protected void doWriteParamDefinitionRef(String n, ParamDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "ParamDefinition" -> doWriteParamDefinition("param", (ParamDefinition) v); - } - } - } - protected void doWriteResponseMessageDefinitionRef(String n, ResponseMessageDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "ResponseMessageDefinition" -> doWriteResponseMessageDefinition("responseMessage", (ResponseMessageDefinition) v); - } - } - } - protected void doWriteRestDefinitionRef(String n, RestDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "RestDefinition" -> doWriteRestDefinition("rest", (RestDefinition) v); - } - } - } - protected void doWriteSecurityDefinitionRef(String n, SecurityDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "SecurityDefinition" -> doWriteSecurityDefinition("security", (SecurityDefinition) v); - } - } - } - protected void doWriteVerbDefinitionRef(String n, VerbDefinition v) throws IOException { - if (v != null) { - switch (v.getClass().getSimpleName()) { - case "DeleteDefinition" -> doWriteDeleteDefinition("delete", (DeleteDefinition) v); - case "GetDefinition" -> doWriteGetDefinition("get", (GetDefinition) v); - case "HeadDefinition" -> doWriteHeadDefinition("head", (HeadDefinition) v); - case "PatchDefinition" -> doWritePatchDefinition("patch", (PatchDefinition) v); - case "PostDefinition" -> doWritePostDefinition("post", (PostDefinition) v); - case "PutDefinition" -> doWritePutDefinition("put", (PutDefinition) v); - } - } - } - - protected void doWriteAttribute( - String attribute, - String value) - throws IOException { - doWriteAttribute(attribute, value, null); - } - protected void doWriteAttribute( - String attribute, - String value, - String defaultValue) - throws IOException { - if (value != null) { - if (defaultValue == null || !defaultValue.equals(value)) { - attribute(attribute, value); - } - } - } - protected void doWriteValue(String value) throws IOException { - if (value != null) { - value(value); - } - } - protected void doWriteList(String wrapperName, String name, List list, ElementSerializer elementSerializer) throws IOException { - if (list != null) { - if (wrapperName != null) { - startElement(wrapperName); - } - for (T v : list) { - elementSerializer.doWriteElement(name, v); - } - if (wrapperName != null) { - endElement(wrapperName); - } - } - } - protected void doWriteElement(String name, T v, ElementSerializer elementSerializer) throws IOException { - if (v != null) { - elementSerializer.doWriteElement(name, v); - } - } - protected String toString(Boolean b) { - return b != null ? b.toString() : null; - } - protected String toString(Enum e) { - return e != null ? e.name() : null; - } - protected String toString(Number n) { - return n != null ? n.toString() : null; - } - protected String toString(byte[] b) { - return b != null ? Base64.getEncoder().encodeToString(b) : null; - } - protected void doWriteString(String name, String value) throws IOException { - if (value != null) { - startElement(name); - text(name, value); - endElement(name); - } - } - protected void doWriteNamespaces( - NamespaceAwareExpression def) - throws IOException { - if (def.getNamespaceAsMap() != null) { - for (var e : def.getNamespaceAsMap().entrySet()) { - doWriteAttribute("xmlns:" + e.getKey(), e.getValue()); - } - } - } - - public interface ElementSerializer { - void doWriteElement(String name, T value) throws IOException; - } -} \ No newline at end of file diff --git a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java deleted file mode 100644 index dc698a21e3041..0000000000000 --- a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/io/YamlWriter.java +++ /dev/null @@ -1,599 +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.yaml.io; - -import java.io.IOException; -import java.io.Writer; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.StringJoiner; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; -import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.apache.camel.catalog.impl.DefaultRuntimeCamelCatalog; -import org.apache.camel.support.service.ServiceSupport; -import org.apache.camel.tooling.model.BaseOptionModel; -import org.apache.camel.tooling.model.EipModel; -import org.apache.camel.util.StringHelper; -import org.apache.camel.util.URISupport; -import org.apache.camel.util.json.JsonArray; -import org.apache.camel.util.json.JsonObject; - -/** - * YAML writer which uses Jackson to dump to yaml format. - * - * Implementation notes: - * - * This writer is based on the same principle for the XML writer which parses the Camel routes (model classes) and emit - * a StAX based events for start/end elements. - * - * However since the YAML DSL is not as easy to dump as XML, then we need to enrich with additional metadata from the - * runtime catalog ({@link EipModel}). We then abuse the {@link EipModel} and store the route details in its metadata. - * After this we transform from {@link EipModel} to {@link EipNode} to have a List/Map structure that we then transform - * to JSon, and then from JSon to YAML. - */ -public class YamlWriter extends ServiceSupport implements CamelContextAware { - - private CamelContext camelContext; - private final Writer writer; - private final DefaultRuntimeCamelCatalog catalog; - private final ModelJSonSchemaResolver resolver; - private final List roots = new ArrayList<>(); - private boolean routesIsRoot; - private final ArrayDeque models = new ArrayDeque<>(); - private String expression; - private boolean uriAsParameters; - - public YamlWriter(Writer writer) { - this.writer = writer; - this.resolver = new ModelJSonSchemaResolver(); - this.catalog = new DefaultRuntimeCamelCatalog(); - this.catalog.setJSonSchemaResolver(this.resolver); - this.catalog.setCaching(false); // turn cache off as we store state per node - this.catalog.start(); - } - - @Override - public CamelContext getCamelContext() { - return camelContext; - } - - @Override - public void setCamelContext(CamelContext camelContext) { - this.camelContext = camelContext; - } - - @Override - protected void doStart() throws Exception { - if (camelContext != null) { - this.resolver.setCamelContext(camelContext); - this.resolver.setClassLoader(camelContext.getApplicationContextClassLoader()); - } - } - - private EipModel lookupEipModel(String name) { - // namespace is using the property model - if ("namespace".equals(name)) { - name = "property"; - } - return catalog.eipModel(name); - } - - public void setUriAsParameters(boolean uriAsParameters) { - this.uriAsParameters = uriAsParameters; - } - - public void startElement(String name) throws IOException { - if ("routes".equals(name) || "rests".equals(name) || "routeConfigurations".equals(name) - || "dataFormats".equals(name)) { - routesIsRoot = true; - return; - } - - EipModel model = lookupEipModel(name); - if (model == null) { - // not an EIP model or namespace - return; - } - - EipModel parent = models.isEmpty() ? null : models.peek(); - model.getMetadata().put("_parent", parent); - models.push(model); - if (parent == null) { - // its a root element - roots.add(model); - } - } - - public void startExpressionElement(String name) throws IOException { - // currently building an expression - this.expression = name; - } - - public void endExpressionElement(String name) throws IOException { - // expression complete, back to normal mode - this.expression = null; - } - - public void endElement(String name) throws IOException { - if ("routes".equals(name) || "rests".equals(name) || "routeConfigurations".equals(name) - || "dataFormats".equals(name)) { - writer.write(toYaml()); - return; - } - - EipModel model = lookupEipModel(name); - if (model == null) { - // not an EIP model - return; - } - - // special for namespace - if ("namespace".equals(name)) { - EipModel last = models.isEmpty() ? null : models.peek(); - if (!models.isEmpty()) { - models.pop(); - } - EipModel parent = models.isEmpty() ? null : models.peek(); - if (parent != null) { - Map map = (Map) parent.getMetadata().get("namespace"); - if (map == null) { - map = new LinkedHashMap<>(); - parent.getMetadata().put("namespace", map); - } - String key = (String) last.getMetadata().get("key"); - String value = (String) last.getMetadata().get("value"); - // skip xsi namespace - if (key != null && !"xsi".equals(key) && value != null) { - map.put(key, value); - } - } - return; - } - - EipModel last = models.isEmpty() ? null : models.peek(); - if (last != null && isLanguage(last)) { - if (!models.isEmpty()) { - models.pop(); - } - // okay we ended a language which we need to set on a parent EIP - EipModel parent = models.isEmpty() ? null : models.peek(); - if (parent != null) { - String key = expressionName(parent, expression); - if (key != null) { - parent.getMetadata().put(key, last); - } - } - return; - } - - if (last != null) { - if (!models.isEmpty()) { - models.pop(); - } - // is this input/output on the parent - EipModel parent = models.isEmpty() ? null : models.peek(); - if (parent != null && parent.isAbstractModel()) { - // transacted/policy is special as they are abstract so we should go one level back - int pos = models.size() - 1; - var it = models.iterator(); - for (int i = 0; i <= pos; i++) { - parent = it.next(); - } - } - if (parent != null) { - if ("from".equals(name) && parent.isInput()) { - // only set input once - parent.getMetadata().put("_input", last); - } else if ("dataFormats".equals(parent.getName())) { - // special for dataFormats - List list = (List) parent.getMetadata().get("_output"); - if (list == null) { - list = new ArrayList<>(); - parent.getMetadata().put("_output", list); - } - list.add(last); - } else if ("choice".equals(parent.getName())) { - // special for choice/doCatch/doFinally - setMetadata(parent, name, last); - } else if ("setHeaders".equals(parent.getName())) { - // special for setHeaders - setMetadata(parent, "headers", last); - } else if ("setVariables".equals(parent.getName())) { - // special for setVariables - setMetadata(parent, "variables", last); - } else if ("resequence".equals(parent.getName()) - && ("batchConfig".equals(name) || "streamConfig".equals(name))) { - // special for resequence - setMetadata(parent, "resequenceConfig", last); - } else if ("circuitBreaker".equals(parent.getName()) - && ("resilience4jConfiguration".equals(name) - || "faultToleranceConfiguration".equals(name))) { - setMetadata(parent, name, last); - } else if (parent.isOutput()) { - List list = (List) parent.getMetadata().get("_output"); - if (list == null) { - list = new ArrayList<>(); - parent.getMetadata().put("_output", list); - } - // abstracts are special and should be added in the top - if (last.isAbstractModel()) { - list.add(0, last); - } else { - list.add(last); - } - } else if ("marshal".equals(parent.getName()) || "unmarshal".equals(parent.getName())) { - parent.getMetadata().put("_dataFormatType", last); - } else if ("errorHandler".equals(parent.getName())) { - parent.getMetadata().put("_errorHandlerType", last); - } - } - } - - if (models.isEmpty() && !routesIsRoot) { - // we are done - writer.write(toYaml()); - } - } - - public void writeText(String name, String text) throws IOException { - EipModel last = models.isEmpty() ? null : models.peek(); - if (last != null) { - // special as writeText can be used for list of string values - setMetadata(last, name, text); - } - } - - public void writeValue(String value) throws IOException { - EipModel last = models.isEmpty() ? null : models.peek(); - if (last != null) { - String key = valueName(last); - if (key != null) { - last.getMetadata().put(key, value); - } - } - } - - public void addAttribute(String name, Object value) throws IOException { - EipModel last = models.isEmpty() ? null : models.peek(); - if (last != null) { - // uri should be expanded into more human-readable with parameters - if (uriAsParameters && "uri".equals(name) && value != null) { - try { - String base = StringHelper.before(value.toString(), ":"); - if (base != null) { - Map parameters = catalog.endpointProperties(value.toString()); - if (!parameters.isEmpty()) { - prepareParameters(parameters); - last.getMetadata().put("uri", base); - last.getMetadata().put("parameters", parameters); - return; - } - } - } catch (Exception e) { - // ignore will attempt without catalog - } - try { - String base = URISupport.stripQuery(value.toString()); - String query = URISupport.extractQuery(value.toString()); - if (base != null && query != null) { - Map parameters = URISupport.parseQuery(query); - if (!parameters.isEmpty()) { - prepareParameters(parameters); - last.getMetadata().put("uri", base); - last.getMetadata().put("parameters", parameters); - return; - } - } - } catch (Exception e) { - // ignore - } - } - - last.getMetadata().put(name, value); - } - } - - private static void prepareParameters(Map parameters) { - // convert "true" / "false" to boolean values - parameters.forEach((k, v) -> { - if ("true".equals(v) || "false".equals(v)) { - Object s = Boolean.valueOf(v.toString()); - parameters.replace(k, s); - } - }); - } - - private EipNode asExpressionNode(EipModel model, String name) { - EipNode node = new EipNode(name, null, false, true); - doAsNode(model, node); - return node; - } - - private EipNode asNode(EipModel model) { - EipNode node = new EipNode(model.getName(), null, false, false); - doAsNode(model, node); - return node; - } - - private void doAsNode(EipModel model, EipNode node) { - for (Map.Entry entry : model.getMetadata().entrySet()) { - String key = entry.getKey(); - if ("_input".equals(key)) { - EipModel m = (EipModel) entry.getValue(); - node.setInput(asNode(m)); - } else if ("_output".equals(key)) { - List list = (List) entry.getValue(); - for (EipModel m : list) { - node.addOutput(asNode(m)); - } - } else if ("setHeaders".equals(node.getName()) && "headers".equals(key)) { - List list = (List) entry.getValue(); - for (EipModel m : list) { - node.addOutput(asNode(m)); - } - } else if ("setVariables".equals(node.getName()) && "variables".equals(key)) { - List list = (List) entry.getValue(); - for (EipModel m : list) { - node.addOutput(asNode(m)); - } - } else if ("resequence".equals(node.getName()) && "resequenceConfig".equals(key)) { - EipModel config = (EipModel) entry.getValue(); - JsonObject jo = new JsonObject(); - for (var o : config.getOptions()) { - String n = o.getName(); - Object v = config.getMetadata().get(n); - if (v != null) { - jo.put(n, v); - } - } - if (!jo.isEmpty()) { - node.addProperty(config.getName(), jo); - } - } else if ("circuitBreaker".equals(node.getName()) - && ("resilience4jConfiguration".equals(key) - || "faultToleranceConfiguration".equals(key))) { - EipModel config = (EipModel) entry.getValue(); - JsonObject jo = new JsonObject(); - for (var o : config.getOptions()) { - String n = o.getName(); - Object v = config.getMetadata().get(n); - if (v != null) { - jo.put(n, v); - } - } - if (!jo.isEmpty()) { - node.addProperty(config.getName(), jo); - } - } else if ("choice".equals(node.getName()) && "otherwise".equals(key)) { - EipModel other = (EipModel) entry.getValue(); - node.addOutput(asNode(other)); - } else if ("choice".equals(node.getName()) && "when".equals(key)) { - Object v = entry.getValue(); - if (v instanceof List list) { - // can be a list in choice - for (Object item : list) { - EipModel m = (EipModel) item; - node.addOutput(asNode(m)); - } - } else { - node.addOutput(asNode((EipModel) v)); - } - } else if (("marshal".equals(node.getName()) || "unmarshal".equals(node.getName())) - && "_dataFormatType".equals(key)) { - EipModel other = (EipModel) entry.getValue(); - node.addOutput(asNode(other)); - } else if ("errorHandler".equals(node.getName()) - && "_errorHandlerType".equals(key)) { - EipModel other = (EipModel) entry.getValue(); - node.addOutput(asNode(other)); - } else { - boolean skip = key.startsWith("_") || key.equals("customId"); - if (skip) { - continue; - } - String exp = null; - if (!isLanguage(model)) { - // special for expressions that are a property where we need to use expression name as key - exp = expressionName(model, key); - } - Object v = entry.getValue(); - if (v instanceof EipModel m) { - if (exp == null || "expression".equals(exp)) { - v = asExpressionNode(m, m.getName()); - } else { - v = asExpressionNode(m, exp); - } - } - if (exp != null && v instanceof EipNode eipNode) { - node.addExpression(eipNode); - } else { - node.addProperty(key, v); - if ("expression".equals(key) || node.isExpression()) { - node.addProperty("language", model.getName()); - } - } - } - } - } - - public String toYaml() { - try { - // model to json - JsonArray arr = transformToJson(roots); - // load into jackson - JsonNode jsonNodeTree = new ObjectMapper().readTree(arr.toJson()); - // map to yaml via jackson - YAMLMapper mapper = new YAMLMapper(); - mapper.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER); - mapper.enable(YAMLGenerator.Feature.MINIMIZE_QUOTES); - mapper.enable(YAMLGenerator.Feature.INDENT_ARRAYS_WITH_INDICATOR); - String jsonAsYaml = mapper.writeValueAsString(jsonNodeTree); - // strip leading yaml indent of 2 spaces (because INDENT_ARRAYS_WITH_INDICATOR is enabled) - StringJoiner sj = new StringJoiner("\n"); - for (String line : jsonAsYaml.split("\n")) { - if (line.startsWith(" ")) { - line = line.substring(2); - } - sj.add(line); - } - sj.add(""); // end with empty line - jsonAsYaml = sj.toString(); - return jsonAsYaml; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private JsonArray transformToJson(List models) { - JsonArray arr = new JsonArray(); - for (EipModel model : models) { - JsonObject jo = asJSonNode(model); - arr.add(jo); - } - return arr; - } - - private JsonObject asJSonNode(EipModel model) { - JsonObject answer = new JsonObject(); - JsonObject jo = new JsonObject(); - answer.put(model.getName(), jo); - - for (Map.Entry entry : model.getMetadata().entrySet()) { - String key = entry.getKey(); - boolean skip = key.equals("customId"); - if (skip) { - continue; - } - Object value = entry.getValue(); - if (value != null) { - if (value instanceof Collection col) { - List list = new ArrayList<>(); - for (Object v : col) { - Object r = v; - if (r instanceof EipModel eipModel) { - EipNode en = asNode(eipModel); - value = en.asJsonObject(); - if ("route".equals(model.getName()) && "errorHandler".equals(en.getName())) { - jo.put("errorHandler", value); - continue; - } - JsonObject wrap = new JsonObject(); - wrap.put(en.getName(), value); - r = wrap; - } - list.add(r); - } - if ("_output".equals(key)) { - key = "steps"; - } - if ("route".equals(model.getName())) { - // special with "from" where outputs needs to be embedded - if (jo.containsKey("from")) { - jo = jo.getMap("from"); - } - } - jo.put(key, list); - } else if ("_input".equals(key)) { - jo = answer.getMap("route"); - if (!jo.containsKey("from")) { - jo.put("from", new JsonObject()); - } - jo = jo.getMap("from"); - if (value instanceof EipModel eipModel) { - EipNode r = asNode(eipModel); - JsonObject uri = r.asJsonObject(); - Object steps = jo.remove("steps"); - if (steps == null) { - // steps was placed directly on route and not under from so move it - var route = answer.getMap("route"); - steps = route.remove("steps"); - } - // ensure uri comes before steps - jo.putAll(uri); - if (steps != null) { - jo.put("steps", steps); - } - } else { - jo.put(key, value); - } - } else { - if (value instanceof EipModel eipModel) { - EipNode r = asNode(eipModel); - value = r.asJsonObject(); - jo.put(r.getName(), value); - } else { - jo.put(key, value); - } - } - } - } - - return answer; - } - - @SuppressWarnings("unchecked") - private static void setMetadata(EipModel model, String name, Object value) { - // special for choice - boolean array = isArray(model, name); - if (array) { - List list = (List) model.getMetadata().get(name); - if (list == null) { - list = new ArrayList<>(); - model.getMetadata().put(name, list); - } - list.add(value); - } else { - model.getMetadata().put(name, value); - } - } - - private static String valueName(EipModel model) { - return model.getOptions().stream() - .filter(o -> "value".equals(o.getKind())) - .map(BaseOptionModel::getName) - .findFirst().orElse(null); - } - - private static String expressionName(EipModel model, String name) { - return model.getOptions().stream() - .filter(o -> "expression".equals(o.getKind())) - .map(BaseOptionModel::getName) - .filter(oName -> name == null || oName.equalsIgnoreCase(name)) - .findFirst().orElse(null); - } - - private static boolean isArray(EipModel model, String name) { - return model.getOptions().stream() - .filter(o -> o.getName().equalsIgnoreCase(name)) - .map(o -> "array".equals(o.getType())) - .findFirst().orElse(false); - } - - private static boolean isLanguage(EipModel model) { - return model.getJavaType().startsWith("org.apache.camel.model.language"); - } - -} diff --git a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/BaseWriter.java b/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/BaseWriter.java deleted file mode 100644 index 1d66fb031a523..0000000000000 --- a/core/camel-yaml-io/src/main/java/org/apache/camel/yaml/out/BaseWriter.java +++ /dev/null @@ -1,104 +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.yaml.out; - -import java.io.IOException; -import java.io.Writer; -import java.util.List; - -import org.w3c.dom.Element; - -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.apache.camel.support.service.ServiceHelper; -import org.apache.camel.support.service.ServiceSupport; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.yaml.io.YamlWriter; - -public class BaseWriter extends ServiceSupport implements CamelContextAware { - - protected final YamlWriter writer; - - public BaseWriter(Writer writer, String namespace) throws IOException { - this.writer = new YamlWriter(writer); - // namespace is only for XML - } - - @Override - public CamelContext getCamelContext() { - return writer.getCamelContext(); - } - - @Override - public void setCamelContext(CamelContext camelContext) { - this.writer.setCamelContext(camelContext); - } - - public void setUriAsParameters(boolean uriAsParameters) { - this.writer.setUriAsParameters(uriAsParameters); - } - - @Override - protected void doStart() throws Exception { - ObjectHelper.notNull(getCamelContext(), "CamelContext", this); - ServiceHelper.startService(this.writer); - } - - @Override - protected void doStop() throws Exception { - ServiceHelper.stopService(this.writer); - } - - public String toYaml() { - return writer.toYaml(); - } - - protected void startElement(String name) throws IOException { - writer.startElement(name); - } - - protected void startExpressionElement(String name) throws IOException { - writer.startExpressionElement(name); - } - - protected void endElement(String name) throws IOException { - writer.endElement(name); - } - - protected void endExpressionElement(String name) throws IOException { - writer.endExpressionElement(name); - } - - protected void text(String name, String text) throws IOException { - writer.writeText(name, text); - } - - protected void value(String value) throws IOException { - writer.writeValue(value); - } - - protected void attribute(String name, Object value) throws IOException { - if (value != null) { - writer.addAttribute(name, value); - } - } - - protected void domElements(List elements) throws IOException { - // not in use for yaml-dsl - } - -} diff --git a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/ModelWriterTest.java b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/ModelWriterTest.java deleted file mode 100644 index 122c5e032d994..0000000000000 --- a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/ModelWriterTest.java +++ /dev/null @@ -1,465 +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.yaml.out; - -import java.io.IOException; -import java.io.StringWriter; -import java.nio.file.Paths; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.model.AggregateDefinition; -import org.apache.camel.model.ChoiceDefinition; -import org.apache.camel.model.ErrorHandlerDefinition; -import org.apache.camel.model.ExpressionSubElementDefinition; -import org.apache.camel.model.FromDefinition; -import org.apache.camel.model.LogDefinition; -import org.apache.camel.model.MarshalDefinition; -import org.apache.camel.model.ModelCamelContext; -import org.apache.camel.model.ProcessDefinition; -import org.apache.camel.model.ResequenceDefinition; -import org.apache.camel.model.RouteDefinition; -import org.apache.camel.model.RoutesDefinition; -import org.apache.camel.model.SetBodyDefinition; -import org.apache.camel.model.SetHeaderDefinition; -import org.apache.camel.model.SetHeadersDefinition; -import org.apache.camel.model.SetVariableDefinition; -import org.apache.camel.model.SetVariablesDefinition; -import org.apache.camel.model.SplitDefinition; -import org.apache.camel.model.ToDefinition; -import org.apache.camel.model.TransactedDefinition; -import org.apache.camel.model.dataformat.CsvDataFormat; -import org.apache.camel.model.errorhandler.NoErrorHandlerDefinition; -import org.apache.camel.model.language.ConstantExpression; -import org.apache.camel.model.language.HeaderExpression; -import org.apache.camel.model.language.SimpleExpression; -import org.apache.camel.model.rest.RestDefinition; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import static org.apache.camel.util.IOHelper.stripLineComments; - -public class ModelWriterTest { - - @Test - public void testTimerLog() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute0"); - route.setInput(new FromDefinition("timer:yaml?period=1234&includeMetadata=true")); - SetBodyDefinition sb = new SetBodyDefinition(); - sb.setExpression(new ConstantExpression("Hello from yaml")); - route.addOutput(sb); - route.addOutput(new LogDefinition("${body}")); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route0b.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testFromTo() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute1"); - route.setInput(new FromDefinition("direct:start")); - ToDefinition to = new ToDefinition("log:input"); - route.addOutput(to); - ToDefinition to2 = new ToDefinition("mock:result"); - to2.setPattern("InOut"); - route.addOutput(to2); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route1.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testFromSplitTo() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute2"); - route.setInput(new FromDefinition("direct:start2")); - SplitDefinition sp = new SplitDefinition(); - SimpleExpression e = new SimpleExpression("${body}"); - e.setResultTypeName("int.class"); - sp.setExpression(e); - sp.setStreaming("true"); - route.addOutput(sp); - ToDefinition to = new ToDefinition("kafka:line"); - sp.addOutput(to); - to = new ToDefinition("mock:result2"); - route.addOutput(to); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route2.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testFromAggregateTo() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute3"); - route.setInput(new FromDefinition("direct:start2")); - final AggregateDefinition ag = createAggregateDefinition(); - route.addOutput(ag); - ToDefinition to = new ToDefinition("kafka:line"); - ag.addOutput(to); - to = new ToDefinition("mock:result2"); - route.addOutput(to); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route3.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - private static AggregateDefinition createAggregateDefinition() { - AggregateDefinition ag = new AggregateDefinition(); - SimpleExpression e = new SimpleExpression("${body}"); - e.setResultTypeName("int.class"); - ag.setExpression(e); - ag.setCorrelationExpression(new ExpressionSubElementDefinition(new HeaderExpression("myHeader"))); - ConstantExpression cons = new ConstantExpression("5"); - cons.setResultTypeName("int.class"); - ag.setCompletionSizeExpression(new ExpressionSubElementDefinition(cons)); - ag.setCompletionTimeoutExpression(new ExpressionSubElementDefinition(new ConstantExpression("4000"))); - return ag; - } - - @Test - public void testFromSetBodyTo() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute4"); - route.setInput(new FromDefinition("direct:start")); - SetBodyDefinition body = new SetBodyDefinition(); - body.setExpression(new ConstantExpression("{\n key: '123'\n}")); - route.addOutput(body); - ToDefinition to = new ToDefinition("mock:result"); - route.addOutput(to); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route4.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testFromLogSetBodyTo() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute5"); - route.setInput(new FromDefinition("direct:start")); - LogDefinition log = new LogDefinition(); - log.setLoggingLevel("WARN"); - log.setLogName("myLogger"); - route.addOutput(log); - SetBodyDefinition body = new SetBodyDefinition(); - body.setExpression(new SimpleExpression("${body}")); - route.addOutput(body); - ToDefinition to = new ToDefinition("mock:result"); - route.addOutput(to); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route5.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Disabled("TODO: https://issues.apache.org/jira/browse/CAMEL-21490") - @Test - public void testFromChoice() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute6"); - route.setInput(new FromDefinition("direct:start6")); - ChoiceDefinition choice = new ChoiceDefinition(); - route.addOutput(choice); - choice.when().simple("${header.age} < 21").to("mock:young"); - choice.when().simple("${header.age} > 21 && ${header.age} < 70").to("mock:work"); - choice.otherwise().to("mock:senior"); - ToDefinition to = new ToDefinition("mock:result"); - route.addOutput(to); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route6.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testFromTryCatch() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - CamelContext context = new DefaultCamelContext(); - context.addRoutes(new RouteBuilder() { - @Override - public void configure() { - from("direct:start7").routeId("myRoute7") - .doTry() - .to("mock:try1") - .to("mock:try2") - .doCatch(IOException.class) - .to("mock:io1") - .to("mock:io2") - .doFinally() - .to("mock:finally1") - .to("mock:finally2") - .end() - .to("mock:result"); - } - }); - - ModelCamelContext mcc = (ModelCamelContext) context; - writer.writeRouteDefinition(mcc.getRouteDefinition("myRoute7")); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route7.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testTwoRoutes() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RoutesDefinition routes = new RoutesDefinition(); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute0"); - route.setInput(new FromDefinition("timer:yaml?period=1234")); - SetBodyDefinition sb = new SetBodyDefinition(); - sb.setExpression(new ConstantExpression("Hello from yaml")); - route.addOutput(sb); - route.addOutput(new LogDefinition("${body}")); - routes.getRoutes().add(route); - - route = new RouteDefinition(); - route.setId("myRoute1"); - route.setInput(new FromDefinition("direct:start")); - ToDefinition to = new ToDefinition("log:input"); - route.addOutput(to); - ToDefinition to2 = new ToDefinition("mock:result"); - to2.setPattern("InOut"); - route.addOutput(to2); - routes.getRoutes().add(route); - - writer.writeRoutesDefinition(routes); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route8b.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testMarshal() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute9"); - route.setInput(new FromDefinition("timer:foo")); - MarshalDefinition mar = new MarshalDefinition(); - mar.setDataFormatType(new CsvDataFormat()); - route.addOutput(mar); - route.addOutput(new LogDefinition("${body}")); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route9.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - @Disabled("CAMEL-20402") - public void testRest() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RestDefinition rest = new RestDefinition(); - rest.verb("get").to("direct:start"); - writer.writeRestDefinition(rest); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute10"); - route.setInput(new FromDefinition("direct:start")); - SetBodyDefinition sb = new SetBodyDefinition(new SimpleExpression("${body}${body}")); - route.addOutput(sb); - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route10.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testSetHeaders() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRout12"); - route.setInput(new FromDefinition("timer:foo")); - SetHeadersDefinition sh = new SetHeadersDefinition(); - sh.getHeaders().add(new SetHeaderDefinition("foo", new ConstantExpression("hello world"))); - sh.getHeaders().add(new SetHeaderDefinition("bar", new SimpleExpression("bye ${body}"))); - route.addOutput(sh); - route.addOutput(new LogDefinition("${body}")); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route12.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testSetVariables() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRout13"); - route.setInput(new FromDefinition("timer:foo")); - SetVariablesDefinition sv = new SetVariablesDefinition(); - sv.getVariables().add(new SetVariableDefinition("foo", new ConstantExpression("hello2 world"))); - sv.getVariables().add(new SetVariableDefinition("bar", new SimpleExpression("bye2 ${body}"))); - route.addOutput(sv); - route.addOutput(new LogDefinition("${body}")); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route13.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testResequenceBatch() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRout14"); - route.setInput(new FromDefinition("timer:foo")); - ResequenceDefinition rd = new ResequenceDefinition(new SimpleExpression("${body}")); - rd.batch().size(300).timeout("4000"); - route.addOutput(rd); - rd.addOutput(new ToDefinition("mock:result")); - route.addOutput(new LogDefinition("${body}")); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route14.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testResequenceStream() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRout15"); - route.setInput(new FromDefinition("timer:foo")); - ResequenceDefinition rd = new ResequenceDefinition(new SimpleExpression("${body}")); - rd.stream().capacity(123).timeout("4000").rejectOld(); - route.addOutput(rd); - rd.addOutput(new ToDefinition("mock:result")); - route.addOutput(new LogDefinition("${body}")); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route15.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testTransacted() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRout16"); - route.setInput(new FromDefinition("jms:cheese")); - TransactedDefinition td = new TransactedDefinition(); - route.addOutput(td); - td.addOutput(new ToDefinition("bean:foo")); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route16.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testErrorHandler() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - - RouteDefinition route = new RouteDefinition(); - ErrorHandlerDefinition ehd = new ErrorHandlerDefinition(); - ehd.setErrorHandlerType(new NoErrorHandlerDefinition()); - route.setErrorHandler(ehd); - route.setId("myRout17"); - route.setInput(new FromDefinition("direct:sub")); - route.addOutput(new ToDefinition("mock:b")); - ProcessDefinition p = new ProcessDefinition(); - p.setRef("myProcessor"); - route.addOutput(p); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route17.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - -} diff --git a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/ModelWriterUriAsParametersTest.java b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/ModelWriterUriAsParametersTest.java deleted file mode 100644 index edad85b4134ad..0000000000000 --- a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/ModelWriterUriAsParametersTest.java +++ /dev/null @@ -1,356 +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.yaml.out; - -import java.io.IOException; -import java.io.StringWriter; -import java.nio.file.Paths; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.model.AggregateDefinition; -import org.apache.camel.model.ChoiceDefinition; -import org.apache.camel.model.ExpressionSubElementDefinition; -import org.apache.camel.model.FromDefinition; -import org.apache.camel.model.LogDefinition; -import org.apache.camel.model.MarshalDefinition; -import org.apache.camel.model.ModelCamelContext; -import org.apache.camel.model.RouteDefinition; -import org.apache.camel.model.RoutesDefinition; -import org.apache.camel.model.SetBodyDefinition; -import org.apache.camel.model.SetHeaderDefinition; -import org.apache.camel.model.SplitDefinition; -import org.apache.camel.model.ToDefinition; -import org.apache.camel.model.WhenDefinition; -import org.apache.camel.model.dataformat.CsvDataFormat; -import org.apache.camel.model.language.ConstantExpression; -import org.apache.camel.model.language.HeaderExpression; -import org.apache.camel.model.language.SimpleExpression; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import static org.apache.camel.util.IOHelper.stripLineComments; - -public class ModelWriterUriAsParametersTest { - - @Test - public void testTimerLog() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - writer.setUriAsParameters(true); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute0"); - route.setInput(new FromDefinition("timer:yaml?period=1234&includeMetadata=true")); - SetBodyDefinition sb = new SetBodyDefinition(); - sb.setExpression(new ConstantExpression("Hello from yaml")); - route.addOutput(sb); - route.addOutput(new LogDefinition("${body}")); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route0.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testFromTo() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - writer.setUriAsParameters(true); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute1"); - route.setInput(new FromDefinition("direct:start")); - ToDefinition to = new ToDefinition("log:input"); - route.addOutput(to); - ToDefinition to2 = new ToDefinition("mock:result"); - to2.setPattern("InOut"); - route.addOutput(to2); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route1.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testFromSplitTo() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - writer.setUriAsParameters(true); - - final RouteDefinition route = createRouteDefinition(); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route2.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - private static RouteDefinition createRouteDefinition() { - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute2"); - route.setInput(new FromDefinition("direct:start2")); - SplitDefinition sp = new SplitDefinition(); - SimpleExpression e = new SimpleExpression("${body}"); - e.setResultTypeName("int.class"); - sp.setExpression(e); - sp.setStreaming("true"); - route.addOutput(sp); - ToDefinition to = new ToDefinition("kafka:line"); - sp.addOutput(to); - to = new ToDefinition("mock:result2"); - route.addOutput(to); - return route; - } - - @Test - public void testFromAggregateTo() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - writer.setUriAsParameters(true); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute3"); - route.setInput(new FromDefinition("direct:start2")); - final AggregateDefinition ag = createAggregateDefinition(); - route.addOutput(ag); - ToDefinition to = new ToDefinition("kafka:line"); - ag.addOutput(to); - to = new ToDefinition("mock:result2"); - route.addOutput(to); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route3.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - private static AggregateDefinition createAggregateDefinition() { - AggregateDefinition ag = new AggregateDefinition(); - SimpleExpression e = new SimpleExpression("${body}"); - e.setResultTypeName("int.class"); - ag.setExpression(e); - ag.setCorrelationExpression(new ExpressionSubElementDefinition(new HeaderExpression("myHeader"))); - ConstantExpression cons = new ConstantExpression("5"); - cons.setResultTypeName("int.class"); - ag.setCompletionSizeExpression(new ExpressionSubElementDefinition(cons)); - ag.setCompletionTimeoutExpression(new ExpressionSubElementDefinition(new ConstantExpression("4000"))); - return ag; - } - - @Test - public void testFromSetBodyTo() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - writer.setUriAsParameters(true); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute4"); - route.setInput(new FromDefinition("direct:start")); - SetBodyDefinition body = new SetBodyDefinition(); - body.setExpression(new ConstantExpression("{\n key: '123'\n}")); - route.addOutput(body); - ToDefinition to = new ToDefinition("mock:result"); - route.addOutput(to); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route4.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testFromLogSetBodyTo() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - writer.setUriAsParameters(true); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute5"); - route.setInput(new FromDefinition("direct:start")); - LogDefinition log = new LogDefinition(); - log.setLoggingLevel("WARN"); - log.setLogName("myLogger"); - route.addOutput(log); - SetBodyDefinition body = new SetBodyDefinition(); - body.setExpression(new SimpleExpression("${body}")); - route.addOutput(body); - ToDefinition to = new ToDefinition("mock:result"); - route.addOutput(to); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route5.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testFromChoice() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - writer.setUriAsParameters(true); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute6"); - route.setInput(new FromDefinition("direct:start6")); - ChoiceDefinition choice = new ChoiceDefinition(); - route.addOutput(choice); - - WhenDefinition when = new WhenDefinition(); - when.setExpression(new SimpleExpression("${header.age} < 21")); - when.addOutput(new ToDefinition("mock:young")); - choice.addOutput(when); - - when = new WhenDefinition(); - when.setExpression(new SimpleExpression("${header.age} > 21 && ${header.age} < 70")); - when.addOutput(new ToDefinition("mock:work")); - choice.addOutput(when); - - choice.otherwise().to("mock:senior"); - ToDefinition to = new ToDefinition("mock:result"); - route.addOutput(to); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route6.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testFromTryCatch() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - writer.setUriAsParameters(true); - - CamelContext context = new DefaultCamelContext(); - context.addRoutes(new RouteBuilder() { - @Override - public void configure() { - from("direct:start7").routeId("myRoute7") - .doTry() - .to("mock:try1") - .to("mock:try2") - .doCatch(IOException.class) - .to("mock:io1") - .to("mock:io2") - .doFinally() - .to("mock:finally1") - .to("mock:finally2") - .end() - .to("mock:result"); - } - }); - - ModelCamelContext mcc = (ModelCamelContext) context; - writer.writeRouteDefinition(mcc.getRouteDefinition("myRoute7")); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route7.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testTwoRoutes() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - writer.setUriAsParameters(true); - - RoutesDefinition routes = new RoutesDefinition(); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute0"); - route.setInput(new FromDefinition("timer:yaml?period=1234")); - SetBodyDefinition sb = new SetBodyDefinition(); - sb.setExpression(new ConstantExpression("Hello from yaml")); - route.addOutput(sb); - route.addOutput(new LogDefinition("${body}")); - routes.getRoutes().add(route); - - route = new RouteDefinition(); - route.setId("myRoute1"); - route.setInput(new FromDefinition("direct:start")); - ToDefinition to = new ToDefinition("log:input"); - route.addOutput(to); - ToDefinition to2 = new ToDefinition("mock:result"); - to2.setPattern("InOut"); - route.addOutput(to2); - routes.getRoutes().add(route); - - writer.writeRoutesDefinition(routes); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route8.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testMarshal() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - writer.setUriAsParameters(true); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute9"); - route.setInput(new FromDefinition("timer:foo")); - MarshalDefinition mar = new MarshalDefinition(); - mar.setDataFormatType(new CsvDataFormat()); - route.addOutput(mar); - route.addOutput(new LogDefinition("${body}")); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route9.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - - @Test - public void testConstantExpression() throws Exception { - StringWriter sw = new StringWriter(); - ModelWriter writer = new ModelWriter(sw); - writer.setUriAsParameters(true); - - RouteDefinition route = new RouteDefinition(); - route.setId("myRoute11"); - route.setInput(new FromDefinition("timer:yaml?period=1234&includeMetadata=true")); - SetBodyDefinition sb = new SetBodyDefinition(); - sb.setExpression(new ConstantExpression("Hello from yaml")); - route.addOutput(sb); - route.addOutput(new LogDefinition("${body}")); - SetHeaderDefinition sh = new SetHeaderDefinition(); - sh.setName("Exchange.HTTP_RESPONSE_CODE"); - sh.setExpression(new ConstantExpression("404")); - route.addOutput(sh); - - writer.writeRouteDefinition(route); - - String out = sw.toString(); - String expected = stripLineComments(Paths.get("src/test/resources/route11.yaml"), "#", true); - Assertions.assertEquals(expected, out); - } - -} diff --git a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/XPathNamespacesTest.java b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/XPathNamespacesTest.java index 0fba4ee4d9114..bb7c474443f76 100644 --- a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/XPathNamespacesTest.java +++ b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/XPathNamespacesTest.java @@ -17,13 +17,15 @@ package org.apache.camel.yaml.out; import java.io.ByteArrayInputStream; -import java.io.StringWriter; import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; import java.util.Optional; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.RoutesDefinition; +import org.apache.camel.util.json.JsonObject; import org.apache.camel.xml.in.ModelParser; import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; @@ -43,10 +45,14 @@ void testNamespace() throws Exception { .extracting(RouteDefinition::getOutputs, InstanceOfAssertFactories.list(ProcessorDefinition.class)) .hasSize(3); - StringWriter sw = new StringWriter(); - new ModelWriter(sw).writeRoutesDefinition(routesDefinition.get()); + YamlModelWriter writer = new YamlModelWriter(); + List roots = new ArrayList<>(); + for (RouteDefinition route : routesDefinition.get().getRoutes()) { + roots.add(writer.writeRouteDefinition(route)); + } + String out = writer.printAsYaml(roots); - assertThat(sw).hasToString(EXPECTED_YAML); + assertThat(out).isEqualTo(EXPECTED_YAML); } } @@ -82,6 +88,7 @@ void testNamespace() throws Exception { //language=yaml private static final String EXPECTED_YAML = """ - route: + customId: true id: direct:route-with-xpath-expression-custom-namespace from: uri: direct:route-with-xpath-expression-custom-namespace @@ -91,31 +98,44 @@ void testNamespace() throws Exception { expression: xpath: resultType: java.lang.String - saxon: "true" + saxon: true expression: /routes-ns-def:parent/routes-ns-def:child namespace: - routes-ns-def: http://www.example.com/schema - route-ns-def: http://www.example.com/schema + - key: xsi + value: http://www.w3.org/2001/XMLSchema-instance + - key: routes-ns-def + value: http://www.example.com/schema + - key: route-ns-def + value: http://www.example.com/schema - setProperty: name: child-expression-namespace-from-route expression: xpath: resultType: java.lang.String - saxon: "true" + saxon: true expression: /route-ns-def:parent/route-ns-def:child namespace: - routes-ns-def: http://www.example.com/schema - route-ns-def: http://www.example.com/schema + - key: xsi + value: http://www.w3.org/2001/XMLSchema-instance + - key: routes-ns-def + value: http://www.example.com/schema + - key: route-ns-def + value: http://www.example.com/schema - setProperty: name: child-expression-namespace-from-xpath expression: xpath: resultType: java.lang.String - saxon: "true" + saxon: true expression: /expression-ns-def:parent/expression-ns-def:child namespace: - routes-ns-def: http://www.example.com/schema - route-ns-def: http://www.example.com/schema - expression-ns-def: http://www.example.com/schema - """; + - key: xsi + value: http://www.w3.org/2001/XMLSchema-instance + - key: routes-ns-def + value: http://www.example.com/schema + - key: route-ns-def + value: http://www.example.com/schema + - key: expression-ns-def + value: http://www.example.com/schema + """; } diff --git a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/XmlToYamlTest.java b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/XmlToYamlTest.java index 484fa4e16fbcd..1d2cbf5f11e23 100644 --- a/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/XmlToYamlTest.java +++ b/core/camel-yaml-io/src/test/java/org/apache/camel/yaml/out/XmlToYamlTest.java @@ -20,12 +20,15 @@ import java.io.IOError; import java.io.IOException; import java.io.InputStream; -import java.io.StringWriter; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; import java.util.stream.Stream; +import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.RoutesDefinition; +import org.apache.camel.util.json.JsonObject; import org.apache.camel.xml.in.ModelParser; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.params.ParameterizedTest; @@ -46,9 +49,13 @@ public class XmlToYamlTest { void testRoutes(String xml) throws Exception { try (InputStream is = new FileInputStream("../camel-xml-io/src/test/resources/" + xml)) { RoutesDefinition expected = new ModelParser(is, NAMESPACE).parseRoutesDefinition().get(); - StringWriter sw = new StringWriter(); - new ModelWriter(sw).writeRoutesDefinition(expected); - LOG.info("xml={}\n{}\n", xml, sw); + YamlModelWriter writer = new YamlModelWriter(); + List roots = new ArrayList<>(); + for (RouteDefinition route : expected.getRoutes()) { + roots.add(writer.writeRouteDefinition(route)); + } + String out = writer.printAsYaml(roots); + LOG.info("xml={}\n{}\n", xml, out); } } diff --git a/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/TransformTools.java b/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/TransformTools.java index 0bd498c0c8889..ac86f075918fd 100644 --- a/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/TransformTools.java +++ b/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/TransformTools.java @@ -43,7 +43,8 @@ import org.apache.camel.support.PluginHelper; import org.apache.camel.support.ResourceHelper; import org.apache.camel.xml.in.ModelParser; -import org.apache.camel.yaml.out.ModelWriter; +import org.apache.camel.util.json.JsonObject; +import org.apache.camel.yaml.out.YamlModelWriter; /** * MCP Tools for validating and transforming Camel routes using Quarkus MCP Server. @@ -227,9 +228,12 @@ private String transformXmlToYaml(String xml) throws Exception { "Could not parse XML route. Ensure it contains a valid or element."); } - StringWriter sw = new StringWriter(); - new ModelWriter(sw).writeRoutesDefinition(routes); - return sw.toString(); + YamlModelWriter writer = new YamlModelWriter(); + List roots = new ArrayList<>(); + for (RouteDefinition route : routes.getRoutes()) { + roots.add(writer.writeRouteDefinition(route)); + } + return writer.printAsYaml(roots); } /** diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlModelWriterGeneratorMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlModelWriterGeneratorMojo.java deleted file mode 100644 index 3fd3cc85519f2..0000000000000 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlModelWriterGeneratorMojo.java +++ /dev/null @@ -1,74 +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.maven.packaging; - -import java.io.File; -import java.nio.file.Path; - -import javax.inject.Inject; - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.plugins.annotations.ResolutionScope; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectHelper; -import org.codehaus.plexus.build.BuildContext; - -/** - * Generate Model lightweight YAML Writer source code. - */ -@Mojo(name = "generate-yaml-writer", threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, - defaultPhase = LifecyclePhase.PROCESS_CLASSES) -public class YamlModelWriterGeneratorMojo extends ModelWriterGeneratorMojo { - - public static final String WRITER_PACKAGE = "org.apache.camel.yaml.out"; - - @Parameter(defaultValue = "${camel-generate-yaml-writer}") - protected boolean generateYamlWriter; - - @Inject - public YamlModelWriterGeneratorMojo(MavenProjectHelper projectHelper, BuildContext buildContext) { - super(projectHelper, buildContext); - } - - @Override - public void execute(MavenProject project) throws MojoFailureException, MojoExecutionException { - sourcesOutputDir = new File(project.getBasedir(), "src/generated/java"); - generateYamlWriter = Boolean.parseBoolean(project.getProperties().getProperty("camel-generate-yaml-writer", "false")); - super.execute(project); - } - - @Override - public void execute() throws MojoExecutionException { - if (!generateYamlWriter) { - return; - } - Path javaDir = sourcesOutputDir.toPath(); - String writer = generateWriter(); - writer = postGenerateWriter(writer); - updateResource(javaDir, (getWriterPackage() + ".ModelWriter").replace('.', '/') + ".java", writer); - } - - @Override - String getWriterPackage() { - return WRITER_PACKAGE; - } - -} From 89f41f3de6e787f9ed9e1c2d39b5c0ee961b01f1 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Thu, 21 May 2026 12:23:30 +0200 Subject: [PATCH 8/9] CAMEL-23596: camel-yaml-io - Rename YamlDirectModelWriterGeneratorMojo to YamlModelWriterGeneratorMojo The "Direct" qualifier was only needed to distinguish from the old mojo that has been removed. Rename the mojo, goal, and property to the simpler names: generate-yaml-writer and camel-generate-yaml-writer. Co-Authored-By: Claude Opus 4.6 --- core/camel-yaml-io/pom.xml | 4 ++-- .../apache/camel/yaml/out/YamlModelWriter.java | 2 +- ....java => YamlModelWriterGeneratorMojo.java} | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) rename tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/{YamlDirectModelWriterGeneratorMojo.java => YamlModelWriterGeneratorMojo.java} (79%) diff --git a/core/camel-yaml-io/pom.xml b/core/camel-yaml-io/pom.xml index 6cf99fe9b1cdf..1d21353b2299a 100644 --- a/core/camel-yaml-io/pom.xml +++ b/core/camel-yaml-io/pom.xml @@ -33,7 +33,7 @@ 4.0.0 - true + true @@ -99,7 +99,7 @@ generate-sources generate-sources - generate-yaml-direct-writer + generate-yaml-writer diff --git a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java index 4693789f75955..b9ddb7fa5e4ca 100644 --- a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java +++ b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java @@ -42,7 +42,7 @@ import org.apache.camel.model.transformer.*; import org.apache.camel.model.validator.*; -@Generated("org.apache.camel.maven.packaging.YamlDirectModelWriterGeneratorMojo") +@Generated("org.apache.camel.maven.packaging.YamlModelWriterGeneratorMojo") @SuppressWarnings({"deprecation","rawtypes"}) public class YamlModelWriter extends YamlModelWriterSupport { diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlDirectModelWriterGeneratorMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlModelWriterGeneratorMojo.java similarity index 79% rename from tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlDirectModelWriterGeneratorMojo.java rename to tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlModelWriterGeneratorMojo.java index 1aaac0a355565..11579a39cbc2e 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlDirectModelWriterGeneratorMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/YamlModelWriterGeneratorMojo.java @@ -32,34 +32,34 @@ import org.codehaus.plexus.build.BuildContext; /** - * Generate direct YAML Model Writer that builds JsonObject/JsonArray structures for YAML serialization without Jackson. + * Generate YAML Model Writer that builds JsonObject/JsonArray structures for YAML serialization. */ -@Mojo(name = "generate-yaml-direct-writer", threadSafe = true, +@Mojo(name = "generate-yaml-writer", threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, defaultPhase = LifecyclePhase.PROCESS_CLASSES) -public class YamlDirectModelWriterGeneratorMojo extends ModelWriterGeneratorMojo { +public class YamlModelWriterGeneratorMojo extends ModelWriterGeneratorMojo { public static final String WRITER_PACKAGE = "org.apache.camel.yaml.out"; - @Parameter(defaultValue = "${camel-generate-yaml-direct-writer}") - protected boolean generateYamlDirectWriter; + @Parameter(defaultValue = "${camel-generate-yaml-writer}") + protected boolean generateYamlWriter; @Inject - public YamlDirectModelWriterGeneratorMojo(MavenProjectHelper projectHelper, BuildContext buildContext) { + public YamlModelWriterGeneratorMojo(MavenProjectHelper projectHelper, BuildContext buildContext) { super(projectHelper, buildContext); } @Override public void execute(MavenProject project) throws MojoFailureException, MojoExecutionException { sourcesOutputDir = new File(project.getBasedir(), "src/generated/java"); - generateYamlDirectWriter - = Boolean.parseBoolean(project.getProperties().getProperty("camel-generate-yaml-direct-writer", "false")); + generateYamlWriter + = Boolean.parseBoolean(project.getProperties().getProperty("camel-generate-yaml-writer", "false")); super.execute(project); } @Override public void execute() throws MojoExecutionException { - if (!generateYamlDirectWriter) { + if (!generateYamlWriter) { return; } Path javaDir = sourcesOutputDir.toPath(); From f56811c42a66710da51a19a6c6ab033e12a36579 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Thu, 21 May 2026 13:01:29 +0200 Subject: [PATCH 9/9] CAMEL-23596: camel-yaml-io - Fix import ordering in TransformTools Co-Authored-By: Claude Opus 4.6 --- .../camel/dsl/jbang/core/commands/mcp/TransformTools.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/TransformTools.java b/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/TransformTools.java index ac86f075918fd..8b19c5e21cebe 100644 --- a/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/TransformTools.java +++ b/dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/TransformTools.java @@ -42,8 +42,8 @@ import org.apache.camel.spi.Resource; import org.apache.camel.support.PluginHelper; import org.apache.camel.support.ResourceHelper; -import org.apache.camel.xml.in.ModelParser; import org.apache.camel.util.json.JsonObject; +import org.apache.camel.xml.in.ModelParser; import org.apache.camel.yaml.out.YamlModelWriter; /**