opencard.opt.util
Class URLClassLoader
java.lang.Object
|
+--java.lang.ClassLoader
|
+--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.
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 |
defineClass,
defineClass,
defineClass,
definePackage,
findClass,
findLibrary,
findLoadedClass,
findResource,
findResources,
findSystemClass,
getPackage,
getPackages,
getParent,
getResource,
getResourceAsStream,
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 |
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
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 archivearchive
- path to the archive relative to url
loadClass
protected java.lang.Class loadClass(java.lang.String name,
boolean resolve)
throws java.lang.ClassNotFoundException
- Load a class with the given name.
- 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.
- Overrides:
- loadClass in class java.lang.ClassLoader
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
inputStreamToByteArray
protected byte[] inputStreamToByteArray(java.io.InputStream is)
throws java.io.IOException