[jira] [Commented] (JEXL-197) Add annotations

2016-08-02 Thread Dmitri Blinov (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15404348#comment-15404348
 ] 

Dmitri Blinov commented on JEXL-197:


Is it correct behaviour that the following script is parsed correctly
{code}
@lenient x = 1
{code}

while the following script is not parsed 
{code}
@lenient var x = 1
{code}

with error 
{quote}
parsing error in 'var'
{quote}

> Add annotations
> ---
>
> Key: JEXL-197
> URL: https://issues.apache.org/jira/browse/JEXL-197
> Project: Commons JEXL
>  Issue Type: Improvement
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
> Fix For: 3.1
>
>
> Follow up from JEXL-194...
> 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. 
> {code}
> @synchronized(items) {for (x : items) ...}
> {code}
> Each statement block should be allowed to have only one annotation but it 
> would be convenient to allow the syntax 
> {code}
> @silent @lenient {null.tryMe()}
> {code}
> which should be syntaxically equivalent to:
> {code}
> @silent {@lenient {null.tryMe()}}
> {code}
> From the JexlEngine point of view, each annotation could be implemented in 
> the form of Interceptor interface, for example
> {code}
> public interface Interceptor {
>public Object onExecute(JexlStatement block, String annotation, Object.. 
> args);
> }
> {code}
> 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. 
> {code}
> @silent {@default {...}}
> {code}
> 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.
> {code}
> public interface JexlStatement {
>public Object interpret();
>// ..
> }
> {code}
> 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 interceptors.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-197) Add annotations

2016-07-17 Thread Dmitri Blinov (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15381151#comment-15381151
 ] 

Dmitri Blinov commented on JEXL-197:


I'm reflecting on the possible ways to debug script execution. For example to 
use annotation in a way like
{code}
@breakpoint {x = faulycode();}
{code}

To debug a script I believe two things are important - first is to know where 
we have stopped, some information about current statement, for what I thought 
JexlNode would be informative, and the other - to know what is the current 
state we are in. We have already had JexlContext to examine, but there is 
curent stack frame we know nothing about, - and for what I thought the access 
to Interpreter would be useful.

I agree exposing internal classes is not the best idea. For the one hand, we 
can wrap Interpreter to some interface, for example, JexlInterpreter, leaving 
access to only relevant methods, for the other hand we can still use a Callable 
instead of JexlNode, say JexlCallable, and provide some method to it, may be 
overload toString(), to get info about the statement itself.

What do you think of it? 

> Add annotations
> ---
>
> Key: JEXL-197
> URL: https://issues.apache.org/jira/browse/JEXL-197
> Project: Commons JEXL
>  Issue Type: Improvement
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
> Fix For: 3.1
>
>
> Follow up from JEXL-194...
> 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. 
> {code}
> @synchronized(items) {for (x : items) ...}
> {code}
> Each statement block should be allowed to have only one annotation but it 
> would be convenient to allow the syntax 
> {code}
> @silent @lenient {null.tryMe()}
> {code}
> which should be syntaxically equivalent to:
> {code}
> @silent {@lenient {null.tryMe()}}
> {code}
> From the JexlEngine point of view, each annotation could be implemented in 
> the form of Interceptor interface, for example
> {code}
> public interface Interceptor {
>public Object onExecute(JexlStatement block, String annotation, Object.. 
> args);
> }
> {code}
> 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. 
> {code}
> @silent {@default {...}}
> {code}
> 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.
> {code}
> public interface JexlStatement {
>public Object interpret();
>// ..
> }
> {code}
> 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 interceptors.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-197) Add annotations

2016-07-16 Thread Henri Biestro (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15380663#comment-15380663
 ] 

Henri Biestro commented on JEXL-197:


It would expose the internal classes (Interpreter, JexlNode); this is why I 
chose a Callable as the encapsulation of the statement.
What occurs behind the scenes is more or less what you describe; annotation 
processing occurs at execution time and the callable ends up doing a 
node.jjtAccept(Interpreter.this, null).
What do you have in mind ?

