Allow additional applications to be run from a single Getdown-based
application deployment.
This commit is contained in:
@@ -95,10 +95,17 @@ public class Application
|
||||
* Creates an application instance which records the location of the
|
||||
* <code>getdown.txt</code> 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 *
|
||||
* <code>appid.class</code> and <code>appid.apparg</code> to configure
|
||||
* itself but all other parameters will be the same as the primary
|
||||
* application.
|
||||
*/
|
||||
public Application (File appdir)
|
||||
public Application (File appdir, String appid)
|
||||
{
|
||||
_appdir = appdir;
|
||||
_appid = appid;
|
||||
_config = getLocalPath(CONFIG_FILE);
|
||||
}
|
||||
|
||||
@@ -226,8 +233,10 @@ public class Application
|
||||
throw new NestableIOException(err, mue);
|
||||
}
|
||||
|
||||
String prefix = (_appid == null) ? "" : (_appid + ".");
|
||||
|
||||
// determine our application class name
|
||||
_class = (String)cdata.get("class");
|
||||
_class = (String)cdata.get(prefix + "class");
|
||||
if (_class == null) {
|
||||
throw new IOException("m.missing_class");
|
||||
}
|
||||
@@ -272,7 +281,7 @@ public class Application
|
||||
}
|
||||
|
||||
// transfer our application arguments
|
||||
String[] appargs = ConfigUtil.getMultiValue(cdata, "apparg");
|
||||
String[] appargs = ConfigUtil.getMultiValue(cdata, prefix + "apparg");
|
||||
if (appargs != null) {
|
||||
for (int ii = 0; ii < appargs.length; ii++) {
|
||||
_appargs.add(appargs[ii]);
|
||||
@@ -742,6 +751,7 @@ public class Application
|
||||
}
|
||||
|
||||
protected File _appdir;
|
||||
protected String _appid;
|
||||
protected File _config;
|
||||
protected Digest _digest;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ import com.threerings.getdown.util.ProgressObserver;
|
||||
public class Getdown extends Thread
|
||||
implements Application.StatusDisplay
|
||||
{
|
||||
public Getdown (File appDir)
|
||||
public Getdown (File appDir, String appId)
|
||||
{
|
||||
super("Getdown");
|
||||
try {
|
||||
@@ -75,7 +75,7 @@ public class Getdown extends Thread
|
||||
updateStatus(errmsg);
|
||||
_dead = true;
|
||||
}
|
||||
_app = new Application(appDir);
|
||||
_app = new Application(appDir, appId);
|
||||
_startup = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@@ -576,14 +576,22 @@ public class Getdown extends Thread
|
||||
public static void main (String[] args)
|
||||
{
|
||||
// maybe they specified the appdir in a system property
|
||||
int aidx = 0;
|
||||
String adarg = System.getProperty("appdir");
|
||||
// if not, check for a command line argument
|
||||
if (StringUtil.blank(adarg)) {
|
||||
if (args.length != 1) {
|
||||
System.err.println("Usage: java -jar getdown.jar app_dir");
|
||||
if (args.length < 1) {
|
||||
System.err.println(
|
||||
"Usage: java -jar getdown.jar app_dir [app_id]");
|
||||
System.exit(-1);
|
||||
}
|
||||
adarg = args[0];
|
||||
adarg = args[aidx++];
|
||||
}
|
||||
|
||||
// look for a specific app identifier
|
||||
String appId = null;
|
||||
if (args.length > aidx) {
|
||||
appId = args[aidx++];
|
||||
}
|
||||
|
||||
// ensure a valid directory was supplied
|
||||
@@ -620,7 +628,7 @@ public class Getdown extends Thread
|
||||
Log.info("---------------------------------------------");
|
||||
|
||||
try {
|
||||
Getdown app = new Getdown(appDir);
|
||||
Getdown app = new Getdown(appDir, appId);
|
||||
app.start();
|
||||
} catch (Exception e) {
|
||||
Log.logStackTrace(e);
|
||||
|
||||
@@ -73,13 +73,13 @@ public class Differ
|
||||
", overs=" + overs + "].");
|
||||
}
|
||||
|
||||
Application oapp = new Application(ovdir);
|
||||
Application oapp = new Application(ovdir, null);
|
||||
oapp.init(false);
|
||||
ArrayList orsrcs = new ArrayList();
|
||||
orsrcs.addAll(oapp.getCodeResources());
|
||||
orsrcs.addAll(oapp.getResources());
|
||||
|
||||
Application napp = new Application(nvdir);
|
||||
Application napp = new Application(nvdir, null);
|
||||
napp.init(false);
|
||||
ArrayList nrsrcs = new ArrayList();
|
||||
nrsrcs.addAll(napp.getCodeResources());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: DigesterTask.java,v 1.4 2004/08/10 07:23:12 mdb Exp $
|
||||
// $Id$
|
||||
|
||||
package com.threerings.getdown.tools;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class DigesterTask extends Task
|
||||
System.out.println("Generating digest file '" + target + "'...");
|
||||
|
||||
// create our application and instruct it to parse its business
|
||||
Application app = new Application(appdir);
|
||||
Application app = new Application(appdir, null);
|
||||
app.init(false);
|
||||
|
||||
ArrayList rsrcs = new ArrayList();
|
||||
|
||||
Reference in New Issue
Block a user