MAEPlugin
Class FileClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--MAEPlugin.FileClassLoader

public class FileClassLoader
extends java.lang.ClassLoader

Class to dynamic classes from local disks. This allows plugins to be loaded.

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The MAExplorer Mozilla and Legal files are available on http://maexplorer.sourceforge.net/.

Version:
$Date: 2002/10/13 17:39:33 $ / $Revision: $
Author:
Jai Evans. Modified from Chan, P. et.al. The JavaClass Libraries, v.1. Addison Wesley, 1998 pp.416-418.); C. Santos (DECA/CIT), P. Lemkin (NCI-Frederick
See Also:
MAExplorer Home, ClassLoader

Constructor Summary
FileClassLoader(java.io.File file)
          FileClassLoader() - Constructor to load .classfile.
FileClassLoader(java.lang.String path)
          FileClassLoader() - Constructor to load path.
 
Method Summary
 java.lang.Class findFileClass(java.lang.String name)
          findFileClass() - find file of class by name.
 java.net.URL getResource(java.lang.String name)
          getResource() - Returns a URL containing the location of the named resource.
 java.io.InputStream getResourceAsStream(java.lang.String name)
          getResourceAsStream() - returns an input stream to the named source.
 java.lang.Class loadClass(java.io.File file)
          loadClass() - Implementation of ClassLoader.loadClass() by name of File pointer.
protected  java.lang.Class loadClass(java.io.File file, boolean resolve)
          * loadClass() - Implementation of ClassLoader.loadClass() by name of File pointer and user option to resolve.
 java.lang.Class loadClass(java.lang.String name)
          loadClass() - Implementation of ClassLoader.loadClass() by name of class.
protected  java.lang.Class loadClass(java.lang.String name, boolean resolve)
          loadClass() - Implementation of ClassLoader.loadClass() From javadoc v.
protected  java.lang.Class loadClassFromZip(java.lang.String zipPath, java.lang.String className)
          loadClassFromZip() - loads classes and resources of a zip or jar file and loads the one class that has the same name as the archive.
 
Methods inherited from class java.lang.ClassLoader
defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileClassLoader

public FileClassLoader(java.lang.String path)
FileClassLoader() - Constructor to load path.
Parameters:
path - class to be loaded

FileClassLoader

public FileClassLoader(java.io.File file)
FileClassLoader() - Constructor to load .classfile.
Parameters:
File - itself, directory, class file or jar archive of class to be loaded
Method Detail

loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
loadClass() - Implementation of ClassLoader.loadClass() From javadoc v. 1.3 Loads the class with the specified name. The default implementation of this method searches for classes in the following order:

  1. Call findLoadedClass(String) to check if class hasalready been loaded.

  2. Call the loadClass method on the parent class loader. If the parent is null the class loader built-in to the virtual machine is used, instead.

  3. Call the findClass(String) method to find class.

If the class was found using the above steps, and the resolve flag is true, this method will then call the resolveClass(Class) method on the resulting class object.

From the Java 2 SDK, v1.2, subclasses of ClassLoader are encouraged to override findClass(String), rather than this method.

Parameters:
name - the name of the class
resolve - if true then resolve class
Returns:
the resulting Class object
Throws:
ClassNotFoundException - if class couldn't be found
Overrides:
loadClass in class java.lang.ClassLoader
Parameters:
className - name of the class to load
resolve - called by Classloader savvy code to force resolution of the class.
Returns:
Return the Class object or null if class not found.
Throws:
java.lang.ClassNotFoundException - thrown whenever class can not be loaded.

loadClass

public java.lang.Class loadClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
loadClass() - Implementation of ClassLoader.loadClass() by name of class.
Overrides:
loadClass in class java.lang.ClassLoader
Parameters:
className - Name of the class to load equivalent of loadClass(name, false);
Returns:
Return the Class object or null if class not found.
Throws:
java.lang.ClassNotFoundException - Thrown whenever class can't be loaded.

loadClass

public java.lang.Class loadClass(java.io.File file)
                          throws java.lang.ClassNotFoundException
loadClass() - Implementation of ClassLoader.loadClass() by name of File pointer. File pointer version. @see #loadClass(String)
Parameters:
file - file to be loaded
Returns:
Class instance

loadClass

protected java.lang.Class loadClass(java.io.File file,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
* loadClass() - Implementation of ClassLoader.loadClass() by name of File pointer and user option to resolve. File pointer version. @see #loadClass
Parameters:
file - file to be loaded
resolve - try to resolve classes if true
Returns:
Class instance

findFileClass

public java.lang.Class findFileClass(java.lang.String name)
                              throws java.lang.ClassNotFoundException
findFileClass() - find file of class by name.
Parameters:
name - Name of the Class
Returns:
Returns the Class from the file.
Throws:
java.lang.ClassNotFoundException - If any error occurs, a ClassNotFoundException is thrown.

getResource

public java.net.URL getResource(java.lang.String name)
getResource() - Returns a URL containing the location of the named resource.
Overrides:
getResource in class java.lang.ClassLoader
Parameters:
name - Name of the resource
Returns:
URL of the named resource.

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
getResourceAsStream() - returns an input stream to the named source.
Overrides:
getResourceAsStream in class java.lang.ClassLoader
Parameters:
name - Name of the resource
Returns:
input stream to the resource

loadClassFromZip

protected java.lang.Class loadClassFromZip(java.lang.String zipPath,
                                           java.lang.String className)
loadClassFromZip() - loads classes and resources of a zip or jar file and loads the one class that has the same name as the archive.