> Add annotations
> ---
>
> Key: JEXL-197
> URL: https://issues.apache.org/jira/browse/JEXL-197
> Project: Commons JEXL
>  Issue Type: Improvement
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
> Fix For: 3.1
>
>
> Follow up from JEXL-194...
> 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. 
> {code}
> @synchronized(items) {for (x : items) ...}
> {code}
> Each statement block should be allowed to have only one annotation but it 
> would be convenient to allow the syntax 
> {code}
> @silent @lenient {null.tryMe()}
> {code}
> which should be syntaxically equivalent to:
> {code}
> @silent {@lenient {null.tryMe()}}
> {code}
> From the JexlEngine point of view, each annotation could be implemented in 
> the form of Interceptor interface, for example
> {code}
> public interface Interceptor {
>public Object onExecute(JexlStatement block, String annotation, Object.. 
> args);
> }
> {code}
> 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. 
> {code}
> @silent {@default {...}}
> {code}
> 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.
> {code}
> public interface JexlStatement {
>public Object interpret();
>// ..
> }
> {code}
> 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 interceptors.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-197) Add annotations

2016-07-15 Thread Dmitri Blinov (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15380003#comment-15380003
 ] 

Dmitri Blinov commented on JEXL-197:


I wonder if it's possible to chage signature of 
JexlContext.AnnotationProcessor.processAnnotation method from
{code}
Object processAnnotation(String name, Object[] args, Callable 
statement) throws Exception
{code}
To
{code}
Object processAnnotation(String name, Object[] args, Interpreter interpreter, 
JexlNode node) throws Exception
{code}
Would it be then possible to call interpreter.interpret(node) during annotation 
processing?

> Add annotations
> ---
>
> Key: JEXL-197
> URL: https://issues.apache.org/jira/browse/JEXL-197
> Project: Commons JEXL
>  Issue Type: Improvement
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
> Fix For: 3.1
>
>
> Follow up from JEXL-194...
> 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. 
> {code}
> @synchronized(items) {for (x : items) ...}
> {code}
> Each statement block should be allowed to have only one annotation but it 
> would be convenient to allow the syntax 
> {code}
> @silent @lenient {null.tryMe()}
> {code}
> which should be syntaxically equivalent to:
> {code}
> @silent {@lenient {null.tryMe()}}
> {code}
> From the JexlEngine point of view, each annotation could be implemented in 
> the form of Interceptor interface, for example
> {code}
> public interface Interceptor {
>public Object onExecute(JexlStatement block, String annotation, Object.. 
> args);
> }
> {code}
> 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. 
> {code}
> @silent {@default {...}}
> {code}
> 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.
> {code}
> public interface JexlStatement {
>public Object interpret();
>// ..
> }
> {code}
> 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 interceptors.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-197) Add annotations

2016-07-05 Thread Dmitri Blinov (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15362455#comment-15362455
 ] 

Dmitri Blinov commented on JEXL-197:


Putting the JEXL-185 aside, the first impression is yes, that is what I need. 
Now as I'm in the process of adopting this, I think some other issues may 
arise, likes JEXL-201, but again - in principle yes, great extensibility point 
and great job, many thanks. As for JexlContext, first I was a little puzzled 
why it was put in JexlContext but not in JexlArithmetic for example, where 
major part of customization code is to be placed, but now I'm starting to think 
it's even better that way, since annotations may have access to JexlContext 
internal structures.

> Add annotations
> ---
>
> Key: JEXL-197
> URL: https://issues.apache.org/jira/browse/JEXL-197
> Project: Commons JEXL
>  Issue Type: Improvement
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
> Fix For: 3.1
>
>
> Follow up from JEXL-194...
> 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. 
> {code}
> @synchronized(items) {for (x : items) ...}
> {code}
> Each statement block should be allowed to have only one annotation but it 
> would be convenient to allow the syntax 
> {code}
> @silent @lenient {null.tryMe()}
> {code}
> which should be syntaxically equivalent to:
> {code}
> @silent {@lenient {null.tryMe()}}
> {code}
> From the JexlEngine point of view, each annotation could be implemented in 
> the form of Interceptor interface, for example
> {code}
> public interface Interceptor {
>public Object onExecute(JexlStatement block, String annotation, Object.. 
> args);
> }
> {code}
> 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. 
> {code}
> @silent {@default {...}}
> {code}
> 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.
> {code}
> public interface JexlStatement {
>public Object interpret();
>// ..
> }
> {code}
> 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 interceptors.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-197) Add annotations

2016-07-05 Thread Henri Biestro (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15362414#comment-15362414
 ] 

Henri Biestro commented on JEXL-197:


