Extract our myriad system properties into one place.

This makes it easier to see all the secret configuration tweaks that one can
supply to Getdown if you have the esoteric knowledge.
This commit is contained in:
Michael Bayne
2013-01-29 10:33:53 -08:00
parent 431e35d3e2
commit 406657ff43
4 changed files with 112 additions and 19 deletions
@@ -1219,7 +1219,7 @@ public class Application
}
MetaProgressObserver mpobs = new MetaProgressObserver(obs, totalSize);
boolean noUnpack = Boolean.getBoolean("no_unpack");
boolean noUnpack = SysProps.noUnpack();
for (Resource rsrc : rsrcs) {
if (Thread.interrupted()) {
throw new InterruptedException("m.applet_stopped");
@@ -1658,7 +1658,7 @@ public class Application
*/
protected String replaceDomain (String appbase)
{
String appbaseDomain = System.getProperty("appbase_domain");
String appbaseDomain = SysProps.appbaseDomain();
if (appbaseDomain != null) {
Matcher m = Pattern.compile("(http://[^/]+)(.*)").matcher(appbase);
appbase = m.replaceAll(appbaseDomain + "$2");
@@ -0,0 +1,88 @@
//
// $Id$
//
// Getdown - application installer, patcher and launcher
// Copyright (C) 2004-2010 Three Rings Design, Inc.
// http://code.google.com/p/getdown/
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.threerings.getdown.data;
/**
* This class encapsulates all system properties that are read and processed by Getdown. Don't
* stick a call to {@code System.getProperty} randomly into the code, put it in here and give it an
* accessor so that it's easy to see all of the secret system property arguments that Getdown makes
* use of.
*/
public class SysProps
{
/** Configures the appdir (in lieu of passing it in argv). Usage: {@code -Dappdir=foo}. */
public static String appDir () {
return System.getProperty("appdir");
}
/** Configures the appid (in lieu of passing it in argv). Usage: {@code -Dappid=foo}. */
public static String appId () {
return System.getProperty("appid");
}
/** If true, disables redirection of logging into {@code launcher.log}.
* Usage: {@code -Dno_log_redir}. */
public static boolean noLogRedir () {
return System.getProperty("no_log_redir") != null;
}
/** Overrides the domain on {@code appbase}. Usage: {@code -Dappbase_domain=foo}. */
public static String appbaseDomain () {
return System.getProperty("appbase_domain");
}
/** If true, Getdown installs the app without ever bringing up a UI, except in the event of an
* error. NOTE: it does not launch the app. See {@link #launchInSilent}.
* Usage: {@code -Dsilent}. */
public static boolean silent () {
return System.getProperty("silent") != null;
}
/** If true, Getdown installs the app without ever bringing up a UI and then launches it.
* Usage: {@code -Dsilent=launch}. */
public static boolean launchInSilent () {
return "launch".equals(System.getProperty("silent"));
}
/** Specifies the a delay (in minutes) to wait before starting the update and install process.
* Usage: {@code -Ddelay=N}. */
public static int startDelay () {
return Integer.getInteger("delay", 0);
}
/** If true, Getdown will not unpack {@code uresource} jars. Usage: {@code -Dno_unpack}. */
public static boolean noUnpack () {
return Boolean.getBoolean("no_unpack");
}
/** If true, Getdown will run the application in the same VM in which Getdown is running. If
* false (the default), Getdown will fork a new VM. Note that reusing the same VM prevents
* Getdown from configuring some launch-time-only VM parameters (like -mxN etc.).
* Usage: {@code -Ddirect}. */
public static boolean direct () {
return Boolean.getBoolean("direct");
}
}
@@ -78,9 +78,10 @@ import com.samskivert.text.MessageUtil;
import com.samskivert.util.RunAnywhere;
import com.samskivert.util.StringUtil;
import com.threerings.getdown.data.Application;
import com.threerings.getdown.data.Application.UpdateInterface.Step;
import com.threerings.getdown.data.Application;
import com.threerings.getdown.data.Resource;
import com.threerings.getdown.data.SysProps;
import com.threerings.getdown.net.Downloader;
import com.threerings.getdown.net.HTTPDownloader;
import com.threerings.getdown.tools.Patcher;
@@ -117,12 +118,11 @@ public abstract class Getdown extends Thread
try {
// If the silent property exists, install without bringing up any gui. If it equals
// launch, start the application after installing. Otherwise, just install and exit.
String silent = System.getProperty("silent");
_silent = silent != null;
_silent = SysProps.silent();
if (_silent) {
_launchInSilent = silent.equals("launch");
_launchInSilent = SysProps.launchInSilent();
}
_delay = Integer.getInteger("delay", 0);
_delay = SysProps.startDelay();
} catch (SecurityException se) {
// don't freak out, just assume non-silent and no delay; we're probably already
// recovering from a security failure
@@ -1127,8 +1127,9 @@ public abstract class Getdown extends Thread
*/
protected boolean invokeDirect ()
{
// allow passing -Ddirect=true to force direct invocation
return Boolean.getBoolean("direct");
// by default check a sysprop (which itself defaults to false); in applet mode this is
// overridden to check the applet config
return SysProps.direct();
}
/**
@@ -46,6 +46,7 @@ import com.samskivert.util.ArrayUtil;
import com.samskivert.util.RunAnywhere;
import com.samskivert.util.StringUtil;
import com.threerings.getdown.data.SysProps;
import static com.threerings.getdown.Log.log;
/**
@@ -53,13 +54,13 @@ import static com.threerings.getdown.Log.log;
*/
public class GetdownApp
{
public static void main (String[] argArray)
public static void main (String[] argv)
{
// maybe they specified the appdir in a system property
int aidx = 0;
List<String> args = Arrays.asList(argArray);
String adarg = System.getProperty("appdir");
// if not, check for a command line argument
List<String> args = Arrays.asList(argv);
// check for app dir in a sysprop and then via argv
String adarg = SysProps.appDir();
if (StringUtil.isBlank(adarg)) {
if (args.isEmpty()) {
System.err.println("Usage: java -jar getdown.jar app_dir [app_id] [app args]");
@@ -68,12 +69,15 @@ public class GetdownApp
adarg = args.get(aidx++);
}
// look for a specific app identifier
String appId = (aidx < args.size()) ? args.get(aidx++) : System.getProperty("appid");
// check for an app identifier in a sysprop and then via argv
String appId = SysProps.appId();
if (StringUtil.isBlank(appId) && aidx < args.size()) {
appId = args.get(aidx++);
}
// pass along anything after that as app args
String[] appArgs = (aidx < args.size()) ?
args.subList(aidx, args.size()).toArray(ArrayUtil.EMPTY_STRING) : null;
String[] appArgs = (aidx >= args.size()) ? null :
args.subList(aidx, args.size()).toArray(ArrayUtil.EMPTY_STRING);
// ensure a valid directory was supplied
File appDir = new File(adarg);
@@ -83,7 +87,7 @@ public class GetdownApp
}
// pipe our output into a file in the application directory
if (System.getProperty("no_log_redir") == null) {
if (!SysProps.noLogRedir()) {
File logFile = new File(appDir, "launcher.log");
try {
PrintStream logOut = new PrintStream(