You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dmitri Blinov (JIRA)" <ji...@apache.org> on 2016/07/15 19:54:20 UTC

[jira] [Comment Edited] (JEXL-197) Add annotations

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

Dmitri Blinov edited comment on JEXL-197 at 7/15/16 7:53 PM:
-------------------------------------------------------------

I wonder if it's possible to change signature of JexlContext.AnnotationProcessor.processAnnotation method from
{code}
Object processAnnotation(String name, Object[] args, Callable<Object> 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?


was (Author: dmitri_blinov):
I wonder if it's possible to chage signature of JexlContext.AnnotationProcessor.processAnnotation method from
{code}
Object processAnnotation(String name, Object[] args, Callable<Object> 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)