org.javagroup.util
Class StandardLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--org.javagroup.util.StandardLoader

public class StandardLoader
extends java.lang.ClassLoader

This is a basic ClassLoader for loading files from directories on the local filesystem either in directories or zipfiles.


Field Summary
protected  java.lang.Object[] _classPath
          Classpath to search for class files.
 
Constructor Summary
StandardLoader(java.lang.String classPath)
          Constructs a new StandardLoader with the specified classpath.
 
Method Summary
protected  java.io.File initDirectory(java.lang.String name)
          Initialize a directory accessible on the local filesystem.
protected  java.lang.Object initPath(java.lang.String name)
          Initializes a path entry.
 java.util.zip.ZipFile initZipFile(java.lang.String name)
          Initialize a zip-file accessible on the local filesystem.
 java.lang.Class loadClass(java.lang.String name, boolean resolve)
          Load a class from from available locations.
 byte[] loadClassDef(java.lang.Object from, java.lang.String name)
          Reads a byte[] from the given path.
 
Methods inherited from class java.lang.ClassLoader
defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_classPath

protected java.lang.Object[] _classPath
Classpath to search for class files.
Constructor Detail

StandardLoader

public StandardLoader(java.lang.String classPath)
Constructs a new StandardLoader with the specified classpath. The classpath can contain directories and/or zip-files.
Parameters:
classPath - The classpath to use for this loader.
Method Detail

initPath

protected java.lang.Object initPath(java.lang.String name)
Initializes a path entry. Directories and zip files are supported.
Parameters:
name - Path name of the entry.
Returns:
An Object representing a classpath entry.

initDirectory

protected java.io.File initDirectory(java.lang.String name)
Initialize a directory accessible on the local filesystem.
Parameters:
name - Name of the directory.
Returns:
A File representing the directory.

initZipFile

public java.util.zip.ZipFile initZipFile(java.lang.String name)
Initialize a zip-file accessible on the local filesystem.
Parameters:
name - Name of the Zip-file
Returns:
A ZipFile representing the Zip classpath entry.

loadClass

public java.lang.Class loadClass(java.lang.String name,
                                 boolean resolve)
                          throws java.lang.ClassNotFoundException
Load a class from from available locations.
Overrides:
loadClass in class java.lang.ClassLoader

loadClassDef

public byte[] loadClassDef(java.lang.Object from,
                           java.lang.String name)
                    throws java.io.IOException
Reads a byte[] from the given path.
Parameters:
from - The path to load from.
name - The name of the class to load.
Returns:
A byte[] containing the class data.