spring-framework / org.springframework.scripting.support / StandardScriptEvaluator

StandardScriptEvaluator

open class StandardScriptEvaluator : ScriptEvaluator, BeanClassLoaderAware

javax.script (JSR-223) based implementation of Spring's ScriptEvaluator strategy interface.

Author
Juergen Hoeller

Author
Costin Leau

Since
4.0

See Also
ScriptEngine#eval(String)

Constructors

<init>

StandardScriptEvaluator()

Construct a new StandardScriptEvaluator.

StandardScriptEvaluator(classLoader: ClassLoader)

Construct a new StandardScriptEvaluator for the given class loader.

StandardScriptEvaluator(scriptEngineManager: ScriptEngineManager)

Construct a new StandardScriptEvaluator for the given JSR-223 ScriptEngineManager to obtain script engines from.

Functions

evaluate

open fun evaluate(script: ScriptSource): Any
open fun evaluate(script: ScriptSource, argumentBindings: MutableMap<String, Any>): Any

setBeanClassLoader

open fun setBeanClassLoader(classLoader: ClassLoader): Unit

setEngineName

open fun setEngineName(engineName: String): Unit

Set the name of the script engine for evaluating the scripts (e.g. "Groovy"), as exposed by the JSR-223 script engine factory.

setGlobalBindings

open fun setGlobalBindings(globalBindings: MutableMap<String, Any>): Unit

Set the globally scoped bindings on the underlying script engine manager, shared by all scripts, as an alternative to script argument bindings.

setLanguage

open fun setLanguage(language: String): Unit

Set the name of the language meant for evaluating the scripts (e.g. "Groovy").

This is effectively an alias for "engineName", potentially (but not yet) providing common abbreviations for certain languages beyond what the JSR-223 script engine factory exposes.