Apache Commons JEXL

来源:互联网 发布:合同矩阵和相似矩阵 编辑:程序博客网 时间:2024/05/16 15:54

Apache Commons JEXL

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

example:

import org.apache.commons.jexl3.*;public class MyJEXL {    public static void main(String[] args) {        JexlEngine jexl = new JexlBuilder().create();        String jexlExp = "person.getName()";        JexlExpression jexlExpression = jexl.createExpression(jexlExp);        JexlContext jexlContext = new MapContext();        Person person = new Person("aaa", "20");        jexlContext.set("person", person);        Object o = jexlExpression.evaluate(jexlContext);        System.out.println(o);    }}

pom.xml

 <dependencies>        <dependency>            <groupId>org.apache.commons</groupId>            <artifactId>commons-jexl3</artifactId>            <version>3.0</version>        </dependency>    </dependencies>
0 0