gnodet commented on PR #23127:
URL: https://github.com/apache/camel/pull/23127#issuecomment-4430121784
**Alternative approach worth considering: use the existing
`PropertyConfigurer` API instead of a new SPI**
Rather than introducing `ContentCacheAware` in `camel-api` and migrating
components one by one, the `DevModeContentCacheStrategy` could use the existing
generated `PropertyConfigurer` to detect and set the `contentCache` property on
any component that has it:
```java
@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:**
- No new SPI interface in `camel-api` (smaller API surface)
- Works immediately for **all ~13 components** with `contentCache`
(freemarker, velocity, mustache, jte, jolt, jslt, jsonata, json-validator,
json-patch, mvel, chunk, stringtemplate, language) — no per-component migration
needed
- No `boolean` → `Boolean` field change, so no binary compatibility concern
- The timing works for the common case: user properties via
`camel.component.<name>.contentCache=true` are bound *after* `onComponentAdd`,
so they naturally override the strategy's change
**Downside:**
- Cannot distinguish "default `true`" from "user explicitly set `true`
programmatically before adding the component to the context" (e.g.,
`component.setContentCache(true); context.addComponent(...)`). The strategy
would wrongly override it in that scenario. The tri-state `Boolean` (null =
unset) in the current PR handles this edge case correctly.
- That said, programmatic pre-registration configuration is uncommon with
Camel Main, which is the primary consumer of this feature.
Not a blocker — just flagging the trade-off for consideration.
_Claude Code on behalf of Guillaume Nodet_
--
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]