|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovy.util.GroovyScriptEngine
public class GroovyScriptEngine
Specific script engine able to reload modified scripts as well as dealing properly with dependent scripts.
Constructor Summary | |
---|---|
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)
|
|
GroovyScriptEngine(java.net.URL[] roots,
java.lang.ClassLoader parentClassLoader)
|
Method Summary | |
---|---|
Script |
createScript(java.lang.String scriptName,
Binding binding)
Creates a Script with a given scriptName and binding. |
CompilerConfiguration |
getConfig()
|
GroovyClassLoader |
getGroovyClassLoader()
Returns the GroovyClassLoader associated with this script engine instance. |
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 . |
protected boolean |
isSourceNewer(groovy.util.GroovyScriptEngine.ScriptCacheEntry entry)
|
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. |
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 with a given binding. |
java.lang.String |
run(java.lang.String scriptName,
java.lang.String argument)
Run a script identified by name with a single argument. |
void |
setConfig(CompilerConfiguration config)
sets a compiler configuration |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GroovyScriptEngine(java.net.URL[] roots)
public 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)
Method Detail |
---|
public static void main(java.lang.String[] urls) throws java.lang.Exception
urls
- an array of URLs
java.lang.Exception
- if something goes wrongpublic 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 retrieved
ResourceException
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 java.lang.Class loadScriptByName(java.lang.String scriptName) throws ResourceException, ScriptException
scriptName
- resource name pointing to the script
ResourceException
- if there is a problem accessing the script
ScriptException
- if there is a problem parsing the scriptpublic 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 binding
toString()
representation of the result of the execution of the script
ResourceException
- if there is a problem accessing the script
ScriptException
- if there is a problem parsing the scriptpublic java.lang.Object run(java.lang.String scriptName, Binding binding) throws ResourceException, ScriptException
scriptName
- name of the script to runbinding
- the binding to pass to the script
ResourceException
- if there is a problem accessing the script
ScriptException
- if there is a problem parsing the scriptpublic Script createScript(java.lang.String scriptName, Binding binding) throws ResourceException, ScriptException
scriptName
- name of the script to runbinding
- the binding to pass to the script
ResourceException
- if there is a problem accessing the script
ScriptException
- if there is a problem parsing the scriptprotected boolean isSourceNewer(groovy.util.GroovyScriptEngine.ScriptCacheEntry entry) throws ResourceException
ResourceException
public GroovyClassLoader getGroovyClassLoader()
public CompilerConfiguration getConfig()
public void setConfig(CompilerConfiguration config)
config
- - the compiler configuration
java.lang.NullPointerException
- if config is null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |