|
|||||||||
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,
ClassLoader parentClassLoader)
|
|
GroovyScriptEngine(String url)
|
|
GroovyScriptEngine(String[] urls)
|
|
GroovyScriptEngine(String[] urls,
ClassLoader parentClassLoader)
|
|
GroovyScriptEngine(String url,
ClassLoader parentClassLoader)
|
|
GroovyScriptEngine(URL[] roots)
The groovy script engine will run groovy scripts and reload them and their dependencies when they are modified. |
|
GroovyScriptEngine(URL[] roots,
ClassLoader parentClassLoader)
|
Method Summary | |
---|---|
Script |
createScript(Binding binding,
groovy.util.GroovyScriptEngine.ScriptCacheEntry entry)
Creates a Script object given a cache entry object and a binding. |
ClassLoader |
getParentClassLoader()
Get the ClassLoader that will serve as the parent ClassLoader of the
GroovyClassLoader in which scripts will be executed. |
URLConnection |
getResourceConnection(String resourceName)
Get a resource connection as a URLConnection to retrieve a script
from the ResourceConnector |
Class |
loadScriptByName(String scriptName)
Get the class of the scriptName in question, so that you can instantiate Groovy objects with caching and reloading. |
Class |
loadScriptByName(String scriptName,
ClassLoader parentClassLoader)
Deprecated. |
static void |
main(String[] urls)
Simple testing harness for the GSE. |
Object |
run(String scriptName,
Binding binding)
Run a script identified by name with a given binding. |
String |
run(String scriptName,
String argument)
Run a script identified by name with a single argument. |
void |
setParentClassLoader(ClassLoader parentClassLoader)
Deprecated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GroovyScriptEngine(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(URL[] roots, ClassLoader parentClassLoader)
public GroovyScriptEngine(String[] urls) throws IOException
IOException
public GroovyScriptEngine(String[] urls, ClassLoader parentClassLoader) throws IOException
IOException
public GroovyScriptEngine(String url) throws IOException
IOException
public GroovyScriptEngine(String url, ClassLoader parentClassLoader) throws IOException
IOException
public GroovyScriptEngine(ResourceConnector rc)
public GroovyScriptEngine(ResourceConnector rc, ClassLoader parentClassLoader)
Method Detail |
---|
public static void main(String[] urls) throws Exception
urls
- an array of URLs
Exception
- if something goes wrongpublic URLConnection getResourceConnection(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 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(ClassLoader parentClassLoader)
parentClassLoader
- ClassLoader to be used as the parent ClassLoader for scripts executed by the enginepublic Class loadScriptByName(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 Class loadScriptByName(String scriptName, ClassLoader parentClassLoader) throws ResourceException, ScriptException
scriptName
- resource name pointing to the scriptparentClassLoader
- the class loader to use when loading the script
ResourceException
- if there is a problem accessing the script
ScriptException
- if there is a problem parsing the scriptpublic String run(String scriptName, 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 Object run(String scriptName, Binding binding) throws ResourceException, ScriptException
scriptName
- name of the script to runbinding
- 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(Binding binding, groovy.util.GroovyScriptEngine.ScriptCacheEntry entry)
binding
- the binding to useentry
- the script cache entry
|
Copyright © 2003-2008 The Codehaus. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |