Class JavaScriptEngine

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

    public class JavaScriptEngine
    extends java.lang.Object
    implements javax.script.ScriptEngine, javax.script.Compilable
    Script engine to compile and run a Java class on the fly.
    • Field Detail

      • context

        private javax.script.ScriptContext context
      • executionClassLoader

        private java.lang.ClassLoader executionClassLoader
    • Constructor Detail

      • JavaScriptEngine

        public JavaScriptEngine()
    • Method Detail

      • setNameStrategy

        public void setNameStrategy​(NameStrategy nameStrategy)
        Sets the name strategy used to determine the Java class name from a script.
        Parameters:
        nameStrategy - the NameStrategy to use in this script engine
      • setConstructorStrategy

        public void setConstructorStrategy​(ConstructorStrategy constructorStrategy)
        Sets the constructor strategy used to construct a Java instance of a class.
        Parameters:
        constructorStrategy - the ConstructorStrategy to use in this script engine
      • setExecutionStrategyFactory

        public void setExecutionStrategyFactory​(ExecutionStrategyFactory executionStrategyFactory)
        Sets the factory for the execution strategy used to execute a method of a class instance.
        Parameters:
        executionStrategyFactory - the ExecutionStrategyFactory to use in this script engine
      • setExecutionClassLoader

        public void setExecutionClassLoader​(java.lang.ClassLoader executionClassLoader)
        Sets the ClassLoader used to load and execute the class.
        Parameters:
        executionClassLoader - the execution ClassLoader
      • setIsolation

        public void setIsolation​(Isolation isolation)
        Sets the isolation of the script.
        Parameters:
        isolation - the Isolation
      • getContext

        public javax.script.ScriptContext getContext()
        Specified by:
        getContext in interface javax.script.ScriptEngine
      • setContext

        public void setContext​(javax.script.ScriptContext context)
        Specified by:
        setContext in interface javax.script.ScriptEngine
      • createBindings

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

        public javax.script.Bindings getBindings​(int scope)
        Specified by:
        getBindings in interface javax.script.ScriptEngine
      • setBindings

        public void setBindings​(javax.script.Bindings bindings,
                                int scope)
        Specified by:
        setBindings in interface javax.script.ScriptEngine
      • put

        public void put​(java.lang.String key,
                        java.lang.Object value)
        Specified by:
        put in interface javax.script.ScriptEngine
      • get

        public java.lang.Object get​(java.lang.String key)
        Specified by:
        get in interface javax.script.ScriptEngine
      • eval

        public java.lang.Object eval​(java.io.Reader reader)
                              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)
                              throws javax.script.ScriptException
        Specified by:
        eval in interface javax.script.ScriptEngine
        Throws:
        javax.script.ScriptException
      • 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
      • eval

        public java.lang.Object eval​(java.io.Reader reader,
                                     javax.script.Bindings bindings)
                              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.Bindings bindings)
                              throws javax.script.ScriptException
        Specified by:
        eval in interface javax.script.ScriptEngine
        Throws:
        javax.script.ScriptException
      • compile

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

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

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

        private java.lang.String readScript​(java.io.Reader reader)
                                     throws javax.script.ScriptException
        Throws:
        javax.script.ScriptException