Allow getdown applets to specify an app_properties param which contains a comma

separated list of system properties specified as <key>=<value> to set on the
launched application.
This commit is contained in:
Charlie Groves
2008-07-15 01:50:55 +00:00
parent 152f016f92
commit da393149db
3 changed files with 30 additions and 7 deletions
@@ -157,7 +157,7 @@ public class Application
*/ */
public Application (File appdir, String appid) public Application (File appdir, String appid)
{ {
this(appdir, appid, null); this(appdir, appid, null, null);
} }
/** /**
@@ -169,13 +169,17 @@ public class Application
* <code>appid.apparg</code> to configure itself but all other parameters will be the same as * <code>appid.apparg</code> to configure itself but all other parameters will be the same as
* the primary application. * the primary application.
* @param signers an array of possible signers of this application. Used to verify the digest. * @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; _appdir = appdir;
_appid = appid; _appid = appid;
_signers = signers; _signers = signers;
_config = getLocalPath(CONFIG_FILE); _config = getLocalPath(CONFIG_FILE);
if (jvmargs != null) {
_baseJvmArgs = jvmargs;
}
} }
/** /**
@@ -538,6 +542,11 @@ public class Application
} }
} }
// Add the launch specific JVM arguments
for (String arg : _baseJvmArgs) {
_jvmargs.add(arg);
}
// transfer our application arguments // transfer our application arguments
String[] appargs = ConfigUtil.getMultiValue(cdata, prefix + "apparg"); String[] appargs = ConfigUtil.getMultiValue(cdata, prefix + "apparg");
if (appargs != null) { if (appargs != null) {
@@ -1316,6 +1325,8 @@ public class Application
protected ArrayList<String> _jvmargs = new ArrayList<String>(); protected ArrayList<String> _jvmargs = new ArrayList<String>();
protected ArrayList<String> _appargs = new ArrayList<String>(); protected ArrayList<String> _appargs = new ArrayList<String>();
protected String[] _baseJvmArgs = new String[0];
protected Object[] _signers; protected Object[] _signers;
/** If a warning has been issued about not being able to set modtimes. */ /** If a warning has been issued about not being able to set modtimes. */
@@ -84,10 +84,10 @@ public abstract class Getdown extends Thread
public Getdown (File appDir, String appId) 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"); super("Getdown");
try { try {
@@ -116,7 +116,7 @@ public abstract class Getdown extends Thread
"\nis invalid. The directory must not contain the '!' character. Please reinstall."; "\nis invalid. The directory must not contain the '!' character. Please reinstall.";
fail(errmsg); fail(errmsg);
} }
_app = new Application(appDir, appId, signers); _app = new Application(appDir, appId, signers, jvmargs);
_startup = System.currentTimeMillis(); _startup = System.currentTimeMillis();
} }
@@ -28,12 +28,12 @@ import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import javax.swing.JApplet; import javax.swing.JApplet;
import javax.swing.JPanel; import javax.swing.JPanel;
import com.samskivert.util.RunAnywhere; import com.samskivert.util.RunAnywhere;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.getdown.Log; import com.threerings.getdown.Log;
/** /**
@@ -91,11 +91,23 @@ public class GetdownApplet extends JApplet
_errmsg = e.getMessage(); _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 { try {
// XXX getSigners() returns all certificates used to sign this applet which may allow // 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 // a third party to insert a trusted certificate. This should be replaced with
// statically included trusted keys. // statically included trusted keys.
_getdown = new Getdown(appdir, null, GetdownApplet.class.getSigners()) { _getdown = new Getdown(appdir, null, GetdownApplet.class.getSigners(), jvmargs) {
protected Container createContainer () { protected Container createContainer () {
getContentPane().removeAll(); getContentPane().removeAll();
return getContentPane(); return getContentPane();