brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [07/10] git commit: JavaSoftwareProcessSshDriver: installing java
Date Tue, 05 Aug 2014 05:24:51 GMT
JavaSoftwareProcessSshDriver: installing java

Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/15a1340e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/15a1340e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/15a1340e

Branch: refs/heads/master
Commit: 15a1340e5177128017e7f89aeb8235a19a51ed55
Parents: f6878b1
Author: Aled Sage <aled.sage@gmail.com>
Authored: Thu Jul 31 06:55:34 2014 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Thu Jul 31 06:55:34 2014 +0100

----------------------------------------------------------------------
 .../java/JavaSoftwareProcessSshDriver.java      | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/15a1340e/software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java
b/software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java
index 86359eb..56ddc1f 100644
--- a/software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java
@@ -315,7 +315,7 @@ public abstract class JavaSoftwareProcessSshDriver extends AbstractSoftwareProce
         }
     }
 
-    private int tryJavaInstall(String version, String command) {
+    protected int tryJavaInstall(String version, String command) {
         try {
             getLocation().acquireMutex("installing", "installing Java at " + getLocation());
             log.debug("Installing Java {} at {}@{}", new Object[]{version, getEntity(), getLocation()});
@@ -355,6 +355,27 @@ public abstract class JavaSoftwareProcessSshDriver extends AbstractSoftwareProce
     }
 
     /**
+     * Answers one of "OpenJDK", "Oracle", or other vendor info.
+     */
+    protected Optional<String> getCurrentJavaVendor() {
+        // TODO Also handle IBM jvm
+        log.debug("Checking Java vendor at {}@{}", getEntity(), getLocation());
+        ProcessTaskWrapper<Integer> versionCommand = Entities.submit(getEntity(), SshTasks.newSshExecTaskFactory(
+                getLocation(), "java -version 2>&1 | awk 'NR==2 {print $1}'"));
+        versionCommand.get();
+        String stdOut = versionCommand.getStdout().trim();
+        if (Strings.isBlank(stdOut)) {
+            log.debug("Found no Java installed at {}@{}", getEntity(), getLocation());
+            return Optional.absent();
+        } else if ("Java(TM)".equals(stdOut)) {
+            log.debug("Found Java version at {}@{}: {}", new Object[] {getEntity(), getLocation(),
stdOut});
+            return Optional.of("Oracle");
+        } else {
+            return Optional.of(stdOut);
+        }
+    }
+
+    /**
      * Checks for Java 6 or 7, installing Java 7 if neither are found. Override this method
to
      * check for and install specific versions of Java.
      * @see #checkForAndInstallJava6()


Mime
View raw message