Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## groovy.util
[Java] Class GroovyScriptEngine

    java.lang.Object
      groovy.util.GroovyScriptEngine

All Implemented Interfaces:
  ResourceConnector

    public class GroovyScriptEngine
    extends java.lang.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
`java.lang.Object` | `GroovyScriptEngine(java.net.URL[] roots)`
`java.lang.Object` | `GroovyScriptEngine(java.net.URL[] roots, java.lang.ClassLoader parentClassLoader)`
`java.lang.Object` | `GroovyScriptEngine(java.lang.String[] urls)`
`java.lang.Object` | `GroovyScriptEngine(java.lang.String[] urls, java.lang.ClassLoader parentClassLoader)`
`java.lang.Object` | `GroovyScriptEngine(java.lang.String url)`
`java.lang.Object` | `GroovyScriptEngine(java.lang.String url, java.lang.ClassLoader parentClassLoader)`
`java.lang.Object` | `GroovyScriptEngine(ResourceConnector rc)`
`java.lang.Object` | `GroovyScriptEngine(ResourceConnector rc, java.lang.ClassLoader parentClassLoader)`
`Script` | `createScript(java.lang.String scriptName, Binding binding)`
`CompilerConfiguration` | `getConfig()`
`GroovyClassLoader` | `getGroovyClassLoader()` Returns the GroovyClassLoader associated with this script engine instance.
`java.lang.ClassLoader` | `getParentClassLoader()`
`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(GroovyScriptEngine.ScriptCacheEntry entry)`
`java.lang.Class` | `loadScriptByName(java.lang.String scriptName)`
`static void` | `main(java.lang.String[] urls)` Simple testing harness for the GSE.
`java.lang.String` | `run(java.lang.String scriptName, java.lang.String argument)` Run a script identified by name with a single argument.
`java.lang.Object` | `run(java.lang.String scriptName, Binding binding)`
`void` | `setConfig(CompilerConfiguration config)`

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Method Detail

### GroovyScriptEngine

    public java.lang.Object GroovyScriptEngine(java.net.URL[] roots)

### GroovyScriptEngine

    public java.lang.Object GroovyScriptEngine(java.net.URL[] roots, java.lang.ClassLoader parentClassLoader)

### GroovyScriptEngine

    public java.lang.Object GroovyScriptEngine(java.lang.String[] urls)

### GroovyScriptEngine

    public java.lang.Object GroovyScriptEngine(java.lang.String[] urls, java.lang.ClassLoader parentClassLoader)

### GroovyScriptEngine

    public java.lang.Object GroovyScriptEngine(java.lang.String url)

### GroovyScriptEngine

    public java.lang.Object GroovyScriptEngine(java.lang.String url, java.lang.ClassLoader parentClassLoader)

### GroovyScriptEngine

    public java.lang.Object GroovyScriptEngine(ResourceConnector rc)

### GroovyScriptEngine

    public java.lang.Object GroovyScriptEngine(ResourceConnector rc, java.lang.ClassLoader parentClassLoader)

### createScript

    public Script createScript(java.lang.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 java.lang.ClassLoader getParentClassLoader()

### getResourceConnection

    public java.net.URLConnection getResourceConnection(java.lang.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 java.lang.Class loadScriptByName(java.lang.String scriptName)

### main

    public static void main(java.lang.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 java.lang.String run(java.lang.String scriptName, java.lang.String argument)

  Run a script identified by name with a single argument.
  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
    `argument` - a single argument passed as a variable named `arg` in the binding
  Returns:
    a `toString()` representation of the result of the execution of the script

### run

    public java.lang.Object run(java.lang.String scriptName, Binding binding)

### setConfig

    public void setConfig(CompilerConfiguration config)

Groovy Documentation