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