Java El series -2.juel Quick Start

Source: Internet
Author: User

Inkfish translation, do not reprint the commercial nature, reproduced please indicate the source (http://blog.csdn.net/inkfish). This article is I study juel at the same time, to the original website carries on the simple translation, the original website address: http://juel.sourceforge.net/guide/start.html.

Quick Start

The Juel release contains some of the following jar files: (Source: Http://blog.csdn.net/inkfish)

1.juel-api-2.2.x.jar--contains some classes under the Javax.el package
2.juel-impl-2.2.x.jar--contains De.odysseus.el implementation classes
3.juel-spi-2.2.x.jar--contains definitions of meta-inf/service/javax.el.expressionfactory service provisioning resources (if you have multiple implementations of El in your classpath, And you want to use the Juel implementation, then you need to call Expressionfactory.newinstance ())
The 4.juel-2.2.x.jar--contains classes under the Java.el package and contains implementation classes under De.odysseus.el, as well as a service Provider Interface (SPI)

That is to say: Juel-2.2.x.jar = Juel-api-2.2.x.jar + Juel-impl-2.2.x.jar + Juel-spi-2.2.x.jar. (Source: Http://blog.csdn.net/inkfish)

Here's what you need to use El in your application (assuming you've put Juel-2.2.x.jar under Classpath and imported javax.el.*): (Source: Http://blog.csdn.net/inkfish)

1. Factory and Context (Source: http://blog.csdn.net/inkfish)

The implementation of the Expressionfactory class is De.odysseus.el.ExpressionFactoryImpl expressionfactory factory = new De.odysseus.el.ExpressionFactoryImpl (); De.odysseus.el.util provides package provides instantly available subclasses Elcontext de.odysseus.el.util.SimpleContext context = new De.odysseus.el.util.SimpleContext ();

2. Functions and Variables (source: http://blog.csdn.net/inkfish)

Set the map function math:max (int, int) using Java.lang.Math.max (int, int) context.setfunction ("Math", "Max", Math.class.getMethod (" Max ", Int.class, Int.class)); The map variable foo is set to 0 context.setvariable ("foo", Factory.createvalueexpression (0, Int.class));

3. Resolution and Evaluation (Source: Http://blog.csdn.net/inkfish)

Parse expression valueexpression e = factory.createvalueexpression (Context, "${math:max (Foo,bar)}", Int.class); Setting the top-level property "bar" value is 1 factory.createvalueexpression (context, "${bar}", Int.class). SetValue (context, 1);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.