davsclaus opened a new pull request, #27129: URL: https://github.com/apache/camel/pull/27129
_Claude Code on behalf of davsclaus_ JIRA: [CAMEL-25157](https://issues.apache.org/jira/browse/CAMEL-25157) ## Why `LwModelToJavaDumper` wrote invalid Java for many routes. The round-trip tests of CAMEL-25148 (#27122) found this: XML → model → Java → parse → Java. It chose how to write each option from hand-kept lists and wrote anything else as `.name("value")`. It also wrote options that the Java DSL takes as *arguments of the step* as calls after it. ## What **Options written by the methods the definition has**, in place of the lists: - **Quoted** when a `name(String)` method exists, so placeholders stay valid. - **Otherwise the typed form:** - a toggle, like `markRollbackOnly()` or `stopOnException()`; - a number, like `startupOrder(5)`, with a duration such as `2s` converted to millis; - a boolean; - an enum constant, like `retryAttemptedLogLevel(LoggingLevel.WARN)`; - name plus value, like `modeBeforeConsumer()`. - `errorHandlerRef` is written as `errorHandler(...)`. **Options written as arguments of the step:** - `convertBodyTo(String.class, "UTF-8")`, and likewise `convertHeaderTo`/`convertVariableTo` with `toName`, `charset` and `mandatory`; - `removeHeaders("*", "Keep*")` and `removeProperties(...)`; - `toV(...)`, and `toD(uri, …)` with its variables, `ignoreInvalidEndpoint` or `cacheSize`; - `log(LoggingLevel.WARN, "my.log", "hi")`; - `sample(10)`, `loopDoWhile(...)`, `bean(Foo.class)` and `markRollbackOnly()`. **Structure:** - `setHeaders("h1", expr, "h2", expr)` and `setVariables(...)` as varargs. - Aggregate's `completionSize(expr)`/`completionTimeout(expr)`. - `enrich()`/`pollEnrich()` with the expression first. - `tokenize` with its token, through the language builder. - The weighted and custom load balancers with their arguments, and the stream resequencer. - `policy(...)` closed with `end()`, and `onFallback()` written last in a circuit breaker. - `inputType("urn")`/`outputType("urn")`. **Routes built in Java,** such as a dump from a running Java application: - Expression clauses and value builders are written as their language. - `Class` options and arrays are written from the definition: `throwException(Foo.class, "msg")`, `failover(IOException.class)`, `removeHeaders("*", "Keep*")`. - The model is not changed, since the dumper may be given the live route definitions. The generated writer's inline steps now tell the support class which definition they write. That's the change to the template `model-java-dsl-writer.vm`, and `JavaDslModelWriter` is regenerated. **Not expressible in today's Java DSL, left as is:** - `throwException` with a `ref`; - options of `marshal`/`unmarshal`; - a logger bean `ref`; - predicates built in Java (`isEqualTo`, ...). These are noted for [CAMEL-25166](https://issues.apache.org/jira/browse/CAMEL-25166). ## Tests - **Compile test:** a new XML route file (`stepArgumentsAndTypedOptions.xml`) covering every shape above. `JavaDslCompileTest` compiles its dump, now 106 route files and all compiling, and `RoundTripTest` reads it back. - **camel-spring-xml round trip:** the floor rises from **674 to 815** of 925 routes. - **Core XML round trip:** one known difference remains: a `float` option keeps `30` as `30.0`. - **New test** for a route built in Java, which also checks that the model is left unchanged. - **Local run:** camel-java-io's 167 tests pass. No other module's tests depend on the dumper's output. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
