|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.ClassLoader java.security.SecureClassLoader java.net.URLClassLoader groovy.lang.GroovyClassLoader
public class GroovyClassLoader extends java.net.URLClassLoader
A ClassLoader which can load Groovy classes. The loaded classes are cached, classes from other classloaders should not be cached. To be able to load a script that was asked for earlier but was created later it is essential not to keep anything like a "class not found" information for that class name. This includes possible parent loaders. Classes that are not cached are always reloaded.
Nested Class Summary | |
---|---|
static class |
GroovyClassLoader.ClassCollector
|
static class |
GroovyClassLoader.InnerLoader
|
Field Summary | |
---|---|
protected java.util.Map |
classCache
this cache contains the loaded classes or PARSING, if the class is currently parsed |
protected java.util.Map |
sourceCache
This cache contains mappings of file name to class. |
Constructor Summary | |
GroovyClassLoader()
creates a GroovyClassLoader using the current Thread's context Class loader as parent. |
|
GroovyClassLoader(java.lang.ClassLoader loader)
creates a GroovyClassLoader using the given ClassLoader as parent |
|
GroovyClassLoader(GroovyClassLoader parent)
creates a GroovyClassLoader using the given GroovyClassLoader as parent. |
|
GroovyClassLoader(java.lang.ClassLoader parent, CompilerConfiguration config, boolean useConfigurationClasspath)
creates a GroovyClassLoader. |
|
GroovyClassLoader(java.lang.ClassLoader loader, CompilerConfiguration config)
creates a GroovyClassLoader using the given ClassLoader as parent. |
Method Summary | |
---|---|
void
|
addClasspath(java.lang.String path)
|
void
|
addURL(java.net.URL url)
|
void
|
clearCache()
|
protected GroovyClassLoader.ClassCollector
|
createCollector(CompilationUnit unit, SourceUnit su)
|
protected CompilationUnit
|
createCompilationUnit(CompilerConfiguration config, java.security.CodeSource source)
|
java.lang.Class
|
defineClass(ClassNode classNode, java.lang.String file, java.lang.String newCodeBase)
Loads the given class node returning the implementation Class. |
java.lang.Class
|
defineClass(java.lang.String name, byte[] b)
|
java.lang.String
|
generateScriptName()
|
protected java.lang.Class
|
getClassCacheEntry(java.lang.String name)
|
protected java.lang.String[]
|
getClassPath()
gets the currently used classpath. |
java.lang.Class[]
|
getLoadedClasses()
|
protected java.security.PermissionCollection
|
getPermissions(java.security.CodeSource codeSource)
|
GroovyResourceLoader
|
getResourceLoader()
|
protected long
|
getTimeStamp(java.lang.Class cls)
|
protected boolean
|
isRecompilable(java.lang.Class cls)
|
java.lang.Boolean
|
isShouldRecompile()
|
protected boolean
|
isSourceNewer(java.net.URL source, java.lang.Class cls)
adds a classpath to this classloader. |
java.lang.Class
|
loadClass(java.lang.String name, boolean lookupScriptFiles, boolean preferClassOverScript)
|
java.lang.Class
|
loadClass(java.lang.String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve)
|
protected java.lang.Class
|
loadClass(java.lang.String name, boolean resolve)
This method will take a file name and try to "decode" any URL encoded characters. |
java.lang.Class
|
parseClass(java.io.File file)
Parses the given file into a Java class capable of being run |
java.lang.Class
|
parseClass(java.lang.String text, java.lang.String fileName)
Parses the given text into a Java class capable of being run |
java.lang.Class
|
parseClass(java.lang.String text)
Parses the given text into a Java class capable of being run |
java.lang.Class
|
parseClass(java.io.InputStream in, java.lang.String fileName)
@deprecated Prefer using methods taking a Reader rather than an InputStream to avoid wrong encoding issues. |
java.lang.Class
|
parseClass(GroovyCodeSource codeSource)
|
java.lang.Class
|
parseClass(GroovyCodeSource codeSource, boolean shouldCacheSource)
|
protected java.lang.Class
|
recompile(java.net.URL source, java.lang.String className, java.lang.Class oldClass)
(Re)Compiles the given source. |
protected void
|
removeClassCacheEntry(java.lang.String name)
|
protected void
|
setClassCacheEntry(java.lang.Class cls)
|
void
|
setResourceLoader(GroovyResourceLoader resourceLoader)
|
void
|
setShouldRecompile(java.lang.Boolean mode)
sets if the recompilation should be enable. |
Methods inherited from class java.net.URLClassLoader | |
---|---|
java.net.URLClassLoader#findResource(java.lang.String), java.net.URLClassLoader#findResources(java.lang.String), java.net.URLClassLoader#newInstance([Ljava.net.URL;, java.lang.ClassLoader), java.net.URLClassLoader#newInstance([Ljava.net.URL;), java.net.URLClassLoader#getResourceAsStream(java.lang.String), java.net.URLClassLoader#close(), java.net.URLClassLoader#getURLs(), java.net.URLClassLoader#loadClass(java.lang.String), java.net.URLClassLoader#getSystemClassLoader(), java.net.URLClassLoader#getResources(java.lang.String), java.net.URLClassLoader#getSystemResources(java.lang.String), java.net.URLClassLoader#getParent(), java.net.URLClassLoader#setDefaultAssertionStatus(boolean), java.net.URLClassLoader#setPackageAssertionStatus(java.lang.String, boolean), java.net.URLClassLoader#setClassAssertionStatus(java.lang.String, boolean), java.net.URLClassLoader#clearAssertionStatus(), java.net.URLClassLoader#getResource(java.lang.String), java.net.URLClassLoader#getSystemResourceAsStream(java.lang.String), java.net.URLClassLoader#getSystemResource(java.lang.String), java.net.URLClassLoader#wait(long), java.net.URLClassLoader#wait(long, int), java.net.URLClassLoader#wait(), java.net.URLClassLoader#equals(java.lang.Object), java.net.URLClassLoader#toString(), java.net.URLClassLoader#hashCode(), java.net.URLClassLoader#getClass(), java.net.URLClassLoader#notify(), java.net.URLClassLoader#notifyAll() |
Methods inherited from class java.security.SecureClassLoader | |
---|---|
java.security.SecureClassLoader#loadClass(java.lang.String), java.security.SecureClassLoader#getSystemClassLoader(), java.security.SecureClassLoader#getResources(java.lang.String), java.security.SecureClassLoader#getSystemResources(java.lang.String), java.security.SecureClassLoader#getParent(), java.security.SecureClassLoader#setDefaultAssertionStatus(boolean), java.security.SecureClassLoader#setPackageAssertionStatus(java.lang.String, boolean), java.security.SecureClassLoader#setClassAssertionStatus(java.lang.String, boolean), java.security.SecureClassLoader#clearAssertionStatus(), java.security.SecureClassLoader#getResourceAsStream(java.lang.String), java.security.SecureClassLoader#getResource(java.lang.String), java.security.SecureClassLoader#getSystemResourceAsStream(java.lang.String), java.security.SecureClassLoader#getSystemResource(java.lang.String), java.security.SecureClassLoader#wait(long), java.security.SecureClassLoader#wait(long, int), java.security.SecureClassLoader#wait(), java.security.SecureClassLoader#equals(java.lang.Object), java.security.SecureClassLoader#toString(), java.security.SecureClassLoader#hashCode(), java.security.SecureClassLoader#getClass(), java.security.SecureClassLoader#notify(), java.security.SecureClassLoader#notifyAll() |
Field Detail |
---|
protected final java.util.Map classCache
protected final java.util.Map sourceCache
Constructor Detail |
---|
public GroovyClassLoader()
public GroovyClassLoader(java.lang.ClassLoader loader)
public GroovyClassLoader(GroovyClassLoader parent)
public GroovyClassLoader(java.lang.ClassLoader parent, CompilerConfiguration config, boolean useConfigurationClasspath)
parent
- the parent class loaderconfig
- the compiler configurationuseConfigurationClasspath
- determines if the configurations classpath should be added
public GroovyClassLoader(java.lang.ClassLoader loader, CompilerConfiguration config)
Method Detail |
---|
public void addClasspath(java.lang.String path)
Returns all Groovy classes loaded by this class loader.
public void addURL(java.net.URL url)
public void clearCache()
protected GroovyClassLoader.ClassCollector createCollector(CompilationUnit unit, SourceUnit su)
protected CompilationUnit createCompilationUnit(CompilerConfiguration config, java.security.CodeSource source)
public java.lang.Class defineClass(ClassNode classNode, java.lang.String file, java.lang.String newCodeBase)
public java.lang.Class defineClass(java.lang.String name, byte[] b)
public java.lang.String generateScriptName()
protected java.lang.Class getClassCacheEntry(java.lang.String name)
protected java.lang.String[] getClassPath()
public java.lang.Class[] getLoadedClasses()
protected java.security.PermissionCollection getPermissions(java.security.CodeSource codeSource)
public GroovyResourceLoader getResourceLoader()
protected long getTimeStamp(java.lang.Class cls)
protected boolean isRecompilable(java.lang.Class cls)
public java.lang.Boolean isShouldRecompile()
protected boolean isSourceNewer(java.net.URL source, java.lang.Class cls)
path
- is a jar file or a directory.
public java.lang.Class loadClass(java.lang.String name, boolean lookupScriptFiles, boolean preferClassOverScript)
public java.lang.Class loadClass(java.lang.String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve)
protected java.lang.Class loadClass(java.lang.String name, boolean resolve)
public java.lang.Class parseClass(java.io.File file)
file
- the file name to parse
public java.lang.Class parseClass(java.lang.String text, java.lang.String fileName)
text
- the text of the script/class to parsefileName
- the file name to use as the name of the class
public java.lang.Class parseClass(java.lang.String text)
text
- the text of the script/class to parse
public java.lang.Class parseClass(java.io.InputStream in, java.lang.String fileName)
public java.lang.Class parseClass(GroovyCodeSource codeSource)
public java.lang.Class parseClass(GroovyCodeSource codeSource, boolean shouldCacheSource)
protected java.lang.Class recompile(java.net.URL source, java.lang.String className, java.lang.Class oldClass)
source
- the source pointer for the compilationclassName
- the name of the class to be generatedoldClass
- a possible former class
protected void removeClassCacheEntry(java.lang.String name)
protected void setClassCacheEntry(java.lang.Class cls)
public void setResourceLoader(GroovyResourceLoader resourceLoader)
public void setShouldRecompile(java.lang.Boolean mode)
mode
- the recompilation mode
Groovy Documentation