public class GroovyCodeSource
extends Object
CodeSource wrapper class that allows specific security policies to be associated with a class compiled from groovy source.
| Constructor and description |
|---|
GroovyCodeSource(String script, String name, String codeBase)Creates a code source from script text with an explicit logical name and code base. |
GroovyCodeSource(Reader reader, String name, String codeBase)Construct a GroovyCodeSource for an inputStream of groovyCode that has an unknown provenance -- meaning it didn't come from a File or a URL (e.g. a String). |
GroovyCodeSource(File infile, String encoding)Creates a code source from a Groovy source file. |
GroovyCodeSource(File infile)
|
GroovyCodeSource(URI uri)Creates a code source from the Groovy source available at the supplied URI. |
GroovyCodeSource(URL url)Creates a code source from the Groovy source available at the supplied URL. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public boolean |
equals(Object o){@inheritDoc} |
|
public CodeSource |
getCodeSource()Returns the CodeSource associated with compiled script classes. |
|
public File |
getFile()Returns the backing file when this code source was created from a file. |
|
public String |
getName()Returns the logical name used for the script. |
|
public String |
getScriptText()Returns the Groovy source text. |
|
public URL |
getURL()Returns the backing URL when this code source was created from a URL. |
|
public int |
hashCode(){@inheritDoc} |
|
public boolean |
isCachable()Indicates whether classes compiled from this source may be cached. |
|
public void |
setCachable(boolean b)Controls whether classes compiled from this source may be cached by GroovyClassLoader. |
Creates a code source from script text with an explicit logical name and code base.
script - the Groovy source textname - the logical script namecodeBase - the code base used to create the backing CodeSourceConstruct a GroovyCodeSource for an inputStream of groovyCode that has an unknown provenance -- meaning it didn't come from a File or a URL (e.g. a String). The supplied codeBase will be used to construct a File URL that should match up with a java Policy entry that determines the grants to be associated with the class that will be built from the InputStream.
The permission groovy.security.GroovyCodeSourcePermission will be used to determine if the given codeBase may be specified. That is, the current Policy set must have a GroovyCodeSourcePermission that implies the codeBase, or an exception will be thrown. This is to prevent callers from hijacking existing codeBase policy entries unless explicitly authorized by the user.
Creates a code source from a Groovy source file.
infile - the source fileencoding - the character encoding used to read the file, or null for the default handlinginfile - the file to create a GroovyCodeSource for.Creates a code source from the Groovy source available at the supplied URI.
uri - the source URICreates a code source from the Groovy source available at the supplied URL.
url - the source URL{@inheritDoc}
Returns the CodeSource associated with compiled script classes.
Returns the backing file when this code source was created from a file.
null if this source does not originate from a fileReturns the logical name used for the script.
Returns the Groovy source text.
Returns the backing URL when this code source was created from a URL.
null if this source does not originate from a URL{@inheritDoc}
Indicates whether classes compiled from this source may be cached.
true if the source is cacheableControls whether classes compiled from this source may be cached by GroovyClassLoader.
b - true to allow caching, false otherwiseCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.