Class JexlScriptEngine

  • All Implemented Interfaces:
    javax.script.Compilable, javax.script.ScriptEngine

    public class JexlScriptEngine
    extends javax.script.AbstractScriptEngine
    implements javax.script.Compilable
    Implements the Jexl ScriptEngine for JSF-223.

    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.

    See Java Scripting API Javadoc.
    Since:
    2.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  JexlScriptEngine.JexlScriptObject
      Implements engine and engine context properties for use by JEXL scripts.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      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.
      • Fields inherited from class javax.script.AbstractScriptEngine

        context
      • Fields inherited from interface javax.script.ScriptEngine

        ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME
    • Constructor Summary

      Constructors 
      Constructor Description
      JexlScriptEngine()
      Default constructor.
      JexlScriptEngine​(javax.script.ScriptEngineFactory factory)
      Create a scripting engine using the supplied factory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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()
      • Methods inherited from class javax.script.AbstractScriptEngine

        eval, eval, eval, eval, get, getBindings, getContext, getScriptContext, put, setBindings, setContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JexlScriptEngine

        public JexlScriptEngine​(javax.script.ScriptEngineFactory factory)
        Create a scripting engine using the supplied factory.
        Parameters:
        factory - the factory which created this instance.
        Throws:
        java.lang.NullPointerException - if factory is null
    • Method Detail

      • createBindings

        public javax.script.Bindings createBindings()
        Specified by:
        createBindings in interface javax.script.ScriptEngine
      • eval

        public java.lang.Object eval​(java.io.Reader reader,
                                     javax.script.ScriptContext context)
                              throws javax.script.ScriptException
        Specified by:
        eval in interface javax.script.ScriptEngine
        Throws:
        javax.script.ScriptException
      • eval

        public java.lang.Object eval​(java.lang.String script,
                                     javax.script.ScriptContext context)
                              throws javax.script.ScriptException
        Specified by:
        eval in interface javax.script.ScriptEngine
        Throws:
        javax.script.ScriptException
      • getFactory

        public javax.script.ScriptEngineFactory getFactory()
        Specified by:
        getFactory in interface javax.script.ScriptEngine
      • compile

        public javax.script.CompiledScript compile​(java.lang.String script)
                                            throws javax.script.ScriptException
        Specified by:
        compile in interface javax.script.Compilable
        Throws:
        javax.script.ScriptException
      • compile

        public javax.script.CompiledScript compile​(java.io.Reader script)
                                            throws javax.script.ScriptException
        Specified by:
        compile in interface javax.script.Compilable
        Throws:
        javax.script.ScriptException