Questions tagged [jexl]

JEXL is a library intended to facilitate the implementation of dynamic and scripting features in applications and frameworks written in Java.

JEXL is a library intended to facilitate the implementation of dynamic and scripting features in applications and frameworks written in Java.

From the official documentation:

JEXL implements an Expression Language based on some extensions to the JSTL Expression Language supporting most of the constructs seen in shell-script or ECMAScript. Its goal is to expose scripting features usable by technical operatives or consultants working with enterprise platforms.

The library exposes a small footprint API - the core features fit in 3 classes and 10 methods - that can be used in various conditions:

  • Scripting features:
    • Your application lets (advanced) users evaluate or define some simple expressions like computation formulas.
  • Module or component configuration:
    • Your application has configuration files (eventually generated by a design module) consumed by the end-user module that would benefit from variables and expressions.
    • When it would be convenient to use IOC but overall complexity doesn't require (or can't depend upon) a full-blown library (Spring, Guice...).
  • Loose-coupling of interfaces and implementations or duck-typing:
    • You have optional classes that your code cant consider as compilation dependencies.
    • You have to integrate and call "legacy" code or use components that you don't want to strongly depend upon.
  • Simple template capabilities:
    • Your application has basic template requirements and JSPs or Velocity would be overkill or too inconvenient to deploy.

JEXL name stands for Java EXpression Language, a simple expression language originally inspired by Apache Velocity and the Expression Language defined in the JavaServer Pages Standard Tag Library version 1.1 (JSTL) and JavaServer Pages version 2.0 (JSP). JEXL 2.0 added features inspired by Unified EL. The syntax is now close to a mix of ECMAScript and "shell-script" making it easy to master by technical operatives or consultants. The objects exposed and their behavior obviously need to be documented though...

The API and the expression language exploit Java-beans naming patterns through introspection to expose property getters and setters. It also considers public class fields as properties and allows to invoke any accessible method.

JEXL attempts to bring some of the lessons learned by the Velocity community about expression languages in templating to a wider audience. Commons Jelly needed Velocity-ish method access, it just had to have it.

It must be noted that JEXL is not a compatible implementation of EL as defined in JSTL 1.1 (JSR-052) or JSP 2.0 (JSR-152). For a compatible implementation of these specifications, see the Commons EL project.

79 questions
1
vote
1 answer

JMeter - jexl3 function can't declare local variables

I'm using latest JMeter 4 and trying to use basic jexl syntax of declaring local variable in jexl function Local variables Can be defined using the var keyword; their identifying rules are the same as contextual variables. Basic declaration:…
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
1
vote
1 answer

Jexl parallel processing example

I need to do several actions at the same time in Jexl. In official guide I found annotation @parallel: https://commons.apache.org/proper/commons-jexl/reference/syntax.html But I didn't find any examples how to use it. Can anyone provide some…
1
vote
0 answers

Check parsing error in .jexl file using java

How to check parsing error in .jexl file using java? The application uses a directory comprising of several .jexl files. Some of them experiences parsing error post code merging. Are there any ways to externally check for the existing parsing error…
1
vote
1 answer

Sonatype Nexus 3 content selector by docker container name?

I can't seem to find the documentation on how to set a content selector by a docker container name. I tried to find all containers that have "_api" in the name: format == "docker" and name =~ "_api" which does not seem to work I also tried: format…
Theo
  • 2,262
  • 3
  • 23
  • 49
1
vote
1 answer

JEXL - How to get all warning message of unknown variables?

How to get all warning message of unknown variables? I have a expression which I would like to evaluate and know all the missing variables. Example: jexl.setStrict(false); Expression e = (Expression)…
Uma
  • 21
  • 8
1
vote
1 answer

type casting in jexl expression

I get the status code using the following code. String statusCode = ((Map) product.getStatus().get("abc")).get("code"); I want to use jexl expression to get value. JexlEngine jexlEngine = new JexlEngine(); Expression expression =…
choom
  • 45
  • 1
  • 11
1
vote
1 answer

ClassLookupException: Invalid class reference if using shrinker without proguard

I use JEXL library in my app and it seems like the new Android class shrinker fails to process it. Here is my dependency: compile 'org.apache.commons:commons-jexl:2.1.1' My build type is defined as follows: debug { versionNameSuffix…
Igor Bubelov
  • 5,154
  • 5
  • 25
  • 24
1
vote
1 answer

Jexl3 throws exceptions on variable starting with $

I'm trying to move from jexl2 to jexl3 and I noticed that it throws exception on variables starting with $. It used to work on jexl2. The problem is that I've been using this extensively everywhere. This works in jexl2 JexlContext jc = new…
biliboc
  • 737
  • 1
  • 10
  • 25
1
vote
2 answers

Performance problems after upgrading to JXLS 2.2.3

I recently upgraded to the new version of JXLS (from 1.0.2) and found that it caused a significant performance hit. My use case is writing excel reports based on a template. Previously, the reports were written out in a matter of 4 minutes, but now…
subodh
  • 337
  • 2
  • 6
  • 18
1
vote
1 answer

How to concatenate a String and expression in JEXL

I am using JEXL http://commons.apache.org/proper/commons-jexl/ to evaluate Strings. I tried the following code String jexlExp = "'some text ' + output?'true':'false'"; JexlEngine jexl = new JexlEngine(); Expression e =…
abhinav
  • 527
  • 3
  • 11
  • 24
1
vote
2 answers

Jmeter- How to manipulate DateTime Type Variable?

We need to add n Minutes to a work order start time variable (WOStartTime) for every sample, what are possible ways? Currently we are using jexl function in jp@gc - Parameterized Controller; ${__jexl(${__threadNum()}*8 + ${WOStartTime})} where…
Anil
  • 3,722
  • 2
  • 24
  • 49
1
vote
1 answer

JEXL 2.1.1 - Big Decimal Literal in expression String causing Parsing Error

I am trying to use BigDecimal Literal in expression String I am using JEXL 2.1.1 I am using literal suffix 'h' as mentioned in http://commons.apache.org/jexl/reference/syntax.html#Literals JexlEngine expressionFactory = new JexlEngine(); JexlContext…
harrybvp
  • 2,445
  • 2
  • 22
  • 30
0
votes
1 answer

JEXL2.1 Circular Bit Shift To Mirror Java

I wrote a hashing function that takes a 64 bit integer in, and outputs a 64 bit integer out in JAVA and translated it to JEXL 2.1 I need it to return the same results in both, but am not too picky about how it works Everything was fine until this…
Luc Taylor
  • 29
  • 5
0
votes
2 answers

DBeaver CSV Import Transform Expression

I'm trying to import a CSV into an existing PostgreSQL table using DBeaver Import Tool and I need to transform a numeric value multiplying it by 100. Someone knows the syntax to be used in the expression? The official documentation talks about JEXL…
0
votes
1 answer

Jexl - How to check one list contains other list

For me, the below logic, single value contains in an array is working perfectly. value = "a" list1 = ["a","b","c","d"] value =~ list1 But if both are list, as given below, it is not working. list1 = ["a","b","c","d"] list2 = ["b","c"] How will…
skmaran.nr.iras
  • 8,152
  • 28
  • 81
  • 116