commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Biestro (JIRA)" <>
Subject [jira] [Comment Edited] (JEXL-194) synchronize on iterableValue in foreach statement
Date Fri, 27 May 2016 11:33:13 GMT


Henri Biestro edited comment on JEXL-194 at 5/27/16 11:33 AM:

Another train of thoughts...
Moved to  JEXL-197 - Add annotations

was (Author: dmitri_blinov):
Another train of thoughts...

As an implementation to the extension of statement executions in JEXL we could introduce the
use of annotations to each statement or block in the script, i.e. 

@synchronized(items) {for (x : items) ...}

Each statement block should be allowed to have only one annotation but it would be convenient
to allow the syntax 
@silent @lenient {null.tryMe()}

which should be syntaxically equivalent to:

@silent {@lenient {null.tryMe()}}

>From the JexlEngine point of view, each annotation could be implemented in the form of
Interceptor interface, for example

public interface Interceptor {
   public Object onExecute(JexlStatement block, String annotation, Object.. args);

The annotation syntax should allow for zero, one or more parameters. Those parameters should
be evaluated before interceptor execution and submitted to the Interceptor.onExecute() method
via args parameter.

JexlEngine should be given a method to register annotation interceptor based on annotation
name, and the one for default interceptor, which should be called before each statement execution
as if @default annotation is declared in each statement in script. 

@silent {@default {...}}

The JexlStatement is the proposed new interface to somehow identify the statement or block
of code which may also provide some info about it's stack frame.

public interface JexlStatement {
   public Object interpret();

   // ..

The JexlStatement.interpret() method should trigger the execution of the statement block,
returning statement's result as its return value.

In the absence of a matching interceptor corresponding to the annotation name, JexlEngine
should simply ignore that, or write some diagnostic message in the log file.

Such implementation could provide developers with excellent tool to add various checks and
enhancements to scripting without pushing for new features that eventually would mess up the
basic code. The JEXL-185 issue could also be dropped since tracing could be added easily via

> synchronize on iterableValue in foreach statement
> -------------------------------------------------
>                 Key: JEXL-194
>                 URL:
>             Project: Commons JEXL
>          Issue Type: Improvement
>    Affects Versions: 3.0
>            Reporter: Dmitri Blinov
>            Assignee: Henri Biestro
>            Priority: Minor
> Since it is a requirement to synchronize on simple Collections and synchronized Collections
while iterating over them and since jexl has no instrument to control synchronization in script,
I think its reasonable to implement synchronization in jexl itself on iterableValue. In case
of concurrent collections it will possibly block other threads only if they are synchronizing
on those collections themselves, which will be complementary to required synchronization in

This message was sent by Atlassian JIRA

View raw message