Java Reference
In-Depth Information
L ISTING 8.9 Continued
int jarNumber = jarSequence.length;
try {
ds =
(DownloadService)ServiceManager.lookup(“javax.jnlp.DownloadService”);
} catch (UnavailableServiceException use) {
ds = null;
System.out.println(“Service is not supported: “+use);
}//once have a ds you can do a lot of things
//begin downloading jars
for (int i=0;i<jarNumber;i++){
if (ds != null) {
processJar(ds,i);
}
//take a breath
try {
140: Thread.currentThread().sleep(3000);//IT'S ONLY COSMETICS!
// Thread.currentThread().yield();
} catch (Exception e) {
System.out.println(“Synchronization Exception: “+e);
8
}
}//-for
showUp(false);//all the needed JARs have been processed
extensionInstaller.installSucceeded(true);//we're optimistic
}
/**
* A fancy method that finds out if a JAR is cached and removes it.
* substitute it with your code.
*/
private void processJar(DownloadService ds, int i){
try {
// determine if a particular resource is cached
URL url =
new URL(codebase + jarSequence[i]);
boolean cached = ds.isResourceCached(url, null);
160: // remove the resource from the cache, just for fun
if (cached) {
ds.removeResource(url, null);
}
// reload the resource into the cache, yes!
setMessage(msgSequence[i]);
setLoadingResource(jarSequence[i]);
Search WWH ::




Custom Search