From 90edcdf571fb8c5b5489af93648a3f8687d782c1 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 7 Apr 2011 21:07:23 +0000 Subject: [PATCH] Some tidying. --- .../threerings/getdown/data/Application.java | 35 +++++++++---------- .../threerings/getdown/launcher/Getdown.java | 3 +- .../getdown/launcher/GetdownApp.java | 8 ++--- .../getdown/launcher/GetdownApplet.java | 2 +- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/threerings/getdown/data/Application.java b/src/main/java/com/threerings/getdown/data/Application.java index ce7107e..8b6e695 100644 --- a/src/main/java/com/threerings/getdown/data/Application.java +++ b/src/main/java/com/threerings/getdown/data/Application.java @@ -69,6 +69,7 @@ import org.apache.commons.codec.binary.Base64; import com.samskivert.io.StreamUtil; import com.samskivert.text.MessageUtil; +import com.samskivert.util.ArrayUtil; import com.samskivert.util.RandomUtil; import com.samskivert.util.RunAnywhere; import com.samskivert.util.StringUtil; @@ -179,26 +180,22 @@ public class Application * configuration file from the supplied application directory. * * @param appid usually null but a string identifier if a secondary application is desired to - * be launched. That application will use appid.class and - * appid.apparg to configure itself but all other parameters will be the same as - * the primary application. + * be launched. That application will use {@code appid.class} and {@code 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 - * @param appargs arguments to pass on to launched application + * @param jvmargs additional arguments to pass on to launched jvms. + * @param appargs additional arguments to pass on to launched application; these will be added + * after the args in the getdown.txt file. */ - public Application ( - File appdir, String appid, Object[] signers, String[] jvmargs, String[] appargs) + public Application (File appdir, String appid, Object[] signers, + String[] jvmargs, String[] appargs) { _appdir = appdir; _appid = appid; _signers = signers; _config = getLocalPath(CONFIG_FILE); - if (jvmargs != null) { - _baseJvmArgs = jvmargs; - } - if (appargs != null) { - _baseAppArgs = appargs; - } + _extraJvmArgs = (jvmargs == null) ? ArrayUtil.EMPTY_STRING : jvmargs; + _extraAppArgs = (appargs == null) ? ArrayUtil.EMPTY_STRING : appargs; } /** @@ -567,7 +564,7 @@ public class Application } // Add the launch specific JVM arguments - for (String arg : _baseJvmArgs) { + for (String arg : _extraJvmArgs) { _jvmargs.add(arg); } @@ -580,7 +577,7 @@ public class Application } // add the launch specific application arguments - for (String arg : _baseAppArgs) { + for (String arg : _extraAppArgs) { _appargs.add(arg); } @@ -1411,7 +1408,7 @@ public class Application protected String[] parseList (Map cdata, String name) { String value = (String)cdata.get(name); - return (value == null) ? new String[0] : StringUtil.parseStringArray(value); + return (value == null) ? ArrayUtil.EMPTY_STRING : StringUtil.parseStringArray(value); } /** Possibly generates and returns a google analytics tracking cookie. */ @@ -1476,15 +1473,15 @@ public class Application protected List _jvmargs = new ArrayList(); protected List _appargs = new ArrayList(); - protected String[] _baseJvmArgs = new String[0]; - protected String[] _baseAppArgs = new String[0]; + protected String[] _extraJvmArgs; + protected String[] _extraAppArgs; protected Object[] _signers; /** If a warning has been issued about not being able to set modtimes. */ protected boolean _warnedAboutSetLastModified; - protected static final String[] SA_PROTO = new String[0]; + protected static final String[] SA_PROTO = ArrayUtil.EMPTY_STRING; /** Locks gettingdown.lock in the app dir. Held the entire time updating is going on.*/ protected FileLock _lock; diff --git a/src/main/java/com/threerings/getdown/launcher/Getdown.java b/src/main/java/com/threerings/getdown/launcher/Getdown.java index f4f8173..e4f512f 100644 --- a/src/main/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/main/java/com/threerings/getdown/launcher/Getdown.java @@ -93,8 +93,7 @@ public abstract class Getdown extends Thread this(appDir, appId, null, null, null); } - public Getdown ( - File appDir, String appId, Object[] signers, String[] jvmargs, String[] appargs) + public Getdown (File appDir, String appId, Object[] signers, String[] jvmargs, String[] appargs) { super("Getdown"); try { diff --git a/src/main/java/com/threerings/getdown/launcher/GetdownApp.java b/src/main/java/com/threerings/getdown/launcher/GetdownApp.java index e3d05b0..8840531 100644 --- a/src/main/java/com/threerings/getdown/launcher/GetdownApp.java +++ b/src/main/java/com/threerings/getdown/launcher/GetdownApp.java @@ -41,9 +41,9 @@ import java.util.List; import javax.swing.JFrame; import javax.swing.WindowConstants; -import com.samskivert.util.StringUtil; - import com.samskivert.swing.util.SwingUtil; +import com.samskivert.util.ArrayUtil; +import com.samskivert.util.StringUtil; import static com.threerings.getdown.Log.log; @@ -71,8 +71,8 @@ public class GetdownApp String appId = (aidx < args.size()) ? args.get(aidx++) : null; // pass along anything after that as app args - String[] appArgs = (aidx < args.size()) - ? args.subList(aidx, args.size()).toArray(new String[0]) : null; + String[] appArgs = (aidx < args.size()) ? + args.subList(aidx, args.size()).toArray(ArrayUtil.EMPTY_STRING) : null; // ensure a valid directory was supplied File appDir = new File(adarg); diff --git a/src/main/java/com/threerings/getdown/launcher/GetdownApplet.java b/src/main/java/com/threerings/getdown/launcher/GetdownApplet.java index 93736c2..a9da88c 100644 --- a/src/main/java/com/threerings/getdown/launcher/GetdownApplet.java +++ b/src/main/java/com/threerings/getdown/launcher/GetdownApplet.java @@ -62,7 +62,7 @@ public class GetdownApplet extends JApplet // a third party to insert a trusted certificate. This should be replaced with // statically included trusted keys. _getdown = new Getdown(_config.appdir, null, GetdownApplet.class.getSigners(), - _config.jvmargs, null) { + _config.jvmargs, _config.appargs) { @Override protected Container createContainer () { getContentPane().removeAll();