FileClassLoaderpublic class FileClassLoader extends ClassLoader
Fields Summary |
---|
String | codebase | Hashtable | cache | private static com.sun.enterprise.util.LocalStringManagerImpl | localStrings |
Constructors Summary |
---|
public FileClassLoader(String codebase)
this.codebase = codebase;
|
Methods Summary |
---|
java.lang.String | getClassName(java.io.File f)
FileInputStream fis = new FileInputStream(f);
int avail = fis.available();
byte[] buf = new byte[avail];
fis.read(buf);
fis.close();
Class c = super.defineClass(null, buf, 0, avail);
return c.getName();
| public synchronized java.lang.Class | loadClass(java.lang.String name, boolean resolve)
Class c = (Class)cache.get(name);
if (c == null) {
try {
byte data[] = loadClassData(name);
c = defineClass(null,data, 0, data.length);
if( !name.equals(c.getName()) ) {
throw new ClassNotFoundException(localStrings.getLocalString("classloader.wrongpackage", "", new Object[] { name, c.getName() }));
}
}
catch ( Exception ex ) {
// Try to use default classloader. If this fails,
// then a ClassNotFoundException is thrown.
c = Class.forName(name);
}
cache.put(name, c);
}
if (resolve)
resolveClass(c);
return c;
| private byte[] | loadClassData(java.lang.String name)
// load the class data from the codebase
String sep = System.getProperty("file.separator");
String c = name.replace('.", sep.charAt(0)) + ".class";
File file = new File(codebase + sep + c);
if (!file.exists()) {
File wf = new File(codebase + sep + "WEB-INF" + sep + "classes" + sep + c);
if (wf.exists()) {
file = wf;
}
}
FileInputStream fis = new FileInputStream(file);
int avail = fis.available();
byte[] buf = new byte[avail];
fis.read(buf);
fis.close();
return buf;
| public java.lang.String | toString()
return "FileClassLoader: Codebase = "+codebase+"\n";
|
|