Java Reference
In-Depth Information
L ISTING 6.3 Continued
// 2. if not found, see if super-classloader has class
if (neededClass == null) {
try {
neededClass = super.findSystemClass(name);
if (neededClass != null) {
System.out.println(“BankClientLoader- class: “+name+” loaded from
super classloader”);
return neededClass;
}
} catch (ClassNotFoundException e) {
// ignore this error
// System.out.println(“BankClientLoader- class not found in super
classloader, name=”+name);
}
}
// 3. if still not found, look for it on the server, using a standard GET
if (neededClass==null) {
try {
File f = helper.getRemoteFile(name, true);
if (f.exists()) {
neededClass = loadClass(helper.getCacheClassFileName(name),
getClass(name));
}
else
System.out.println(“BankClientLoader- - class: “+name+” not found on
server.”);
} catch (Exception ex) {
System.out.println(“BankClientLoader- loadClass() while GET: “+ex);
}
}
// 4. finally, throw an exception
if (neededClass == null) {
System.out.println(“BankClassLoader- couldn't find class: “+ name +”
anywhere.”);
throw new ClassNotFoundException(“BankClassLoader- couldn't find class:
“+ name);
}
return neededClass;
}
/**
Search WWH ::




Custom Search