It works but does it fit the intended purpose ? Does this allow implementing 
what you had in mind / your use cases ?
Delegating to the JexlContext because annotations seem akin to functors or 
namespace resolution which are handled that way 
(JexlIContext.NamespaceResolver, JexlContext.NamespaceFunctor).

> Add annotations
> ---
>
> Key: JEXL-197
> URL: https://issues.apache.org/jira/browse/JEXL-197
> Project: Commons JEXL
>  Issue Type: Improvement
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
> Fix For: 3.1
>
>
> Follow up from JEXL-194...
> 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. 
> {code}
> @synchronized(items) {for (x : items) ...}
> {code}
> Each statement block should be allowed to have only one annotation but it 
> would be convenient to allow the syntax 
> {code}
> @silent @lenient {null.tryMe()}
> {code}
> which should be syntaxically equivalent to:
> {code}
> @silent {@lenient {null.tryMe()}}
> {code}
> From the JexlEngine point of view, each annotation could be implemented in 
> the form of Interceptor interface, for example
> {code}
> public interface Interceptor {
>public Object onExecute(JexlStatement block, String annotation, Object.. 
> args);
> }
> {code}
> 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. 
> {code}
> @silent {@default {...}}
> {code}
> 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.
> {code}
> public interface JexlStatement {
>public Object interpret();
>// ..
> }
> {code}
> 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 interceptors.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-197) Add annotations

2016-07-05 Thread Dmitri Blinov (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15362134#comment-15362134
 ] 

Dmitri Blinov commented on JEXL-197:


Well, the thing basically works. Out of curiocity, what is the point to 
delegate annotation processing to JexlContext? 

> Add annotations
> ---
>
> Key: JEXL-197
> URL: https://issues.apache.org/jira/browse/JEXL-197
> Project: Commons JEXL
>  Issue Type: Improvement
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
> Fix For: 3.1
>
>
> Follow up from JEXL-194...
> 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. 
> {code}
> @synchronized(items) {for (x : items) ...}
> {code}
> Each statement block should be allowed to have only one annotation but it 
> would be convenient to allow the syntax 
> {code}
> @silent @lenient {null.tryMe()}
> {code}
> which should be syntaxically equivalent to:
> {code}
> @silent {@lenient {null.tryMe()}}
> {code}
> From the JexlEngine point of view, each annotation could be implemented in 
> the form of Interceptor interface, for example
> {code}
> public interface Interceptor {
>public Object onExecute(JexlStatement block, String annotation, Object.. 
> args);
> }
> {code}
> 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. 
> {code}
> @silent {@default {...}}
> {code}
> 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.
> {code}
> public interface JexlStatement {
>public Object interpret();
>// ..
> }
> {code}
> 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 interceptors.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (JEXL-197) Add annotations

2016-07-03 Thread Henri Biestro (JIRA)

[ 
https://issues.apache.org/jira/browse/JEXL-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15360623#comment-15360623
 ] 

Henri Biestro commented on JEXL-197:


I've dropped some initial code (that leaves out trying to tackle JEXL-185).
Arg/no-arg and multiple annotations supported as in:
{code}@one(1) @synchronized { return 42; }{code}
I've simplified the interfaces (Callable / JexlContext.AnnotationProcessor); 
tests in AnnotationTests.java in trunk.
Comments welcome.

> Add annotations
> ---
>
> Key: JEXL-197
> URL: https://issues.apache.org/jira/browse/JEXL-197
> Project: Commons JEXL
>  Issue Type: Improvement
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
> Fix For: 3.1
>
>
> Follow up from JEXL-194...
> 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. 
> {code}
> @synchronized(items) {for (x : items) ...}
> {code}
> Each statement block should be allowed to have only one annotation but it 
> would be convenient to allow the syntax 
> {code}
> @silent @lenient {null.tryMe()}
> {code}
> which should be syntaxically equivalent to:
> {code}
> @silent {@lenient {null.tryMe()}}
> {code}
> From the JexlEngine point of view, each annotation could be implemented in 
> the form of Interceptor interface, for example
> {code}
> public interface Interceptor {
>public Object onExecute(JexlStatement block, String annotation, Object.. 
> args);
> }
> {code}
> 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. 
> {code}
> @silent {@default {...}}
> {code}
> 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.
> {code}
> public interface JexlStatement {
>public Object interpret();
>// ..
> }
> {code}
> 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 interceptors.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)