Some tidying.

This commit is contained in:
Michael Bayne
2011-04-07 21:07:23 +00:00
parent 14bb4f0f9b
commit 90edcdf571
4 changed files with 22 additions and 26 deletions
@@ -69,6 +69,7 @@ import org.apache.commons.codec.binary.Base64;
import com.samskivert.io.StreamUtil; import com.samskivert.io.StreamUtil;
import com.samskivert.text.MessageUtil; import com.samskivert.text.MessageUtil;
import com.samskivert.util.ArrayUtil;
import com.samskivert.util.RandomUtil; import com.samskivert.util.RandomUtil;
import com.samskivert.util.RunAnywhere; import com.samskivert.util.RunAnywhere;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
@@ -179,26 +180,22 @@ public class Application
* configuration file from the supplied application directory. * configuration file from the supplied application directory.
* *
* @param appid usually null but a string identifier if a secondary application is desired to * @param appid usually null but a string identifier if a secondary application is desired to
* be launched. That application will use <code>appid.class</code> and * be launched. That application will use {@code appid.class} and {@code appid.apparg} to
* <code>appid.apparg</code> to configure itself but all other parameters will be the same as * 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 * @param jvmargs additional arguments to pass on to launched jvms.
* @param appargs arguments to pass on to launched application * @param appargs additional arguments to pass on to launched application; these will be added
* after the args in the getdown.txt file.
*/ */
public Application ( public Application (File appdir, String appid, Object[] signers,
File appdir, String appid, Object[] signers, String[] jvmargs, String[] appargs) String[] jvmargs, String[] appargs)
{ {
_appdir = appdir; _appdir = appdir;
_appid = appid; _appid = appid;
_signers = signers; _signers = signers;
_config = getLocalPath(CONFIG_FILE); _config = getLocalPath(CONFIG_FILE);
if (jvmargs != null) { _extraJvmArgs = (jvmargs == null) ? ArrayUtil.EMPTY_STRING : jvmargs;
_baseJvmArgs = jvmargs; _extraAppArgs = (appargs == null) ? ArrayUtil.EMPTY_STRING : appargs;
}
if (appargs != null) {
_baseAppArgs = appargs;
}
} }
/** /**
@@ -567,7 +564,7 @@ public class Application
} }
// Add the launch specific JVM arguments // Add the launch specific JVM arguments
for (String arg : _baseJvmArgs) { for (String arg : _extraJvmArgs) {
_jvmargs.add(arg); _jvmargs.add(arg);
} }
@@ -580,7 +577,7 @@ public class Application
} }
// add the launch specific application arguments // add the launch specific application arguments
for (String arg : _baseAppArgs) { for (String arg : _extraAppArgs) {
_appargs.add(arg); _appargs.add(arg);
} }
@@ -1411,7 +1408,7 @@ public class Application
protected String[] parseList (Map<String, Object> cdata, String name) protected String[] parseList (Map<String, Object> cdata, String name)
{ {
String value = (String)cdata.get(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. */ /** Possibly generates and returns a google analytics tracking cookie. */
@@ -1476,15 +1473,15 @@ public class Application
protected List<String> _jvmargs = new ArrayList<String>(); protected List<String> _jvmargs = new ArrayList<String>();
protected List<String> _appargs = new ArrayList<String>(); protected List<String> _appargs = new ArrayList<String>();
protected String[] _baseJvmArgs = new String[0]; protected String[] _extraJvmArgs;
protected String[] _baseAppArgs = new String[0]; protected String[] _extraAppArgs;
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. */
protected boolean _warnedAboutSetLastModified; 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.*/ /** Locks gettingdown.lock in the app dir. Held the entire time updating is going on.*/
protected FileLock _lock; protected FileLock _lock;
@@ -93,8 +93,7 @@ public abstract class Getdown extends Thread
this(appDir, appId, null, null, null); this(appDir, appId, null, null, null);
} }
public Getdown ( public Getdown (File appDir, String appId, Object[] signers, String[] jvmargs, String[] appargs)
File appDir, String appId, Object[] signers, String[] jvmargs, String[] appargs)
{ {
super("Getdown"); super("Getdown");
try { try {
@@ -41,9 +41,9 @@ import java.util.List;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import com.samskivert.util.StringUtil;
import com.samskivert.swing.util.SwingUtil; import com.samskivert.swing.util.SwingUtil;
import com.samskivert.util.ArrayUtil;
import com.samskivert.util.StringUtil;
import static com.threerings.getdown.Log.log; import static com.threerings.getdown.Log.log;
@@ -71,8 +71,8 @@ public class GetdownApp
String appId = (aidx < args.size()) ? args.get(aidx++) : null; String appId = (aidx < args.size()) ? args.get(aidx++) : null;
// pass along anything after that as app args // pass along anything after that as app args
String[] appArgs = (aidx < args.size()) String[] appArgs = (aidx < args.size()) ?
? args.subList(aidx, args.size()).toArray(new String[0]) : null; args.subList(aidx, args.size()).toArray(ArrayUtil.EMPTY_STRING) : null;
// ensure a valid directory was supplied // ensure a valid directory was supplied
File appDir = new File(adarg); File appDir = new File(adarg);
@@ -62,7 +62,7 @@ public class GetdownApplet extends JApplet
// 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(_config.appdir, null, GetdownApplet.class.getSigners(), _getdown = new Getdown(_config.appdir, null, GetdownApplet.class.getSigners(),
_config.jvmargs, null) { _config.jvmargs, _config.appargs) {
@Override @Override
protected Container createContainer () { protected Container createContainer () {
getContentPane().removeAll(); getContentPane().removeAll();