From: <tr...@hy...> - 2010-03-18 16:38:21
|
Author: trader Date: 2010-03-18 09:38:12 -0700 (Thu, 18 Mar 2010) New Revision: 14396 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14396 Modified: branches/HQ_4_2_0_PATCH/plugins/tomcat/src/org/hyperic/hq/plugin/tomcat/TomcatServerDetector.java Log: [No JIRA] Fix issue identified by tcServer team in naming Tomcat servers Modified: branches/HQ_4_2_0_PATCH/plugins/tomcat/src/org/hyperic/hq/plugin/tomcat/TomcatServerDetector.java =================================================================== --- branches/HQ_4_2_0_PATCH/plugins/tomcat/src/org/hyperic/hq/plugin/tomcat/TomcatServerDetector.java 2010-03-18 16:31:56 UTC (rev 14395) +++ branches/HQ_4_2_0_PATCH/plugins/tomcat/src/org/hyperic/hq/plugin/tomcat/TomcatServerDetector.java 2010-03-18 16:38:12 UTC (rev 14396) @@ -23,17 +23,17 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.hyperic.hq.product.PluginException; -import org.hyperic.hq.product.ProductPlugin; import org.hyperic.hq.product.ServerResource; import org.hyperic.hq.product.Win32ControlPlugin; import org.hyperic.hq.product.jmx.MxServerDetector; import org.hyperic.hq.product.jmx.MxUtil; import org.hyperic.hq.product.jmx.MxServerDetector.MxProcess; -import org.hyperic.util.config.ConfigOption; +import org.hyperic.hq.product.pluginxml.PluginData; import org.hyperic.util.config.ConfigResponse; -import org.hyperic.util.config.ConfigSchema; import org.hyperic.sigar.win32.RegistryKey; import org.hyperic.sigar.win32.Win32Exception; @@ -168,18 +168,32 @@ if (!correctVersion) { return false; } - // catalina-ha.jar will be in both tc Server 6.0 and Apache Tomcat 6.0. - // We need - // to further distinguish.... - final String tcServerVersionFile = getTypeProperty("SpringSource tc Server 6.0", "VERSION_FILE"); - if (tcServerVersionFile == null) { - // tc Server plugin is not installed - return true; + + Iterator keys = PluginData.getGlobalProperties().keySet().iterator(); + String extend_server = null; + while (keys.hasNext()) { + String key = (String) keys.next(); + if (key.toUpperCase().endsWith(".EXTENDS")) { + String val = (String) PluginData.getGlobalProperties().get(key); + Pattern p = Pattern.compile(val); + Matcher m = p.matcher(getTypeInfo().getName()); + boolean find = m.find(); + getLog().debug("[isInstallTypeVersion] " + key + "=" + val + " (" + getTypeInfo().getName() + ") m.find()=" + find); + if (find) { + extend_server = key.substring(0, key.lastIndexOf(".")); + final String tcServerVersionFile = getTypeProperty(extend_server, "VERSION_FILE"); + if (tcServerVersionFile != null) { + File file = new File(catalinaHome, tcServerVersionFile); + if (file.exists()) { + getLog().debug("[isInstallTypeVersion] '" + getTypeInfo().getName() + " [" + process.getInstallPath() + "]' is a '" + extend_server + "'"); + return false; + } else { + getLog().debug("[isInstallTypeVersion] '" + getTypeInfo().getName() + " [" + process.getInstallPath() + "]' is not a '" + extend_server + "'"); + } + } + } + } } - File file = new File(catalinaHome, tcServerVersionFile); - if (file.exists()) { - return false; - } return true; } |