Groovy 1.8.7

groovy.util
[Java] Class GroovyScriptEngine

java.lang.Object
  groovy.util.GroovyScriptEngine
All Implemented Interfaces:
ResourceConnector

public class GroovyScriptEngine
extends Object

Specific script engine able to reload modified scripts as well as dealing properly with dependent scripts.

Authors:
sam
Marc Palmer
Guillaume Laforge
Jochen Theodorou


Method Summary
def GroovyScriptEngine(URL[] roots)

def GroovyScriptEngine(URL[] roots, ClassLoader parentClassLoader)

def GroovyScriptEngine(String[] urls)

def GroovyScriptEngine(String[] 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)

CompilerConfiguration getConfig()

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.

protected boolean isSourceNewer(GroovyScriptEngine.ScriptCacheEntry entry)

Class loadScriptByName(String scriptName)

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.

static void main(String[] urls)

Simple testing harness for the GSE.

String run(String scriptName, String argument)

Run a script identified by name with a given binding.

Object run(String scriptName, Binding binding)

void setConfig(CompilerConfiguration config)

void setParentClassLoader(ClassLoader parentClassLoader)

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Method Detail

GroovyScriptEngine

public def GroovyScriptEngine(URL[] roots)


GroovyScriptEngine

public def GroovyScriptEngine(URL[] roots, ClassLoader parentClassLoader)


GroovyScriptEngine

public def GroovyScriptEngine(String[] urls)


GroovyScriptEngine

public def GroovyScriptEngine(String[] 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)


getConfig

public CompilerConfiguration getConfig()


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.
Returns:
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.
throws:
ResourceException
Parameters:
resourceName - name of the resource to be retrieved
Returns:
a URLConnection to the resource


isSourceNewer

protected boolean isSourceNewer(GroovyScriptEngine.ScriptCacheEntry entry)


loadScriptByName

public Class loadScriptByName(String scriptName)


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.
throws:
ResourceException if there is a problem accessing the script
throws:
ScriptException if there is a problem parsing the script
deprecated:
Parameters:
scriptName - resource name pointing to the script
parentClassLoader - the class loader to use when loading the script
Returns:
the loaded scriptName as a compiled class


main

public static void main(String[] urls)
Simple testing harness for the GSE. Enter script roots as arguments and then input script names to run them.
throws:
Exception if something goes wrong
Parameters:
urls - an array of URLs


run

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


run

public Object run(String scriptName, Binding binding)


setConfig

public void setConfig(CompilerConfiguration config)


setParentClassLoader

public void setParentClassLoader(ClassLoader parentClassLoader)


 

Copyright © 2003-2012 The Codehaus. All rights reserved.