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 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. |
| public class | JexlScriptEngine.JexlScriptObject
Implements engine and engine context properties for use by JEXL scripts. |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | CACHE_SIZE
The shared expression cache size. |
| public static final String | CONTEXT_KEY
Reserved key for context (mandated by JSR-223). |
| public static final String | JEXL_OBJECT_KEY
Reserved key for JexlScriptObject. |
| private final JexlEngine | jexlEngine
The JEXL EL engine. |
| private final JexlScriptEngine. | jexlObject
The JexlScriptObject instance. |
| private static final Log | LOG
The logger. |
| private final ScriptEngineFactory | parentFactory
The factory which created this instance. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | JexlScriptEngine(final ScriptEngineFactory
the factory which created this instance. factory)Create a scripting engine using the supplied factory. |
| Modifier and Type | Method and Description |
|---|---|
| public CompiledScript | compile(final String
The source of the script, represented as a script)String.Implements javax. String) for
later execution.
|
| public CompiledScript | compile(final Reader
The reader from which the script source is obtained. script)Implements javax. Reader) for
later execution.
|
| public Bindings | createBindings()
Implements javax. Bindings.
|
| public Object | eval(final Reader
The source of the script to be executed by the script engine. reader, final ScriptContext The context)ScriptContext passed to the script engine.Implements javax. eval(String, ScriptContext) where the source of the script
is read from a Reader.
|
| public Object | eval(final String
The script to be executed by the script engine. script, final ScriptContext A context)ScriptContext exposing sets of attributes in
different scopes. The meanings of the scopes ScriptContext.GLOBAL_SCOPE,
and ScriptContext.ENGINE_SCOPE are defined in the specification.
The ENGINE_SCOPE Bindings of the ScriptContext contains the
bindings of scripting variables to application objects to be used during this
script execution.Implements javax. |
| public ScriptEngineFactory | getFactory()
Implements javax. ScriptEngineFactory for the class to which this ScriptEngine belongs.
|
| private String |
| CACHE_SIZE | back to summary |
|---|---|
| private static final int CACHE_SIZE The shared expression cache size. | |
| CONTEXT_KEY | back to summary |
|---|---|
| public static final String CONTEXT_KEY Reserved key for context (mandated by JSR-223). | |
| JEXL_OBJECT_KEY | back to summary |
|---|---|
| public static final String JEXL_OBJECT_KEY Reserved key for JexlScriptObject. | |
| jexlEngine | back to summary |
|---|---|
| private final JexlEngine jexlEngine The JEXL EL engine. | |
| jexlObject | back to summary |
|---|---|
| private final JexlScriptEngine. The JexlScriptObject instance. | |
| LOG | back to summary |
|---|---|
| private static final Log LOG The logger. | |
| parentFactory | back to summary |
|---|---|
| private final ScriptEngineFactory parentFactory The factory which created this instance. | |
| JexlScriptEngine | back to summary |
|---|---|
| public JexlScriptEngine() Default constructor.
Only intended for use when not using a factory.
Sets the factory to | |
| JexlScriptEngine | back to summary |
|---|---|
| public JexlScriptEngine(final ScriptEngineFactory factory) Create a scripting engine using the supplied factory.
| |
| compile | back to summary |
|---|---|
| public CompiledScript compile(final String script) throws ScriptException Implements javax. Doc from javax. Compiles the script (source represented as a
| |
| compile | back to summary |
|---|---|
| public CompiledScript compile(final Reader script) throws ScriptException Implements javax. Doc from javax. Compiles the script (source read from
| |
| createBindings | back to summary |
|---|---|
| public Bindings createBindings() Implements javax. Doc from javax. Returns an uninitialized
| |
| eval | back to summary |
|---|---|
| public Object eval(final Reader reader, final ScriptContext context) throws ScriptException Implements javax. Doc from javax. Same as
| |
| eval | back to summary |
|---|---|
| public Object eval(final String script, final ScriptContext context) throws ScriptException Implements javax. Doc from javax. Causes the immediate execution of the script whose source is the String passed as the first argument. The script may be reparsed or recompiled before execution. State left in the engine from previous executions, including variable values and compiled procedures may be visible during this execution.
| |
| getFactory | back to summary |
|---|---|
| public ScriptEngineFactory getFactory() Implements javax. Doc from javax. Returns a
| |
| readerToString | back to summary |
|---|---|
| private String readerToString(final Reader script) throws ScriptException Reads a script.
| |
A single JEXL engine and Uberspect is shared by all instances of JexlScriptEngine.
| Modifier and Type | Field and Description |
|---|---|
| private static final JexlEngine | DEFAULT_ENGINE
The JEXL engine singleton instance. |
| Access | Constructor and Description |
|---|---|
| private |
| DEFAULT_ENGINE | back to summary |
|---|---|
| private static final JexlEngine DEFAULT_ENGINE The JEXL engine singleton instance. | |
| EngineSingletonHolder | back to summary |
|---|---|
| private EngineSingletonHolder() non instantiable. | |
| Modifier and Type | Field and Description |
|---|---|
| private static final JexlScriptEngineFactory | DEFAULT_FACTORY
The engine factory singleton instance. |
| Access | Constructor and Description |
|---|---|
| private |
| DEFAULT_FACTORY | back to summary |
|---|---|
| private static final JexlScriptEngineFactory DEFAULT_FACTORY The engine factory singleton instance. | |
| FactorySingletonHolder | back to summary |
|---|---|
| private FactorySingletonHolder() non instantiable. | |
| Modifier and Type | Field and Description |
|---|---|
| private final Script | script
The underlying Jexl expression instance. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Object | eval(final ScriptContext
A context)ScriptContext that is used in the same way as
the ScriptContext passed to the eval methods of
ScriptEngine.Implements abstract javax. CompiledScript object.
|
| public ScriptEngine | getEngine()
Implements abstract javax. ScriptEngine whose compile method created this CompiledScript.
|
| public String |
| script | back to summary |
|---|---|
| private final Script script The underlying Jexl expression instance. | |
| JexlCompiledScript | back to summary |
|---|---|
| private JexlCompiledScript(final Script theScript) Creates an instance.
| |
| eval | back to summary |
|---|---|
| public Object eval(final ScriptContext context) throws ScriptException Implements abstract javax. Doc from javax. Executes the program stored in this
| |
| getEngine | back to summary |
|---|---|
| public ScriptEngine getEngine() Implements abstract javax. Doc from javax. Returns the
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| Modifier and Type | Field and Description |
|---|---|
| private final ScriptContext | scriptContext
The wrapped script context. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Object | get(final String
the variable's name name)Implements org. |
| public boolean | has(final String
the variable's name name)Implements org. |
| public void | set(final String
the variable's name name, final Object the variable's value value)Implements org. |
| scriptContext | back to summary |
|---|---|
| private final ScriptContext scriptContext The wrapped script context. | |
| JexlContextWrapper | back to summary |
|---|---|
| private JexlContextWrapper(final ScriptContext theContext) Creates a context wrapper.
| |
| get | back to summary |
|---|---|
| public Object get(final String name) Implements org. Doc from org. Gets the value of a variable. | |
| has | back to summary |
|---|---|
| public boolean has(final String name) Implements org. Doc from org. Checks whether a variable is defined in this context. A variable may be defined with a null value; this method checks whether the value is null or if the variable is undefined.
| |
| set | back to summary |
|---|---|
| public void set(final String name, final Object value) Implements org. Doc from org. Sets the value of a variable. | |
The following properties are defined:
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public JexlEngine | Returns: the shared underlying JEXL engineGives access to the underlying JEXL engine shared between all ScriptEngine instances. |
| public PrintWriter | Returns: the engine error writerGives access to the engine scope error writer (defaults to System.err). |
| public Reader | Returns: the engine input readerGives access to the engine scope input reader (defaults to System.in). |
| public Log | |
| public PrintWriter | Returns: the engine output writerGives access to the engine scope output writer (defaults to System.out). |
| public Class |
| JexlScriptObject | back to summary |
|---|---|
| public JexlScriptObject() | |
| getEngine | back to summary |
|---|---|
| public JexlEngine getEngine() Gives access to the underlying JEXL engine shared between all ScriptEngine instances. Although this allows to manipulate various engine flags (lenient, debug, cache...) for all JexlScriptEngine instances, you probably should only do so if you are in strict control and sole user of the Jexl scripting feature.
| |
| getErr | back to summary |
|---|---|
| public PrintWriter getErr() Gives access to the engine scope error writer (defaults to System.err).
| |
| getIn | back to summary |
|---|---|
| public Reader getIn() Gives access to the engine scope input reader (defaults to System.in).
| |
| getLogger | back to summary |
|---|---|
| public Log getLogger() Gives access to the engine logger.
| |
| getOut | back to summary |
|---|---|
| public PrintWriter getOut() Gives access to the engine scope output writer (defaults to System.out).
| |
| getSystem | back to summary |
|---|---|
| public Class Gives access to System class. | |