X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=getdown%2Fsrc%2Fgetdown%2Fcore%2Fsrc%2Fmain%2Fjava%2Fcom%2Fthreerings%2Fgetdown%2Fdata%2FApplication.java;h=b6ae55d3bff8aa65ce0f74856fdaf24bb95debca;hb=d1c8640fb18d4fad7cf630d2ccb9cf31dfc3db25;hp=501407c0f541a2c639b27303085d5f20d6adeb40;hpb=f517e5ea31f1749617ac191137891cf87111550b;p=jalview.git diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java index 501407c..b6ae55d 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java @@ -448,7 +448,8 @@ public class Application return null; } - String vmfile = LaunchUtil.LOCAL_JAVA_DIR + ".jar"; + String extension = (_javaLocation.endsWith(".tgz"))?".tgz":".jar"; + String vmfile = LaunchUtil.LOCAL_JAVA_DIR + extension; log.info("vmfile is '"+vmfile+"'"); System.out.println("vmfile is '"+vmfile+"'"); try { @@ -580,6 +581,10 @@ public class Application // first determine our application base, this way if anything goes wrong later in the // process, our caller can use the appbase to download a new configuration file _appbase = config.getString("appbase"); + // override if a Version Locator file has been used + if (newAppbase != null) { + _appbase = newAppbase.toString(); + } if (_appbase == null) { throw new RuntimeException("m.missing_appbase"); } @@ -766,7 +771,7 @@ public class Application // add the launch specific application arguments _appargs.addAll(_envc.appArgs); - + // look for custom arguments fillAssignmentListFromPairs("extra.txt", _txtJvmArgs); @@ -1042,11 +1047,32 @@ public class Application args.add(_class); } + // almost finally check the startup file arguments + for (File f : startupFiles) { + _appargs.add(f.getAbsolutePath()); + break; // Only add one file to open + } + + // check if one arg with recognised extension + if ( _appargs.size() == 1 && _appargs.get(0) != null ) { + String filename = _appargs.get(0); + String ext = null; + int j = filename.lastIndexOf('.'); + if (j > -1) { + ext = filename.substring(j+1); + } + if (startupFileExtensions.contains(ext.toLowerCase())) { + _appargs.add(0, "-open"); + } else if (locatorFileExtension.equals(ext.toLowerCase())) { + // deal with this when first encountered in Getdown! + } + } + // finally add the application arguments for (String string : _appargs) { args.add(processArg(string)); } - + String[] envp = createEnvironment(); String[] sargs = args.toArray(new String[args.size()]); log.info("Running " + StringUtil.join(sargs, "\n ")); @@ -1759,6 +1785,23 @@ public class Application { return new File(appdir, path); } + + public void addStartupFile (File f) { + startupFiles.add(f); + } + + public void newAppbase (URL url) { + if ( + url.getHost().endsWith(".jalview.org") + || url.equals("jalview.org") + || (url.getProtocol().equals("file") && url.getHost().equals("")) + ) { + newAppbase = url; + log.info("Appbase set to Java Version Locator url '"+url.toString()+"'"); + return; + } + log.info("Java Version Locator url '"+url.toString()+"' does not have a jalview.org domain. Ignoring"); + } protected final EnvConfig _envc; protected File _config; @@ -1803,6 +1846,8 @@ public class Application protected List _jvmargs = new ArrayList<>(); protected List _appargs = new ArrayList<>(); + protected List startupFiles = new ArrayList<>(); + protected URL newAppbase; protected String[] _optimumJvmArgs; @@ -1823,4 +1868,7 @@ public class Application protected static final String ENV_VAR_PREFIX = "%ENV."; protected static final Pattern ENV_VAR_PATTERN = Pattern.compile("%ENV\\.(.*?)%"); + + public static final List startupFileExtensions = Arrays.asList(new String[] { "jvp" }); + public static final String locatorFileExtension = "jvl"; }