Someone asked about Commons EL:
"Is there no way to test this stuff outside of a Servlet/JSP
container?"
Commons SCXML supports EL as an expression language that may be used within the expressions in an SCXML document. As a side-effect, a simple API may be available for anyone who has the need to test without wanting to deal with a Servlet/JSP container. We understand this has limited use.
To test an expression language implementation, one minimally needs a context of evaluation and an evaluator, which gives us the following usage:
//import org.apache.commons.scxml.Context; //import org.apache.commons.scxml.Evaluator; //import org.apache.commons.scxml.SCXMLExpressionException; //import org.apache.commons.scxml.env.jsp.ELContext; //import org.apache.commons.scxml.env.jsp.ELEvaluator; Context context = new ELContext(); // Say we have an instance 'foo' of type Foo which // has a property 'bar' of type String context.set("foo", foo); Evaluator evaluator = new ELEvaluator(); String bar = null; try { bar = (String) evaluator.eval(context, "${foo.bar}"); } catch (SCXMLExpressionException see) { // Commons SCXML wraps the underlying exception, // in this case, a javax.servlet.jsp.el.ELException }