From da393149db600d3f6c19c39d30217dd437542667 Mon Sep 17 00:00:00 2001 From: Charlie Groves Date: Tue, 15 Jul 2008 01:50:55 +0000 Subject: [PATCH] Allow getdown applets to specify an app_properties param which contains a comma separated list of system properties specified as = to set on the launched application. --- .../com/threerings/getdown/data/Application.java | 15 +++++++++++++-- .../com/threerings/getdown/launcher/Getdown.java | 6 +++--- .../getdown/launcher/GetdownApplet.java | 16 ++++++++++++++-- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/java/com/threerings/getdown/data/Application.java b/src/java/com/threerings/getdown/data/Application.java index 9c2bbb8..81e067e 100644 --- a/src/java/com/threerings/getdown/data/Application.java +++ b/src/java/com/threerings/getdown/data/Application.java @@ -157,7 +157,7 @@ public class Application */ public Application (File appdir, String appid) { - this(appdir, appid, null); + this(appdir, appid, null, null); } /** @@ -169,13 +169,17 @@ public class Application * appid.apparg to configure itself but all other parameters will be the same as * the primary application. * @param signers an array of possible signers of this application. Used to verify the digest. + * @param jvmargs arguments to pass on to launched jvms */ - public Application (File appdir, String appid, Object[] signers) + public Application (File appdir, String appid, Object[] signers, String[] jvmargs) { _appdir = appdir; _appid = appid; _signers = signers; _config = getLocalPath(CONFIG_FILE); + if (jvmargs != null) { + _baseJvmArgs = jvmargs; + } } /** @@ -537,6 +541,11 @@ public class Application _jvmargs.add(jvmargs[ii]); } } + + // Add the launch specific JVM arguments + for (String arg : _baseJvmArgs) { + _jvmargs.add(arg); + } // transfer our application arguments String[] appargs = ConfigUtil.getMultiValue(cdata, prefix + "apparg"); @@ -1315,6 +1324,8 @@ public class Application protected ArrayList _jvmargs = new ArrayList(); protected ArrayList _appargs = new ArrayList(); + + protected String[] _baseJvmArgs = new String[0]; protected Object[] _signers; diff --git a/src/java/com/threerings/getdown/launcher/Getdown.java b/src/java/com/threerings/getdown/launcher/Getdown.java index a138067..4432fca 100644 --- a/src/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/java/com/threerings/getdown/launcher/Getdown.java @@ -84,10 +84,10 @@ public abstract class Getdown extends Thread public Getdown (File appDir, String appId) { - this(appDir, appId, null); + this(appDir, appId, null, null); } - public Getdown (File appDir, String appId, Object[] signers) + public Getdown (File appDir, String appId, Object[] signers, String[] jvmargs) { super("Getdown"); try { @@ -116,7 +116,7 @@ public abstract class Getdown extends Thread "\nis invalid. The directory must not contain the '!' character. Please reinstall."; fail(errmsg); } - _app = new Application(appDir, appId, signers); + _app = new Application(appDir, appId, signers, jvmargs); _startup = System.currentTimeMillis(); } diff --git a/src/java/com/threerings/getdown/launcher/GetdownApplet.java b/src/java/com/threerings/getdown/launcher/GetdownApplet.java index 8f41b37..57b6a35 100644 --- a/src/java/com/threerings/getdown/launcher/GetdownApplet.java +++ b/src/java/com/threerings/getdown/launcher/GetdownApplet.java @@ -28,12 +28,12 @@ import java.io.IOException; import java.io.PrintStream; import java.net.MalformedURLException; import java.net.URL; - import javax.swing.JApplet; import javax.swing.JPanel; import com.samskivert.util.RunAnywhere; import com.samskivert.util.StringUtil; + import com.threerings.getdown.Log; /** @@ -91,11 +91,23 @@ public class GetdownApplet extends JApplet _errmsg = e.getMessage(); } + // Pull out system properties to pass through to the launched vm if they exist + String params = getParameter("app_properties"); + String[] jvmargs; + if(params == null){ + jvmargs = new String[0]; + } else { + jvmargs = params.split(","); + for (int ii = 0; ii < jvmargs.length; ii++) { + jvmargs[ii] = "-D" + jvmargs[ii]; + } + } + try { // XXX getSigners() returns all certificates used to sign this applet which may allow // a third party to insert a trusted certificate. This should be replaced with // statically included trusted keys. - _getdown = new Getdown(appdir, null, GetdownApplet.class.getSigners()) { + _getdown = new Getdown(appdir, null, GetdownApplet.class.getSigners(), jvmargs) { protected Container createContainer () { getContentPane().removeAll(); return getContentPane();