groovy.lang
Class GroovyClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended bygroovy.lang.GroovyClassLoader

public class GroovyClassLoader
extends java.lang.ClassLoader

A ClassLoader which can load Groovy classes

Version:
$Revision: 1.14 $
Author:
James Strachan, Guillaume Laforge

Nested Class Summary
protected static class GroovyClassLoader.ClassCollector
           
 
Constructor Summary
GroovyClassLoader()
           
GroovyClassLoader(java.lang.ClassLoader loader)
           
GroovyClassLoader(java.lang.ClassLoader loader, CompilerConfig config)
           
GroovyClassLoader(GroovyClassLoader parent)
           
 
Method Summary
protected  GroovyClassLoader.ClassCollector createCollector(CompileUnit unit)
           
 java.lang.Class defineClass(ClassNode classNode, java.lang.String file)
          Loads the given class node returning the implementation Class
protected  java.lang.Class findClass(java.lang.String name)
          Using this classloader you can load groovy classes from the system classpath as though they were already compiled.
protected  java.lang.Class loadClass(java.lang.String name, byte[] bytecode)
          A helper method to allow bytecode to be loaded
 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.io.InputStream in)
          Parses the given character stream into a Java class capable of being run
 java.lang.Class parseClass(java.io.InputStream in, java.lang.String fileName)
          Parses the given character stream 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.lang.String text, java.lang.String fileName)
          Parses the given text into a Java class capable of being run
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroovyClassLoader

public GroovyClassLoader()

GroovyClassLoader

public GroovyClassLoader(java.lang.ClassLoader loader)

GroovyClassLoader

public GroovyClassLoader(GroovyClassLoader parent)

GroovyClassLoader

public GroovyClassLoader(java.lang.ClassLoader loader,
                         CompilerConfig config)
Method Detail

defineClass

public java.lang.Class defineClass(ClassNode classNode,
                                   java.lang.String file)
Loads the given class node returning the implementation Class

Parameters:
classNode -
Returns:

parseClass

public java.lang.Class parseClass(java.io.File file)
                           throws SyntaxException,
                                  java.io.IOException
Parses the given file into a Java class capable of being run

Parameters:
file - the file name to parse
Returns:
the main class defined in the given script
Throws:
SyntaxException
java.io.IOException

parseClass

public java.lang.Class parseClass(java.lang.String text,
                                  java.lang.String fileName)
                           throws SyntaxException,
                                  java.io.IOException
Parses the given text into a Java class capable of being run

Parameters:
text - the text of the script/class to parse
fileName - the file name to use as the name of the class
Returns:
the main class defined in the given script
Throws:
SyntaxException
java.io.IOException

parseClass

public java.lang.Class parseClass(java.lang.String text)
                           throws SyntaxException,
                                  java.io.IOException
Parses the given text into a Java class capable of being run

Parameters:
text - the text of the script/class to parse
Returns:
the main class defined in the given script
Throws:
SyntaxException
java.io.IOException

parseClass

public java.lang.Class parseClass(java.io.InputStream in)
                           throws SyntaxException,
                                  java.io.IOException
Parses the given character stream into a Java class capable of being run

Parameters:
in - an InputStream
Returns:
the main class defined in the given script
Throws:
SyntaxException
java.io.IOException

parseClass

public java.lang.Class parseClass(java.io.InputStream in,
                                  java.lang.String fileName)
                           throws SyntaxException,
                                  java.io.IOException
Parses the given character stream into a Java class capable of being run

Parameters:
in - an InputStream
fileName - the file name to use as the name of the class
Returns:
the main class defined in the given script
Throws:
SyntaxException
java.io.IOException

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Using this classloader you can load groovy classes from the system classpath as though they were already compiled.

Throws:
java.lang.ClassNotFoundException

loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    byte[] bytecode)
A helper method to allow bytecode to be loaded


createCollector

protected GroovyClassLoader.ClassCollector createCollector(CompileUnit unit)


Copyright © 2003-2004 The Codehaus. All Rights Reserved.