public class JexlScriptEngine
extends javax.script.AbstractScriptEngine
implements javax.script.Compilable
This implementation gives access to both ENGINE_SCOPE and GLOBAL_SCOPE bindings. When a JEXL script accesses a variable for read or write, this implementation checks first ENGINE and then GLOBAL scope. The first one found is used. If no variable is found, and the JEXL script is writing to a variable, it will be stored in the ENGINE scope.
The implementation also creates the "JEXL" script object as an instance of the
class JexlScriptEngine.JexlScriptObject
for access to utility methods and variables.
Modifier and Type | Class and Description |
---|---|
private static class |
JexlScriptEngine.EngineSingletonHolder
Holds singleton JexlScriptEngine (IODH).
|
private static class |
JexlScriptEngine.FactorySingletonHolder
Holds singleton JexlScriptEngineFactory (IODH).
|
private class |
JexlScriptEngine.JexlCompiledScript
Wrapper to help convert a Jexl Script into a JSR-223 CompiledScript.
|
private class |
JexlScriptEngine.JexlContextWrapper
Wrapper to help convert a JSR-223 ScriptContext into a JexlContext.
|
class |
JexlScriptEngine.JexlScriptObject
Implements engine and engine context properties for use by JEXL scripts.
|
Modifier and Type | Field and Description |
---|---|
private static int |
CACHE_SIZE
The shared expression cache size.
|
static java.lang.String |
CONTEXT_KEY
Reserved key for context (mandated by JSR-223).
|
static java.lang.String |
JEXL_OBJECT_KEY
Reserved key for JexlScriptObject.
|
private JexlEngine |
jexlEngine
The JEXL EL engine.
|
private JexlScriptEngine.JexlScriptObject |
jexlObject
The JexlScriptObject instance.
|
private static org.apache.commons.logging.Log |
LOG
The logger.
|
private javax.script.ScriptEngineFactory |
parentFactory
The factory which created this instance.
|
Constructor and Description |
---|
JexlScriptEngine()
Default constructor.
|
JexlScriptEngine(javax.script.ScriptEngineFactory factory)
Create a scripting engine using the supplied factory.
|
Modifier and Type | Method and Description |
---|---|
javax.script.CompiledScript |
compile(java.io.Reader script) |
javax.script.CompiledScript |
compile(java.lang.String script) |
javax.script.Bindings |
createBindings() |
java.lang.Object |
eval(java.io.Reader reader,
javax.script.ScriptContext context) |
java.lang.Object |
eval(java.lang.String script,
javax.script.ScriptContext context) |
javax.script.ScriptEngineFactory |
getFactory() |
private java.lang.String |
readerToString(java.io.Reader script)
Reads a script.
|
private static final org.apache.commons.logging.Log LOG
private static final int CACHE_SIZE
public static final java.lang.String CONTEXT_KEY
public static final java.lang.String JEXL_OBJECT_KEY
private final JexlScriptEngine.JexlScriptObject jexlObject
private final javax.script.ScriptEngineFactory parentFactory
private final JexlEngine jexlEngine
public JexlScriptEngine()
Only intended for use when not using a factory.
Sets the factory to JexlScriptEngineFactory
.
public JexlScriptEngine(javax.script.ScriptEngineFactory factory)
factory
- the factory which created this instance.java.lang.NullPointerException
- if factory is nullpublic javax.script.Bindings createBindings()
createBindings
in interface javax.script.ScriptEngine
public java.lang.Object eval(java.io.Reader reader, javax.script.ScriptContext context) throws javax.script.ScriptException
eval
in interface javax.script.ScriptEngine
javax.script.ScriptException
public java.lang.Object eval(java.lang.String script, javax.script.ScriptContext context) throws javax.script.ScriptException
eval
in interface javax.script.ScriptEngine
javax.script.ScriptException
public javax.script.ScriptEngineFactory getFactory()
getFactory
in interface javax.script.ScriptEngine
public javax.script.CompiledScript compile(java.lang.String script) throws javax.script.ScriptException
compile
in interface javax.script.Compilable
javax.script.ScriptException
public javax.script.CompiledScript compile(java.io.Reader script) throws javax.script.ScriptException
compile
in interface javax.script.Compilable
javax.script.ScriptException
private java.lang.String readerToString(java.io.Reader script) throws javax.script.ScriptException
script
- the script readerjavax.script.ScriptException
- if an exception occurs during read