ammachado opened a new pull request, #23263: URL: https://github.com/apache/camel/pull/23263
# Description First incremental step toward [CAMEL-22894](https://issues.apache.org/jira/browse/CAMEL-22894): break up the 4,500-line `SimpleFunctionExpression` that today carries both runtime Simple language and compile-time CSimple code-generation responsibilities, with no behaviour change. This PR establishes the pattern and ports the first batch of small built-in families. Larger families (`header`, `exchangeProperty`, the rest) will follow in subsequent PRs once the dispatcher pattern lands. **Three commits, each independently reviewable:** 1. **`fc43e0d` — Deprecate `SimpleLanguageFunctionFactory#createCode`.** The `createCode(...)` method on the public `SimpleLanguageFunctionFactory` SPI (`@since 4.10`) exists solely to support csimple, which is already `@Deprecated(since = \"4.19\")` and slated for removal in 5.0. Marked the method `@Deprecated(since = \"4.21\")` and made it a `default` returning `null`, so implementations that don't care about csimple no longer have to override it. The three in-tree implementations (`camel-attachments`, `camel-base64`, `camel-jsoup`) keep their existing overrides and pick up the deprecation marker via inheritance. 2. **`4beafc9` — Centralize external-component function dispatch in `SimpleFunctionDispatcher`.** `SimpleFunctionExpression` previously had six near-identical methods plus six gating predicate blocks dedicated to dispatching to the three external `SimpleLanguageFunctionFactory` implementations (`camel-attachments`, `camel-base64`, `camel-jsoup`). Moved the dispatch into a new internal `SimpleFunctionDispatcher` that owns the list of known component factories and their gating predicates, exposing `tryCreate(...)` / `tryCreateCode(...)` entry points. Behaviour preserved exactly: same factories, same order, same gating (so a missing component still surfaces the helpful \"add this JAR\" error via `ResolverHelper.resolveMandatoryBootstrapService`), and `camel-jsoup` remains excluded from the csimple `createCode` path because its `createCode` throws `UnsupportedOperationException`. 3. **`63d326e` — Extract `random`, `skip`, `collate`, `join` into `SimpleLanguageFunctionFactory` classes.** Moved four self-contained Simple functions out of `SimpleFunctionExpression` into their own factory implementations under `org.apache.camel.language.simple.functions`, registered as built-ins on `SimpleFunctionDispatcher`. The dispatcher consults built-ins before external component factories, preserving today's priority. Both `createFunction` (Simple) and `createCode` (csimple) live side by side in each class, instead of being ~2,000 lines apart in `SimpleFunctionExpression`. **Net structural impact so far:** - `SimpleFunctionExpression.java`: 4,526 → ~4,255 lines (−270 LOC), with the new dispatcher (~150 LOC) and four small factory classes (~300 LOC combined). - Adding a new external-component factory is now a one-line edit in `SimpleFunctionDispatcher` instead of a six-block change spread across `SimpleFunctionExpression`. - Built-in extraction template established for follow-up PRs. **Out of scope for this PR** (and the broader refactor, see plan locked in JIRA discussion): - No public-API additions (no new SPI, no `addFunctionFactory(...)` on `SimpleFunctionRegistry`). - No CSimple-side restructure: no visitor pattern, no type-safe code-generator, no parameterized cross-tests. The current generated csimple Java source is identical before/after. - No classloader auto-discovery of factories — would not work in Quarkus native; current explicit allowlist is the right shape. **Verification:** - `mvnd clean install -Dquickly -Dci.env.name=local` from repo root: ✅ BUILD SUCCESS. - `SimpleTest` (227), `CSimpleTest` (1), `SimpleCustomFunctionTest` (5), `CSimplePredicateParserTest` (4), `CSimpleExpressionParserTest` (13), `SimpleExpressionParserNodesTest` (2), `SimplePredicateParserNodesTest` (3): all green. - `camel-attachments` `SimpleAttachmentTest` (10), `camel-base64` `SimpleBase64Test` (2), full `camel-jsoup` test suite (3): all green. - `mvn formatter:format impsort:sort` clean. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL-22894) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [x] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. --- _Claude Code on behalf of Adriano Machado_ -- 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]
