davsclaus opened a new pull request, #26714: URL: https://github.com/apache/camel/pull/26714
Fixes https://issues.apache.org/jira/browse/CAMEL-24884 The `resource:` prefix is resolved on an expression's text (`constant: "resource:file:order.json"`, `simple: "resource:file:${...}"`, `groovy: "resource:file:script.groovy"`), never on a value the expression returns. Choosing a file per message in any language but Simple therefore took two steps, and a script that returns `'resource:file:order.json'` hands the route that text, which is what the local model did in the camel-jbang-mcp stepwise benchmark (CAMEL-24882). New option `resolveResource` on `ExpressionDefinition`, so it applies to every language, default `false`. When true, `ExpressionReifier` wraps the created expression: a String result starting with `resource:` is loaded through the same `ScriptHelper.resolveOptionalExternalScript` the prefix uses today, a name without a scheme (`resource:orderTemplate.json`) is a classpath resource, and the loaded content is the final value, not evaluated again. Without the option nothing changes. ```yaml - setBody: expression: groovy: expression: "exchangeProperties.CamelTimerCounter == 1 ? 'resource:file:order.json' : 'resource:file:order-bad-email.json'" resolveResource: true ``` Verified with `camel run` on that route: the two orders are read from their files. Tests: `ResolveResourceExpressionTest` (camel-core: with a scheme, without, other results untouched, off by default) and `ResolveResourceTest` (camel-yaml-dsl). Generated files regenerated (model JSONs, catalog models, XML IO, YAML deserializers and schemas), upgrade note added. While testing this I hit a pre-existing bug, a Simple text `resource:x/${...}` without a scheme recursing into a StackOverflowError; that is CAMEL-24885, a separate PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj -- 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]
