Author: aidan Date: Wed Jan 7 03:54:14 2009 New Revision: 732311 URL: http://svn.apache.org/viewvc?rev=732311&view=rev Log: QPID-1528: Add get/set commands for JMX attributes.
Modified: qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java Modified: qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java?rev=732311&r1=732310&r2=732311&view=diff ============================================================================== --- qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java (original) +++ qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java Wed Jan 7 03:54:14 2009 @@ -49,10 +49,12 @@ import jline.SimpleCompletor; import org.apache.qpid.commands.Commanddelete; +import org.apache.qpid.commands.Commandget; import org.apache.qpid.commands.Commandhelp; import org.apache.qpid.commands.Commandinfo; import org.apache.qpid.commands.Commandlist; import org.apache.qpid.commands.Commandmove; +import org.apache.qpid.commands.Commandset; import org.apache.qpid.commands.Commandview; import org.apache.qpid.commands.Commandviewcontent; import org.apache.qpid.utils.CommandLineOptionParser; @@ -106,9 +108,16 @@ /* This implementation is for the people who are using the interactive mode for one shot this run the user given command and exit */ for (int i = 0; i < args.length; i++) { - if (args[i].compareTo("list") == 0 || args[i].compareTo("info") == 0 || args[i].compareTo("view") == 0 || args[i].compareTo("viewcontent") == 0 - || args[i].compareTo("delete") == 0 || args[i].compareTo("move") == 0) { - oneshotmode(args,commandlineoptionparser,jmxc,mbsc); + if (args[i].compareTo("list") == 0 || + args[i].compareTo("info") == 0 || + args[i].compareTo("view") == 0 || + args[i].compareTo("viewcontent") == 0 || + args[i].compareTo("delete") == 0 || + args[i].compareTo("move") == 0 || + args[i].compareTo("set") == 0 || + args[i].compareTo("get") == 0) + { + oneshotmode(args, commandlineoptionparser, jmxc, mbsc); return; } @@ -124,7 +133,9 @@ /* prividing GNU readline features using Jline library */ PrintWriter out = new PrintWriter(System.out); reader.addCompletor(new ArgumentCompletor( - new SimpleCompletor(new String[]{"list", "info", "exit", "quit", "delete", "move", "view", "viewcontent", "queue", "exchange", "connection", "usermanagement", "virtualhost"}))); + new SimpleCompletor(new String[]{"get","set","list", "info", "exit", "quit", "delete", "move", "view", + "viewcontent", "queue", "exchange", "connection", "usermanagement", + "virtualhost"}))); while ((line = reader.readLine("qpid-admin-$ ")) != null) { out.flush(); if (removeSpaces(line).equalsIgnoreCase("quit") || removeSpaces(line).equalsIgnoreCase("exit")) @@ -140,6 +151,7 @@ engine.runcommand(); } } + conn.getConnector().close(); } catch (Exception ex) { @@ -150,10 +162,12 @@ private static void registerCommands() { CommandExecutionEngine.addCommand(Commanddelete.COMMAND_NAME, Commanddelete.class); + CommandExecutionEngine.addCommand(Commandget.COMMAND_NAME, Commandget.class); CommandExecutionEngine.addCommand(Commandhelp.COMMAND_NAME, Commandhelp.class); CommandExecutionEngine.addCommand(Commandinfo.COMMAND_NAME, Commandinfo.class); CommandExecutionEngine.addCommand(Commandlist.COMMAND_NAME, Commandlist.class); CommandExecutionEngine.addCommand(Commandmove.COMMAND_NAME, Commandmove.class); + CommandExecutionEngine.addCommand(Commandset.COMMAND_NAME, Commandset.class); CommandExecutionEngine.addCommand(Commandview.COMMAND_NAME, Commandview.class); CommandExecutionEngine.addCommand(Commandviewcontent.COMMAND_NAME, Commandviewcontent.class); } Modified: qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java?rev=732311&r1=732310&r2=732311&view=diff ============================================================================== --- qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java (original) +++ qpid/trunk/qpid/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java Wed Jan 7 03:54:14 2009 @@ -25,10 +25,16 @@ import javax.management.MBeanServerConnection; import javax.management.ObjectName; import javax.management.MBeanInfo; +import javax.management.MBeanException; +import javax.management.AttributeNotFoundException; +import javax.management.InstanceNotFoundException; +import javax.management.ReflectionException; +import javax.management.Attribute; import java.util.Iterator; import java.util.Set; import java.util.List; import java.util.ArrayList; +import java.io.IOException; /** * Created by IntelliJ IDEA. @@ -114,7 +120,7 @@ temp = "=" + temp; echo(temp); echo("There are no attributes for this object Type"); - return; + continue; } for (MBeanAttributeInfo attr : attr_info) { Object toWrite = null; @@ -474,4 +480,30 @@ return set; } + public Object getAttribute(ObjectName object, String attribute) + { + try + { + return mbsc.getAttribute(object, attribute); + } + catch (Exception e) + { + e.printStackTrace(); + } + + return null; + } + + public void setAttribute(ObjectName object, Attribute attribute) + { + try + { + mbsc.setAttribute(object, attribute); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + }