public class GroovyScriptEngine extends java.lang.Object implements ResourceConnector
Constructor and Description |
---|
GroovyScriptEngine(ResourceConnector rc) |
GroovyScriptEngine(ResourceConnector rc,
java.lang.ClassLoader parentClassLoader) |
GroovyScriptEngine(java.lang.String url) |
GroovyScriptEngine(java.lang.String[] urls) |
GroovyScriptEngine(java.lang.String[] urls,
java.lang.ClassLoader parentClassLoader) |
GroovyScriptEngine(java.lang.String url,
java.lang.ClassLoader parentClassLoader) |
GroovyScriptEngine(java.net.URL[] roots)
The groovy script engine will run groovy scripts and reload them and
their dependencies when they are modified.
|
GroovyScriptEngine(java.net.URL[] roots,
java.lang.ClassLoader parentClassLoader) |
Modifier and Type | Method and Description |
---|---|
java.lang.ClassLoader |
getParentClassLoader()
Get the
ClassLoader that will serve as the parent ClassLoader of the
GroovyClassLoader in which scripts will be executed. |
java.net.URLConnection |
getResourceConnection(java.lang.String resourceName)
Get a resource connection as a
URLConnection to retrieve a script
from the ResourceConnector |
java.lang.Class |
loadScriptByName(java.lang.String scriptName)
Get the class of the scriptName in question, so that you can instantiate Groovy objects with caching and reloading.
|
java.lang.Class |
loadScriptByName(java.lang.String scriptName,
java.lang.ClassLoader parentClassLoader)
Deprecated.
|
static void |
main(java.lang.String[] urls)
Simple testing harness for the GSE.
|
java.lang.Object |
run(java.lang.String scriptName,
Binding binding)
Run a script identified by name.
|
java.lang.String |
run(java.lang.String scriptName,
java.lang.String argument)
Run a script identified by name.
|
void |
setParentClassLoader(java.lang.ClassLoader parentClassLoader)
Deprecated.
|
public GroovyScriptEngine(java.net.URL[] roots)
roots
- This an array of URLs where Groovy scripts will be stored. They should
be layed out using their package structure like Java classespublic GroovyScriptEngine(java.net.URL[] roots, java.lang.ClassLoader parentClassLoader)
public GroovyScriptEngine(java.lang.String[] urls) throws java.io.IOException
java.io.IOException
public GroovyScriptEngine(java.lang.String[] urls, java.lang.ClassLoader parentClassLoader) throws java.io.IOException
java.io.IOException
public GroovyScriptEngine(java.lang.String url) throws java.io.IOException
java.io.IOException
public GroovyScriptEngine(java.lang.String url, java.lang.ClassLoader parentClassLoader) throws java.io.IOException
java.io.IOException
public GroovyScriptEngine(ResourceConnector rc)
public GroovyScriptEngine(ResourceConnector rc, java.lang.ClassLoader parentClassLoader)
public static void main(java.lang.String[] urls) throws java.lang.Exception
urls
- array of URLsjava.lang.Exception
public java.net.URLConnection getResourceConnection(java.lang.String resourceName) throws ResourceException
URLConnection
to retrieve a script
from the ResourceConnector
getResourceConnection
in interface ResourceConnector
resourceName
- name of the resource to be retrievedResourceException
public java.lang.ClassLoader getParentClassLoader()
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.public void setParentClassLoader(java.lang.ClassLoader parentClassLoader)
parentClassLoader
- ClassLoader to be used as the parent ClassLoader for scripts executed by the enginepublic java.lang.Class loadScriptByName(java.lang.String scriptName) throws ResourceException, ScriptException
scriptName
- ResourceException
ScriptException
public java.lang.Class loadScriptByName(java.lang.String scriptName, java.lang.ClassLoader parentClassLoader) throws ResourceException, ScriptException
scriptName
- ResourceException
ScriptException
public java.lang.String run(java.lang.String scriptName, java.lang.String argument) throws ResourceException, ScriptException
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 scriptResourceException
ScriptException
public java.lang.Object run(java.lang.String scriptName, Binding binding) throws ResourceException, ScriptException
scriptName
- name of the script to runbinding
- binding to pass to the scriptResourceException
ScriptException