aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
diff options
context:
space:
mode:
authorOmair Majid <omajid@redhat.com>2011-02-10 17:25:18 -0500
committerOmair Majid <omajid@redhat.com>2011-02-10 17:25:18 -0500
commitbd77d9b6fd61b02fda0e0c3bba478caf7dfe8258 (patch)
treee46d6648f8b07edbeef40f95c2f6aec0bb45a217 /netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
parentd0496a267170fb065b28352281a7b70a66e94e2f (diff)
Fix RH669942: Add support for packEnabled and versionEnabled
This changeset adds support for explicitly using jars with pack200 compression and versioning. This requires no server side support, but expects the client to try and find the right jar and fallback to using uncompressed/unversioned jars if the versioned/compressed ones can not be found. 2011-02-10 Omair Majid <omajid@redhat.com> Fix RH669942; Add support for packEnabled and versionEnabled. * NEWS: Update with bugfix. * netx/net/sourceforge/jnlp/DownloadOptions.java: New file. * netx/net/sourceforge/jnlp/JNLPFile.java (openURL): Use null for DownloadOptions. (getResourceDescs): New method. (getResourceDescs(Locale,String,String)): New method. * netx/net/sourceforge/jnlp/Launcher.java (launchApplication): Add image to downloader with null DownloadOptions. * netx/net/sourceforge/jnlp/cache/CacheUtil.java (getCachedResource): Add resource with null DownloadOptions. * netx/net/sourceforge/jnlp/cache/Resource.java: Add new field downloadLocation. (Resource): Initialize downloadLocation. (getDownloadLocation): New method. (setDownloadLocation): New method. * netx/net/sourceforge/jnlp/cache/ResourceTracker.java: Add new field downloadOptions. (addResource(URL,Version,UpdatePolicy)): Renamed to... (addResource(URL,Version,DownloadOptions,UpdatePolicy)): New method. (downloadResource): Add support for explicit downloading of packed jars as well as content-encoded packed jars. (initializeResource): Invokde findBestUrl to find the best url. Set that as the download location for the resource. (getVersionedResourceURL): Remove. (findBestUrl): New method. Use ResourceUrlCreator to get a list of all possible urls that can be used to download this resource. Try them one by one until one works and return that. * netx/net/sourceforge/jnlp/cache/ResourceUrlCreator.java: New file. * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java (initializeResources): Add resource with appropriate download options. (activateJars): Likewise. (loadClass): Likewise. (getDownloadOptionsForJar): New method.
Diffstat (limited to 'netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java')
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
index 30f1af2..a76a3a4 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
@@ -45,6 +45,7 @@ import java.util.Vector;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
+import net.sourceforge.jnlp.DownloadOptions;
import net.sourceforge.jnlp.ExtensionDesc;
import net.sourceforge.jnlp.JARDesc;
import net.sourceforge.jnlp.JNLPFile;
@@ -406,6 +407,7 @@ public class JNLPClassLoader extends URLClassLoader {
tracker.addResource(jars[i].getLocation(),
jars[i].getVersion(),
+ getDownloadOptionsForJar(jars[i]),
jars[i].isCacheable() ? JNLPRuntime.getDefaultUpdatePolicy() : UpdatePolicy.FORCE
);
}
@@ -696,7 +698,7 @@ public class JNLPClassLoader extends URLClassLoader {
List<JARDesc> jars = new ArrayList<JARDesc>();
JARDesc jarDesc = new JARDesc(new File(extractedJarLocation).toURL(), null, null, false, false, false, false);
jars.add(jarDesc);
- tracker.addResource(new File(extractedJarLocation).toURL(), null, null);
+ tracker.addResource(new File(extractedJarLocation).toURL(), null, null, null);
signer.verifyJars(jars, tracker);
if (signer.anyJarsSigned() && !signer.getAlreadyTrustPublisher()) {
@@ -1007,6 +1009,7 @@ public class JNLPClassLoader extends URLClassLoader {
tracker.addResource(desc.getLocation(),
desc.getVersion(),
+ null,
JNLPRuntime.getDefaultUpdatePolicy()
);
@@ -1247,4 +1250,27 @@ public class JNLPClassLoader extends URLClassLoader {
jarLocationSecurityMap.put(key, extLoader.jarLocationSecurityMap.get(key));
}
}
+
+ private DownloadOptions getDownloadOptionsForJar(JARDesc jar) {
+ boolean usePack = false;
+ boolean useVersion = false;
+
+ ResourcesDesc[] descs = file.getResourceDescs();
+ for (ResourcesDesc desc: descs) {
+ JARDesc[] jars = desc.getJARs();
+ for (JARDesc aJar: jars) {
+ if (jar == aJar) {
+ if (Boolean.valueOf(desc.getPropertiesMap().get("jnlp.packEnabled"))) {
+ usePack = true;
+ }
+ if (Boolean.valueOf(desc.getPropertiesMap().get("jnlp.versionEnabled"))) {
+ useVersion = true;
+ }
+ }
+ }
+ }
+
+ return new DownloadOptions(usePack, useVersion);
+ }
+
}