# HG changeset patch # User Mario Torre # Date 1366033504 -7200 # Node ID c8d427902c6bda4230e33e3aba44969495e5d301 # Parent ef9be67db1adf2bdd9218b42706a2889482e6ca8 Schema for plugin.xml files reviewed-by: neugens, omajid, jerboaa, vanaltj contributed-by: obryan review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-April/006307.html diff -r ef9be67db1ad -r c8d427902c6b host-cpu/distribution/plugin.xml --- a/host-cpu/distribution/plugin.xml Mon Apr 08 17:06:45 2013 -0400 +++ b/host-cpu/distribution/plugin.xml Mon Apr 15 15:45:04 2013 +0200 @@ -36,29 +36,31 @@ to do so, delete this exception statement from your version. --> - - - + + + gui thermostat-host-cpu-common-${project.version}.jar thermostat-host-cpu-client-core-${project.version}.jar thermostat-host-cpu-client-swing-${project.version}.jar - - + + agent thermostat-host-cpu-common-${project.version}.jar thermostat-host-cpu-agent-${project.version}.jar - + - + webservice thermostat-host-cpu-common-${project.version}.jar - - - \ No newline at end of file + + + diff -r ef9be67db1ad -r c8d427902c6b host-memory/distribution/plugin.xml --- a/host-memory/distribution/plugin.xml Mon Apr 08 17:06:45 2013 -0400 +++ b/host-memory/distribution/plugin.xml Mon Apr 15 15:45:04 2013 +0200 @@ -36,29 +36,31 @@ to do so, delete this exception statement from your version. --> - - - + + + gui thermostat-host-memory-common-${project.version}.jar thermostat-host-memory-client-core-${project.version}.jar thermostat-host-memory-client-swing-${project.version}.jar - - + + agent thermostat-host-memory-common-${project.version}.jar thermostat-host-memory-agent-${project.version}.jar - + - + webservice thermostat-host-memory-common-${project.version}.jar - - - \ No newline at end of file + + + diff -r ef9be67db1ad -r c8d427902c6b host-overview/distribution/plugin.xml --- a/host-overview/distribution/plugin.xml Mon Apr 08 17:06:45 2013 -0400 +++ b/host-overview/distribution/plugin.xml Mon Apr 15 15:45:04 2013 +0200 @@ -36,14 +36,16 @@ to do so, delete this exception statement from your version. --> - - - + + + gui thermostat-host-overview-client-core-${project.version}.jar thermostat-host-overview-client-swing-${project.version}.jar - - - \ No newline at end of file + + + diff -r ef9be67db1ad -r c8d427902c6b launcher/src/main/java/com/redhat/thermostat/launcher/internal/PluginConfiguration.java --- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/PluginConfiguration.java Mon Apr 08 17:06:45 2013 -0400 +++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/PluginConfiguration.java Mon Apr 15 15:45:04 2013 +0200 @@ -88,16 +88,15 @@ private final String commandName; private final String description; - private final String usage; + private String usage; private final Options options; private final List additionalResources; private final List coreDeps; - public NewCommand(String name, String usage, String description, + public NewCommand(String name, String description, Options options, List additionalResources, List coreDeps) { this.commandName = name; this.description = description; - this.usage = usage; this.options = options; this.additionalResources = additionalResources; this.coreDeps = coreDeps; diff -r ef9be67db1ad -r c8d427902c6b launcher/src/main/java/com/redhat/thermostat/launcher/internal/PluginConfigurationParser.java --- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/PluginConfigurationParser.java Mon Apr 08 17:06:45 2013 -0400 +++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/PluginConfigurationParser.java Mon Apr 15 15:45:04 2013 +0200 @@ -74,44 +74,115 @@ * A example configuration looks like the following: * *
- * <?xml version="1.0"?>
- * <plugin>
- *   <commands>
- *     <command type="extends">
- *       <name>gui</name>
- *       <bundles>
- *         <bundle>hello-world-plugin-0.1-SNAPSHOT.jar</bundle>
- *       </bundles>
- *       <dependencies>
- *         <dependency>thermostat-client-core-0.6.0-SNAPSHOT.jar</dependency>
- *       </dependencies>
- *     </command>
- *     <command type="provides">
- *       <name>hello</name>
- *       <description>print hello</description>
- *       <usage>hello</usage>
- *       <options>
- *         <options>
- *           <long>long</long>
- *           <short>l</short>
- *           <hasArg>true</hasArg>
- *           <required>true</required>
- *           <description>some required and long option</description>
- *         </option>
- *         <options common="true">
- *           <long>dbUrl</long>
- *           <required>true</required>
- *         </option>
- *       </options>
- *       <bundles>
- *         <bundle>hello-world-plugin-0.1-SNAPSHOT.jar</bundle>
- *       </bundles>
- *       <dependencies>
- *         <dependency>thermostat-client-core-0.6.0-SNAPSHOT.jar</dependency>
- *       </dependencies>
- *     </command>
- *   </commands>
- * </plugin>
+ * 
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin xmlns="http://icedtea.classpath.org/thermostat/plugins/v1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://icedtea.classpath.org/thermostat/plugins/v1.0">
+  <commands>  
+    <command>
+      <name>platform</name>
+      <description>launches a bare bone Platform Client</description>
+      <options> 
+	<group>
+	  <required>true</required>
+	  <option>
+	    <long>optA</long>
+	    <short>a</short>
+	    <required>true</required>
+	  </option>
+	  <option>
+	    <long>optB</long>
+	    <short>b</short>
+	    <required>true</required>
+          </option>
+	  <option>
+	    <long>optC</long>
+	    <short>b</short>	    
+	    <required>false</required>
+	  </option>
+	  <option common="true">
+            <long>dbUrl</long>
+          </option>
+          <option common="true">
+            <long>username</long>
+          </option>
+          <option common="true">
+            <long>password</long>
+          </option>
+          <option common="true">
+            <long>logLevel</long>
+          </option>
+	</group>   
+	<option>
+	  <long>heapId</long>
+	  <short>h</short>
+	  <argument>heapArgument</argument>
+	  <required>true</required>
+	  <description>the ID of the heapdump to analyze</description>
+	</option>
+	<option>
+	  <long>limit</long>
+	  <short>L</short>
+	  <argument>limitArgument</argument>
+	  <required>false</required>
+	  <description>limit search to top N results, defaults to 10</description>
+	</option>
+      </options>
+      <bundles>
+	<bundle>thermostat-platform-common-0.6.0-SNAPSHOT.jar</bundle>
+	<bundle>thermostat-platform-swing-0.6.0-SNAPSHOT.jar</bundle>
+      </bundles>
+      <dependencies>
+	<dependency>thermostat-client-core-0.6.0-SNAPSHOT.jar</dependency>
+      </dependencies>
+    </command>
+    <command>
+      <name>platform2</name>
+      <description>launches a bare bone Platform Client</description>
+       <options> 
+	<option>
+	  <long>heapId2</long>
+	  <short>h</short>
+	  <argument>heapId2Argument</argument>
+	  <required>true</required>
+	  <description>the ID of the heapdump to analyze</description>
+	</option>
+	<option>
+	  <long>limit2</long>
+	  <short>L</short>
+	  <argument>limit2Argument</argument>
+	  <required>false</required>
+	  <description>limit search to top N results, defaults to 10</description>
+	</option>
+      </options>
+      <bundles>
+	<bundle>thermostat-platform-common-0.6.0-SNAPSHOT.jar</bundle>
+	<bundle>thermostat-platform-controllers-0.6.0-SNAPSHOT.jar</bundle>
+      </bundles>
+      <dependencies>
+	<dependency>thermostat-common-core-0.6.0-SNAPSHOT.jar</dependency>
+      </dependencies>
+    </command>
+  </commands>
+  <extensions>
+    <extension>
+      <name>platform3</name>
+      <bundles>
+        <bundle>thermostat-platform-common-0.6.0-SNAPSHOT.jar</bundle>
+	<bundle>thermostat-platform-controllers-0.6.0-SNAPSHOT.jar</bundle>
+	<bundle>thermostat-platform-command-0.6.0-SNAPSHOT.jar</bundle>
+	<bundle>thermostat-platform-common-export-0.6.0-SNAPSHOT.jar</bundle>
+	<bundle>thermostat-platform-swing-0.6.0-SNAPSHOT.jar</bundle>
+      </bundles>
+      <dependencies>
+	<dependency>thermostat-common-core-0.6.0-SNAPSHOT.jar</dependency>
+	<dependency>thermostat-client-core-0.6.0-SNAPSHOT.jar</dependency>
+      </dependencies>
+    </extension>
+  </extensions>
+</plugin>
+
  * 
