Java Reference
In-Depth Information
L ISTING 6.3 Continued
6
/**
* see superclasss
*/
public InputStream getResourceAsStream(String name) {
URL url = getResource(name);
InputStream is = null;
if (url != null) {
try {
is = url.openStream();
} catch (IOException e) {
System.out.println(“BankClientLoader- getResourceAsStream( “+name+” ):
“+e);
}
}
return is;
}
/**
* see superclasss
*/
public Class loadClass(String name) throws ClassNotFoundException {
// This is the actions sequence:
//
// 1. check if the class is in local cache,
// if it is the case, load the class in cache
//
// 2. if it's not in local cache, try with the super classloader
//
// 3. if it is not in cache and not loaded by the ancestor classloader
// then ask it directly to the remote server
//
// 4. if not found otherwise, quit throwing an exception
Class neededClass = null;
// 1. check if it is cached
if (helper.isCached(helper.getCacheClassFileName(name)+”.class”)) {
System.out.println(“BankClientLoader- class: “+name+” loaded from local
cache”);
neededClass = loadClass(helper.getCacheClassFileName(name),
getClass(name));
}
Search WWH ::




Custom Search