pnuts.ext
Class JarClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--pnuts.ext.JarClassLoader

public class JarClassLoader
extends java.lang.ClassLoader

This classloader can read JAR files dynamically. jarClassLoader.pnut is a sample script in Pnuts. Besides, after this class is loaded, jar URL can be used as defined in JDK1.2. For example, URL("jar:http://www.etale.com/pnuts/pnuts.jar!/lib/init.pnut").


Field Summary
 java.util.Hashtable classes
           
 java.util.Hashtable resources
           
 
Constructor Summary
JarClassLoader()
           
 
Method Summary
static JarClassLoader getLoader(java.lang.Object key)
           
 java.net.URL getResource(java.lang.String name)
          URL scheme for a resource in a JAR file is:
 java.io.InputStream getResourceAsStream(java.lang.String name)
          Get an InputStream on a given resource.
 java.lang.Class loadClass(java.lang.String name, boolean resolve)
          Resolves the specified name to a Class.
 void loadJar(java.lang.String filename)
          Load a JAR file specified with the filename.
 void loadJar(java.net.URL url)
          Load a JAR file from the specified URL.
protected  void loadJar(java.util.zip.ZipFile file)
           
 void loadJar(java.util.zip.ZipInputStream zin)
          Load a JAR file through ZipInputStream.
 
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, loadClass, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classes

public java.util.Hashtable classes

resources

public java.util.Hashtable resources
Constructor Detail

JarClassLoader

public JarClassLoader()
Method Detail

getLoader

public static JarClassLoader getLoader(java.lang.Object key)

loadJar

public void loadJar(java.net.URL url)
             throws java.io.IOException
Load a JAR file from the specified URL.

loadJar

public void loadJar(java.util.zip.ZipInputStream zin)
             throws java.io.IOException
Load a JAR file through ZipInputStream. The contents of entries are kept in a hashtable (, so this operation is heavy weight). When JAR file is randomly accessible, use loadJar(String filename).

loadJar

public void loadJar(java.lang.String filename)
             throws java.io.IOException
Load a JAR file specified with the filename. The corresponding ZipFile object is kept in a hashtable.

loadJar

protected void loadJar(java.util.zip.ZipFile file)
                throws java.io.IOException

loadClass

public java.lang.Class loadClass(java.lang.String name,
                                 boolean resolve)
                          throws java.lang.ClassNotFoundException
Resolves the specified name to a Class. The method loadClass() is called by the virtual machine.

If the resolve flag is true, the method should call the resolveClass method on the resulting class object.

Overrides:
loadClass in class java.lang.ClassLoader
Parameters:
name - the name of the desired Class.
resolve - true if the Class needs to be resolved.
Returns:
the resulting Class, or null if it was not found.
Throws:
java.lang.ClassNotFoundException - if the class loader cannot find a definition for the class.

getResource

public java.net.URL getResource(java.lang.String name)
URL scheme for a resource in a JAR file is:
Overrides:
getResource in class java.lang.ClassLoader

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Get an InputStream on a given resource. Will return null if no resource with this name is found.

Overrides:
getResourceAsStream in class java.lang.ClassLoader
Parameters:
name - the name of the resource, to be used as is.
Returns:
an InputStream on the resource, or null if not found.