Allow specifying a "latest" attribute containing the URL of the latest
getdown.txt (from which we retrieve the most recent version).
This commit is contained in:
@@ -468,6 +468,16 @@ public class Application
|
|||||||
throw (IOException) new IOException(err).initCause(mue);
|
throw (IOException) new IOException(err).initCause(mue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for a latest config URL
|
||||||
|
String latest = (String)cdata.get("latest");
|
||||||
|
if (latest != null) {
|
||||||
|
try {
|
||||||
|
_latest = new URL(latest);
|
||||||
|
} catch (MalformedURLException mue) {
|
||||||
|
log.warning("Invalid URL for latest attribute.", mue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String prefix = (_appid == null) ? "" : (_appid + ".");
|
String prefix = (_appid == null) ? "" : (_appid + ".");
|
||||||
|
|
||||||
// determine our application class name
|
// determine our application class name
|
||||||
@@ -1000,6 +1010,7 @@ public class Application
|
|||||||
_targetVersion = _version;
|
_targetVersion = _version;
|
||||||
|
|
||||||
// if we are a versioned application, read in the contents of the version.txt file
|
// if we are a versioned application, read in the contents of the version.txt file
|
||||||
|
// and/or check the latest config URL for a newer version
|
||||||
if (_version != -1) {
|
if (_version != -1) {
|
||||||
File vfile = getLocalPath(VERSION_FILE);
|
File vfile = getLocalPath(VERSION_FILE);
|
||||||
FileInputStream fin = null;
|
FileInputStream fin = null;
|
||||||
@@ -1015,6 +1026,24 @@ public class Application
|
|||||||
} finally {
|
} finally {
|
||||||
StreamUtil.close(fin);
|
StreamUtil.close(fin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_latest != null) {
|
||||||
|
InputStream in = null;
|
||||||
|
try {
|
||||||
|
in = _latest.openStream();
|
||||||
|
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
|
||||||
|
for (String[] pair : ConfigUtil.parsePairs(bin, false)) {
|
||||||
|
if (pair[0].equals("version")) {
|
||||||
|
_targetVersion = Long.parseLong(pair[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warning("Unable to retrieve version from latest config file.", e);
|
||||||
|
} finally {
|
||||||
|
StreamUtil.close(in);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally let the caller know if we need an update
|
// finally let the caller know if we need an update
|
||||||
@@ -1425,6 +1454,7 @@ public class Application
|
|||||||
protected long _targetVersion = -1;
|
protected long _targetVersion = -1;
|
||||||
protected String _appbase;
|
protected String _appbase;
|
||||||
protected URL _vappbase;
|
protected URL _vappbase;
|
||||||
|
protected URL _latest;
|
||||||
protected String _class;
|
protected String _class;
|
||||||
protected String _name;
|
protected String _name;
|
||||||
protected String _dockIconPath;
|
protected String _dockIconPath;
|
||||||
|
|||||||
Reference in New Issue
Block a user