import jalview.bin.HiDPISetting;
import jalview.bin.MemorySetting;
+import jalview.util.ChannelProperties;
import jalview.util.HttpUtils;
import jalview.util.LaunchUtils;
public Application (EnvConfig envc) {
_envc = envc;
_config = getLocalPath(envc.appDir, CONFIG_FILE);
- _backupConfig = getLocalPath(envc.appDir, BACKUP_CONFIG_DIR+File.separator+CONFIG_FILE);
+ _backupConfig = getLocalPath(envc.appDir, BACKUP_CONFIG_DIR + File.separator + CONFIG_FILE);
+ log.warning("##### SET _config to", "_config", _config.getAbsolutePath());
}
/**
public File getAppDir () {
return _envc.appDir;
}
+
+ public EnvConfig getEnvConfig() {
+ return _envc;
+ }
/**
* Returns whether the application should cache code resources prior to launching the
* @exception IOException thrown if there is an error reading the file or an error encountered
* during its parsing.
*/
- public Config init (boolean checkPlatform)
+ public Config init (boolean checkPlatform) throws IOException {
+ /*#####
+ return init(checkPlatform, false);
+ }
+
+ public Config init (boolean checkPlatform, boolean secondCall)
throws IOException
{
- if (_initialised && _initialisedConfig != null)
- {
- return _initialisedConfig;
- }
+ */
+ if (_initialised && _initialisedConfig != null)
+ {
+ return _initialisedConfig;
+ }
try {
Application.i4jVersion = com.install4j.api.launcher.Variables.getCompilerVariable("sys.install4jVersion");
// merge the locator file config into config (or replace config with)
if (locatorConfig != null) {
- if (config == null || locatorConfig.getBoolean(LOCATOR_FILE_EXTENSION+"_replace") || locatorConfig.hasValue("appbase")) {
+ //##### if (config == null || locatorConfig.getBoolean(LOCATOR_FILE_EXTENSION+"_replace") || (locatorConfig.hasValue("appbase") && !secondCall)) {
+ if (config == null || locatorConfig.getBoolean(LOCATOR_FILE_EXTENSION+"_replace")) {
config = locatorConfig;
- log.warning("Replacing config with locator file", LOCATOR_FILE_EXTENSION+" file", locatorConfig);
+ log.warning("Replacing config with locator file", LOCATOR_FILE_EXTENSION+"_file", locatorConfig);
} else {
config.mergeConfig(locatorConfig, locatorConfig.getBoolean(LOCATOR_FILE_EXTENSION+"_merge"));
log.warning("Merging config with locator file", LOCATOR_FILE_EXTENSION+" file", locatorConfig);
// process, our caller can use the appbase to download a new configuration file
_appbase = config.getString("appbase");
+ /* #####
// see if locatorConfig override
- if (locatorConfig != null && !StringUtil.isBlank(locatorConfig.getString("appbase"))) {
- _appbase = locatorConfig.getString("appbase");
+ if (!secondCall && locatorConfig != null && !StringUtil.isBlank(locatorConfig.getString("appbase"))) {
+ String lAppbase = locatorConfig.getString("appbase");
+ if (lAppbase != null && !lAppbase.endsWith("/")) {
+ lAppbase = lAppbase + "/";
+ }
+ if (lAppbase != null && !lAppbase.equals(_appbase)) {
+ _appbase = lAppbase;
+ // get new getdown.txt
+ log.warning("Attempting to download new getdown.txt from " + _appbase + " and use that");
+ updateMetadata();
+ setLocatorFile(null);
+ return init(checkPlatform, true);
+ }
}
+ */
if (_appbase == null) {
throw new RuntimeException("m.missing_appbase");
return sb.toString();
}
+ public static String getLocatorFile() {
+ return _locatorFile;
+ }
+
public static void setLocatorFile(String filename) {
_locatorFile = filename;
}
args.add(sb.toString());
}
+ public boolean updateMetadataAndRelaunch(String newAppbase, Class startClass, String locatorFileArg, String[] argv, List<Note> notes) {
+ _appbase = newAppbase;
+ try {
+ updateMetadata();
+ } catch(IOException e) {
+ notes.add(Note.warn("IOException when trying to update metadata files with new appbase '" + newAppbase + "': " + e.getMessage()));
+ return false;
+ }
+
+ String appDir = this.getAppDir().getAbsolutePath();
+ String appName = StringUtil.isBlank(_envc.getAppname()) ? ChannelProperties.FALLBACK_APPNAME : _envc.getAppname();
+
+ String javaBin = LaunchUtils.findJavaBin(false);
+
+ List<String> removeJvmArgs = new ArrayList<>();
+ removeJvmArgs.add("-Dappbase=");
+ List<String> addJvmArgs = new ArrayList<>();
+ addJvmArgs.add("-Dappbase=" + newAppbase);
+
+ String macIcons = System.getProperty("installer.mac_icons");
+ // we love our Mac users, so we do nice things to preserve our application identity
+ if (LaunchUtil.isMacOS()) {
+ removeJvmArgs = new ArrayList<>();
+ addJvmArgs = new ArrayList<>();
+ if (macIcons != null) {
+ removeJvmArgs.add("-Xdock:icon=");
+ addJvmArgs.add("-Xdock:icon=" + appDir + File.separator + "resource" + File.separator + macIcons );
+ }
+ removeJvmArgs.add("-Xdock:name=");
+ addJvmArgs.add("-Xdock:name=" + ( appName != null ? appName : ChannelProperties.FALLBACK_APPNAME ));
+ }
+
+ List<String> removeArgs = new ArrayList<>();
+ if (locatorFileArg != null) {
+ removeArgs.add("locatorFileArg");
+ }
+
+ String startClassName = startClass == null ? null : startClass.getName();
+
+ int exitValue = LaunchUtils.startNewJvm(javaBin, removeJvmArgs, addJvmArgs, null, null, null, startClassName, removeArgs, null, Arrays.asList(argv), true, true, false, true, false);
+
+ if (exitValue == 0) {
+ notes.add(Note.info("Relaunching getdown succeeded. Original getdown exiting now."));
+ _envc.setRelaunched(true);
+ return true;
+ } else {
+ notes.add(Note.warn("Relaunching getdown did not seem to succeed with exit value " + exitValue + ". Continuing with this getdown process."));
+ }
+
+ return false;
+ }
+
protected final EnvConfig _envc;
protected File _config;
protected File _backupConfig;