This is an automated email from the ASF dual-hosted git repository. udo pushed a commit to branch feature/GEODE-5660 in repository https://gitbox.apache.org/repos/asf/geode.git
commit 2633be49df4077cd2a8c6fbd9299d9e9b872cee6 Author: Udo Kohlmeyer <[email protected]> AuthorDate: Thu Aug 30 09:32:45 2018 -0700 GEODE-5660: Addressing review commentary --- .../geode/management/internal/AgentUtil.java | 41 ++++------------------ 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/AgentUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/AgentUtil.java index 83ec51e..6b80802 100755 --- a/geode-core/src/main/java/org/apache/geode/management/internal/AgentUtil.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/AgentUtil.java @@ -16,9 +16,7 @@ package org.apache.geode.management.internal; import java.io.File; -import java.net.URL; import java.util.Arrays; -import java.util.Objects; import java.util.stream.Stream; import org.apache.commons.lang.StringUtils; @@ -30,13 +28,14 @@ import org.apache.geode.internal.logging.LogService; /** * Hosts common utility methods needed by the management package * - * @since Geode 1.0.0.0 + * @since Geode 1.0.0 */ public class AgentUtil { private static final Logger logger = LogService.getLogger(); private final String gemfireVersion; + private static final String GEODE_HOME = "GEODE_HOME"; public AgentUtil(String gemfireVersion) { this.gemfireVersion = gemfireVersion; @@ -68,36 +67,10 @@ public class AgentUtil { return possiblePath; } - // if $GEODE_HOME is not set or we are not able to find it in all the possible locations under - // $GEODE_HOME, try to find in the classpath - possiblePath = - findPossibleWarLocationFromExtraLocations(versionedWarFileName, unversionedWarFileName); - if (possiblePath != null) { - return possiblePath; - } - logger.warn(warFilePrefix + " war file was not found"); return null; } - private String findPossibleWarLocationFromExtraLocations(String versionedWarFileName, - String unversionedWarFileName) { - final URL url = Arrays.stream(new String[] {versionedWarFileName, - "tools/Pulse/" + versionedWarFileName, - "tools/Extensions/" + versionedWarFileName, - "lib/" + versionedWarFileName, - unversionedWarFileName}) - .map(possibleFile -> this.getClass().getClassLoader().getResource(possibleFile)) - .filter(Objects::nonNull).findFirst().orElse(null); - - if (url != null) { - final String path = url.getPath(); - logger.info("War file found: {}", path); - return path; - } - return null; - } - private String findPossibleWarLocationForGeodeHome(String versionedWarFileName, String unversionedWarFileName) { String[] possibleFiles = {}; @@ -127,11 +100,11 @@ public class AgentUtil { .findFirst().orElse(null); } - public boolean isWebApplicationAvailable(final String warFileLocation) { + boolean isWebApplicationAvailable(final String warFileLocation) { return StringUtils.isNotBlank(warFileLocation); } - public boolean isWebApplicationAvailable(final String... warFileLocations) { + boolean isWebApplicationAvailable(final String... warFileLocations) { for (String warFileLocation : warFileLocations) { if (isWebApplicationAvailable(warFileLocation)) { return true; @@ -141,11 +114,11 @@ public class AgentUtil { return false; } - public String getGeodeHome() { + private String getGeodeHome() { - String geodeHome = System.getenv("GEODE_HOME"); + String geodeHome = System.getenv(GEODE_HOME); - logger.info("GEODE_HOME:" + geodeHome); + logger.info(GEODE_HOME+":" + geodeHome); // Check for empty variable. if empty, then log message and exit HTTP server // startup if (StringUtils.isBlank(geodeHome)) {
