From: <jko...@hy...> - 2010-04-16 20:23:45
|
Author: jkonicki Date: 2010-04-16 13:21:43 -0700 (Fri, 16 Apr 2010) New Revision: 14514 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14514 Modified: trunk/src/org/hyperic/hq/product/ProductPluginManager.java trunk/src/org/hyperic/hq/product/ant/PluginJar.java Log: HHQ-3842 The manifests will now be printed when running the agent in debug mode, or the plugindumper is executed with debug logging. Modified: trunk/src/org/hyperic/hq/product/ProductPluginManager.java =================================================================== --- trunk/src/org/hyperic/hq/product/ProductPluginManager.java 2010-04-16 19:19:35 UTC (rev 14513) +++ trunk/src/org/hyperic/hq/product/ProductPluginManager.java 2010-04-16 20:21:43 UTC (rev 14514) @@ -30,6 +30,9 @@ import java.io.FileInputStream; import java.io.InputStream; import java.lang.reflect.Method; +import java.net.JarURLConnection; +import java.net.MalformedURLException; +import java.net.URL; import java.util.Arrays; import java.util.Comparator; @@ -40,6 +43,7 @@ import java.util.Iterator; import java.util.Properties; import java.util.Set; +import java.util.jar.Attributes; import org.hyperic.hq.agent.AgentConfig; import org.hyperic.hq.common.LicenseManager; @@ -881,6 +885,29 @@ addClassPath(loader, path); } } + + private void logPluginManifest(String jarName) { + if (log.isDebugEnabled()) { + URL url; + try { + url = new URL("jar", "", "file:" + jarName + "!/"); + JarURLConnection jarConn = (JarURLConnection) url.openConnection(); + Map attributeMap = jarConn.getManifest().getMainAttributes(); + if (!attributeMap.isEmpty()) { + StringBuilder manifestLog = new StringBuilder("\n--- Manifest entries for: " + url.toString() + + " ---\n"); + Iterator iter = attributeMap.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + manifestLog.append(entry.getKey() + " - " + entry.getValue() + "\n"); + } + log.debug(manifestLog.toString()); + } + } catch (Exception e) { + log.debug("Manifest retrieval had an exception (continuing): " + e.getMessage()); + } + } + } /** * Load a product plugin jar. @@ -909,7 +936,8 @@ PluginLoader loader = PluginLoader.create(jarName, this.getClass().getClassLoader()); - + + logPluginManifest(jarName); PluginLoader.setClassLoader(loader); ClassLoader dataLoader; if (resourceLoader != null) { Modified: trunk/src/org/hyperic/hq/product/ant/PluginJar.java =================================================================== --- trunk/src/org/hyperic/hq/product/ant/PluginJar.java 2010-04-16 19:19:35 UTC (rev 14513) +++ trunk/src/org/hyperic/hq/product/ant/PluginJar.java 2010-04-16 20:21:43 UTC (rev 14514) @@ -207,30 +207,44 @@ try { addConfiguredManifest(manifest); manifest.getMainSection().addConfiguredAttribute(new Attribute("Build-Owner", getProperty("user.name", - "Unknown"))); + "Unknown"))); String hostName = "Unknown"; try { hostName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { - //ignore + // ignore } manifest.getMainSection().addConfiguredAttribute(new Attribute("Build-Host", hostName)); - + if (getProperty("release.comment", null) != null) { manifest.getMainSection() .addConfiguredAttribute(new Attribute("Build-Type", getProperty("release.comment", "Unknown"))); } manifest.getMainSection().addConfiguredAttribute(new Attribute("Build-Date", new Date().toString())); - manifest.getMainSection().addConfiguredAttribute(new Attribute("Specification-Title", "HQU Plugin")); - manifest.getMainSection().addConfiguredAttribute(new Attribute("Specification-Vendor", "VMware Inc.")); - manifest.getMainSection().addConfiguredAttribute(new Attribute("Specification-Version", - getProperty("version", "Unknown") + "-" + - getProperty("build", "Unknown"))); + manifest.getMainSection().addConfiguredAttribute(new Attribute("Specification-Title", + getProperty("specification.title", + "HQ Plugin"))); + manifest.getMainSection().addConfiguredAttribute(new Attribute("Specification-Vendor", + getProperty("specification.vendor", + "VMware Inc."))); + manifest.getMainSection() + .addConfiguredAttribute(new Attribute("Specification-Version", + getProperty("specification.version", getProperty("version", + "Unknown") + + "-" + + getProperty("build", + "Unknown")))); manifest.getMainSection().addConfiguredAttribute(new Attribute("Implementation-Title", getName())); - manifest.getMainSection().addConfiguredAttribute(new Attribute("Implementation-Version", - getProperty("version", "Unknown") + "-" + - getProperty("build", "Unknown"))); - manifest.getMainSection().addConfiguredAttribute(new Attribute("Implementation-Vendor", "VMware Inc.")); + manifest.getMainSection().addConfiguredAttribute(new Attribute("Implementation-Vendor", + getProperty("implementation.vendor", + "VMware Inc."))); + manifest.getMainSection() + .addConfiguredAttribute(new Attribute("Implementation-Version", + getProperty("implementation.version", getProperty("version", + "Unknown") + + "-" + + getProperty("build", + "Unknown")))); String mainClass = getMainClass(); if (mainClass != null) { |