[ 
https://issues.apache.org/jira/browse/SCXML-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13867735#comment-13867735
 ] 

Ate Douma edited comment on SCXML-186 at 1/10/14 11:36 AM:
-----------------------------------------------------------

Great start Woonsan!

I've been playing and testing with the Groovy support the last few days and 
have several improvements and enhancements in mind, which is why I reopened 
this issue.

Things I'll try to add/improve:
- performance: preliminary testing (using a very minimal SCXML document) shows 
JEXL is ~50x faster. But when I added Groovy Script compilation caching and a 
custom Script base class (instead of injecting MethodClosure objects) for SCXML 
builtin support, I now got Groovy ~ 30% *faster* than JEXL (on average, 
executing 100x)
- support for adding custom Groovy functions into the evaluation scope (other 
than through closure definitions in parent <script/> elements) by extending the 
custom base Script class
- support for Groovy operator aliasing, e.g. cond="x < y" is an invalid XML 
attribute definition. JEXL allows using cond="x lt y" but Groovy doesn't and 
this cannot be redefined/extended in the Groovy language itself :(
I'm considering adding (optional) regex based word replacement support *before* 
compiling a Groovy expression/script,  converting "x lt y" with "x < y"
- trying to add support for a (JEXL like) boolean empty(var) method, which 
currently might lead to an too early exception in Groovy as it will *first* try 
to resolve the parameter before invoking the method. If that parameter doesn't 
exist in the binding it would throw an exception. Alternatively in Groovy you 
already can use empty(binding?.var)  now, but I like that less


was (Author: adouma):
Great start Woonsan!

I've been playing and testing with the Groovy support the last few days and 
have several improvements and enhancements in mind, which is why I reopened 
this issue.

Things I'll try to add/improve:
- performance: preliminary testing (using a very minimal SCXML document) shows 
JEXL is ~50x faster. But when I added Groovy Script compilation caching and a 
custom Script base class (instead of injecting MethodClosure objects) for SCXML 
builtin support, I now got Groovy ~ 30x *faster* than JEXL (on average, 
executing 100x)
- support for adding custom Groovy functions into the evaluation scope (other 
than through closure definitions in parent <script/> elements) by extending the 
custom base Script class
- support for Groovy operator aliasing, e.g. cond="x < y" is an invalid XML 
attribute definition. JEXL allows using cond="x lt y" but Groovy doesn't and 
this cannot be redefined/extended in the Groovy language itself :(
I'm considering adding (optional) regex based word replacement support *before* 
compiling a Groovy expression/script,  converting "x lt y" with "x < y"
- trying to add support for a (JEXL like) boolean empty(var) method, which 
currently might lead to an too early exception in Groovy as it will *first* try 
to resolve the parameter before invoking the method. If that parameter doesn't 
exist in the binding it would throw an exception. Alternatively in Groovy you 
already can use empty(binding?.var)  now, but I like that less

> Groovy expression evaluator
> ---------------------------
>
>                 Key: SCXML-186
>                 URL: https://issues.apache.org/jira/browse/SCXML-186
>             Project: Commons SCXML
>          Issue Type: New Feature
>            Reporter: Woonsan Ko
>            Assignee: Ate Douma
>             Fix For: 2.0
>
>
> A Groovy expression evaluator for SCXML expression can offer richer 
> functionality which cannot be supported by the other simpler expression 
> evaluator.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to