|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.ClassLoader net.wotonomy.foundation.internal.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.
Constructor Summary | |
---|---|
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 java.lang.Class |
defineClass(java.lang.String classname,
byte[] classdata)
java.lang.ClassLoader's defineClass method is final, so the its subclasses cannot override this method. |
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. |
java.io.InputStream |
getResourceAsStream(java.lang.String name)
|
java.util.Enumeration |
getURLs()
|
java.lang.Class |
loadClass(java.lang.String name,
boolean resolve)
|
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, findResources, 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(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.util.Enumeration getURLs()
public java.lang.Class findClass(java.lang.String name)
findClass
in class java.lang.ClassLoader
protected byte[] loadResource(java.net.URL url, java.lang.String resourceName) throws java.io.IOException
java.io.IOException
protected 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
public java.io.InputStream getResourceAsStream(java.lang.String name)
getResourceAsStream
in class java.lang.ClassLoader
protected java.lang.Class defineClass(java.lang.String classname, byte[] classdata)
The
- name of the class without ".class" extension.The
- class data bytes.
public java.lang.Class loadClass(java.lang.String name, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
java.lang.ClassNotFoundException
public final void clear()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |