Changed java_version_max to java_max_version.
Other tidying and consolidation.
This commit is contained in:
@@ -516,26 +516,11 @@ public class Application
|
|||||||
|
|
||||||
// extract our version information
|
// extract our version information
|
||||||
String vstr = (String)cdata.get("version");
|
String vstr = (String)cdata.get("version");
|
||||||
if (vstr != null) {
|
if (vstr != null) _version = parseLong(vstr, "m.invalid_version");
|
||||||
try {
|
|
||||||
_version = Long.parseLong(vstr);
|
|
||||||
} catch (Exception e) {
|
|
||||||
String err = MessageUtil.tcompose("m.invalid_version", vstr);
|
|
||||||
throw (IOException) new IOException(err).initCause(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check to see if we require a particular max JVM version and have a supplied JVM
|
// check to see if we require a particular max JVM version and have a supplied JVM
|
||||||
vstr = (String)cdata.get("java_version_max");
|
vstr = (String)cdata.get("java_max_version");
|
||||||
if (vstr != null) {
|
if (vstr != null) _javaMaxVersion = (int)parseLong(vstr, "m.invalid_java_version");
|
||||||
try {
|
|
||||||
_javaVersionMax = Integer.parseInt(vstr);
|
|
||||||
} catch (Exception e) {
|
|
||||||
String err = MessageUtil.tcompose("m.invalid_java_version", vstr);
|
|
||||||
throw (IOException) new IOException(err).initCause(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// if we are a versioned deployment, create a versioned appbase
|
// if we are a versioned deployment, create a versioned appbase
|
||||||
try {
|
try {
|
||||||
@@ -570,14 +555,7 @@ public class Application
|
|||||||
|
|
||||||
// check to see if we require a particular JVM version and have a supplied JVM
|
// check to see if we require a particular JVM version and have a supplied JVM
|
||||||
vstr = (String)cdata.get("java_version");
|
vstr = (String)cdata.get("java_version");
|
||||||
if (vstr != null) {
|
if (vstr != null) _javaMinVersion = (int)parseLong(vstr, "m.invalid_java_version");
|
||||||
try {
|
|
||||||
_javaVersion = Integer.parseInt(vstr);
|
|
||||||
} catch (Exception e) {
|
|
||||||
String err = MessageUtil.tcompose("m.invalid_java_version", vstr);
|
|
||||||
throw (IOException) new IOException(err).initCause(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check to see if we require a particular JVM version and have a supplied JVM
|
// check to see if we require a particular JVM version and have a supplied JVM
|
||||||
vstr = (String)cdata.get("java_exact_version_required");
|
vstr = (String)cdata.get("java_exact_version_required");
|
||||||
@@ -789,7 +767,7 @@ public class Application
|
|||||||
public boolean haveValidJavaVersion ()
|
public boolean haveValidJavaVersion ()
|
||||||
{
|
{
|
||||||
// if we're doing no version checking, then yay!
|
// if we're doing no version checking, then yay!
|
||||||
if (_javaVersion <= 0 && _javaVersionMax <= 0) {
|
if (_javaMinVersion == 0 && _javaMaxVersion == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -806,7 +784,7 @@ public class Application
|
|||||||
// if we can't parse the java version we're in weird land and should probably just try
|
// if we can't parse the java version we're in weird land and should probably just try
|
||||||
// our luck with what we've got rather than try to download a new jvm
|
// our luck with what we've got rather than try to download a new jvm
|
||||||
log.warning("Unable to parse VM version, hoping for the best",
|
log.warning("Unable to parse VM version, hoping for the best",
|
||||||
"version", verstr, "needed", _javaVersion);
|
"version", verstr, "needed", _javaMinVersion);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -817,24 +795,17 @@ public class Application
|
|||||||
int version = patch + 100 * (revis + 100 * (minor + 100 * major));
|
int version = patch + 100 * (revis + 100 * (minor + 100 * major));
|
||||||
|
|
||||||
if (_javaExactVersionRequired) {
|
if (_javaExactVersionRequired) {
|
||||||
if (version == _javaVersion) {
|
if (version == _javaMinVersion) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
log.warning("An exact Java VM version is required.", "current", version,
|
log.warning("An exact Java VM version is required.", "current", version,
|
||||||
"required", _javaVersion);
|
"required", _javaMinVersion);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean minVersionOK = true;
|
boolean minVersionOK = (_javaMinVersion == 0) || (version >= _javaMinVersion);
|
||||||
if ( _javaVersion > 0 ) {
|
boolean maxVersionOK = (_javaMaxVersion == 0) || (version <= _javaMaxVersion);
|
||||||
minVersionOK = version >= _javaVersion;
|
|
||||||
}
|
|
||||||
boolean maxVersionOK = true;
|
|
||||||
if ( _javaVersionMax > 0 ) {
|
|
||||||
maxVersionOK = version <= _javaVersionMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
return minVersionOK && maxVersionOK;
|
return minVersionOK && maxVersionOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1687,6 +1658,20 @@ public class Application
|
|||||||
return appbase;
|
return appbase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses and returns a long. {@code value} must be non-null.
|
||||||
|
* @throws IOException on malformed value.
|
||||||
|
*/
|
||||||
|
protected static long parseLong (String value, String errkey) throws IOException
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return Long.parseLong(value);
|
||||||
|
} catch (Exception e) {
|
||||||
|
String err = MessageUtil.tcompose(errkey, value);
|
||||||
|
throw (IOException) new IOException(err).initCause(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected File _appdir;
|
protected File _appdir;
|
||||||
protected String _appid;
|
protected String _appid;
|
||||||
protected File _config;
|
protected File _config;
|
||||||
@@ -1712,8 +1697,7 @@ public class Application
|
|||||||
protected long _trackingStart;
|
protected long _trackingStart;
|
||||||
protected int _trackingId;
|
protected int _trackingId;
|
||||||
|
|
||||||
protected int _javaVersion;
|
protected int _javaMinVersion, _javaMaxVersion;
|
||||||
protected long _javaVersionMax = -1;
|
|
||||||
protected boolean _javaExactVersionRequired;
|
protected boolean _javaExactVersionRequired;
|
||||||
protected String _javaLocation;
|
protected String _javaLocation;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user