JWSClassLoaderpublic class JWSClassLoader extends ClassLoader Class loader for JWS files. There is one of these per JWS class, and
we keep a static Hashtable of them, indexed by class name. When we want
to reload a JWS, we replace the ClassLoader for that class and let the
old one get GC'ed. |
Fields Summary |
---|
private String | classFile | private String | name |
Constructors Summary |
---|
public JWSClassLoader(String name, ClassLoader cl, String classFile)Construct a JWSClassLoader with a class name, a parent ClassLoader,
and a filename of a .class file containing the bytecode for the class.
The constructor will load the bytecode, define the class, and register
this JWSClassLoader in the static registry.
super(cl);
this.name = name + ".class";
this.classFile = classFile;
FileInputStream fis = new FileInputStream( classFile );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte buf[] = new byte[1024];
for(int i = 0; (i = fis.read(buf)) != -1; )
baos.write(buf, 0, i);
fis.close();
baos.close();
/* Create a new Class object from it */
/*************************************/
byte[] data = baos.toByteArray();
defineClass( name, data, 0, data.length );
ClassUtils.setClassLoader(name,this);
|
Methods Summary |
---|
public java.io.InputStream | getResourceAsStream(java.lang.String resourceName)Overloaded getResourceAsStream() so we can be sure to return the
correct class file regardless of where it might live on our hard
drive.
try {
if (resourceName.equals(name))
return new FileInputStream( classFile );
} catch (FileNotFoundException e) {
// Fall through, return null.
}
return null;
|
|