Raymond created CAMEL-24654:
-------------------------------
Summary: Allow Simple language validation to take registered
custom functions into account
Key: CAMEL-24654
URL: https://issues.apache.org/jira/browse/CAMEL-24654
Project: Camel
Issue Type: Improvement
Components: camel-catalog
Affects Versions: 4.22.0
Reporter: Raymond
Somewhat related to this issue:
https://issues.apache.org/jira/browse/CAMEL-24585
*Background*
In Fluxygen we allow user to test expressions to see if they are valid. Then
before installation we run those test so that no invalid or unknown expression
are installed. Currently routes with custom function cannot install.
*Validate Custom Function*
I added some custom functions similar to the documentation example:
{code:java}
var bar = context.resolveLanguage("simple").createExpression("${trim()} ~>
${normalizeWhitespace()} ~> ${capitalize()} ~> ${quote()}");
reg.addFunction("bar", bar);{code}
This works, however when test this:
{{}}
{code:java}
catalog.validateLanguageExpression(ClassLoader.getSystemClassLoader(),
"simple", "${bar}");
{code}
Then I get:
{code:java}
Unknown function: flowVersion at location 0 ${bar} *{code}
*Wish*
It would be nice if custom functions can be validated as well. Either by
automatically registering, or something like:
{{}}
{code:java}
catalog.validateLanguageExpression(
context,
"simple",
"${flowVersion}"
); {code}
or otherwise allow a {{SimpleFunctionRegistry}} to be supplied to the validator
manually.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)