public class GroovyScriptEngine
extends Object
implements ResourceConnector
Specific script engine able to reload modified scripts as well as dealing properly with dependent scripts.
| Constructor and description |
|---|
GroovyScriptEngine(URL[] roots)Creates a script engine rooted at the supplied URLs. |
GroovyScriptEngine(URL[] roots, ClassLoader parentClassLoader)Creates a script engine rooted at the supplied URLs. |
GroovyScriptEngine(String[] urls)Creates a script engine from string root locations. |
GroovyScriptEngine(String[] urls, ClassLoader parentClassLoader)Creates a script engine from string root locations. |
GroovyScriptEngine(String url)Creates a script engine for a single root location. |
GroovyScriptEngine(String url, ClassLoader parentClassLoader)Creates a script engine for a single root location. |
GroovyScriptEngine(ResourceConnector rc)Creates a script engine that delegates resource lookup to the supplied connector. |
GroovyScriptEngine(ResourceConnector rc, ClassLoader parentClassLoader)Creates a script engine that delegates resource lookup to the supplied connector. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public Script |
createScript(String scriptName, Binding binding)Creates a Script with a given scriptName and binding. |
|
public CompilerConfiguration |
getConfig()
|
|
protected long |
getCurrentTime()Returns the current time used for recompilation checks. |
|
public GroovyClassLoader |
getGroovyClassLoader()Returns the GroovyClassLoader associated with this script engine instance. |
|
public ClassLoader |
getParentClassLoader()Get the ClassLoader that will serve as the parent ClassLoader of the
GroovyClassLoader in which scripts will be executed. |
|
public URLConnection |
getResourceConnection(String resourceName)Get a resource connection as a URLConnection to retrieve a script
from the ResourceConnector. |
|
protected boolean |
isSourceNewer(GroovyScriptEngine.ScriptCacheEntry entry)Determines whether a cached script or one of its dependencies should be recompiled. |
|
public Class |
loadScriptByName(String scriptName)Get the class of the scriptName in question, so that you can instantiate Groovy objects with caching and reloading. |
|
public static void |
main(String[] urls)Simple testing harness for the GSE. |
|
public String |
run(String scriptName, String argument)Run a script identified by name with a single argument. |
|
public Object |
run(String scriptName, Binding binding)Run a script identified by name with a given binding. |
|
public void |
setConfig(CompilerConfiguration config)sets a compiler configuration |
Creates a script engine rooted at the supplied URLs.
roots - script root URLsCreates a script engine rooted at the supplied URLs.
roots - script root URLsparentClassLoader - parent class loader for compiled scriptsCreates a script engine from string root locations.
urls - script root URLs or file pathsCreates a script engine from string root locations.
urls - script root URLs or file pathsparentClassLoader - parent class loader for compiled scriptsCreates a script engine for a single root location.
url - script root URL or file pathCreates a script engine for a single root location.
url - script root URL or file pathparentClassLoader - parent class loader for compiled scriptsCreates a script engine that delegates resource lookup to the supplied connector.
rc - resource connector used to resolve scriptsCreates a script engine that delegates resource lookup to the supplied connector.
rc - resource connector used to resolve scriptsparentClassLoader - parent class loader for compiled scriptsCreates a Script with a given scriptName and binding.
scriptName - name of the script to runbinding - the binding to pass to the script
Returns the current time used for recompilation checks.
Returns the GroovyClassLoader associated with this script engine instance. Useful if you need to pass the class loader to another library.
Get the ClassLoader that will serve as the parent ClassLoader of the
GroovyClassLoader in which scripts will be executed. By default, this is the
ClassLoader that loaded the GroovyScriptEngine class.
Get a resource connection as a URLConnection to retrieve a script
from the ResourceConnector.
resourceName - name of the resource to be retrievedDetermines whether a cached script or one of its dependencies should be recompiled.
entry - the cached script entrytrue if recompilation is requiredGet the class of the scriptName in question, so that you can instantiate Groovy objects with caching and reloading.
scriptName - resource name pointing to the scriptSimple testing harness for the GSE. Enter script roots as arguments and then input script names to run them.
urls - an array of URLsRun a script identified by name with a single argument.
scriptName - name of the script to runargument - a single argument passed as a variable named arg in the bindingtoString() representation of the result of the execution of the scriptRun a script identified by name with a given binding.
scriptName - name of the script to runbinding - the binding to pass to the scriptsets a compiler configuration
config - - the compiler configurationCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.