public class GroovyScriptEngine extends Object
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Type | Name and description |
---|---|
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) Creates a Script with a given scriptName and binding. |
CompilerConfiguration |
getConfig() @return a non null compiler configuration |
protected long |
getCurrentTime() |
GroovyClassLoader |
getGroovyClassLoader() Returns the GroovyClassLoader associated with this script engine instance. |
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 . |
protected boolean |
isSourceNewer(GroovyScriptEngine.ScriptCacheEntry entry) |
Class |
loadScriptByName(String scriptName) 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 single argument. |
Object |
run(String scriptName, Binding binding) Run a script identified by name with a given binding. |
void |
setConfig(CompilerConfiguration config) sets a compiler configuration |
Creates a Script with a given scriptName and binding.
scriptName
- name of the script to runbinding
- the binding to pass to the script
Returns the GroovyClassLoader associated with this script engine instance. Useful if you need to pass the class loader to another library.
Get the 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.
Get a resource connection as a URLConnection
to retrieve a script
from the ResourceConnector
.
resourceName
- name of the resource to be retrievedGet the class of the scriptName in question, so that you can instantiate Groovy objects with caching and reloading.
scriptName
- resource name pointing to the scriptSimple testing harness for the GSE. Enter script roots as arguments and then input script names to run them.
urls
- an array of URLsRun a script identified by name with a single argument.
scriptName
- name of the script to runargument
- a single argument passed as a variable named arg
in the bindingtoString()
representation of the result of the execution of the scriptRun a script identified by name with a given binding.
scriptName
- name of the script to runbinding
- the binding to pass to the scriptsets a compiler configuration
config
- - the compiler configuration