groovy.util
Class ScriptCacheEntry

Field Summary
 Map dependencies
           
 long lastModified
           
 Class scriptClass
           
 
Constructor Summary
ScriptCacheEntry()
           
 
Method Summary
def GroovyScriptEngine(def roots)
           The groovy script engine will run groovy scripts and reload them and their dependencies when they are modified.
def GroovyScriptEngine(def roots, ClassLoader parentClassLoader)
          
def GroovyScriptEngine(def urls)
          
def GroovyScriptEngine(def urls, ClassLoader parentClassLoader)
          
def GroovyScriptEngine(String url)
          
def GroovyScriptEngine(String url, ClassLoader parentClassLoader)
          
def GroovyScriptEngine(ResourceConnector rc)
          
def GroovyScriptEngine(ResourceConnector rc, ClassLoader parentClassLoader)
          
Script createScript(String scriptName, Binding binding)
           Creates a Script with a given scriptName and binding.
boolean dependencyOutOfDate(ScriptCacheEntry entry)
          
GroovyClassLoader getGroovyClassLoader()
           Returns the GroovyClassLoader associated with this script engine instance.
ClassLoader getParentClassLoader()
          
URLConnection getResourceConnection(String resourceName)
           Get a resource connection as a URLConnection to retrieve a script from the ResourceConnector.
void initGroovyLoader(ClassLoader parentClassLoader)
           Initialize a new GroovyClassLoader with the parentClassLoader passed as a parameter.
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)
           Get the class of the scriptName in question, so that you can instantiate Groovy objects with caching and reloading.
String run(String scriptName, String argument)
           Run a script identified by name with a single argument.
Object run(String scriptName, Binding binding)
           Run a script identified by name with a given binding.
void setParentClassLoader(ClassLoader parentClassLoader)
          
ScriptCacheEntry updateCacheEntry(String scriptName)
           Locate the class and reload it or any of its dependencies
 

Constructor Detail

ScriptCacheEntry

ScriptCacheEntry()


Method Detail

GroovyScriptEngine

public def GroovyScriptEngine(def roots)
The groovy script engine will run groovy scripts and reload them and their dependencies when they are modified. This is useful for embedding groovy in other containers like games and application servers.
param:
roots This an array of URLs where Groovy scripts will be stored. They should
be layed out using their package structure like Java classes


GroovyScriptEngine

public def GroovyScriptEngine(def roots, ClassLoader parentClassLoader)


GroovyScriptEngine

public def GroovyScriptEngine(def urls)


GroovyScriptEngine

public def GroovyScriptEngine(def urls, ClassLoader parentClassLoader)


GroovyScriptEngine

public def GroovyScriptEngine(String url)


GroovyScriptEngine

public def GroovyScriptEngine(String url, ClassLoader parentClassLoader)


GroovyScriptEngine

public def GroovyScriptEngine(ResourceConnector rc)


GroovyScriptEngine

public def GroovyScriptEngine(ResourceConnector rc, ClassLoader parentClassLoader)


createScript

public Script createScript(String scriptName, Binding binding)
Creates a Script with a given scriptName and binding.
param:
scriptName name of the script to run
param:
binding the binding to pass to the script
return:
the script object
throws:
ResourceException if there is a problem accessing the script
throws:
ScriptException if there is a problem parsing the script


dependencyOutOfDate

boolean dependencyOutOfDate(ScriptCacheEntry entry)


getGroovyClassLoader

public GroovyClassLoader getGroovyClassLoader()
Returns the GroovyClassLoader associated with this script engine instance. Useful if you need to pass the class loader to another library.
return:
the GroovyClassLoader


getParentClassLoader

public ClassLoader getParentClassLoader()


getResourceConnection

public URLConnection getResourceConnection(String resourceName)
Get a resource connection as a URLConnection to retrieve a script from the ResourceConnector.
param:
resourceName name of the resource to be retrieved
return:
a URLConnection to the resource
throws:
ResourceException


initGroovyLoader

void initGroovyLoader(ClassLoader parentClassLoader)
Initialize a new GroovyClassLoader with the parentClassLoader passed as a parameter. A GroovyScriptEngine should only use one GroovyClassLoader but since in version prior to 1.0-RC-01 you could set a new parentClassLoader Ultimately groovyLoader should be final and only set in the constructor
param:
parentClassLoader the class loader to use


loadScriptByName

public Class loadScriptByName(String scriptName)
Get the class of the scriptName in question, so that you can instantiate Groovy objects with caching and reloading.
param:
scriptName resource name pointing to the script
return:
the loaded scriptName as a compiled class
throws:
ResourceException if there is a problem accessing the script
throws:
ScriptException if there is a problem parsing the script


loadScriptByName

public Class loadScriptByName(String scriptName, ClassLoader parentClassLoader)
Get the class of the scriptName in question, so that you can instantiate Groovy objects with caching and reloading.
param:
scriptName resource name pointing to the script
param:
parentClassLoader the class loader to use when loading the script
return:
the loaded scriptName as a compiled class
throws:
ResourceException if there is a problem accessing the script
throws:
ScriptException if there is a problem parsing the script
deprecated:


run

public String run(String scriptName, String argument)
Run a script identified by name with a single argument.
param:
scriptName name of the script to run
param:
argument a single argument passed as a variable named arg in the binding
return:
a toString() representation of the result of the execution of the script
throws:
ResourceException if there is a problem accessing the script
throws:
ScriptException if there is a problem parsing the script


run

public Object run(String scriptName, Binding binding)
Run a script identified by name with a given binding.
param:
scriptName name of the script to run
param:
binding the binding to pass to the script
return:
an object
throws:
ResourceException if there is a problem accessing the script
throws:
ScriptException if there is a problem parsing the script


setParentClassLoader

public void setParentClassLoader(ClassLoader parentClassLoader)
param:
parentClassLoader ClassLoader to be used as the parent ClassLoader for scripts executed by the engine
deprecated:


updateCacheEntry

ScriptCacheEntry updateCacheEntry(String scriptName)
Locate the class and reload it or any of its dependencies
param:
scriptName resource name pointing to the script
return:
the cache entry for scriptName
throws:
ResourceException if there is a problem accessing the script
throws:
ScriptException if there is a problem parsing the script