[
https://issues.apache.org/jira/browse/JEXL-55?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Henri Biestro updated JEXL-55:
------------------------------
Description:
JEXL 2.0 redux
This is an attempt at restarting the JEXL 2.0 release effort based on the 2.0
trunk.
There was a lot of effort & good ideas already in the 2.0 branch and JEXL is
just too convenient (imho) to be left in this state.
The patch keeps the 2.0 structure, most notably using the visitor pattern to
implement the interpreter.
This allows to modify the grammar much more easily since the javacc generated
code does not need to be modified.
This patch incorporates a few fixes & enhancements:
- Bean & ant-ish like assignment; allows expressions like "foo.bar.quux = 'some
value'"
If 'foo' is resolved as an object from the JexlContext, and 'foo' can access a
'bar' (either as
a map access or a bean property) that itself allows to set a 'quux', that
'quux' will be set with
the value.
The 'ant-ish' like properties can only be set if no bean can be accessed during
the evaluation.
That is, in our case, if 'foo' & 'foo.bar' can *not* be solved as beans from
the JexlContext,
the property 'foo.bar.quux' will be added to the JexlContext. This is to avoid
ambiguities
that could stem from having both a 'foo.quux' ant property and a 'foo' in the
JexlContext.
- Ternary operator (+ GNU C extension '?:'); allows expressions like
"foo?'true-or-not-null':'false-or-null'
and 'foo?:"foo-is-null"
The ternary operator is what you expect; the "?:" syntax allows the second
operand to be omitted, and the first operand is implicitly used as the second.
The expression 'x?:z' is equivalent to 'x?x:z'
- Exception handling revisited; silent (aka 1.1 mode) or not
The 1.1 code was silent in almost all cases when an exception occurs and
usually returns 'null' in that case.
The new code also allows to set the engine in a non lenient mode where all
exceptions & errors will be reported,
wrapped in a o.a.c.jexl.JexlException. This runtime exception carries which
node (in the tree) is the point of origin, allowing
to better diagnose why the error (the cause) occurs.
- ScriptFactory, ExpressionFactory refactored
A JexlEngine class is used as the non-static version instance; this should
allow easier customization.
The pre/post resolvers have been removed from expressions since it is now much
easier to just derive
from Interpreter to implement something specific.
- java 5 based
Allows to use generics making the code easier to understand & maintain.
The JEXL-54 patch has been folded in; besides light performance improvement, it
makes the code more
readable.
- java.util.logging (replaces dependency on commons-logging)
Controversial, as usual wrt Java logging :-). Added twist is a "local" class
that acts as a facade to the LogManager allowing to use anonymous Loggers
(necessary for applets, convenient to avoid WAS console output or to
override/divert jul towards log4j/slf4j).
was:
JEXL 2.0 redux
This is an attempt at restarting the JEXL 2.0 release effort based on the 2.0
trunk.
There was a lot of effort & good ideas already in the 2.0 branch and JEXL is
just too convenient (imho) to be left in this state.
The patch keeps the 2.0 structure, most notably using the visitor pattern to
implement the interpreter.
This allows to modify the grammar much more easily since the javacc generated
code does not need to be modified.
This patch incorporates a few fixes & enhancements:
- Bean & ant-ish like assignment; allows expressions like "foo.bar.quux = 'some
value'"
If 'foo' is resolved as an object from the JexlContext, and 'foo' can access a
'bar' (either as
a map access or a bean property) that itself allows to set a 'quux', that
'quux' will be set with
the value.
The 'ant-ish' like properties can only be set if no bean can be accessed during
the evaluation.
That is, in our case, if 'foo' & 'foo.bar' can *not* be solved as beans from
the JexlContext,
the property 'foo.bar.quux' will be added to the JexlContext. This is to avoid
ambiguities
that could stem from having both a 'foo.quux' ant property and a 'foo' in the
JexlContext.
- Ternary operator (+ GNU C extension '?:'); allows expressions like
"foo?'true-or-not-null':'false-or-null'
and 'foo?:"foo-is-null"
The ternary operator is what you expect; the "?:" syntax allows the second
operand to be omitted, and the first operand is implicitly used as the second.
The expression 'x?:z' is equivalent to 'x?x:z'
- Exception handling revisited; silent (aka 1.1 mode) or not
The 1.1 code was silent in almost all cases when an exception occurs and
usually returns 'null' in that case.
The new code also allows to set the engine in a non lenient mode where all
exceptions & errors will be reported,
wrapped in a o.a.c.jexl.JexlException. This runtime exception carries which
node (in the tree) is the point of origin, allowing
to better diagnose why the error (the cause) occurs.
- ScriptFactory, ExpressionFactory refactored
A JexlEngine class is used as the non-static version instance; this should
allow easier customization.
The pre/post resolvers have been removed from expressions since it is now much
easier to just derive
from Interpreter to implement something specific.
- java 5 based
The JEXL-54 patch has been folded in; besides light performance improvement, it
makes the code more
readable.
> JEXL 2.0 redux, attempting to restart the effort to release 2.0
> ---------------------------------------------------------------
>
> Key: JEXL-55
> URL: https://issues.apache.org/jira/browse/JEXL-55
> Project: Commons JEXL
> Issue Type: Improvement
> Affects Versions: 2.0
> Reporter: Henri Biestro
> Fix For: 2.0
>
> Attachments: JEXL-55.patch, jexl-redux.zip
>
>
> JEXL 2.0 redux
> This is an attempt at restarting the JEXL 2.0 release effort based on the 2.0
> trunk.
> There was a lot of effort & good ideas already in the 2.0 branch and JEXL is
> just too convenient (imho) to be left in this state.
> The patch keeps the 2.0 structure, most notably using the visitor pattern to
> implement the interpreter.
> This allows to modify the grammar much more easily since the javacc generated
> code does not need to be modified.
> This patch incorporates a few fixes & enhancements:
> - Bean & ant-ish like assignment; allows expressions like "foo.bar.quux =
> 'some value'"
> If 'foo' is resolved as an object from the JexlContext, and 'foo' can access
> a 'bar' (either as
> a map access or a bean property) that itself allows to set a 'quux', that
> 'quux' will be set with
> the value.
> The 'ant-ish' like properties can only be set if no bean can be accessed
> during the evaluation.
> That is, in our case, if 'foo' & 'foo.bar' can *not* be solved as beans from
> the JexlContext,
> the property 'foo.bar.quux' will be added to the JexlContext. This is to
> avoid ambiguities
> that could stem from having both a 'foo.quux' ant property and a 'foo' in the
> JexlContext.
> - Ternary operator (+ GNU C extension '?:'); allows expressions like
> "foo?'true-or-not-null':'false-or-null'
> and 'foo?:"foo-is-null"
> The ternary operator is what you expect; the "?:" syntax allows the second
> operand to be omitted, and the first operand is implicitly used as the second.
> The expression 'x?:z' is equivalent to 'x?x:z'
> - Exception handling revisited; silent (aka 1.1 mode) or not
> The 1.1 code was silent in almost all cases when an exception occurs and
> usually returns 'null' in that case.
> The new code also allows to set the engine in a non lenient mode where all
> exceptions & errors will be reported,
> wrapped in a o.a.c.jexl.JexlException. This runtime exception carries which
> node (in the tree) is the point of origin, allowing
> to better diagnose why the error (the cause) occurs.
> - ScriptFactory, ExpressionFactory refactored
> A JexlEngine class is used as the non-static version instance; this should
> allow easier customization.
> The pre/post resolvers have been removed from expressions since it is now
> much easier to just derive
> from Interpreter to implement something specific.
> - java 5 based
> Allows to use generics making the code easier to understand & maintain.
> The JEXL-54 patch has been folded in; besides light performance improvement,
> it makes the code more
> readable.
> - java.util.logging (replaces dependency on commons-logging)
> Controversial, as usual wrt Java logging :-). Added twist is a "local" class
> that acts as a facade to the LogManager allowing to use anonymous Loggers
> (necessary for applets, convenient to avoid WAS console output or to
> override/divert jul towards log4j/slf4j).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.