CAMEL-22894: Extract sys/env, date, properties, ref, type, messageAs, pretty/toJson Simple functions into dedicated factories#23544
Conversation
… pretty/toJson Simple functions into dedicated factories Continues the extraction of inline function logic from SimpleFunctionExpression into SimpleLanguageFunctionFactory implementations: - SystemFunctionFactory: sys., sysenv., env. prefixes - PropertiesFunctionFactory: propertiesExist:, properties:, ref: - TypeFunctionFactory: type: - DateFunctionFactory: date:, date-with-timezone: (including date:millis code-gen) - MessageFunctionFactory: messageAs( - OutputFunctionFactory: pretty(, toJson(, toPrettyJson( Also removes the two deprecated(forRemoval) tryCreate/tryCreateCode methods from SimpleFunctionDispatcher, which were confirmed unused. SimpleFunctionExpression shrinks by ~160 lines. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
…ple function factories Move sys/env, date, properties/ref, type, messageAs, and pretty/toJson tests from SimpleTest into their own *FunctionFactoryTest classes, following the pattern established by previous PRs in this series. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
…st, use JUnit Pioneer, add behavioral comments - Move date, date-with-timezone, sys, sysenv/env, ref, propertiesExist, properties, type, messageAs, pretty, toJson/toPrettyJson tests from SimpleTest into their dedicated factory test classes - Add junit-pioneer dependency to camel-core for @SetSystemProperty, replacing a bare System.setProperty call that leaked the property - Document the XmlPrettyPrinter root-element text-content quirk in OutputFunctionFactoryTest - Document the null-vs-false coercion subtlety in MessageFunctionFactoryTest (expression layer returns null; predicate layer coerced it to false) - Follow the established testCreateCodeUnknown() pattern for all factories that override createCode Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
davsclaus
left a comment
There was a problem hiding this comment.
Clean extraction of six more Simple function families into dedicated factories, continuing the CAMEL-22894 series. All factories faithfully reproduce the original dispatch logic from SimpleFunctionExpression.
Verified:
tryCreate()/tryCreateCode()removals are safe — confirmed no external callers- Dead
parts.length > 2validation inpropertiesExist:correctly dropped (split with limit 2 can never exceed 2 elements) TypeFunctionFactorypreserves theinit()+cacheExpression()wrappingOutputFunctionFactoryprefix ordering is correct- Test coverage is thorough —
MessageFunctionFactoryTestdocuments the subtle null-vs-false semantic,SystemFunctionFactoryTestuses JUnit Pioneer@SetSystemPropertyproperly
Minor observation (non-blocking): PropertiesFunctionFactory.createCode() still has the same dead parts.length > 2 check (line ~42 in the factory). Not a regression, just a cleanup opportunity.
LGTM.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
|
🧪 CI tested the following changed modules:
✅ POM dependency changes: targeted tests included Modules affected by dependency changes (2)
Build reactor — dependencies compiled but only changed modules were tested (2 modules)
|
Description
Continues the CAMEL-22894 series, which extracts inline Simple language function dispatch from the monolithic
SimpleFunctionExpressioninto dedicatedSimpleLanguageFunctionFactoryimplementations.This PR covers six new factory classes:
SystemFunctionFactory${sys.name},${sysenv.name},${sysenv:name},${env.name},${env:name}PropertiesFunctionFactory${propertiesExist:key},${properties:key},${properties:key:default},${ref:name}TypeFunctionFactory${type:fqn},${type:fqn.FIELD}DateFunctionFactory${date:command},${date:command:pattern},${date-with-timezone:command:timezone:pattern}(includingdate:milliscode-gen special case)MessageFunctionFactory${messageAs(type)},${messageAs(type).OGNL}OutputFunctionFactory${pretty(exp)},${toJson(exp)},${toPrettyJson(exp)}All factories follow the established pattern:
createFunction()for runtime evaluation,createCode()(deprecated, csimple only) for code generation where applicable.MessageFunctionFactoryandOutputFunctionFactoryomitcreateCode()since csimple never supported those functions.Also removes the two
@Deprecated(forRemoval = true)methodstryCreate()andtryCreateCode()fromSimpleFunctionDispatcher, which were confirmed unused.SimpleFunctionExpressionshrinks by ~160 lines after this PR.Test changes
Tests for the six factories are moved out of the monolithic
SimpleTestinto dedicated per-factory test classes undero.a.c.language.simple.functions. Notable refinements:SystemFunctionFactoryTestuses JUnit Pioneer's@SetSystemProperty(addedjunit-pioneerdependency tocamel-core) to safely scope the property to the test method.MessageFunctionFactoryTestdocuments a subtle semantic:messageAs(T)returnsnullat the expression layer when the type conversion fails; the Simple predicate engine then coercesnulltofalse. The originalSimpleTestonly tested the predicate layer, masking this.OutputFunctionFactoryTestdocuments theXmlPrettyPrinterbehavior where text content directly inside the root element is silently dropped (only emitted whenindent > 1).Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.Claude Code on behalf of Adriano Machado