CAMEL-23596: Replace hand-written YamlWriter with generated direct YAML writer#23407
Merged
Merged
Conversation
Contributor
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
Contributor
|
🧪 CI tested the following changed modules:
Build reactor — dependencies compiled but only changed modules were tested (3 modules)
|
…ation 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 <noreply@anthropic.com>
…erated 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 <noreply@anthropic.com>
…riter 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 <noreply@anthropic.com>
…m-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 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
…on 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 <noreply@anthropic.com>
…Writer 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 <noreply@anthropic.com>
…o 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 <noreply@anthropic.com>
6e11b1a to
89f41f3
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the old hand-written YAML writer stack with a new generated
YamlModelWriterthat buildsJsonObject/JsonArraystructures and serializes viaYamlPrinter.model-yaml-writer.vmVelocity template generatesYamlModelWriterwithdoWrite*methods returningJsonObjectYamlPrinterconvertsJsonObject/JsonArrayto YAML strings without Jacksonfrom(not route level),expression:wrapper for expression nodes,${...}string quotingModelWriter.java(generated),BaseWriter.java,YamlWriter.java(600 lines hand-written), old generator mojo, old testsYamlDirectModelWriterGeneratorMojo→YamlModelWriterGeneratorMojo(goal:generate-yaml-writer)YamlModelWriterTestcovering all major EIP patternsTransformTools,XmlToYamlTest,XPathNamespacesTestupdated to use new writerTest plan
camel-yaml-io(48 YamlModelWriter + 53 XmlToYaml + 1 XPathNamespaces + 11 others)DumpModelAsYaml*tests pass incamel-coreManagedCamelContextDumpRoutesAsYamlTesttests pass incamel-managementClaude Code on behalf of Claus Ibsen
🤖 Generated with Claude Code