opencard.opt.util
Class URLClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by opencard.opt.util.URLClassLoader

public class URLClassLoader
extends java.lang.ClassLoader

Special class loader for loading classes from a URL. This class loader is very much like the AppletClassLoader which is not part of the official Java API.

Version:
$Id: URLClassLoader.java,v 1.1.1.1 1999/10/05 15:08:48 damke Exp $
Author:
Thomas Schaeck (schaeck@de.ibm.com), Peter Trommler (trp@zurich.ibm.com)

Field Summary
protected  java.lang.String archive
           
protected  boolean archiveLoaded
           
protected  java.util.Hashtable byteCache
           
protected  java.util.Hashtable classCache
           
protected  java.net.URL url
           
 
Constructor Summary
URLClassLoader(java.net.URL url)
          Create a new instance.
URLClassLoader(java.net.URL url, java.lang.String archive)
          Try to load classes from an archive first.
 
Method Summary
protected  byte[] inputStreamToByteArray(java.io.InputStream is)
           
protected  void loadArchive(java.net.URL url, java.lang.String archive)
           
protected  java.lang.Class loadClass(java.lang.String name, boolean resolve)
          Load a class with the given name.
protected  byte[] loadClassData(java.lang.String name)
          Get the bytes for the class with the given name.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classCache

protected java.util.Hashtable classCache

byteCache

protected java.util.Hashtable byteCache

url

protected java.net.URL url

archive

protected java.lang.String archive

archiveLoaded

protected boolean archiveLoaded
Constructor Detail

URLClassLoader

public URLClassLoader(java.net.URL url)
Create a new instance.

Parameters:
url - the URL from which this class loader loads classes.

URLClassLoader

public URLClassLoader(java.net.URL url,
                      java.lang.String archive)
Try to load classes from an archive first.

Parameters:
url - codebase of the archive and classes not found in the archive
archive - path to the archive relative to url
Method Detail

loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
Load a class with the given name.

Overrides:
loadClass in class java.lang.ClassLoader
Parameters:
name - - the name of the class to be loaded.
resolve - - indicates wether the class is to be resolved or not.
Returns:
The class that has been loaded.
Throws:
java.lang.ClassNotFoundException - Could not find class.

loadClassData

protected byte[] loadClassData(java.lang.String name)
                        throws java.lang.ClassNotFoundException
Get the bytes for the class with the given name.

Parameters:
name - the class name
Returns:
The bytes for the class.
Throws:
java.lang.ClassNotFoundException - the archive or class file could not be read

loadArchive

protected void loadArchive(java.net.URL url,
                           java.lang.String archive)
                    throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

inputStreamToByteArray

protected byte[] inputStreamToByteArray(java.io.InputStream is)
                                 throws java.io.IOException
Throws:
java.io.IOException