public class GreeterClassLoader extends ClassLoader {
// basePath gives the path to which this class
// loader appends "/<typename>.class" to get the
// full path name of the class file to load
private String basePath;
public GreeterClassLoader(String basePath) {
this.basePath = basePath;
}
public GreeterClassLoader(ClassLoader parent, String basePath) {
super(parent);
this.basePath = basePath;
}
protected Class findClass(String className)
throws ClassNotFoundException {
byte classData[];
// Try to load it from the basePath directory.
classData = getTypeFromBasePath(className);
if (classData == null) {
throw new ClassNotFoundException();
}
// Parse it
return defineClass(className, classData, 0,
classData.length);
}