public class GroovyScriptEngineImpl
extends AbstractScriptEngine
implements Compilable, Invocable
JSR-223 Engine implementation. Adapted from original by Mike Grogan and A. Sundararajan
| Fields inherited from class | Fields |
|---|---|
class AbstractScriptEngine |
ARGV, FILENAME, ENGINE, ENGINE_VERSION, NAME, LANGUAGE, LANGUAGE_VERSION |
| Constructor and description |
|---|
GroovyScriptEngineImpl()Creates an engine backed by a default GroovyClassLoader. |
GroovyScriptEngineImpl(GroovyClassLoader classLoader)Creates an engine backed by the supplied class loader. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public CompiledScript |
compile(String scriptSource)Compiles Groovy source into a reusable CompiledScript. |
|
public CompiledScript |
compile(Reader reader)Reads and compiles Groovy source from the supplied reader. |
|
public Bindings |
createBindings()Creates a mutable bindings instance suitable for engine-scope variables. |
|
public Object |
eval(Reader reader, ScriptContext ctx)Reads the supplied script source and evaluates it against the given context. |
|
public Object |
eval(String script, ScriptContext ctx)Evaluates Groovy source within the supplied script context. |
|
public GroovyClassLoader |
getClassLoader()Returns the class loader currently used for script compilation. |
|
public ScriptEngineFactory |
getFactory()Returns the factory associated with this engine, creating one lazily if necessary. |
<T> |
public T |
getInterface(Class<T> clazz)Creates a dynamic proxy that dispatches interface method calls to global functions. |
<T> |
public T |
getInterface(Object thiz, Class<T> clazz)Creates a dynamic proxy that dispatches interface method calls to the supplied object. |
|
public Object |
invokeFunction(String name, Object args)Invokes a previously defined global function by name. |
|
public Object |
invokeMethod(Object thiz, String name, Object args)Invokes a method on a script object or other Groovy object. |
|
public void |
setClassLoader(GroovyClassLoader classLoader)Replaces the class loader used for future script compilation. |
| Methods inherited from class | Name |
|---|---|
class AbstractScriptEngine |
createBindings, equals, eval, eval, eval, eval, eval, eval, get, getBindings, getClass, getContext, getFactory, hashCode, notify, notifyAll, put, setBindings, setContext, toString, wait, wait, wait |
Creates an engine backed by a default GroovyClassLoader.
Creates an engine backed by the supplied class loader.
classLoader is nullclassLoader - the class loader used to parse and load generated script classesCompiles Groovy source into a reusable CompiledScript.
scriptSource - the source to compilescriptSourceReads and compiles Groovy source from the supplied reader.
reader - the reader providing script sourceCreates a mutable bindings instance suitable for engine-scope variables.
Reads the supplied script source and evaluates it against the given context.
reader - the reader providing script sourcectx - the execution context to useEvaluates Groovy source within the supplied script context.
If #jsr223.groovy.engine.keep.globals is present in engine scope, its value controls
the reference strength used for cached global closures.
script - the script source to executectx - the execution context to useReturns the class loader currently used for script compilation.
Returns the factory associated with this engine, creating one lazily if necessary.
Creates a dynamic proxy that dispatches interface method calls to global functions.
clazz is null or not an interfaceclazz - the interface to implementT - the proxy typeCreates a dynamic proxy that dispatches interface method calls to the supplied object.
thiz is null, or if clazz is null
or not an interfacethiz - the target object that should receive method callsclazz - the interface to implementT - the proxy typethizInvokes a previously defined global function by name.
name - the global function nameargs - the arguments to pass to the functionInvokes a method on a script object or other Groovy object.
thiz is nullthiz - the target objectname - the method nameargs - the arguments to pass to the methodReplaces the class loader used for future script compilation.
classLoader - the class loader to use for subsequent compilationsCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.