You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Biestro (Jira)" <ji...@apache.org> on 2021/06/07 13:15:06 UTC

[jira] [Closed] (JEXL-333) Allow declaration of namespace within script

     [ https://issues.apache.org/jira/browse/JEXL-333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Biestro closed JEXL-333.
------------------------------

> Allow declaration of namespace within script
> --------------------------------------------
>
>                 Key: JEXL-333
>                 URL: https://issues.apache.org/jira/browse/JEXL-333
>             Project: Commons JEXL
>          Issue Type: Improvement
>    Affects Versions: 3.1
>            Reporter: Henri Biestro
>            Assignee: Henri Biestro
>            Priority: Major
>             Fix For: 3.2
>
>
> *WHAT:*
> Allow declaration of a namespace within a script.
> *WHY:*
> As of 3.1, namespaces must be declared at Jexl engine building time. With an external (properties) configuration, adding new namespaces requires rebuilding the engine or updating the namespace map. This is often inconvenient in test or dev scenarios.
> *HOW:*
> Using a pragma, it is possible to statically add namespace entries for valid for the duration of the script execution. The options vehicle can be reused.
> The syntax will be: 
> {code}#pragma jexl.namespace.xyz f.q.c.n{code}
> Where 'xyz' is the actual namespace prefix and 'f.q.c.n.' the fully qualified class name.
> Example:
> {code}
> #pragma jexl.namespace.tax org.apache.commons.jexl3.ContextNamespaceTest$Taxes
> #pragma jexl.namespace.str java.lang.String
> {code}
> The 1st pragma defines the 'tax' namespace as a static class of a test;
> The 2nd pragma defines the 'str' namespace' as the String class, allowing expression like:
> {code}
> str:format('%04d', 42)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)