|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.ClassLoader
com.compoundtheory.classloader.NetworkClassLoader
public class NetworkClassLoader
The correct name for this class should be URLClassLoader. But there is already a class by that name in JDK1.2. I have had quite a few problems with URLClassLoader in past, so I ended up writing this ClassLoader. I found that the Java 2's URLClassLoader, does not close the Jar file once opened. It is a pretty good optimization step, but if you modify the class in the jar file, it does not pick it up. Some operating systems may not let you modify the jar file while it is still open. IMHO, it does make sense to close the jar file after you are done reading the class data. But this approach may not get you the performance of the URLClassLoader, but it works in all cases and also runs on JDK1.1. I have enhanced this class loader to read all the zip/jar entries once & cache the data, so that there is no overhead of opening/closing jar file to pick up each entry.
Modified and enhanced by Mark Mandel to work specifically with ColdFusion, in specific contexts.
| Constructor Summary | |
|---|---|
NetworkClassLoader()
|
|
NetworkClassLoader(java.lang.ClassLoader parent)
Creates a new instance of the class loader. |
|
| Method Summary | |
|---|---|
void |
addURL(java.net.URL url)
Adds the given URL to this class loader. |
void |
clear()
This method resets this ClassLoader's state. |
protected void |
finalize()
This method resets this ClassLoader's state and resets the references for garbage collection. |
java.lang.Class |
findClass(java.lang.String name)
Call this to bypass the implementation of loadClass. |
protected java.net.URL |
findResource(java.lang.String name)
Overridden to search for a resource and return a "jar"-style URL or normal "file" URL as necessary. |
protected java.util.Enumeration |
findResources(java.lang.String name)
Find all resources for a given name |
java.io.InputStream |
getResourceAsStream(java.lang.String name)
|
java.net.URL[] |
getURLs()
|
java.lang.Class |
loadClass(java.lang.String name,
boolean resolve)
Load a class for given name |
protected byte[] |
loadClassData(java.lang.String classname)
|
protected byte[] |
loadResource(java.lang.String resource)
|
protected byte[] |
loadResource(java.net.URL url,
java.lang.String resourceName)
|
protected void |
setParent(java.lang.ClassLoader parent)
Sets the parent/delegate class loader. |
| Methods inherited from class java.lang.ClassLoader |
|---|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NetworkClassLoader()
public NetworkClassLoader(java.lang.ClassLoader parent)
delegate - /parent class loader.| Method Detail |
|---|
protected final void setParent(java.lang.ClassLoader parent)
delegate - /parent class loader.public void addURL(java.net.URL url)
URL - where to look for the classes.public java.net.URL[] getURLs()
public java.lang.Class findClass(java.lang.String name)
throws java.lang.ClassNotFoundException
findClass in class java.lang.ClassLoaderjava.lang.ClassNotFoundException
protected byte[] loadResource(java.net.URL url,
java.lang.String resourceName)
throws java.io.IOException
java.io.IOExceptionprotected byte[] loadResource(java.lang.String resource)
protected byte[] loadClassData(java.lang.String classname)
protected java.net.URL findResource(java.lang.String name)
findResource in class java.lang.ClassLoader
protected java.util.Enumeration findResources(java.lang.String name)
throws java.io.IOException
findResources in class java.lang.ClassLoaderjava.io.IOExceptionpublic java.io.InputStream getResourceAsStream(java.lang.String name)
getResourceAsStream in class java.lang.ClassLoader
public java.lang.Class loadClass(java.lang.String name,
boolean resolve)
throws java.lang.ClassNotFoundException
loadClass in class java.lang.ClassLoaderjava.lang.ClassNotFoundExceptionpublic final void clear()
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||