CAMEL-23302: camel-xslt - Auto-disable content cache in routes-reload (dev) mode#23127
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an SPI and Camel Main lifecycle strategy to automatically disable resource contentCache when routes-reload/dev mode is enabled, enabling live reload of resource files (first adopter: camel-xslt).
Changes:
- Introduces
ContentCacheAwareSPI andDevModeContentCacheStrategyto auto-disablecontentCachewhencamel.main.routesReloadEnabled=true. - Updates
XsltComponentto implement the SPI with tri-statecontentCache(null/unset vs explicit true/false), and updates generated metadata/configurer accordingly. - Documents live reload behavior in the user manual and XSLT component docs, and adds Camel Main tests.
Reviewed changes
Copilot reviewed 8 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/user-manual/modules/ROOT/pages/route-reload.adoc | Documents resource live reload behavior when routes-reload is enabled |
| docs/user-manual/modules/ROOT/pages/camel-jbang.adoc | Documents --dev behavior tying to routesReloadEnabled and content cache |
| core/camel-main/src/test/java/org/apache/camel/main/MainDevModeContentCacheTest.java | Adds tests for auto-disabling and respecting explicit component-level settings |
| core/camel-main/src/main/java/org/apache/camel/main/DevModeContentCacheStrategy.java | Adds lifecycle strategy that flips contentCache on component add |
| core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java | Wires the lifecycle strategy when routes-reload is enabled |
| core/camel-api/src/main/java/org/apache/camel/spi/ContentCacheAware.java | Adds new SPI for tri-state contentCache |
| components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltComponent.java | Implements SPI and switches contentCache to Boolean tri-state |
| components/camel-xslt/src/main/docs/xslt-component.adoc | Documents dev-mode live reload behavior for XSLT |
| components/camel-xslt/src/generated/resources/META-INF/org/apache/camel/component/xslt/xslt.json | Updates generated metadata to java.lang.Boolean |
| components/camel-xslt/src/generated/java/org/apache/camel/component/xslt/XsltComponentConfigurer.java | Updates configurer to bind/return Boolean tri-state |
| components/camel-xslt-saxon/src/generated/resources/META-INF/org/apache/camel/component/xslt/saxon/xslt-saxon.json | Updates generated metadata to java.lang.Boolean |
| components/camel-xj/src/generated/resources/META-INF/org/apache/camel/component/xj/xj.json | Updates generated metadata to java.lang.Boolean |
| catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xslt.json | Updates catalog metadata to java.lang.Boolean |
| catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xslt-saxon.json | Updates catalog metadata to java.lang.Boolean |
| catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xj.json | Updates catalog metadata to java.lang.Boolean |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet
left a comment
There was a problem hiding this comment.
Nice work on this PR! The tri-state Boolean approach for the ContentCacheAware SPI is a clean design, and the lifecycle strategy is the right integration point for dev-mode behavior.
A few items — see inline comments for specific suggestions:
- Binary backward compatibility (setter signature change): see inline suggestion on
XsltComponent.java - Class visibility:
DevModeContentCacheStrategycould be package-private (see inline) - JIRA link: Consider adding
[CAMEL-23302](https://issues.apache.org/jira/browse/CAMEL-23302)to the PR description body - Upgrade guide: Since
ContentCacheAwareis a new public SPI incamel-api, consider mentioning it in the 4.21 upgrade guide so other component authors know they can opt in
Claude Code on behalf of Guillaume Nodet
|
@ammachado there are uncommitted changes You can |
|
Alternative approach worth considering: use the existing Rather than introducing @Override
public void onComponentAdd(String name, Component component) {
PropertyConfigurer configurer = PluginHelper.getConfigurerResolver(component.getCamelContext())
.resolvePropertyConfigurer(name + "-component", component.getCamelContext());
if (configurer instanceof PropertyConfigurerGetter getter) {
Object val = getter.getOptionValue(component, "contentCache", true);
if (Boolean.TRUE.equals(val)) {
configurer.configure(component.getCamelContext(), component, "contentCache", false, true);
LOG.info("Routes-reload is enabled: disabling contentCache on component '{}' for live resource reload", name);
}
}
}Advantages:
Downside:
Not a blocker — just flagging the trade-off for consideration. Claude Code on behalf of Guillaume Nodet |
… (dev) mode Introduce `ContentCacheAware` SPI so resource-based components can opt into having their content cache set to false when `camel.main.routesReloadEnabled` is set to `true` (set automatically by `camel run --dev`). A new `DevModeContentCacheStrategy` applies the setting on component registration, and explicit user settings on the component, endpoint or URI are always respected. `camel-xslt` is the first adopter: `XsltComponent` now implements `ContentCacheAware` and stores `contentCache` as a Boolean (null = unset). Other resource-based components can be migrated in a follow-up. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
…ility and log level. rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
…ropertyConfigurer` rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
|
🧪 CI tested the following changed modules:
Build reactor — dependencies compiled but only changed modules were tested (3 modules)
|
Description
CAMEL-23302: camel-xslt - Auto-disable content cache in routes-reload (dev) mode
When
camel.main.routesReloadEnabled=true(set automatically bycamel run --dev), Camel now setscontentCachetofalseon resource-based components (components exposingcontentCacheoption, such as xslt, freemarker, velocity, mustache, jte, jolt, jslt, jsonata, json-validator, json-patch, mvel, chunk, stringtemplate, language) so that edits to the resource file are picked up on the next message without restarting the route.Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.