obtain JAVA executable path from the JAVA_HOME variable. Does not require path to...
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 30 Jun 2011 17:22:57 +0000 (17:22 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 30 Jun 2011 17:22:57 +0000 (17:22 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4376 e3abac25-378b-4346-85de-24260fe3988d

TODO.txt
conf/Executable.properties
engine/compbio/engine/client/Util.java
runner/compbio/runner/disorder/Jronn.java

index 6e843bd..67dc7b9 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,3 +1,27 @@
+JABA 1 is to keep working, later when 2 is ready replace jabaws mapping to point to \r
+JABA 2 but provide a link to JABA 1.  \r
+\r
+install JABA 1 stat server \r
+\r
++Get path to Java executable from JAVA_HOME ? (for Jronn AACon) \r
++Describe requirements \r
+\r
+Python > 2.2\r
+Perl > 5.0\r
+Java > 6\r
+\r
+For compilation \r
+C++\r
+C\r
+Gnu make\r
+\r
+Webpage for testing web services?\r
+\r
+Crawler is to update DB records if the directory is not found to prevent link \r
+generation for stats. \r
+\r
\r
+\r
 + Help information? - relative - client to add host and context info\r
 + statistics - result files \r
 + Check progress tracking on large sequence. \r
index f97b168..a1107ca 100644 (file)
@@ -73,9 +73,11 @@ probcons.parameters.file=conf/settings/ProbconsParameters.xml
 #probcons.limits.file=conf/settings/ProbconsLimits.xml\r
 #probcons.cluster.settings=-l h_cpu=24:00:00 -l h_vmem=6000M -l ram=6000M\r
 \r
-### Jronn configuration ### \r
-local.jronn.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe \r
-local.jronn.bin=/sw/java/latest/bin/java\r
+### Jronn configuration ###\r
+# If no local path are specified, Java is loaded from JAVA_HOME environment \r
+# variable for local execution \r
+#local.jronn.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe \r
+#local.jronn.bin=/sw/java/latest/bin/java\r
 cluster.jronn.bin=/sw/java/latest/bin/java\r
 jronn.jar.file=binaries/windows/jronn3.1.jar\r
 jronn.limits.file=conf/settings/JronnLimits.xml\r
@@ -110,8 +112,8 @@ iupred.parameters.file=conf/settings/IUPredParameters.xml
 \r
 ### AACon configuration ###\r
 # This is just a path to the standard java executable \r
-local.aacon.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe \r
-local.aacon.bin=/sw/java/latest/bin/java\r
+#local.aacon.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe \r
+#local.aacon.bin=/sw/java/latest/bin/java\r
 cluster.aacon.bin=/sw/java/latest/bin/java\r
 # Path to the AACon library\r
 aacon.jar.file=binaries/windows/aaconservation.jar\r
index 9d0727b..30ac944 100644 (file)
@@ -225,6 +225,14 @@ public final class Util {
                        } else {\r
                                bin = ph.getProperty("local." + execCommandName + ".bin");\r
                        }\r
+                       // For executable Jar files the location of Java executable is not\r
+                       // required for local execution. If it is not provided, JABAWS will\r
+                       // attempt to use Java from JAVA_HOME env variable\r
+                       if (isJavaLibrary(clazz)) {\r
+                               if (compbio.util.Util.isEmpty(bin)) {\r
+                                       bin = getJava();\r
+                               }\r
+                       }\r
                        // If path to executable defined in the properties is not absolute,\r
                        // then make it so\r
                        // as setting working directory of ProcessBuilder will make it\r
@@ -232,13 +240,62 @@ public final class Util {
                        // to find an executable otherwise\r
                        if (!compbio.util.Util.isEmpty(bin)\r
                                        && !PathValidator.isAbsolutePath(bin)) {\r
-                               bin = PropertyHelperManager.getLocalPath() + bin;\r
+                               bin = bin.trim();\r
+                               if (bin.equalsIgnoreCase("java")\r
+                                               || bin.equalsIgnoreCase("java.exe")) {\r
+                                       // do not make path absolute to the java executable if\r
+                                       // relative path is provided. Java executable is not a part\r
+                                       // of JABAWS distribution!\r
+                               } else {\r
+                                       bin = PropertyHelperManager.getLocalPath() + bin;\r
+                               }\r
                        }\r
                } else {\r
                        bin = ph.getProperty("cluster." + execCommandName + ".bin");\r
                }\r
                return bin; // File.separator\r
        }\r
+       /**\r
+        * Returns true of executableName.jar.file property has some value in the\r
+        * Executable.properties file, false otherwise.\r
+        * \r
+        * @param clazz\r
+        * @return\r
+        */\r
+       public static boolean isJavaLibrary(Class<?> clazz) {\r
+               String execCommandName = clazz.getSimpleName().toLowerCase();\r
+               String java_lib = ph.getProperty(execCommandName + ".jar.file");\r
+               assert FileUtil.exist(java_lib);\r
+               return !compbio.util.Util.isEmpty(java_lib);\r
+       }\r
+\r
+       /**\r
+        * Returns the absolute path to the Java executable from JAVA_HOME\r
+        * \r
+        * @return\r
+        */\r
+       public static String getJava() {\r
+               String javahome = System.getenv("JAVA_HOME");\r
+               File jh = new File(javahome);\r
+               if (jh.exists() && jh.isDirectory()) {\r
+                       String java = javahome + File.separator + "bin" + File.separator\r
+                                       + "java";\r
+                       if (SysPrefs.isWindows) {\r
+                               java += ".exe";\r
+                       }\r
+                       File jexe = new File(java);\r
+                       if (jexe.exists() && jexe.isFile() && jexe.canExecute()) {\r
+                               log.info("Using Java from: " + jexe.getAbsolutePath());\r
+                               return jexe.getAbsolutePath();\r
+                       } else {\r
+                               log.warn("Cannot find java executable in the JAVA_HOME!");\r
+                       }\r
+               } else {\r
+                       log.warn("JAVA_HOME does not seems to point to a valid directory! Value: "\r
+                                       + javahome);\r
+               }\r
+               return null;\r
+       }\r
 \r
        public static ExecProvider getSupportedRuntimes(Class<?> clazz) {\r
                boolean localRuntimeSupport = false;\r
@@ -251,7 +308,10 @@ public final class Util {
                if (!compbio.util.Util.isEmpty(localRuntime1)\r
                                || !compbio.util.Util.isEmpty(localRuntime2)) {\r
                        localRuntimeSupport = true;\r
+               } else {\r
+                       localRuntimeSupport = isJavaLibrary(clazz) && getJava() != null;\r
                }\r
+\r
                String clusterRuntime = ph.getProperty("cluster." + executableName\r
                                + ".bin");\r
                if (!compbio.util.Util.isEmpty(clusterRuntime)) {\r
@@ -269,7 +329,6 @@ public final class Util {
                throw new InvalidParameterException(\r
                                "Executable is not provided for any runtime environments");\r
        }\r
-\r
        public static ConfiguredExecutable<?> loadExecutable(String taskId)\r
                        throws ResultNotAvailableException {\r
                String workDir = compbio.engine.Configurator.getWorkDirectory(taskId);\r
index 8e1eb25..5850eaf 100644 (file)
@@ -93,7 +93,6 @@ public class Jronn extends SkeletalExecutable<Jronn> {
        }\r
 \r
        private static String getLibPath() {\r
-\r
                String settings = ph.getProperty("jronn.jar.file");\r
                if (compbio.util.Util.isEmpty(settings)) {\r
                        throw new NullPointerException(\r