Skip to content

CAMEL-22894: Extract OGNL/exchange-property and function(...) Simple functions into dedicated factories#23576

Merged
davsclaus merged 3 commits into
apache:mainfrom
ammachado:CAMEL-22894
May 28, 2026
Merged

CAMEL-22894: Extract OGNL/exchange-property and function(...) Simple functions into dedicated factories#23576
davsclaus merged 3 commits into
apache:mainfrom
ammachado:CAMEL-22894

Conversation

@ammachado
Copy link
Copy Markdown
Contributor

@ammachado ammachado commented May 27, 2026

Description

Continues the ongoing extraction of SimpleFunctionExpression inline logic into dedicated SimpleLanguageFunctionFactory implementations (CAMEL-22894).

This PR extracts two groups into new factories:

ExchangeFunctionFactory — OGNL/exchange-property group:

  • ${camelContext.OGNL} — CamelContext OGNL navigation
  • ${exception.OGNL} — exception OGNL navigation
  • ${exceptionAs(type).OGNL} — typed exception cast with optional OGNL (CSimple code-gen only)
  • ${exchangeProperty.name}, ${exchangeProperty:name}, ${exchangeProperty[name]} — plain property access
  • ${exchangePropertyAs(key, type)} — typed property access (CSimple code-gen only)
  • ${exchangePropertyAsIndex(key, type, index)} — indexed typed property access (CSimple code-gen only)
  • ${exchange.OGNL} — raw Exchange OGNL navigation

CustomFunctionFactory — user-defined custom functions:

  • ${function(name)} — invoke registered custom function with body as input
  • ${function(name, exp)} — invoke registered custom function with explicit expression as input

All parsing and error messages are preserved exactly from the removed inline blocks. Prefix ordering within each factory is intentional to avoid incorrect prefix matches (e.g. exchangePropertyAsIndex( before exchangePropertyAs( before exchangeProperty).

SimpleFunctionExpression drops from ~560 to 295 lines after this extraction.

A post-review fix was also applied: the exception OGNL invalid-OGNL error message in createCode was incorrectly saying ${exceptionAs(type).OGNL} instead of ${exception.OGNL} (copy-paste from the branch above it). A createCode invalid-OGNL test was added to catch this class of regression.

Claude Code on behalf of Adriano Machado

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

ammachado added 3 commits May 27, 2026 15:40
…hangeFunctionFactory

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
…ory; add createCode invalid-OGNL test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
…nFactory

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
@ammachado ammachado changed the title CAMEL-22894: Extract OGNL/exchange-property Simple functions into ExchangeFunctionFactory CAMEL-22894: Extract OGNL/exchange-property and function(...) Simple functions into dedicated factories May 27, 2026
@ammachado ammachado marked this pull request as ready for review May 28, 2026 01:30
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions github-actions Bot added the core label May 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • core/camel-core-languages
  • core/camel-core

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • core/camel-core: 2 test(s) disabled on GitHub Actions
Build reactor — dependencies compiled but only changed modules were tested (2 modules)
  • Camel :: Core
  • Camel :: Core Languages

⚙️ View full build and test results

Copy link
Copy Markdown
Contributor

@davsclaus davsclaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean extraction that continues the established CAMEL-22894 pattern. Prefix ordering is preserved correctly, the exception OGNL error message bug fix is valid, and tests cover both createFunction and createCode paths.

Optional suggestion: testCreateCodeExceptionInvalidOgnl validates the exception is thrown but doesn't assert the message content. Since the bug was specifically a wrong error message (exceptionAs vs exception), asserting the message would be a stronger regression guard.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Claus Ibsen

@davsclaus davsclaus merged commit e2cce97 into apache:main May 28, 2026
6 checks passed
@ammachado ammachado deleted the CAMEL-22894 branch May 30, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants