brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neykov <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: add support to control java versi...
Date Thu, 30 Apr 2015 16:16:07 GMT
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/619#discussion_r29444340
  
    --- Diff: software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java
---
    @@ -272,69 +273,24 @@ public String getJmxContext() {
         }
     
         /**
    -     * Checks for the presence of Java 6 or 7 on the entity's location, installing if
necessary.
    -     * @return true if Java 6 or 7 was found on the machine or if it was installed correctly,
otherwise false.
    +     * Checks for the presence of Java on the entity's location, installing if necessary.
    +     * @return true if the required version of Java was found on the machine or if it
was installed correctly,
    +     * otherwise false.
          */
    -    protected boolean checkForAndInstallJava6or7() {
    -        Optional<String> version = getCurrentJavaVersion();
    -        if (version.isPresent() && (version.get().startsWith("1.8") || version.get().startsWith("1.7")
|| version.get().startsWith("1.6"))) {
    -            log.debug("Java version {} already installed at {}@{}", new Object[]{version.get(),
getEntity(), getLocation()});
    -            return true;
    -        } else {
    -            // Let's hope not!
    -            if (version.isPresent()) {
    -                log.debug("Found old Java version {} on {}@{}. Going to install latest
Java version.",
    -                        new Object[]{version.get(), getEntity(), getLocation()});
    -            }
    -            return tryJavaInstall("latest", BashCommands.installJava7Or6OrFail()) ==
0;
    -        }
    -    }
    -
    -    /**
    -     * Checks for the presence of Java 7 or 8 on the entity's location, installing if
necessary.
    -     * @return true if Java 7 or 8 was found on the machine or if it was installed correctly,
otherwise false.
    -     */
    -    protected boolean checkForAndInstallJava7or8() {
    -        Optional<String> version = getCurrentJavaVersion();
    -        if (version.isPresent() && (version.get().startsWith("1.8") || version.get().startsWith("1.7")))
{
    -            log.debug("Java version {} already installed at {}@{}", new Object[]{version.get(),
getEntity(), getLocation()});
    -            return true;
    -        } else {
    -            // Let's hope not!
    -            if (version.isPresent()) {
    -                log.debug("Found old Java version {} on {}@{}. Going to install latest
Java version.",
    -                        new Object[]{version.get(), getEntity(), getLocation()});
    +    protected boolean checkForAndInstallJava(String requiredVersion) {
    +        List<String> requiredVersionParts = Splitter.on(".").splitToList(requiredVersion);
    +        int requiredJavaMinor = Integer.valueOf(requiredVersionParts.get(1));
    --- End diff --
    
    Worth checking the length in case invalid format was supplied with more information exception
message.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message