*

* This class is thread-safe @@ -144,49 +215,56 @@ } private PluginConfiguration parseRootElement(String pluginName, Node root) { - List newCommands = Collections.emptyList(); + List commands = Collections.emptyList(); List extensions = Collections.emptyList(); - Pair, List> commands = new Pair<>(newCommands, extensions); if (root.getNodeName().equals("plugin")) { NodeList nodes = root.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node.getNodeName().equals("commands")) { commands = parseCommands(pluginName, node); + } else if (node.getNodeName().equals("extensions")) { + extensions = parseExtensions(pluginName, node); } } } - if (commands.getFirst().isEmpty() && commands.getSecond().isEmpty()) { + if (commands.isEmpty() && extensions.isEmpty()) { logger.warning("plugin " + pluginName + " does not extend any command or provide any new commands"); } - return new PluginConfiguration(commands.getFirst(), commands.getSecond()); + return new PluginConfiguration(commands, extensions); } - private Pair, List> parseCommands(String pluginName, Node commandsNode) { + private List parseCommands(String pluginName, Node commandsNode) { List newCommands = new ArrayList(); - List extendedCommands = new ArrayList(); NodeList childNodes = commandsNode.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeName().equals("command")) { - String type = node.getAttributes().getNamedItem("type").getNodeValue(); - if (type.equals("extends")) { - CommandExtensions additions = parseAdditionsToExistingCommand(pluginName, node); - if (additions != null) { - extendedCommands.add(additions); - } - } else if (type.equals("provides")) { - NewCommand newCmd = parseNewCommand(pluginName, node); - if (newCmd != null) { - newCommands.add(newCmd); - } + NewCommand newCmd = parseNewCommand(pluginName, node); + if (newCmd != null) { + newCommands.add(newCmd); } } } - return new Pair<>(newCommands, extendedCommands); + return newCommands; + } + + private List parseExtensions(String pluginName, Node extensionsNode) { + List commandExtensions = new ArrayList(); + NodeList childNodes = extensionsNode.getChildNodes(); + for (int i = 0; i < childNodes.getLength(); i++) { + Node node = childNodes.item(i); + if (node.getNodeName().equals("extension")) { + CommandExtensions additions = parseAdditionsToExistingCommand(pluginName, node); + if (additions != null) { + commandExtensions.add(additions); + } + } + } + return commandExtensions; } private CommandExtensions parseAdditionsToExistingCommand(String pluginName, Node commandNode) { @@ -219,7 +297,6 @@ private NewCommand parseNewCommand(String pluginName, Node commandNode) { String name = null; - String usage = null; String description = null; Options options = new Options(); List bundles = new ArrayList<>(); @@ -230,8 +307,6 @@ Node node = nodes.item(i); if (node.getNodeName().equals("name")) { name = node.getTextContent().trim(); - } else if (node.getNodeName().equals("usage")) { - usage = node.getTextContent().trim(); } else if (node.getNodeName().equals("description")) { description = node.getTextContent().trim(); } else if (node.getNodeName().equals("options")) { @@ -250,12 +325,12 @@ logger.warning("plugin " + pluginName + " provides a new command " + name + " but lists no dependencies on thermostat"); } - if (name == null || usage == null || description == null) { + if (name == null || description == null) { logger.warning("plugin " + pluginName + " provides an incomplete new command: " + - "name='" + name + "', usage='" + usage + "', description='" + description + "', options='" + options + "'"); + "name='" + name + "', description='" + description + "', options='" + options + "'"); return null; } else { - return new NewCommand(name, usage, description, options, bundles, dependencies); + return new NewCommand(name, description, options, bundles, dependencies); } } @@ -376,7 +451,7 @@ } } - logger.warning("The option " + longName != null ? longName : shortName + " claims to be a common option but isnt"); + logger.warning("The option " + longName != null ? longName : shortName + " claims to be a common option but it isn't"); return null; } @@ -384,9 +459,9 @@ private Option parseNormalOption(Node optionNode) { String longName = null; String shortName = null; + String argument = null; String description = null; boolean required = false; - boolean hasArg = false; NodeList nodes = optionNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { @@ -395,16 +470,16 @@ longName = node.getTextContent().trim(); } else if (node.getNodeName().equals("short")) { shortName = node.getTextContent().trim(); + } else if (node.getNodeName().equals("argument")) { + argument = node.getTextContent().trim(); } else if (node.getNodeName().equals("description")) { description = node.getTextContent().trim(); - } else if (node.getNodeName().equals("hasArg")) { - hasArg = Boolean.valueOf(node.getTextContent().trim()); } else if (node.getNodeName().equals("required")) { required = Boolean.valueOf(node.getTextContent().trim()); } } - Option opt = new Option(shortName, longName, hasArg, description); + Option opt = new Option(shortName, longName, Boolean.parseBoolean(argument), description); opt.setArgName(longName != null? longName : shortName); opt.setRequired(required); return opt; diff -r ef9be67db1ad -r c8d427902c6b launcher/src/test/java/com/redhat/thermostat/launcher/internal/PluginConfigurationParserTest.java --- a/launcher/src/test/java/com/redhat/thermostat/launcher/internal/PluginConfigurationParserTest.java Mon Apr 08 17:06:45 2013 -0400 +++ b/launcher/src/test/java/com/redhat/thermostat/launcher/internal/PluginConfigurationParserTest.java Mon Apr 15 15:45:04 2013 +0200 @@ -85,8 +85,8 @@ public void testConfigurationThatExtendsExistingCommand() throws UnsupportedEncodingException { String config = "\n" + "\n" + - " \n" + - " \n" + + " \n" + + " \n" + " test\n" + " \n" + " foo\n" + @@ -96,8 +96,8 @@ " \n" + " thermostat-foo\n" + " \n" + - " \n" + - " \n" + + " \n" + + " \n" + ""; PluginConfiguration result = new PluginConfigurationParser() @@ -119,9 +119,8 @@ String config = "\n" + "\n" + " \n" + - " \n" + + " \n" + " test\n" + - " usage: test\n" + " description\n" + " \n" + " foo\n" + @@ -146,7 +145,6 @@ NewCommand newCommand = newCommands.get(0); assertEquals("test", newCommand.getCommandName()); - assertEquals("usage: test", newCommand.getUsage()); assertEquals("description", newCommand.getDescription()); Options opts = newCommand.getOptions(); assertTrue(opts.getOptions().isEmpty()); @@ -159,8 +157,8 @@ public void testSpacesAtStartAndEndAreTrimmed() throws UnsupportedEncodingException { String config = "\n" + "\n" + - " \n" + - " \n" + + " " + + " \n" + " \ntest \n\n" + " \n" + " \n \t \nfoo\t \n \n\n" + @@ -170,8 +168,8 @@ " \n\t\n\t \t\t\n" + " \t\t\t thermostat-foo\n\t\t\n\n" + " \n" + - " \n" + - " \n" + + " \n" + + " \n" + ""; PluginConfiguration result = new PluginConfigurationParser() @@ -193,24 +191,23 @@ String config = "\n" + "\n" + " \n" + - " \n" + + " \n" + " test\n" + " just a test\n" + - " test [ -a | -b ] -l <foo>\n" + " \n" + " \n" + " true\n" + " \n" + " \n" + @@ -218,7 +215,7 @@ " \n" + @@ -238,7 +235,6 @@ NewCommand command = newCommands.get(0); assertEquals("test", command.getCommandName()); assertEquals("just a test", command.getDescription()); - assertEquals("test [ -a | -b ] -l ", command.getUsage()); Options opts = command.getOptions(); assertNull(opts.getOption("foobarbaz")); @@ -268,10 +264,9 @@ String config = "\n" + "\n" + " \n" + - " \n" + + " \n" + " test\n" + " just a test\n" + - " test [ -a | -b ] -l <foo>\n" + " \n" + " diff -r ef9be67db1ad -r c8d427902c6b vm-classstat/distribution/plugin.xml --- a/vm-classstat/distribution/plugin.xml Mon Apr 08 17:06:45 2013 -0400 +++ b/vm-classstat/distribution/plugin.xml Mon Apr 15 15:45:04 2013 +0200 @@ -36,30 +36,32 @@ to do so, delete this exception statement from your version. --> - - - + + + gui thermostat-vm-classstat-common-${project.version}.jar thermostat-vm-classstat-client-core-${project.version}.jar thermostat-vm-classstat-client-swing-${project.version}.jar - - + + agent thermostat-vm-classstat-common-${project.version}.jar thermostat-vm-classstat-agent-${project.version}.jar - + - + webservice thermostat-vm-classstat-common-${project.version}.jar - - + + - \ No newline at end of file + diff -r ef9be67db1ad -r c8d427902c6b vm-cpu/distribution/plugin.xml --- a/vm-cpu/distribution/plugin.xml Mon Apr 08 17:06:45 2013 -0400 +++ b/vm-cpu/distribution/plugin.xml Mon Apr 15 15:45:04 2013 +0200 @@ -36,36 +36,38 @@ to do so, delete this exception statement from your version. --> - - - + + + gui thermostat-vm-cpu-common-${project.version}.jar thermostat-vm-cpu-client-core-${project.version}.jar thermostat-vm-cpu-client-swing-${project.version}.jar - - + + agent thermostat-vm-cpu-common-${project.version}.jar thermostat-vm-cpu-agent-${project.version}.jar - + - + webservice thermostat-vm-cpu-common-${project.version}.jar - - + + vm-stat thermostat-vm-cpu-common-${project.version}.jar thermostat-vm-cpu-client-cli-${project.version}.jar - - - \ No newline at end of file + + + diff -r ef9be67db1ad -r c8d427902c6b vm-gc/distribution/plugin.xml --- a/vm-gc/distribution/plugin.xml Mon Apr 08 17:06:45 2013 -0400 +++ b/vm-gc/distribution/plugin.xml Mon Apr 15 15:45:04 2013 +0200 @@ -36,9 +36,11 @@ to do so, delete this exception statement from your version. --> - - - + + + gui thermostat-vm-gc-common-${project.version}.jar @@ -48,8 +50,8 @@ thermostat-gc-remote-collector-client-common-${project.version}.jar thermostat-gc-remote-collector-client-swing-${project.version}.jar - - + + agent thermostat-vm-gc-common-${project.version}.jar @@ -57,14 +59,14 @@ thermostat-gc-remote-collector-common-${project.version}.jar thermostat-gc-remote-collector-command-${project.version}.jar - + - + webservice thermostat-vm-gc-common-${project.version}.jar - - + + - \ No newline at end of file + diff -r ef9be67db1ad -r c8d427902c6b vm-heap-analysis/distribution/plugin.xml --- a/vm-heap-analysis/distribution/plugin.xml Mon Apr 08 17:06:45 2013 -0400 +++ b/vm-heap-analysis/distribution/plugin.xml Mon Apr 15 15:45:04 2013 +0200 @@ -36,47 +36,25 @@ to do so, delete this exception statement from your version. --> - + - - gui - - thermostat-vm-heap-analysis-common-${project.version}.jar - thermostat-vm-heap-analysis-command-${project.version}.jar - thermostat-vm-heap-analysis-client-core-${project.version}.jar - thermostat-vm-heap-analysis-client-swing-${project.version}.jar - - - - agent - - thermostat-vm-heap-analysis-common-${project.version}.jar - thermostat-vm-heap-analysis-agent-${project.version}.jar - - - - - webservice - - thermostat-vm-heap-analysis-common-${project.version}.jar - - - + dump-heap trigger a heap dump on the VM - dump-heap --hostId <host> --vmId <vm> [-d <url> [-u <user> -p <password>]] [-l <level>] @@ -116,22 +94,21 @@ netty.jar - + find-objects finds objects in a heapdump - find-objects [-d <url> [-u <user> -p <password>]] [-l <level>] --heapId <id> --limit <limit> <pattern> @@ -171,29 +148,28 @@ netty.jar - + find-root finds the shortest path from an object to a GC root - find-root --heapId <heap> --objectId <object> [-a] [-d <url> [-u <user> -p <password>]] [-l <level>] @@ -233,22 +209,21 @@ netty.jar - + list-heap-dumps list all heap dumps - list-heap-dumps [--hostId <host>] [--vmId <vm>] [-d <url> [-u <user> -p <password>]] [-l <level>] @@ -288,22 +263,21 @@ netty.jar - + object-info prints information about an object in a heap dump - object-info --heapId <heap> --objectId <object> [-d <url> [-u <user> -p <password>]] [-l <level>] @@ -343,22 +317,21 @@ netty.jar - + save-heap-dump-to-file saves a heap dump to a local file - save-heap-dump-to-file --heapId <heap> --file <filename> [-d <url> [-u <user> -p <password>]] [-l <level>] @@ -398,15 +371,14 @@ netty.jar - + show-heap-histogram show the heap histogram - show-heap-histogram --heapId <heap> [-d <url> [-u <user> -p <password>]] [-l <level>] @@ -447,4 +419,29 @@ - \ No newline at end of file + + + gui + + thermostat-vm-heap-analysis-common-${project.version}.jar + thermostat-vm-heap-analysis-command-${project.version}.jar + thermostat-vm-heap-analysis-client-core-${project.version}.jar + thermostat-vm-heap-analysis-client-swing-${project.version}.jar + + + + agent + + thermostat-vm-heap-analysis-common-${project.version}.jar + thermostat-vm-heap-analysis-agent-${project.version}.jar + + + + + webservice + + thermostat-vm-heap-analysis-common-${project.version}.jar + + + + diff -r ef9be67db1ad -r c8d427902c6b vm-memory/distribution/plugin.xml --- a/vm-memory/distribution/plugin.xml Mon Apr 08 17:06:45 2013 -0400 +++ b/vm-memory/distribution/plugin.xml Mon Apr 15 15:45:04 2013 +0200 @@ -36,37 +36,39 @@ to do so, delete this exception statement from your version. --> - - - + + + gui thermostat-vm-memory-common-${project.version}.jar thermostat-vm-memory-client-core-${project.version}.jar thermostat-vm-memory-client-swing-${project.version}.jar - - + + agent thermostat-vm-memory-common-${project.version}.jar thermostat-vm-memory-agent-${project.version}.jar - + - + webservice thermostat-vm-memory-common-${project.version}.jar - - + + vm-stat thermostat-vm-memory-common-${project.version}.jar thermostat-vm-memory-client-cli-${project.version}.jar - - + + - \ No newline at end of file + diff -r ef9be67db1ad -r c8d427902c6b vm-overview/distribution/plugin.xml --- a/vm-overview/distribution/plugin.xml Mon Apr 08 17:06:45 2013 -0400 +++ b/vm-overview/distribution/plugin.xml Mon Apr 15 15:45:04 2013 +0200 @@ -36,14 +36,16 @@ to do so, delete this exception statement from your version. --> - - - + + + gui thermostat-vm-overview-client-core-${project.version}.jar thermostat-vm-overview-client-swing-${project.version}.jar - - - \ No newline at end of file + + +