From aeb8dbac97efe7dec9452a406c8b93e1eeef07cf Mon Sep 17 00:00:00 2001 From: Denis Lila Date: Fri, 4 Mar 2011 18:16:07 -0500 Subject: Fix PR658 --- ChangeLog | 13 ++++++++++ NEWS | 1 + netx/net/sourceforge/jnlp/JNLPFile.java | 28 ++++++++++++++++++++++ netx/net/sourceforge/jnlp/PluginBridge.java | 23 ++++++++++++++++++ .../sourceforge/jnlp/runtime/JNLPClassLoader.java | 20 +--------------- 5 files changed, 66 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index e089c18..6f47aa3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-03-04 Denis Lila + + * netx/net/sourceforge/jnlp/JNLPFile.java: + (getDownloadOptionsForJar): Moved here from JNLPClassLoader.java. + * netx/net/sourceforge/jnlp/PluginBridge.java + (usePack, useVersion): added. + (PluginBridge): initializing usePack and useVersion. + (getDownloadOptionsForJar): return the download options. + * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java + (getDownloadOptionsForJar): logic moved to JNLPFile.java and its + subclasses. Now just calling file.getDownloadOptionsForJar. + * NEWS: Updated with fix of PR658. + 2011-03-04 Denis Lila * netx/net/sourceforge/jnlp/cache/ResourceTracker.java diff --git a/NEWS b/NEWS index 9cb153d..9231a97 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,7 @@ New in release 1.1 (2011-XX-XX): * NetX - Use Firefox's proxy settings if possible - RH669942: javaws fails to download version/packed files (missing support for jnlp.packEnabled and jnlp.versionEnabled) + - PR658: now jnlp.packEnabled works with applets. * Plugin - PR475, RH604061: Allow applets from the same page to use the same classloader - PR612: NetDania application ends on java.security.AccessControlException: access denied (java.util.PropertyPermission browser read) diff --git a/netx/net/sourceforge/jnlp/JNLPFile.java b/netx/net/sourceforge/jnlp/JNLPFile.java index 1bee246..2596c47 100644 --- a/netx/net/sourceforge/jnlp/JNLPFile.java +++ b/netx/net/sourceforge/jnlp/JNLPFile.java @@ -645,4 +645,32 @@ public class JNLPFile { return newVMArgs; } + /** + * XXX: this method does a "==" comparison between the input JARDesc and + * jars it finds through getResourcesDescs(). If ever the implementation + * of that function should change to return copies of JARDescs objects, + * then the "jar == aJar" comparison below should change accordingly. + * @param jar: the jar whose download options to get. + * @return the download options. + */ + public DownloadOptions getDownloadOptionsForJar(JARDesc jar) { + boolean usePack = false; + boolean useVersion = false; + ResourcesDesc[] descs = getResourcesDescs(); + for (ResourcesDesc desc: descs) { + JARDesc[] jars = desc.getJARs(); + for (JARDesc aJar: jars) { + if (jar == aJar/*jar.getLocation().equals(aJar.getLocation())*/) { + 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); + } + } diff --git a/netx/net/sourceforge/jnlp/PluginBridge.java b/netx/net/sourceforge/jnlp/PluginBridge.java index a3ef9f3..b8f493a 100644 --- a/netx/net/sourceforge/jnlp/PluginBridge.java +++ b/netx/net/sourceforge/jnlp/PluginBridge.java @@ -40,6 +40,8 @@ public class PluginBridge extends JNLPFile { String[] cacheJars = new String[0]; String[] cacheExJars = new String[0]; Hashtable atts; + private boolean usePack; + private boolean useVersion; public PluginBridge(URL codebase, URL documentBase, String jar, String main, int width, int height, Hashtable atts) @@ -134,6 +136,27 @@ public class PluginBridge extends JNLPFile { // same page can communicate (there are applets known to require // such communication for proper functionality) this.uniqueKey = documentBase.toString(); + + usePack = false; + useVersion = false; + String jargs = atts.get("java_arguments"); + if (jargs != null) { + for (String s : jargs.split(" ")) { + String[] parts = s.trim().split("="); + if (parts.length == 2 && Boolean.valueOf(parts[1])) { + if ("-Djnlp.packEnabled".equals(parts[0])) { + usePack = true; + } else if ("-Djnlp.versionEnabled".equals(parts[0])) { + useVersion = true; + } + } + } + } + } + + @Override + public DownloadOptions getDownloadOptionsForJar(JARDesc jar) { + return new DownloadOptions(usePack, useVersion); } public String getTitle() { diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java index aae8b8b..6bebfc6 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java @@ -1321,25 +1321,7 @@ public class JNLPClassLoader extends URLClassLoader { } private DownloadOptions getDownloadOptionsForJar(JARDesc jar) { - boolean usePack = false; - boolean useVersion = false; - - ResourcesDesc[] descs = file.getResourcesDescs(); - 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); + return file.getDownloadOptionsForJar(jar); } /* -- cgit v1.2.3