summaryrefslogtreecommitdiff
path: root/java/management/tools/qpid-cli/src
diff options
context:
space:
mode:
authorAidan Skinner <aidan@apache.org>2009-01-09 16:24:01 +0000
committerAidan Skinner <aidan@apache.org>2009-01-09 16:24:01 +0000
commite8bc90906d322a676b931834a894d5c6bd2aa97e (patch)
tree78e0064a5eecb8b57cb73d02015a08e3d71b7a3d /java/management/tools/qpid-cli/src
parentbd5ae249ef74e1707eb05dd6cc70bb816e318757 (diff)
downloadqpid-python-e8bc90906d322a676b931834a894d5c6bd2aa97e.tar.gz
QPID-1564: Remove duplicate ASL header and unusued imports. Format code according to qpid conventions.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@733073 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/management/tools/qpid-cli/src')
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/Command.java22
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecutionEngine.java35
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java153
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/Connector.java36
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/ConnectorFactory.java39
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/ReportGenerator.java149
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/CommandImpl.java90
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commanddelete.java130
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandget.java31
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandhelp.java39
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandinfo.java146
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandlist.java171
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandmove.java185
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandset.java15
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandview.java180
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandviewcontent.java170
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/AllObjects.java18
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ConnectionObject.java22
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ExchangeObject.java19
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java416
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java36
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/UserManagementObject.java19
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/VirtualHostObject.java22
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOption.java66
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionConstants.java26
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionParser.java165
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfigProperty.java50
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfiguration.java92
-rw-r--r--java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXinfo.java41
29 files changed, 1305 insertions, 1278 deletions
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/Command.java b/java/management/tools/qpid-cli/src/org/apache/qpid/Command.java
index fcb2a0031d..cf6bee619c 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/Command.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/Command.java
@@ -18,29 +18,13 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid;
-public interface Command {
+public interface Command
+{
public static String COMMAND_NAME = null;
-
+
public void execute();
public void printusage();
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecutionEngine.java b/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecutionEngine.java
index 7db43032d5..ee57ba37b2 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecutionEngine.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/CommandExecutionEngine.java
@@ -18,23 +18,6 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid;
import java.util.HashMap;
@@ -42,19 +25,21 @@ import java.util.Map;
import org.apache.qpid.utils.JMXinfo;
-
-public class CommandExecutionEngine {
+public class CommandExecutionEngine
+{
private static Map<String, Class<? extends Command>> _commands = new HashMap<String, Class<? extends Command>>();
private Command currentcommand = null;
private String commandname = null;
private JMXinfo info = null;
- public CommandExecutionEngine(JMXinfo info) {
+ public CommandExecutionEngine(JMXinfo info)
+ {
this.info = info;
this.commandname = info.getCommandLineOptionParser().getcommandname();
}
- public boolean CommandSelector() throws Exception {
+ public boolean CommandSelector() throws Exception
+ {
Class<? extends Command> commandClass = _commands.get(this.commandname);
if (commandClass != null)
{
@@ -68,17 +53,19 @@ public class CommandExecutionEngine {
}
return true;
}
-
+
public static void addCommand(String name, Class<? extends Command> newCommand)
{
_commands.put(name, newCommand);
}
- public void runcommand() {
+ public void runcommand()
+ {
currentcommand.execute();
}
- public void usage() {
+ public void usage()
+ {
System.out.println(commandname + ":Command not found");
}
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java b/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java
index 713233c92a..6e5159aece 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/CommandLineInterpreter.java
@@ -18,23 +18,6 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid;
@@ -61,69 +44,93 @@ import org.apache.qpid.utils.CommandLineOptionParser;
import org.apache.qpid.utils.JMXConfiguration;
import org.apache.qpid.utils.JMXinfo;
-public class CommandLineInterpreter {
-
- public static void main(String[] args) {
+public class CommandLineInterpreter
+{
+
+ public static void main(String[] args)
+ {
Connector conn = null;
- try {
+ try
+ {
// Create an RMI connector client and
// connect it to the RMI connector server
- /*checking the commandline options and
- parse them in to config method */
+ /*
+ * checking the commandline options and parse them in to config
+ * method
+ */
JMXConnector jmxc = null;
MBeanServerConnection mbsc = null;
ConsoleReader reader = new ConsoleReader();
reader.setBellEnabled(false);
CommandLineOptionParser commandlineoptionparser = null;
- if ((args == null) || (args.length) == 0) {
+ if ((args == null) || (args.length) == 0)
+ {
Usage();
}
- /* here special constructor is calling, when parsing options,in here first option value is starting from minus sign
- so this is handle by a special constructor */
- else {
- if (args[0].startsWith("-")) {
- commandlineoptionparser = new CommandLineOptionParser(args, args[0]); // if user specify any argument with the qpid-cli script
+ /*
+ * here special constructor is calling, when parsing options,in here
+ * first option value is starting from minus sign so this is handle
+ * by a special constructor
+ */
+ else
+ {
+ if (args[0].startsWith("-"))
+ {
+ commandlineoptionparser = new CommandLineOptionParser(args, args[0]); // if
+ // user
+ // specify
+ // any
+ // argument
+ // with
+ // the
+ // qpid-cli
+ // script
}
}
registerCommands();
-
+
/* Connecting with the broker */
- try {
+ try
+ {
if (commandlineoptionparser == null)
commandlineoptionparser = new CommandLineOptionParser(args);
JMXConfiguration config = new JMXConfiguration(commandlineoptionparser.getAlloptions());
- conn = ConnectorFactory.getConnector(config.gethostname(), config.getport(),
- config.getUsername(), config.getPassword());
+ conn = ConnectorFactory.getConnector(config.gethostname(), config.getport(), config.getUsername(),
+ config.getPassword());
jmxc = conn.getConnector();
mbsc = conn.getMBeanServerConnection();
- if (config.checkoptionsetting("r", commandlineoptionparser.getAlloptions())) {
+ if (config.checkoptionsetting("r", commandlineoptionparser.getAlloptions()))
+ {
JMXinfo info = new JMXinfo(jmxc, commandlineoptionparser, mbsc);
- ReportGenerator reportgen = new ReportGenerator(config.optionchecker("r", commandlineoptionparser.getAlloptions()), info);
+ ReportGenerator reportgen = new ReportGenerator(config.optionchecker("r", commandlineoptionparser
+ .getAlloptions()), info);
reportgen.loadproperties();
reportgen.run();
}
- /* 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 ||
- args[i].compareTo("set") == 0 ||
- args[i].compareTo("get") == 0)
+ /*
+ * 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
+ || args[i].compareTo("set") == 0 || args[i].compareTo("get") == 0)
{
oneshotmode(args, commandlineoptionparser, jmxc, mbsc);
return;
}
}
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
connectionrefuse(ex);
return;
}
@@ -133,17 +140,18 @@ public class CommandLineInterpreter {
/* prividing GNU readline features using Jline library */
PrintWriter out = new PrintWriter(System.out);
- reader.addCompletor(new ArgumentCompletor(
- 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) {
+ reader.addCompletor(new ArgumentCompletor(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"))
break;
else if (line.length() == 0)
continue;
- else {
+ else
+ {
command = line.split("\\s+");
commandlineoptionparser = new CommandLineOptionParser(command);
JMXinfo info = new JMXinfo(jmxc, commandlineoptionparser, mbsc);
@@ -152,10 +160,11 @@ public class CommandLineInterpreter {
engine.runcommand();
}
}
-
+
conn.getConnector().close();
}
- catch (Exception ex) {
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
}
@@ -173,18 +182,22 @@ public class CommandLineInterpreter {
CommandExecutionEngine.addCommand(Commandviewcontent.COMMAND_NAME, Commandviewcontent.class);
}
- private static void Usage() {
+ private static void Usage()
+ {
System.out.println("Connecting to localhost Qpid java broker...");
}
- private static String removeSpaces(String s) {
+ private static String removeSpaces(String s)
+ {
StringTokenizer st = new StringTokenizer(s, " ", false);
String t = "";
- while (st.hasMoreElements()) t += st.nextElement();
+ while (st.hasMoreElements())
+ t += st.nextElement();
return t;
}
- private static void connectionrefuse(Exception e) {
+ private static void connectionrefuse(Exception e)
+ {
String message = e.getLocalizedMessage();
if (e instanceof SecurityException)
{
@@ -203,22 +216,33 @@ public class CommandLineInterpreter {
System.out.println("Cannot connect with the broker: " + message);
}
- public static String[] oneshotmode(String[] args,CommandLineOptionParser commandlineoptionparser,JMXConnector jmxc,MBeanServerConnection mbsc) throws Exception
+ public static String[] oneshotmode(String[] args, CommandLineOptionParser commandlineoptionparser,
+ JMXConnector jmxc, MBeanServerConnection mbsc) throws Exception
{
int check = 0;
- String [] temp;
- for (int i = 0; i < args.length; i++) {
+ String[] temp;
+ for (int i = 0; i < args.length; i++)
+ {
if (args[i].compareTo("-h") == 0)
check++;
else if (args[i].compareTo("-p") == 0)
check++;
}
- for (int i = 0; i < (args.length - 2 * check); i++) { // mulitply by 2 because have to remove the option letter with the option value//
+ for (int i = 0; i < (args.length - 2 * check); i++)
+ { // mulitply by 2 because have to remove the option letter with the
+ // option value//
args[i] = args[i + check * 2];
}
- commandlineoptionparser = new CommandLineOptionParser(args); //change the args string array which works as interactive mode//
+ commandlineoptionparser = new CommandLineOptionParser(args); // change
+ // the args
+ // string
+ // array
+ // which
+ // works as
+ // interactive
+ // mode//
JMXinfo info = new JMXinfo(jmxc, commandlineoptionparser, mbsc);
CommandExecutionEngine engine = new CommandExecutionEngine(info);
if (engine.CommandSelector())
@@ -227,4 +251,3 @@ public class CommandLineInterpreter {
}
}
-
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/Connector.java b/java/management/tools/qpid-cli/src/org/apache/qpid/Connector.java
index c649390d97..2b887077c3 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/Connector.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/Connector.java
@@ -18,52 +18,32 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid;
import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.JMXConnectorFactory;
-import java.io.IOException;
-
-public class Connector {
+public class Connector
+{
private JMXConnector jmxc = null;
private MBeanServerConnection mbsc = null;
-
- public Connector(JMXConnector jmxc, MBeanServerConnection mbsc) {
+ public Connector(JMXConnector jmxc, MBeanServerConnection mbsc)
+ {
this.jmxc = jmxc;
this.mbsc = mbsc;
-
}
- public JMXConnector getConnector() {
+ public JMXConnector getConnector()
+ {
return jmxc;
}
- public MBeanServerConnection getMBeanServerConnection() {
+ public MBeanServerConnection getMBeanServerConnection()
+ {
return mbsc;
}
-
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/ConnectorFactory.java b/java/management/tools/qpid-cli/src/org/apache/qpid/ConnectorFactory.java
index f9de1e8768..84ba94c5c4 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/ConnectorFactory.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/ConnectorFactory.java
@@ -18,54 +18,31 @@
* under the License.
*
*/
- /*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid;
-import java.io.IOException;
-
import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnector;
import org.apache.qpid.management.common.JMXConnnectionFactory;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Jul 3, 2008
- * Time: 10:51:28 AM
- * To change this template use File | Settings | File Templates.
- */
-public class ConnectorFactory {
+public class ConnectorFactory
+{
private static final long TIMEOUT = 30 * 1000;
- public static Connector getConnector(String host, String port, String username, String password) throws Exception {
+ public static Connector getConnector(String host, String port, String username, String password) throws Exception
+ {
JMXConnector jmxc = null;
MBeanServerConnection mbsc = null;
- try {
+ try
+ {
jmxc = JMXConnnectionFactory.getJMXConnection(TIMEOUT, host, Integer.parseInt(port), username, password);
mbsc = jmxc.getMBeanServerConnection();
- }
+ }
catch (NumberFormatException e)
{
- System.out.println("Illegal port entered:"+port);
+ System.out.println("Illegal port entered:" + port);
System.exit(1);
}
return new Connector(jmxc, mbsc);
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/ReportGenerator.java b/java/management/tools/qpid-cli/src/org/apache/qpid/ReportGenerator.java
index 0a63d73a98..cc8c16f8b0 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/ReportGenerator.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/ReportGenerator.java
@@ -18,23 +18,6 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid;
import org.apache.qpid.commands.objects.*;
@@ -45,16 +28,11 @@ import java.util.*;
import java.io.FileInputStream;
import java.io.IOException;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Aug 12, 2008
- * Time: 4:03:21 PM
- * To change this template use File | Settings | File Templates.
- */
-public class ReportGenerator implements Runnable {
+public class ReportGenerator implements Runnable
+{
- String[] propertyname = {"object", "column", "filter.name", "filter.virtualhost", "output", "seperator", "interval"};
+ String[] propertyname = { "object", "column", "filter.name", "filter.virtualhost", "output", "seperator",
+ "interval" };
String[] propertyvalue = null;
String propertyfilepath = null;
String[] columnvalue = null;
@@ -63,19 +41,24 @@ public class ReportGenerator implements Runnable {
JMXinfo info = null;
int interval = 10;
- public void run() {
- for (; ;) // creating infinite loop
+ public void run()
+ {
+ for (;;) // creating infinite loop
{
generatereport();
- try {
+ try
+ {
Thread.sleep(this.interval * 60000);
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
}
}
- public ReportGenerator(String propfile, JMXinfo info) {
+ public ReportGenerator(String propfile, JMXinfo info)
+ {
this.propertyfilepath = propfile;
props = new Properties();
propertyvalue = new String[propertyname.length];
@@ -83,98 +66,130 @@ public class ReportGenerator implements Runnable {
columns = new ArrayList<String>();
}
- public void loadproperties() // get all the property file values and set the columen values//
+ public void loadproperties() // get all the property file values and set the
+ // columen values//
{
- try {
+ try
+ {
props.load(new FileInputStream(this.propertyfilepath));
- for (int i = 0; i < propertyname.length; i++) {
+ for (int i = 0; i < propertyname.length; i++)
+ {
propertyvalue[i] = props.getProperty(propertyname[i]);
}
this.setcolumnvalues();
this.setinterval();
}
- //catch exception in case properties file does not exist
+ // catch exception in case properties file does not exist
- catch (IOException e) {
+ catch (IOException e)
+ {
System.out.println("Oooops Give property file is not exist");
}
}
- public void generatereport() {
+ public void generatereport()
+ {
this.listobjects(propertyvalue[0]);
}
- private void setcolumnvalues() {
+ private void setcolumnvalues()
+ {
columnvalue = propertyvalue[1].split(",");
- for (int i = 0; i < columnvalue.length; i++) {
+ for (int i = 0; i < columnvalue.length; i++)
+ {
columns.add(columnvalue[i]);
}
}
- private void setinterval() {
+ private void setinterval()
+ {
this.interval = (new Integer(propertyvalue[6])).intValue();
}
- private void listobjects(String option_value) {
- /*pring usage if use is not give the correct option letter or no options */
- if (option_value == null) {
-// System.out.println("testing");
+ private void listobjects(String option_value)
+ {
+ /*
+ * pring usage if use is not give the correct option letter or no
+ * options
+ */
+ if (option_value == null)
+ {
+ // System.out.println("testing");
return;
}
MBeanServerConnection mbsc = info.getmbserverconnector();
Set set = null;
ObjectNames objname = null;
- try {
- if (option_value.compareToIgnoreCase("queue") == 0 || option_value.compareToIgnoreCase("queues") == 0) {
+ try
+ {
+ if (option_value.compareToIgnoreCase("queue") == 0 || option_value.compareToIgnoreCase("queues") == 0)
+ {
objname = new QueueObject(mbsc);
- } else
- if (option_value.compareToIgnoreCase("Virtualhosts") == 0 || option_value.compareToIgnoreCase("Virtualhost") == 0) {
+ }
+ else if (option_value.compareToIgnoreCase("Virtualhosts") == 0
+ || option_value.compareToIgnoreCase("Virtualhost") == 0)
+ {
objname = new VirtualHostObject(mbsc);
-// this.name = option_value;
- } else
- if (option_value.compareToIgnoreCase("Exchange") == 0 || option_value.compareToIgnoreCase("Exchanges") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("Exchange") == 0
+ || option_value.compareToIgnoreCase("Exchanges") == 0)
+ {
objname = new ExchangeObject(mbsc);
-// this.name = option_value;
- } else
- if (option_value.compareToIgnoreCase("Connection") == 0 || option_value.compareToIgnoreCase("Connections") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("Connection") == 0
+ || option_value.compareToIgnoreCase("Connections") == 0)
+ {
objname = new ConnectionObject(mbsc);
-// this.name = option_value;
- } else if (option_value.compareToIgnoreCase("all") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("all") == 0)
+ {
objname = new AllObjects(mbsc);
-// this.name = option_value;
- } else
- if (option_value.compareToIgnoreCase("Usermanagement") == 0 || option_value.compareToIgnoreCase("Usermanagmenets") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("Usermanagement") == 0
+ || option_value.compareToIgnoreCase("Usermanagmenets") == 0)
+ {
objname = new UserManagementObject(mbsc);
-// this.name = option_value;
- } else {
+ // this.name = option_value;
+ }
+ else
+ {
printusage();
echo("Wrong objectName");
return;
}
objname.setQueryString(this.propertyvalue[0], this.propertyvalue[2], this.propertyvalue[3]);
objname.returnObjects();
- if (objname.getSet().size() != 0) {
+ if (objname.getSet().size() != 0)
+ {
objname.reportgenerator(this.propertyvalue[4], this.propertyvalue[5], columns);
- } else {
+ }
+ else
+ {
printusage();
}
}
- catch (Exception ex) {
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
-
}
- public void echo(String str) {
+ public void echo(String str)
+ {
System.out.println(str);
}
- public void printusage() {
+ public void printusage()
+ {
System.out.println("Wrong option or wrong option value");
}
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/CommandImpl.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/CommandImpl.java
index ce5062f7e7..0e24dc3d6f 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/CommandImpl.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/CommandImpl.java
@@ -18,36 +18,17 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid.commands;
+import java.util.Map;
import org.apache.qpid.Command;
-import org.apache.qpid.CommandExecutionEngine;
-import org.apache.qpid.utils.JMXinfo;
import org.apache.qpid.utils.CommandLineOption;
+import org.apache.qpid.utils.JMXinfo;
-import java.util.Map;
-
-
-public abstract class CommandImpl implements Command {
+public abstract class CommandImpl implements Command
+{
protected JMXinfo info = null;
private String name;
@@ -56,41 +37,48 @@ public abstract class CommandImpl implements Command {
private String outputformat = null;
private String seperator = ",";
-
- public CommandImpl(JMXinfo info) {
+
+ public CommandImpl(JMXinfo info)
+ {
this.info = info;
}
- public CommandImpl()
+ public CommandImpl()
{
}
-
- protected void setName(String name) {
+
+ protected void setName(String name)
+ {
this.name = name;
}
- public String getName() {
+ public String getName()
+ {
return this.name;
}
-
- protected boolean hasName() {
+
+ protected boolean hasName()
+ {
if (this.name == null)
return false;
else
return true;
}
-
- protected void setObject(String object) {
+
+ protected void setObject(String object)
+ {
this.object = object;
}
-
- public String getObject() {
+
+ public String getObject()
+ {
return this.object;
}
-
- protected void setOutputFormat(String outputformat) {
+
+ protected void setOutputFormat(String outputformat)
+ {
this.outputformat = outputformat;
}
@@ -98,8 +86,9 @@ public abstract class CommandImpl implements Command {
{
return outputformat;
}
-
- protected void setSeperator(String seperator) {
+
+ protected void setSeperator(String seperator)
+ {
this.seperator = seperator;
}
@@ -107,16 +96,19 @@ public abstract class CommandImpl implements Command {
{
return seperator;
}
-
- protected void setVirtualhost(String virtualhost) {
+
+ protected void setVirtualhost(String virtualhost)
+ {
this.virtualhost = virtualhost;
}
- public String getVirtualhost() {
+ public String getVirtualhost()
+ {
return this.virtualhost;
}
- public String optionchecker(String option_letter) {
+ public String optionchecker(String option_letter)
+ {
Map map = info.getCommandLineOptionParser().getAlloptions();
if (map == null)
return null;
@@ -127,7 +119,8 @@ public abstract class CommandImpl implements Command {
return value;
}
- public boolean checkoptionsetting(String option_letter) {
+ public boolean checkoptionsetting(String option_letter)
+ {
Map map = info.getCommandLineOptionParser().getAlloptions();
if (map == null)
return false;
@@ -141,12 +134,14 @@ public abstract class CommandImpl implements Command {
else
return false;
}
-
- public void echo(String str) {
+
+ public void echo(String str)
+ {
System.out.println(str);
}
- public void unrecognizeoption() {
+ public void unrecognizeoption()
+ {
echo("list: Unrecognized option");
echo("Try `" + COMMAND_NAME + " --help` for more information");
}
@@ -155,5 +150,4 @@ public abstract class CommandImpl implements Command {
public abstract void printusage();
-
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commanddelete.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commanddelete.java
index d8a8724b4d..cdbb8f1d4f 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commanddelete.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commanddelete.java
@@ -18,48 +18,23 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
package org.apache.qpid.commands;
-import org.apache.qpid.utils.JMXinfo;
-import org.apache.qpid.commands.objects.*;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.StringTokenizer;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.StringTokenizer;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Aug 6, 2008
- * Time: 5:34:51 PM
- * To change this template use File | Settings | File Templates.
- */
-public class Commanddelete extends CommandImpl {
+import org.apache.qpid.commands.objects.QueueObject;
+import org.apache.qpid.utils.JMXinfo;
+
+public class Commanddelete extends CommandImpl
+{
private int number = 0;
private QueueObject objname;
private MBeanServerConnection mbsc;
@@ -67,7 +42,8 @@ public class Commanddelete extends CommandImpl {
private ObjectName queue;
public static final String COMMAND_NAME = "delete";
- public Commanddelete(JMXinfo info) {
+ public Commanddelete(JMXinfo info)
+ {
super(info);
this.mbsc = info.getmbserverconnector();
this.objname = new QueueObject(mbsc);
@@ -76,16 +52,20 @@ public class Commanddelete extends CommandImpl {
}
- public void deletemessages() {
+ public void deletemessages()
+ {
Set set = null;
objname.setQueryString(this.getObject(), this.getName(), this.getVirtualhost());
set = objname.returnObjects();
- if (objname.getSet().size() != 0) {
+ if (objname.getSet().size() != 0)
+ {
Iterator it = set.iterator();
this.queue = (ObjectName) it.next();
- try {
- if (this.number == 0) {
+ try
+ {
+ if (this.number == 0)
+ {
echo("");
System.out.print("Do you want to delete all the messages from the Queue [Y/N] :");
InputStreamReader isr = new InputStreamReader(System.in);
@@ -96,59 +76,79 @@ public class Commanddelete extends CommandImpl {
this.mbsc.invoke(queue, this.method2, null, null);
else
return;
- } else if (objname.getmessagecount(this.queue) < this.number) {
+ }
+ else if (objname.getmessagecount(this.queue) < this.number)
+ {
echo("Given number is Greater than the Queue Depth");
return;
- } else {
- for (int i = 0; i < this.number; i++) {
+ }
+ else
+ {
+ for (int i = 0; i < this.number; i++)
+ {
this.mbsc.invoke(queue, this.method1, null, null);
}
}
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
- } else {
- if (hasName()) {
+ }
+ else
+ {
+ if (hasName())
+ {
echo("The Queue you have specified is not in the current broker");
echo("");
- } else {
+ }
+ else
+ {
printusage();
}
}
}
- public void execute() {
- /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
- with main option object or o
+ public void execute()
+ {
+ /*
+ * In here you it's easy to handle any number of otpions which are going
+ * to add with the list command which works with main option object or o
*/
- if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ if (checkoptionsetting("object") || checkoptionsetting("o"))
+ {
String object = optionchecker("object");
- if (object == null) {
+ if (object == null)
+ {
object = optionchecker("o");
}
if (object.compareToIgnoreCase("queue") == 0)
setObject(object);
- else {
+ else
+ {
unrecognizeoption();
echo("This command is only applicable for delete command so please start with queue");
}
- if (checkoptionsetting("name") || checkoptionsetting("n")) {
+ if (checkoptionsetting("name") || checkoptionsetting("n"))
+ {
String name = optionchecker("name");
if (name == null)
name = optionchecker("n");
setName(name);
}
- if (checkoptionsetting("virtualhost") || checkoptionsetting("v")) {
+ if (checkoptionsetting("virtualhost") || checkoptionsetting("v"))
+ {
String vhost = optionchecker("virtualhost");
if (vhost == null)
vhost = optionchecker("v");
setVirtualhost(vhost);
}
- if (checkoptionsetting("top") || checkoptionsetting("t")) {
+ if (checkoptionsetting("top") || checkoptionsetting("t"))
+ {
String number = optionchecker("top");
if (number == null)
number = optionchecker("t");
@@ -156,13 +156,15 @@ public class Commanddelete extends CommandImpl {
setnumber(removeSpaces(number));
}
this.deletemessages();
- } else if (checkoptionsetting("h") || checkoptionsetting("help"))
+ }
+ else if (checkoptionsetting("h") || checkoptionsetting("help"))
printusage();
else
unrecognizeoption();
}
- public void printusage() {
+ public void printusage()
+ {
echo("");
echo("Usage:delete [OPTION] ... [OBJECT TYPE]...\n");
echo("Delete the top most messages from the given queue object\n");
@@ -175,19 +177,23 @@ public class Commanddelete extends CommandImpl {
}
- private void setnumber(String number) {
+ private void setnumber(String number)
+ {
Integer i = new Integer(number);
this.number = i.intValue();
}
- public int getnumber() {
+ public int getnumber()
+ {
return this.number;
}
- private static String removeSpaces(String s) {
+ private static String removeSpaces(String s)
+ {
StringTokenizer st = new StringTokenizer(s, " ", false);
String t = "";
- while (st.hasMoreElements()) t += st.nextElement();
+ while (st.hasMoreElements())
+ t += st.nextElement();
return t;
}
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandget.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandget.java
index 50b0da69eb..35a07798a1 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandget.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandget.java
@@ -18,23 +18,6 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid.commands;
@@ -48,7 +31,7 @@ import java.util.Set;
public class Commandget extends CommandImpl
{
-
+
private String _attributeName;
private String _value;
public static String COMMAND_NAME = "get";
@@ -99,7 +82,7 @@ public class Commandget extends CommandImpl
{
ObjectName object = (ObjectName) objname.getSet().iterator().next();
- Object value= objname.getAttribute(object, _attributeName);
+ Object value = objname.getAttribute(object, _attributeName);
echo(value.toString());
}
@@ -129,8 +112,9 @@ public class Commandget extends CommandImpl
public void execute()
{
- /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
- with main option object or o
+ /*
+ * In here you it's easy to handle any number of otpions which are going
+ * to add with the list command which works with main option object or o
*/
if (checkoptionsetting("output"))
{
@@ -225,8 +209,3 @@ public class Commandget extends CommandImpl
}
}
-
-
-
-
-
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandhelp.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandhelp.java
index 1a95735305..502ac89f74 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandhelp.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandhelp.java
@@ -18,48 +18,27 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid.commands;
import org.apache.qpid.utils.JMXinfo;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Jul 6, 2008
- * Time: 5:55:28 PM
- * To change this template use File | Settings | File Templates.
- */
-public class Commandhelp extends CommandImpl {
+public class Commandhelp extends CommandImpl
+{
public static final String COMMAND_NAME = "help";
-
- public Commandhelp(JMXinfo info)
+
+ public Commandhelp(JMXinfo info)
{
}
-
- public void execute() {
+
+ public void execute()
+ {
printusage();
}
- public void printusage() {
+ public void printusage()
+ {
echo("");
echo("Current version of qpid CLI is supporting following commands");
echo("");
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandinfo.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandinfo.java
index 137304ba05..d016e224b0 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandinfo.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandinfo.java
@@ -18,48 +18,41 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid.commands;
-
-import org.apache.qpid.utils.CommandLineOptionParser;
-import org.apache.qpid.utils.JMXinfo;
-import org.apache.qpid.commands.objects.*;
+import java.util.Set;
import javax.management.MBeanServerConnection;
-import java.util.Set;
+import org.apache.qpid.commands.objects.AllObjects;
+import org.apache.qpid.commands.objects.ConnectionObject;
+import org.apache.qpid.commands.objects.ExchangeObject;
+import org.apache.qpid.commands.objects.ObjectNames;
+import org.apache.qpid.commands.objects.QueueObject;
+import org.apache.qpid.commands.objects.UserManagementObject;
+import org.apache.qpid.commands.objects.VirtualHostObject;
+import org.apache.qpid.utils.JMXinfo;
-public class Commandinfo extends CommandImpl {
+public class Commandinfo extends CommandImpl
+{
public static final String COMMAND_NAME = "info";
-
+
public Commandinfo(JMXinfo info)
{
super(info);
}
- private void listobjects(String option_value) {
- /*pring usage if use is not give the correct option letter or no options */
- if (option_value == null) {
-// System.out.println("testing");
+ private void listobjects(String option_value)
+ {
+ /*
+ * pring usage if use is not give the correct option letter or no
+ * options
+ */
+ if (option_value == null)
+ {
+ // System.out.println("testing");
printusage();
return;
}
@@ -67,95 +60,124 @@ public class Commandinfo extends CommandImpl {
Set set = null;
ObjectNames objname = null;
- try {
- if (option_value.compareToIgnoreCase("queue") == 0 || option_value.compareToIgnoreCase("queues") == 0) {
+ try
+ {
+ if (option_value.compareToIgnoreCase("queue") == 0 || option_value.compareToIgnoreCase("queues") == 0)
+ {
objname = new QueueObject(mbsc);
- } else
- if (option_value.compareToIgnoreCase("Virtualhosts") == 0 || option_value.compareToIgnoreCase("Virtualhost") == 0) {
+ }
+ else if (option_value.compareToIgnoreCase("Virtualhosts") == 0
+ || option_value.compareToIgnoreCase("Virtualhost") == 0)
+ {
objname = new VirtualHostObject(mbsc);
-// this.name = option_value;
- } else
- if (option_value.compareToIgnoreCase("Exchange") == 0 || option_value.compareToIgnoreCase("Exchanges") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("Exchange") == 0
+ || option_value.compareToIgnoreCase("Exchanges") == 0)
+ {
objname = new ExchangeObject(mbsc);
-// this.name = option_value;
- } else
- if (option_value.compareToIgnoreCase("Connection") == 0 || option_value.compareToIgnoreCase("Connections") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("Connection") == 0
+ || option_value.compareToIgnoreCase("Connections") == 0)
+ {
objname = new ConnectionObject(mbsc);
-// this.name = option_value;
- } else if (option_value.compareToIgnoreCase("all") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("all") == 0)
+ {
objname = new AllObjects(mbsc);
-// this.name = option_value;
- } else
- if (option_value.compareToIgnoreCase("Usermanagement") == 0 || option_value.compareToIgnoreCase("Usermanagmenets") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("Usermanagement") == 0
+ || option_value.compareToIgnoreCase("Usermanagmenets") == 0)
+ {
objname = new UserManagementObject(mbsc);
-// this.name = option_value;
- } else {
+ // this.name = option_value;
+ }
+ else
+ {
printusage();
echo("Wrong objectName");
return;
}
objname.setQueryString(this.getObject(), this.getName(), this.getVirtualhost());
objname.returnObjects();
- if (objname.getSet().size() != 0) {
+ if (objname.getSet().size() != 0)
+ {
objname.displayinfo(this.getOutputFormat(), this.getSeperator());
- } else {
- if (hasName()) {
+ }
+ else
+ {
+ if (hasName())
+ {
echo("You might quering wrong " + this.getObject() + " name with --name or -n option ");
echo("");
echo(this.getObject() + "Type Objects might not in the broker currently");
echo("");
- } else {
+ }
+ else
+ {
printusage();
}
}
-
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
-
}
- public void execute() {
- /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
- with main option object or o
+ public void execute()
+ {
+ /*
+ * In here you it's easy to handle any number of otpions which are going
+ * to add with the list command which works with main option object or o
*/
- if (checkoptionsetting("output")) {
+ if (checkoptionsetting("output"))
+ {
setOutputFormat(optionchecker("output"));
if (checkoptionsetting("separator"))
setSeperator(optionchecker("separator"));
}
- if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ if (checkoptionsetting("object") || checkoptionsetting("o"))
+ {
String object = optionchecker("object");
- if (object == null) {
+ if (object == null)
+ {
object = optionchecker("o");
}
setObject(object);
- if (checkoptionsetting("name") || checkoptionsetting("n")) {
+ if (checkoptionsetting("name") || checkoptionsetting("n"))
+ {
String name = optionchecker("name");
if (name == null)
name = optionchecker("n");
setName(name);
}
- if (checkoptionsetting("virtualhost") || checkoptionsetting("v")) {
+ if (checkoptionsetting("virtualhost") || checkoptionsetting("v"))
+ {
String vhost = optionchecker("virtualhost");
if (vhost == null)
vhost = optionchecker("v");
setVirtualhost(vhost);
}
listobjects(this.getObject());
- } else if (checkoptionsetting("h") || checkoptionsetting("help"))
+ }
+ else if (checkoptionsetting("h") || checkoptionsetting("help"))
printusage();
else
unrecognizeoption();
}
- public void printusage() {
+ public void printusage()
+ {
echo("");
echo("Usage:info [OPTION] ... [OBJECT TYPE]...\n");
echo("Give ALL the information about the given object\n");
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandlist.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandlist.java
index fb67b1cf2a..68ee593ba0 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandlist.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandlist.java
@@ -18,42 +18,24 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid.commands;
-import org.apache.qpid.utils.JMXinfo;
-import org.apache.qpid.utils.CommandLineOptionParser;
-import org.apache.qpid.utils.CommandLineOptionConstants;
-import org.apache.qpid.utils.CommandLineOption;
-import org.apache.qpid.commands.objects.*;
-
-import javax.management.ObjectName;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServerConnection;
import java.util.Set;
-import java.util.Iterator;
-import java.util.Map;
+import javax.management.MBeanServerConnection;
-public class Commandlist extends CommandImpl {
+import org.apache.qpid.commands.objects.AllObjects;
+import org.apache.qpid.commands.objects.ConnectionObject;
+import org.apache.qpid.commands.objects.ExchangeObject;
+import org.apache.qpid.commands.objects.ObjectNames;
+import org.apache.qpid.commands.objects.QueueObject;
+import org.apache.qpid.commands.objects.UserManagementObject;
+import org.apache.qpid.commands.objects.VirtualHostObject;
+import org.apache.qpid.utils.JMXinfo;
+
+public class Commandlist extends CommandImpl
+{
public static final String COMMAND_NAME = "list";
@@ -62,10 +44,15 @@ public class Commandlist extends CommandImpl {
super(info);
}
- private void listobjects(String option_value) {
- /*pring usage if use is not give the correct option letter or no options */
- if (option_value == null) {
-// System.out.println("testing");
+ private void listobjects(String option_value)
+ {
+ /*
+ * pring usage if use is not give the correct option letter or no
+ * options
+ */
+ if (option_value == null)
+ {
+ // System.out.println("testing");
printusage();
return;
}
@@ -73,104 +60,137 @@ public class Commandlist extends CommandImpl {
Set set = null;
ObjectNames objname = null;
- try {
- if (option_value.compareToIgnoreCase("queue") == 0 || option_value.compareToIgnoreCase("queues") == 0) {
+ try
+ {
+ if (option_value.compareToIgnoreCase("queue") == 0 || option_value.compareToIgnoreCase("queues") == 0)
+ {
objname = new QueueObject(mbsc);
- } else
- if (option_value.compareToIgnoreCase("Virtualhosts") == 0 || option_value.compareToIgnoreCase("Virtualhost") == 0) {
+ }
+ else if (option_value.compareToIgnoreCase("Virtualhosts") == 0
+ || option_value.compareToIgnoreCase("Virtualhost") == 0)
+ {
objname = new VirtualHostObject(mbsc);
-// this.name = option_value;
- } else
- if (option_value.compareToIgnoreCase("Exchange") == 0 || option_value.compareToIgnoreCase("Exchanges") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("Exchange") == 0
+ || option_value.compareToIgnoreCase("Exchanges") == 0)
+ {
objname = new ExchangeObject(mbsc);
-// this.name = option_value;
- } else
- if (option_value.compareToIgnoreCase("Connection") == 0 || option_value.compareToIgnoreCase("Connections") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("Connection") == 0
+ || option_value.compareToIgnoreCase("Connections") == 0)
+ {
objname = new ConnectionObject(mbsc);
-// this.name = option_value;
- } else if (option_value.compareToIgnoreCase("all") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("all") == 0)
+ {
objname = new AllObjects(mbsc);
-// this.name = option_value;
- } else
- if (option_value.compareToIgnoreCase("Usermanagement") == 0 || option_value.compareToIgnoreCase("Usermanagmenets") == 0) {
+ // this.name = option_value;
+ }
+ else if (option_value.compareToIgnoreCase("Usermanagement") == 0
+ || option_value.compareToIgnoreCase("Usermanagmenets") == 0)
+ {
objname = new UserManagementObject(mbsc);
-// this.name = option_value;
- } else {
+ // this.name = option_value;
+ }
+ else
+ {
printusage();
echo("Wrong objectName");
return;
}
objname.setQueryString(this.getObject(), this.getName(), this.getVirtualhost());
objname.returnObjects();
- if (objname.getSet().size() != 0) {
- if (this.getObject().compareToIgnoreCase("queue") == 0 || this.getObject().compareToIgnoreCase("queues") == 0)
+ if (objname.getSet().size() != 0)
+ {
+ if (this.getObject().compareToIgnoreCase("queue") == 0
+ || this.getObject().compareToIgnoreCase("queues") == 0)
objname.displayqueues(this.getOutputFormat(), this.getSeperator());
else
objname.displayobjects(this.getOutputFormat(), this.getSeperator());
- } else {
- if (hasName()) {
+ }
+ else
+ {
+ if (hasName())
+ {
echo("You might quering wrong " + this.getObject() + " name with --name or -n option ");
echo("");
echo(this.getObject() + "Type Objects might not in the broker currently");
echo("");
- } else {
+ }
+ else
+ {
printusage();
}
}
-
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
-
}
- public void listdomains() {
+ public void listdomains()
+ {
MBeanServerConnection mbsc = info.getmbserverconnector();
- try {
+ try
+ {
String[] domains = mbsc.getDomains();
echo("DOMAINS");
for (int i = 0; i < domains.length; i++)
echo("\tDomain[" + i + "] = " + domains[i]);
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
}
- public void execute() {
- /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
- with main option object or o
+ public void execute()
+ {
+ /*
+ * In here you it's easy to handle any number of otpions which are going
+ * to add with the list command which works with main option object or o
*/
- if (checkoptionsetting("output")) {
+ if (checkoptionsetting("output"))
+ {
setOutputFormat(optionchecker("output"));
if (checkoptionsetting("separator"))
setSeperator(optionchecker("separator"));
}
- if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ if (checkoptionsetting("object") || checkoptionsetting("o"))
+ {
String object = optionchecker("object");
- if (object == null) {
+ if (object == null)
+ {
object = optionchecker("o");
}
setObject(object);
- if (checkoptionsetting("name") || checkoptionsetting("n")) {
+ if (checkoptionsetting("name") || checkoptionsetting("n"))
+ {
String name = optionchecker("name");
if (name == null)
name = optionchecker("n");
setName(name);
}
- if (checkoptionsetting("virtualhost") || checkoptionsetting("v")) {
+ if (checkoptionsetting("virtualhost") || checkoptionsetting("v"))
+ {
String vhost = optionchecker("virtualhost");
if (vhost == null)
vhost = optionchecker("v");
setVirtualhost(vhost);
}
listobjects(this.getObject());
- } else if (checkoptionsetting("domain") || checkoptionsetting("d"))
+ }
+ else if (checkoptionsetting("domain") || checkoptionsetting("d"))
listdomains();
else if (checkoptionsetting("h") || checkoptionsetting("help"))
printusage();
@@ -178,7 +198,8 @@ public class Commandlist extends CommandImpl {
unrecognizeoption();
}
- public void printusage() {
+ public void printusage()
+ {
echo("");
echo("Usage:list [OPTION] ... [OBJECT TYPE]...\n");
echo("List the information about the given object\n");
@@ -207,11 +228,5 @@ public class Commandlist extends CommandImpl {
echo(" ex: <queue list -n ping -v development> list all the queue objects with name ");
echo(" of ping and virtualhost of developement \n");
-
}
}
-
-
-
-
-
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandmove.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandmove.java
index cc98b7cac4..6d1803409b 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandmove.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandmove.java
@@ -18,149 +18,160 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
package org.apache.qpid.commands;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
import org.apache.qpid.commands.objects.QueueObject;
-import org.apache.qpid.commands.objects.ObjectNames;
import org.apache.qpid.utils.JMXinfo;
-import javax.management.ObjectName;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanAttributeInfo;
-import java.util.StringTokenizer;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.List;
-import java.io.InputStreamReader;
-import java.io.BufferedReader;
-
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Aug 6, 2008
- * Time: 5:35:05 PM
- * To change this template use File | Settings | File Templates.
- */
-public class Commandmove extends CommandImpl {
-
+public class Commandmove extends CommandImpl
+{
public static final String COMMAND_NAME = "move";
-
- private String name1 = null, name2 = null, vhost1 = null, vhost2 = null, method1 = null, method2 = null; //target and starting queue specifications happen with these options
+
+ private String name1 = null, name2 = null, vhost1 = null, vhost2 = null, method1 = null, method2 = null; // target
+ // and
+ // starting
+ // queue
+ // specifications
+ // happen
+ // with
+ // these
+ // options
private QueueObject queue1;
private MBeanServerConnection mbsc;
private ObjectName queue;
private int fmid = 0, tmid = 0;
- public Commandmove(JMXinfo info) {
+ public Commandmove(JMXinfo info)
+ {
super(info);
-
+
this.mbsc = info.getmbserverconnector();
this.queue1 = new QueueObject(mbsc);
this.method1 = "moveMessages";
this.method2 = "getMessagesOnTheQueue";
}
-
- public void movemessages() {
+
+ public void movemessages()
+ {
Set set = null;
queue1.setQueryString(this.getObject(), this.name1, this.vhost1);
set = queue1.returnObjects();
- if (queue1.getSet().size() != 0) { // find the queue
+ if (queue1.getSet().size() != 0)
+ { // find the queue
Iterator it = set.iterator();
this.queue = (ObjectName) it.next();
- } else {
- if (isname1() || isname2()) { // if the specified queue is not there in the broker
+ }
+ else
+ {
+ if (isname1() || isname2())
+ { // if the specified queue is not there in the broker
echo("The Queue you have specified is not in the current broker");
echo("");
- } else {
+ }
+ else
+ {
printusage();
}
}
- try {
- Object[] params1 = {getfmid(), gettmid(), this.name2};
- String[] signature1 = {new String("long"), new String("long"), new String("java.lang.String")};
+ try
+ {
+ Object[] params1 = { getfmid(), gettmid(), this.name2 };
+ String[] signature1 = { new String("long"), new String("long"), new String("java.lang.String") };
this.mbsc.invoke(this.queue, this.method1, params1, signature1);
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
echo("Given messageId's might be wrong please run the view command and check messageId's you have given\n");
echo("From MessageId should be greater than 0 and should less than To messageId");
}
-
}
- public void execute() {
- /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
- with main option object or o
+ public void execute()
+ {
+ /*
+ * In here you it's easy to handle any number of otpions which are going
+ * to add with the list command which works with main option object or o
*/
- if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ if (checkoptionsetting("object") || checkoptionsetting("o"))
+ {
String object = optionchecker("object");
- if (object == null) {
+ if (object == null)
+ {
object = optionchecker("o");
}
if (object.compareToIgnoreCase("queue") == 0)
setObject(object);
- else {
+ else
+ {
unrecognizeoption();
echo("This command is only applicable for queue command so please start with queue");
}
- if (checkoptionsetting("n2") && checkoptionsetting("n1")) {
+ if (checkoptionsetting("n2") && checkoptionsetting("n1"))
+ {
setname1(optionchecker("n1"));
setname2(optionchecker("n2"));
- } else {
- echo("You have to specify both n1 and n2 option value to move a message"); /* when user forget to specify target or starting queue name */
+ }
+ else
+ {
+ echo("You have to specify both n1 and n2 option value to move a message"); /*
+ * when
+ * user
+ * forget
+ * to
+ * specify
+ * target
+ * or
+ * starting
+ * queue
+ * name
+ */
return;
}
- if (checkoptionsetting("v1")) {
+ if (checkoptionsetting("v1"))
+ {
setvhost1(optionchecker("v1"));
}
- if (checkoptionsetting("tmid") && checkoptionsetting("fmid")) {
+ if (checkoptionsetting("tmid") && checkoptionsetting("fmid"))
+ {
String tmid = optionchecker("tmid");
String fmid = optionchecker("fmid");
-
settomessageIdandfrommessageId(removeSpaces(tmid), removeSpaces(fmid));
- } else {
+ }
+ else
+ {
echo("You have to set from MessageId and to MessageId in order to move messages between queues");
echo("To view MessageId's use <view> command with -n and -v options");
return;
}
this.movemessages();
- } else if (checkoptionsetting("h") || checkoptionsetting("help"))
+ }
+ else if (checkoptionsetting("h") || checkoptionsetting("help"))
printusage();
else
unrecognizeoption();
}
- public void printusage() {
+ public void printusage()
+ {
echo("");
echo("Usage:move [OPTION] ... [OBJECT TYPE]...\n");
echo("Move the top most messages from the given queue object to the given destination object\n");
@@ -175,15 +186,18 @@ public class Commandmove extends CommandImpl {
}
- private void setname1(String name) {
+ private void setname1(String name)
+ {
this.name1 = name;
}
- private void setname2(String name) {
+ private void setname2(String name)
+ {
this.name2 = name;
}
- private boolean isname1() {
+ private boolean isname1()
+ {
if (this.name1 == null)
return false;
@@ -191,7 +205,8 @@ public class Commandmove extends CommandImpl {
return true;
}
- private boolean isname2() {
+ private boolean isname2()
+ {
if (this.name2 == null)
return false;
@@ -199,37 +214,45 @@ public class Commandmove extends CommandImpl {
return true;
}
- private void setvhost1(String vhost) {
+ private void setvhost1(String vhost)
+ {
this.vhost1 = vhost;
}
- private static String removeSpaces(String s) {
+ private static String removeSpaces(String s)
+ {
StringTokenizer st = new StringTokenizer(s, " ", false);
String t = "";
- while (st.hasMoreElements()) t += st.nextElement();
+ while (st.hasMoreElements())
+ t += st.nextElement();
return t;
}
- private void settomessageIdandfrommessageId(String tmid, String fmid) {
+ private void settomessageIdandfrommessageId(String tmid, String fmid)
+ {
Integer i = new Integer(tmid);
Integer j = new Integer(fmid);
this.tmid = i.intValue();
this.fmid = j.intValue();
}
- public int gettmid() {
+ public int gettmid()
+ {
return this.tmid;
}
- public int getfmid() {
+ public int getfmid()
+ {
return this.fmid;
}
- public String getname1() {
+ public String getname1()
+ {
return this.name1;
}
- public String getname2() {
+ public String getname2()
+ {
return this.name2;
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandset.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandset.java
index eecaf2adbe..4dd97e30b0 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandset.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandset.java
@@ -43,7 +43,10 @@ public class Commandset extends CommandImpl
private void setAttribute(String option_value)
{
- /*print usage if use is not give the correct option letter or no options */
+ /*
+ * print usage if use is not give the correct option letter or no
+ * options
+ */
if (option_value == null)
{
printusage();
@@ -140,8 +143,9 @@ public class Commandset extends CommandImpl
public void execute()
{
- /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
- with main option object or o
+ /*
+ * In here you it's easy to handle any number of otpions which are going
+ * to add with the list command which works with main option object or o
*/
if (checkoptionsetting("output"))
{
@@ -254,8 +258,3 @@ public class Commandset extends CommandImpl
}
}
-
-
-
-
-
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandview.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandview.java
index 94f85fb40d..e98cb336d8 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandview.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandview.java
@@ -18,58 +18,37 @@
* under the License.
*
*/
- /*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid.commands;
-import org.apache.qpid.commands.objects.ObjectNames;
-import org.apache.qpid.commands.objects.QueueObject;
-import org.apache.qpid.utils.JMXinfo;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.openmbean.*;
-import java.util.*;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.awt.font.OpenType;
-
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Aug 8, 2008
- * Time: 11:33:05 PM
- * To change this template use File | Settings | File Templates.
- */
-public class Commandview extends CommandImpl {
-
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularDataSupport;
+
+import org.apache.qpid.commands.objects.QueueObject;
+import org.apache.qpid.utils.JMXinfo;
+
+public class Commandview extends CommandImpl
+{
+
public static final String COMMAND_NAME = "view";
-
+
private int number = 0;
private QueueObject objname;
private MBeanServerConnection mbsc;
private String method1;
private ObjectName queue;
- public Commandview(JMXinfo info) {
+ public Commandview(JMXinfo info)
+ {
super(info);
this.mbsc = info.getmbserverconnector();
this.objname = new QueueObject(mbsc);
@@ -77,54 +56,62 @@ public class Commandview extends CommandImpl {
}
- public void viewmessages() {
+ public void viewmessages()
+ {
Set set = null;
- Object temp[] = {null};
+ Object temp[] = { null };
objname.setQueryString(this.getObject(), this.getName(), this.getVirtualhost());
set = objname.returnObjects();
String header = "", temp_header = "", message_data = "", outline = "";
-
- if (objname.getSet().size() != 0) {
+ if (objname.getSet().size() != 0)
+ {
Iterator it = set.iterator();
this.queue = (ObjectName) it.next();
- try {
- if (objname.getmessagecount(this.queue) == 0) {
+ try
+ {
+ if (objname.getmessagecount(this.queue) == 0)
+ {
echo("Selected Queue doesn't contain any messages");
return;
}
if (this.number == 0)
this.number = objname.getmessagecount(this.queue);
-
- if (objname.getmessagecount(this.queue) < this.number) {
+ if (objname.getmessagecount(this.queue) < this.number)
+ {
echo("Given number is Greater than the Queue Depth");
return;
- } else {
- Object[] params = {1, this.number};
- String[] signature = {new String("int"), new String("int")};
- TabularDataSupport data = (TabularDataSupport) this.mbsc.invoke(queue, this.method1, params, signature);
+ }
+ else
+ {
+ Object[] params = { 1, this.number };
+ String[] signature = { new String("int"), new String("int") };
+ TabularDataSupport data = (TabularDataSupport) this.mbsc.invoke(queue, this.method1, params,
+ signature);
Set entrySet = data.entrySet();
ArrayList<Map.Entry> list = new ArrayList<Map.Entry>(entrySet);
- if (list.size() != 0) {// no data}
- for (int i = 0; i < list.size(); i++) {
- CompositeData compositedata =
- (CompositeData) (list.get(i)).getValue();
- List<String> itemNames = new
- ArrayList<String>(compositedata.getCompositeType().keySet());
+ if (list.size() != 0)
+ {// no data}
+ for (int i = 0; i < list.size(); i++)
+ {
+ CompositeData compositedata = (CompositeData) (list.get(i)).getValue();
+ List<String> itemNames = new ArrayList<String>(compositedata.getCompositeType().keySet());
if (i == 0) // display the table headers
{
- for (int j = 0; j < itemNames.size(); j++) {
+ for (int j = 0; j < itemNames.size(); j++)
+ {
temp_header = "";
- if (j != 1) //skipping header information
+ if (j != 1) // skipping header information
{
temp_header = itemNames.get(j);
while (temp_header.length() < 15)
temp_header = " " + temp_header;
header = header + temp_header + "|";
- } else
+ }
+ else
continue;
}
echo(header);
@@ -133,71 +120,93 @@ public class Commandview extends CommandImpl {
echo(outline);
}
- for (int j = 0; j < itemNames.size(); j++) {
+ for (int j = 0; j < itemNames.size(); j++)
+ {
temp_header = "";
- if (j != 1) {
+ if (j != 1)
+ {
temp_header = String.valueOf(compositedata.get(itemNames.get(j)));
while (temp_header.length() < 15)
temp_header = " " + temp_header;
message_data = message_data + temp_header + "|";
- } else // header information is not displaying unless user specify header information is needed
+ }
+ else
+ // header information is not displaying
+ // unless user specify header information is
+ // needed
continue;
-
}
echo(message_data);
header = "";
message_data = "";
}
- } else {
+ }
+ else
+ {
System.out.println("No Data to Display");
}
}
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
- } else {
- if (hasName()) {
+ }
+ else
+ {
+ if (hasName())
+ {
echo("The Queue you have specified is not in the current broker");
echo("");
- } else {
+ }
+ else
+ {
printusage();
}
}
}
- public void execute() {
- /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
- with main option object or o
+ public void execute()
+ {
+ /*
+ * In here you it's easy to handle any number of otpions which are going
+ * to add with the list command which works with main option object or o
*/
- if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ if (checkoptionsetting("object") || checkoptionsetting("o"))
+ {
String object = optionchecker("object");
- if (object == null) {
+ if (object == null)
+ {
object = optionchecker("o");
}
if (object.compareToIgnoreCase("queue") == 0)
setObject(object);
- else {
+ else
+ {
unrecognizeoption();
echo("This command is only applicable for delete command so please start with queue");
}
- if (checkoptionsetting("name") || checkoptionsetting("n")) {
+ if (checkoptionsetting("name") || checkoptionsetting("n"))
+ {
String name = optionchecker("name");
if (name == null)
name = optionchecker("n");
setName(name);
}
- if (checkoptionsetting("virtualhost") || checkoptionsetting("v")) {
+ if (checkoptionsetting("virtualhost") || checkoptionsetting("v"))
+ {
String vhost = optionchecker("virtualhost");
if (vhost == null)
vhost = optionchecker("v");
setVirtualhost(vhost);
}
- if (checkoptionsetting("top") || checkoptionsetting("t")) {
+ if (checkoptionsetting("top") || checkoptionsetting("t"))
+ {
String number = optionchecker("top");
if (number == null)
number = optionchecker("t");
@@ -205,13 +214,15 @@ public class Commandview extends CommandImpl {
setnumber(removeSpaces(number));
}
this.viewmessages();
- } else if (checkoptionsetting("h") || checkoptionsetting("help"))
+ }
+ else if (checkoptionsetting("h") || checkoptionsetting("help"))
printusage();
else
unrecognizeoption();
}
- public void printusage() {
+ public void printusage()
+ {
echo("");
echo("Usage:view [OPTION] ... [OBJECT TYPE]...\n");
echo("view the information about given number of messages from the given queue object\n");
@@ -224,15 +235,18 @@ public class Commandview extends CommandImpl {
}
- private void setnumber(String number) {
+ private void setnumber(String number)
+ {
Integer i = new Integer(number);
this.number = i.intValue();
}
- private static String removeSpaces(String s) {
+ private static String removeSpaces(String s)
+ {
StringTokenizer st = new StringTokenizer(s, " ", false);
String t = "";
- while (st.hasMoreElements()) t += st.nextElement();
+ while (st.hasMoreElements())
+ t += st.nextElement();
return t;
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandviewcontent.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandviewcontent.java
index 2067a5b35a..a0843b91fa 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandviewcontent.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/Commandviewcontent.java
@@ -18,47 +18,27 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
package org.apache.qpid.commands;
-import org.apache.qpid.commands.objects.QueueObject;
-import org.apache.qpid.utils.JMXinfo;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
-import javax.management.openmbean.TabularData;
import javax.management.openmbean.CompositeData;
-import java.util.*;
-import java.nio.charset.Charset;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Aug 10, 2008
- * Time: 12:19:16 PM
- * To change this template use File | Settings | File Templates.
- */
-public class Commandviewcontent extends CommandImpl {
+import org.apache.qpid.commands.objects.QueueObject;
+import org.apache.qpid.utils.JMXinfo;
+
+public class Commandviewcontent extends CommandImpl
+{
public static final String COMMAND_NAME = "viewcontent";
-
+
private String object;
private String name;
private String vhost;
@@ -68,40 +48,47 @@ public class Commandviewcontent extends CommandImpl {
private String method1;
private ObjectName queue;
- public Commandviewcontent(JMXinfo info) {
+ public Commandviewcontent(JMXinfo info)
+ {
super(info);
this.mbsc = info.getmbserverconnector();
this.objname = new QueueObject(mbsc);
this.method1 = "viewMessageContent";
}
-
- public void viewcontent() {
+
+ public void viewcontent()
+ {
Set set = null;
- Object temp[] = {null};
+ Object temp[] = { null };
objname.setQueryString(this.object, this.name, this.vhost);
set = objname.returnObjects();
String temp_header = "", header = "", message_data = "", encoding = null;
- if (objname.getSet().size() != 0) {
+ if (objname.getSet().size() != 0)
+ {
Iterator it = set.iterator();
this.queue = (ObjectName) it.next();
- try {
- if (objname.getmessagecount(this.queue) == 0) {
+ try
+ {
+ if (objname.getmessagecount(this.queue) == 0)
+ {
echo("Selected Queue doesn't contain any messages");
return;
}
- if (this.number == 0) {
+ if (this.number == 0)
+ {
echo("You haven't selected a MessageId Please use -id and give a message id");
echo("Or run view command with same arguemnts to view messageId list for the queue");
}
- else {
- Object[] params = {this.number};
- String[] signature = {new String("long")};
+ else
+ {
+ Object[] params = { this.number };
+ String[] signature = { new String("long") };
CompositeData data = (CompositeData) this.mbsc.invoke(queue, this.method1, params, signature);
- List<String> itemNames = new
- ArrayList<String>(data.getCompositeType().keySet());
- for (int j = 0; j < itemNames.size(); j++) {
+ List<String> itemNames = new ArrayList<String>(data.getCompositeType().keySet());
+ for (int j = 0; j < itemNames.size(); j++)
+ {
temp_header = "";
temp_header = itemNames.get(j);
while (temp_header.length() < 15)
@@ -110,21 +97,39 @@ public class Commandviewcontent extends CommandImpl {
header = header + temp_header + "|";
}
echo(header);
- encoding = String.valueOf(data.get(itemNames.get(2))); // set the encoding at the beginning because encoding comes later in the loop
- if (encoding == null || encoding.length() == 0) {
+ encoding = String.valueOf(data.get(itemNames.get(2))); // set
+ // the
+ // encoding
+ // at
+ // the
+ // beginning
+ // because
+ // encoding
+ // comes
+ // later
+ // in
+ // the
+ // loop
+ if (encoding == null || encoding.length() == 0)
+ {
encoding = Charset.defaultCharset().name();
}
- for (int j = 0; j < itemNames.size(); j++) {
+ for (int j = 0; j < itemNames.size(); j++)
+ {
temp_header = "";
- if (j != 1) {
+ if (j != 1)
+ {
temp_header = String.valueOf(data.get(itemNames.get(j)));
while (temp_header.length() < 15)
temp_header = " " + temp_header;
- } else {
+ }
+ else
+ {
Byte[] arrayItems = (Byte[]) data.get(itemNames.get(j));
byte[] byteArray = new byte[arrayItems.length];
- for (int i = 0; i < arrayItems.length; i++) {
+ for (int i = 0; i < arrayItems.length; i++)
+ {
byteArray[i] = arrayItems[i];
temp_header = new String(byteArray, encoding);
while (temp_header.length() < 15)
@@ -133,57 +138,71 @@ public class Commandviewcontent extends CommandImpl {
}
message_data = message_data + temp_header + "|";
-
}
echo(message_data);
}
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
echo("Given MessageId is invalid, There's no message with the given messageId");
ex.printStackTrace();
return;
}
- } else {
- if (hasName()) {
+ }
+ else
+ {
+ if (hasName())
+ {
echo("The Queue you have specified is not in the current broker");
echo("");
- } else {
+ }
+ else
+ {
printusage();
}
}
}
- public void execute() {
- /* In here you it's easy to handle any number of otpions which are going to add with the list command which works
- with main option object or o
+ public void execute()
+ {
+ /*
+ * In here you it's easy to handle any number of otpions which are going
+ * to add with the list command which works with main option object or o
*/
- if (checkoptionsetting("object") || checkoptionsetting("o")) {
+ if (checkoptionsetting("object") || checkoptionsetting("o"))
+ {
String object = optionchecker("object");
- if (object == null) {
+ if (object == null)
+ {
object = optionchecker("o");
}
if (object.compareToIgnoreCase("queue") == 0)
setObject(object);
- else {
+ else
+ {
unrecognizeoption();
echo("This command is only applicable for delete command so please start with queue");
}
- if (checkoptionsetting("name") || checkoptionsetting("n")) {
+ if (checkoptionsetting("name") || checkoptionsetting("n"))
+ {
String name = optionchecker("name");
if (name == null)
name = optionchecker("n");
setName(name);
}
- if (checkoptionsetting("virtualhost") || checkoptionsetting("v")) {
+ if (checkoptionsetting("virtualhost") || checkoptionsetting("v"))
+ {
String vhost = optionchecker("virtualhost");
if (vhost == null)
vhost = optionchecker("v");
setVirtualhost(vhost);
}
- if (checkoptionsetting("messageid") || checkoptionsetting("id")) {
+ if (checkoptionsetting("messageid") || checkoptionsetting("id"))
+ {
String number = optionchecker("id");
if (number == null)
number = optionchecker("id");
@@ -191,13 +210,15 @@ public class Commandviewcontent extends CommandImpl {
setnumber(removeSpaces(number));
}
this.viewcontent();
- } else if (checkoptionsetting("h") || checkoptionsetting("help"))
+ }
+ else if (checkoptionsetting("h") || checkoptionsetting("help"))
printusage();
else
unrecognizeoption();
}
- public void printusage() {
+ public void printusage()
+ {
echo("");
echo("Usage:viewcontent [OPTION] ... [OBJECT TYPE]...\n");
echo("view the information about given number of messages from the given queue object\n");
@@ -210,21 +231,24 @@ public class Commandviewcontent extends CommandImpl {
}
- private void setnumber(String number) {
+ private void setnumber(String number)
+ {
Integer i = new Integer(number);
this.number = i.intValue();
}
- private static String removeSpaces(String s) {
+ private static String removeSpaces(String s)
+ {
StringTokenizer st = new StringTokenizer(s, " ", false);
String t = "";
- while (st.hasMoreElements()) t += st.nextElement();
+ while (st.hasMoreElements())
+ t += st.nextElement();
return t;
}
- public int getnumber() {
+ public int getnumber()
+ {
return this.number;
}
-
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/AllObjects.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/AllObjects.java
index 7f16109f0c..253119f057 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/AllObjects.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/AllObjects.java
@@ -23,22 +23,16 @@ package org.apache.qpid.commands.objects;
import javax.management.MBeanServerConnection;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Jun 20, 2008
- * Time: 9:04:22 AM
- * To change this template use File | Settings | File Templates.
- */
-public class AllObjects extends ObjectNames {
+public class AllObjects extends ObjectNames
+{
- public AllObjects(MBeanServerConnection mbsc) {
+ public AllObjects(MBeanServerConnection mbsc)
+ {
ObjectNames(mbsc);
-// querystring = "org.apache.qpid:*";
-// set = returnObjects();
}
- public void setQueryString(String object, String name) {
+ public void setQueryString(String object, String name)
+ {
querystring = "org.apache.qpid:*";
}
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ConnectionObject.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ConnectionObject.java
index 6c427660c0..cb1891481c 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ConnectionObject.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ConnectionObject.java
@@ -23,23 +23,16 @@ package org.apache.qpid.commands.objects;
import javax.management.MBeanServerConnection;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Jun 26, 2008
- * Time: 9:58:02 PM
- * To change this template use File | Settings | File Templates.
- */
-public class ConnectionObject extends ObjectNames {
- public ConnectionObject(MBeanServerConnection mbsc) {
- /*calling parent classes constructor */
+public class ConnectionObject extends ObjectNames
+{
+ public ConnectionObject(MBeanServerConnection mbsc)
+ {
+ /* calling parent classes constructor */
ObjectNames(mbsc);
-// querystring = "org.apache.qpid:type=VirtualHost.Connection,*";
-// set = returnObjects();
-
}
- public void setQueryString(String object, String name, String vhost) {
+ public void setQueryString(String object, String name, String vhost)
+ {
if (name != null && vhost == null)
querystring = "org.apache.qpid:type=Connection,name=" + name + ",*";
else if (name != null && vhost != null)
@@ -51,4 +44,3 @@ public class ConnectionObject extends ObjectNames {
}
}
-
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ExchangeObject.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ExchangeObject.java
index 22439e9d61..2c1c4c47ff 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ExchangeObject.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ExchangeObject.java
@@ -23,22 +23,16 @@ package org.apache.qpid.commands.objects;
import javax.management.MBeanServerConnection;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Jun 24, 2008
- * Time: 12:15:19 AM
- * To change this template use File | Settings | File Templates.
- */
-public class ExchangeObject extends ObjectNames {
- public ExchangeObject(MBeanServerConnection mbsc) {
+public class ExchangeObject extends ObjectNames
+{
+ public ExchangeObject(MBeanServerConnection mbsc)
+ {
ObjectNames(mbsc);
-// querystring = "org.apache.qpid:type=VirtualHost.Exchange,*";
-// set = returnObjects();
}
- public void setQueryString(String object, String name, String vhost) {
+ public void setQueryString(String object, String name, String vhost)
+ {
if (name != null && vhost == null)
querystring = "org.apache.qpid:type=VirtualHost.Exchange,name=" + name + ",*";
else if (name != null && vhost != null)
@@ -50,4 +44,3 @@ public class ExchangeObject extends ObjectNames {
}
}
-
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java
index a07181248c..dc676ebfe3 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/ObjectNames.java
@@ -21,29 +21,18 @@
package org.apache.qpid.commands.objects;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.Attribute;
import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
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.
- * User: lahiru
- * Date: Jun 20, 2008
- * Time: 8:39:01 AM
- * To change this template use File | Settings | File Templates.
- */
-public class ObjectNames {
+
+public class ObjectNames
+{
public String querystring = null;
public MBeanServerConnection mbsc;
public Set set = null;
@@ -51,33 +40,44 @@ public class ObjectNames {
public String attributevalues = "";// = null;
/* method return the Set objects according to the Object type */
- public void ObjectNames(MBeanServerConnection mbsc) {
+ public void ObjectNames(MBeanServerConnection mbsc)
+ {
this.mbsc = mbsc;
}
- public Set returnObjects() {
- try {
+ public Set returnObjects()
+ {
+ try
+ {
set = mbsc.queryNames(new ObjectName(querystring), null);
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
return set;
}
- public void echo(String str) {
+ public void echo(String str)
+ {
System.out.println(str);
}
+
/* display appropriate objects according to the ojbect type */
- public void displayobjects(String output, String seperator) {
+ public void displayobjects(String output, String seperator)
+ {
Iterator it = set.iterator();
String line = "";
String temp2 = "";
int iterator = 0;
- try {
- do {
+ try
+ {
+ do
+ {
ObjectName temp_object = null;
- if (it.hasNext()) {
+ if (it.hasNext())
+ {
temp_object = (ObjectName) it.next();
if (temp_object == null)
System.out.println("null test");
@@ -85,7 +85,8 @@ public class ObjectNames {
// echo(temp_object.getCanonicalKeyPropertyListString());
MBeanInfo bean_info = mbsc.getMBeanInfo(temp_object);
MBeanAttributeInfo[] attr_info = bean_info.getAttributes();
- if (attr_info == null) {
+ if (attr_info == null)
+ {
echo(temp_object.toString());
String temp = "";
while (temp_object.toString().length() > temp.length())
@@ -93,27 +94,37 @@ public class ObjectNames {
if (output == null)
echo(temp);
- } else {
- for (MBeanAttributeInfo attr : attr_info) {
+ }
+ else
+ {
+ for (MBeanAttributeInfo attr : attr_info)
+ {
Object toWrite = null;
- try {
+ try
+ {
String temp1 = attr.getName();
- if (output == null) {
+ if (output == null)
+ {
while (temp1.length() < 15)
temp1 = " " + temp1;
attributes = attributes + temp1 + "|";
- } else if (output.compareToIgnoreCase("csv") == 0)
+ }
+ else if (output.compareToIgnoreCase("csv") == 0)
attributes = attributes + temp1 + seperator;
- else {
+ else
+ {
echo("Wrong output format current version is supporting only for CSV");
return;
}
- } catch (Exception x) {
+ }
+ catch (Exception x)
+ {
x.printStackTrace();
}
}
- if (attributes.equalsIgnoreCase("")) {
+ if (attributes.equalsIgnoreCase(""))
+ {
echo(temp_object.toString());
String temp = "";
while (temp_object.toString().length() > temp.length())
@@ -122,34 +133,40 @@ public class ObjectNames {
echo("There are no attributes for this object Type");
continue;
}
- for (MBeanAttributeInfo attr : attr_info) {
+ for (MBeanAttributeInfo attr : attr_info)
+ {
Object toWrite = null;
temp2 = null;
- try {
+ try
+ {
toWrite = mbsc.getAttribute(temp_object, attr.getName());
- } catch (Exception x) {
+ }
+ catch (Exception x)
+ {
temp2 = "-";
}
if (toWrite != null)
temp2 = toWrite.toString();
else
temp2 = "-";
- if (output == null) {
+ if (output == null)
+ {
while (temp2.length() < 15)
temp2 = " " + temp2;
attributevalues = attributevalues + temp2 + "|";
- } else if (output.compareToIgnoreCase("csv") == 0)
+ }
+ else if (output.compareToIgnoreCase("csv") == 0)
attributevalues = attributevalues + temp2 + seperator;
- //echo(temp1 + " " + temp2 + " " + temp3);
-
+ // echo(temp1 + " " + temp2 + " " + temp3);
}
}
iterator++;
- if (iterator == 1) {
+ if (iterator == 1)
+ {
echo(attributes);
for (int i = 0; i < attributes.length(); i++)
line = line + "-";
@@ -161,21 +178,27 @@ public class ObjectNames {
attributes = "";
attributevalues = "";
} while (it.hasNext());
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
}
- public void reportgenerator(String output, String seperator, List<String> column) {
+ public void reportgenerator(String output, String seperator, List<String> column)
+ {
Iterator it = set.iterator();
String line = "";
String temp2 = "";
int iterator = 0;
- try {
- do {
+ try
+ {
+ do
+ {
ObjectName temp_object = null;
- if (it.hasNext()) {
+ if (it.hasNext())
+ {
temp_object = (ObjectName) it.next();
if (temp_object == null)
System.out.println("null test");
@@ -183,7 +206,8 @@ public class ObjectNames {
// echo(temp_object.getCanonicalKeyPropertyListString());
MBeanInfo bean_info = mbsc.getMBeanInfo(temp_object);
MBeanAttributeInfo[] attr_info = bean_info.getAttributes();
- if (attr_info == null) {
+ if (attr_info == null)
+ {
echo(temp_object.toString());
String temp = "";
while (temp_object.toString().length() > temp.length())
@@ -191,29 +215,40 @@ public class ObjectNames {
if (output == null)
echo(temp);
- } else {
- for (MBeanAttributeInfo attr : attr_info) {
+ }
+ else
+ {
+ for (MBeanAttributeInfo attr : attr_info)
+ {
Object toWrite = null;
- try {
+ try
+ {
String temp1 = attr.getName();
- if (column.contains(temp1)) {
- if (output == null) {
+ if (column.contains(temp1))
+ {
+ if (output == null)
+ {
while (temp1.length() < 15)
temp1 = " " + temp1;
attributes = attributes + temp1 + "|";
- } else if (output.compareToIgnoreCase("csv") == 0)
+ }
+ else if (output.compareToIgnoreCase("csv") == 0)
attributes = attributes + temp1 + seperator;
- else {
+ else
+ {
echo("Wrong output format current version is supporting only for CSV");
return;
}
}
- } catch (Exception x) {
+ }
+ catch (Exception x)
+ {
x.printStackTrace();
}
}
- if (attributes.equalsIgnoreCase("")) {
+ if (attributes.equalsIgnoreCase(""))
+ {
echo(temp_object.toString());
String temp = "";
while (temp_object.toString().length() > temp.length())
@@ -222,37 +257,44 @@ public class ObjectNames {
echo("There are no attributes for this object Type");
return;
}
- for (MBeanAttributeInfo attr : attr_info) {
+ for (MBeanAttributeInfo attr : attr_info)
+ {
Object toWrite = null;
temp2 = null;
- if (column.contains(attr.getName())) {
- try {
+ if (column.contains(attr.getName()))
+ {
+ try
+ {
toWrite = mbsc.getAttribute(temp_object, attr.getName());
- } catch (Exception x) {
+ }
+ catch (Exception x)
+ {
temp2 = "-";
}
if (toWrite != null)
temp2 = toWrite.toString();
else
temp2 = "-";
- if (output == null) {
+ if (output == null)
+ {
while (temp2.length() < 15)
temp2 = " " + temp2;
attributevalues = attributevalues + temp2 + "|";
- } else if (output.compareToIgnoreCase("csv") == 0)
+ }
+ else if (output.compareToIgnoreCase("csv") == 0)
attributevalues = attributevalues + temp2 + seperator;
- //echo(temp1 + " " + temp2 + " " + temp3);
+ // echo(temp1 + " " + temp2 + " " + temp3);
}
-
}
}
iterator++;
- if (iterator == 1) {
+ if (iterator == 1)
+ {
echo(attributes);
for (int i = 0; i < attributes.length(); i++)
line = line + "-";
@@ -264,30 +306,37 @@ public class ObjectNames {
attributes = "";
attributevalues = "";
} while (it.hasNext());
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
}
- public void displayqueues(String output, String seperator) {
+ public void displayqueues(String output, String seperator)
+ {
Iterator it = set.iterator();
String line = "";
int iterator = 0;
int attr_count = 0;
String temp1 = "";
String temp2 = "";
- try {
- do {
+ try
+ {
+ do
+ {
attr_count = 0;
ObjectName temp_object = null;
- if (it.hasNext()) {
+ if (it.hasNext())
+ {
temp_object = (ObjectName) it.next();
}
// echo(temp_object.getCanonicalKeyPropertyListString());
MBeanInfo bean_info = mbsc.getMBeanInfo(temp_object);
MBeanAttributeInfo[] attr_info = bean_info.getAttributes();
- if (attr_info == null) {
+ if (attr_info == null)
+ {
echo(temp_object.toString());
String temp = "";
while (temp_object.toString().length() > temp.length())
@@ -295,93 +344,106 @@ public class ObjectNames {
if (output == null)
echo(temp);
- } else {
- for (MBeanAttributeInfo attr : attr_info) {
+ }
+ else
+ {
+ for (MBeanAttributeInfo attr : attr_info)
+ {
Object toWrite = null;
attr_count++;
- try {
+ try
+ {
toWrite = mbsc.getAttribute(temp_object, attr.getName());
- if (output == null) {
- switch (attr_count) {
- case 1:
- case 3:
- temp1 = attr.getName();
- while (temp1.length() < 10)
- temp1 = " " + temp1;
- attributes = attributes + temp1 + "|";
- temp2 = toWrite.toString();
- while (temp2.length() < 10)
- temp2 = " " + temp2;
- attributevalues = attributevalues + temp2 + "|";
- break;
- case 6:
- temp1 = attr.getName();
- while (temp1.length() < 20)
- temp1 = " " + temp1;
- attributes = attributes + temp1 + "|";
- temp2 = toWrite.toString();
- while (temp2.length() < 20)
- temp2 = " " + temp2;
- attributevalues = attributevalues + temp2 + "|";
- break;
- case 7:
- temp1 = attr.getName();
- while (temp1.length() < 13)
- temp1 = " " + temp1;
- attributes = attributes + temp1 + "|";
- temp2 = toWrite.toString();
- while (temp2.length() < 13)
- temp2 = " " + temp2;
- attributevalues = attributevalues + temp2 + "|";
- break;
- case 9:
- temp1 = attr.getName();
- while (temp1.length() < 20)
- temp1 = " " + temp1;
- attributes = attributes + temp1 + "|";
- temp2 = toWrite.toString();
- while (temp2.length() < 20)
- temp2 = " " + temp2;
- attributevalues = attributevalues + temp2 + "|";
- break;
+ if (output == null)
+ {
+ switch (attr_count)
+ {
+ case 1:
+ case 3:
+ temp1 = attr.getName();
+ while (temp1.length() < 10)
+ temp1 = " " + temp1;
+ attributes = attributes + temp1 + "|";
+ temp2 = toWrite.toString();
+ while (temp2.length() < 10)
+ temp2 = " " + temp2;
+ attributevalues = attributevalues + temp2 + "|";
+ break;
+ case 6:
+ temp1 = attr.getName();
+ while (temp1.length() < 20)
+ temp1 = " " + temp1;
+ attributes = attributes + temp1 + "|";
+ temp2 = toWrite.toString();
+ while (temp2.length() < 20)
+ temp2 = " " + temp2;
+ attributevalues = attributevalues + temp2 + "|";
+ break;
+ case 7:
+ temp1 = attr.getName();
+ while (temp1.length() < 13)
+ temp1 = " " + temp1;
+ attributes = attributes + temp1 + "|";
+ temp2 = toWrite.toString();
+ while (temp2.length() < 13)
+ temp2 = " " + temp2;
+ attributevalues = attributevalues + temp2 + "|";
+ break;
+ case 9:
+ temp1 = attr.getName();
+ while (temp1.length() < 20)
+ temp1 = " " + temp1;
+ attributes = attributes + temp1 + "|";
+ temp2 = toWrite.toString();
+ while (temp2.length() < 20)
+ temp2 = " " + temp2;
+ attributevalues = attributevalues + temp2 + "|";
+ break;
}
- } else if (output.compareToIgnoreCase("csv") == 0) {
- switch (attr_count) {
- case 1:
- case 3:
- case 6:
- temp1 = attr.getName();
- attributes = attributes + temp1 + seperator;
- temp2 = toWrite.toString();
- attributevalues = attributevalues + temp2 + seperator;
- break;
- case 7:
- temp1 = attr.getName();
- attributes = attributes + temp1 + seperator;
- temp2 = toWrite.toString();
- attributevalues = attributevalues + temp2 + seperator;
- break;
- case 9:
- temp1 = attr.getName();
- attributes = attributes + temp1 + seperator;
- temp2 = toWrite.toString();
- attributevalues = attributevalues + temp2 + seperator;
- break;
+ }
+ else if (output.compareToIgnoreCase("csv") == 0)
+ {
+ switch (attr_count)
+ {
+ case 1:
+ case 3:
+ case 6:
+ temp1 = attr.getName();
+ attributes = attributes + temp1 + seperator;
+ temp2 = toWrite.toString();
+ attributevalues = attributevalues + temp2 + seperator;
+ break;
+ case 7:
+ temp1 = attr.getName();
+ attributes = attributes + temp1 + seperator;
+ temp2 = toWrite.toString();
+ attributevalues = attributevalues + temp2 + seperator;
+ break;
+ case 9:
+ temp1 = attr.getName();
+ attributes = attributes + temp1 + seperator;
+ temp2 = toWrite.toString();
+ attributevalues = attributevalues + temp2 + seperator;
+ break;
}
- } else {
+ }
+ else
+ {
echo("Wrong output format specified currently CLI supports only csv output format");
return;
}
-
- } catch (Exception x) {
+ }
+ catch (Exception x)
+ {
x.printStackTrace();
}
}
}
iterator++;
- if (iterator == 1) {
+ if (iterator == 1)
+ {
for (int i = 0; i < attributes.length(); i++)
line = line + "-";
if (output == null)
@@ -395,60 +457,76 @@ public class ObjectNames {
attributes = "";
attributevalues = "";
} while (it.hasNext());
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
}
- public void displayinfo(String output, String seperator) {
+ public void displayinfo(String output, String seperator)
+ {
Iterator it = set.iterator();
String temp1, temp2 = "";
- try {
- do {
+ try
+ {
+ do
+ {
ObjectName temp_object = null;
- if (it.hasNext()) {
+ if (it.hasNext())
+ {
temp_object = (ObjectName) it.next();
}
// echo(temp_object.getCanonicalKeyPropertyListString());
MBeanInfo bean_info = mbsc.getMBeanInfo(temp_object);
MBeanAttributeInfo[] attr_info = bean_info.getAttributes();
- if (attr_info == null) {
+ if (attr_info == null)
+ {
echo(temp_object.toString());
String temp = "";
while (temp_object.toString().length() > temp.length())
temp = "=" + temp;
echo(temp);
- } else {
+ }
+ else
+ {
echo(temp_object.toString());
String temp = "";
while (temp_object.toString().length() > temp.length())
temp = "=" + temp;
echo(temp);
- for (MBeanAttributeInfo attr : attr_info) {
+ for (MBeanAttributeInfo attr : attr_info)
+ {
Object toWrite = null;
- try {
+ try
+ {
toWrite = mbsc.getAttribute(temp_object, attr.getName());
- } catch (Exception x) {
+ }
+ catch (Exception x)
+ {
temp2 = "-";
}
temp1 = attr.getName();
if (toWrite != null)
temp2 = toWrite.toString();
- if (output == null) {
+ if (output == null)
+ {
while (temp1.length() < 35)
temp1 = " " + temp1;
while (temp2.length() < 35)
temp2 = " " + temp2;
echo(temp1 + " " + temp2);
- } else if (output.compareToIgnoreCase("csv") == 0)
+ }
+ else if (output.compareToIgnoreCase("csv") == 0)
echo(temp1 + seperator + temp2);
- else {
+ else
+ {
echo("Wrong output format specified currently CLI supports only csv output format");
return;
}
@@ -458,25 +536,31 @@ public class ObjectNames {
}
} while (it.hasNext());
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
}
- public void setQueryString(String object, String name, String vhost) {
+ public void setQueryString(String object, String name, String vhost)
+ {
}
- public void setQueryStringforinfo(String object, String name, String virtualhost) {
+ public void setQueryStringforinfo(String object, String name, String virtualhost)
+ {
}
- public String getQueryString() {
+ public String getQueryString()
+ {
return querystring;
}
- public Set getSet() {
+ public Set getSet()
+ {
return set;
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java
index 7bbcbf5840..e61d1e626c 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/QueueObject.java
@@ -26,19 +26,15 @@ import javax.management.MBeanAttributeInfo;
import javax.management.MBeanInfo;
import javax.management.ObjectName;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Jun 20, 2008
- * Time: 8:49:56 AM
- * To change this template use File | Settings | File Templates.
- */
-public class QueueObject extends ObjectNames {
- public QueueObject(MBeanServerConnection mbsc) {
+public class QueueObject extends ObjectNames
+{
+ public QueueObject(MBeanServerConnection mbsc)
+ {
ObjectNames(mbsc);
}
- public void setQueryString(String object, String name, String vhost) {
+ public void setQueryString(String object, String name, String vhost)
+ {
if (name != null && vhost == null)
querystring = "org.apache.qpid:type=VirtualHost.Queue,name=" + name + ",*";
else if (name != null && vhost != null)
@@ -49,23 +45,28 @@ public class QueueObject extends ObjectNames {
querystring = "org.apache.qpid:type=VirtualHost.Queue,*";
}
- public int getmessagecount(ObjectName queue) {
+ public int getmessagecount(ObjectName queue)
+ {
int attr_count = 0;
String value;
Integer depth = null;
- try {
+ try
+ {
MBeanInfo bean_info;
bean_info = mbsc.getMBeanInfo(queue);
MBeanAttributeInfo[] attr_info = bean_info.getAttributes();
if (attr_info == null)
return 0;
- else {
- for (MBeanAttributeInfo attr : attr_info) {
+ else
+ {
+ for (MBeanAttributeInfo attr : attr_info)
+ {
Object toWrite = null;
attr_count++;
toWrite = mbsc.getAttribute(queue, attr.getName());
- if (attr_count == 7) {
+ if (attr_count == 7)
+ {
value = toWrite.toString();
depth = new Integer(value);
}
@@ -73,7 +74,9 @@ public class QueueObject extends ObjectNames {
}
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
ex.printStackTrace();
}
if (depth != null)
@@ -82,5 +85,4 @@ public class QueueObject extends ObjectNames {
return -1;
}
-
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/UserManagementObject.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/UserManagementObject.java
index a5f84ea39e..1635877cea 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/UserManagementObject.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/UserManagementObject.java
@@ -23,22 +23,15 @@ package org.apache.qpid.commands.objects;
import javax.management.MBeanServerConnection;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Jun 24, 2008
- * Time: 12:11:52 AM
- * To change this template use File | Settings | File Templates.
- */
-public class UserManagementObject extends ObjectNames {
- public UserManagementObject(MBeanServerConnection mbsc) {
+public class UserManagementObject extends ObjectNames
+{
+ public UserManagementObject(MBeanServerConnection mbsc)
+ {
ObjectNames(mbsc);
-// querystring = "org.apache.qpid:type=UserManagement,*";
-// set = returnObjects();
-
}
- public void setQueryString(String object, String name, String vhost) {
+ public void setQueryString(String object, String name, String vhost)
+ {
querystring = "org.apache.qpid:type=UserManagement,*";
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/VirtualHostObject.java b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/VirtualHostObject.java
index 16bb159990..c4df7a7093 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/VirtualHostObject.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/commands/objects/VirtualHostObject.java
@@ -23,31 +23,25 @@ package org.apache.qpid.commands.objects;
import javax.management.MBeanServerConnection;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Jun 20, 2008
- * Time: 9:02:04 AM
- * To change this template use File | Settings | File Templates.
- */
-public class VirtualHostObject extends ObjectNames {
+public class VirtualHostObject extends ObjectNames
+{
- public VirtualHostObject(MBeanServerConnection mbsc) {
+ public VirtualHostObject(MBeanServerConnection mbsc)
+ {
ObjectNames(mbsc);
-// querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,*";
-// set = returnObjects();
}
- public void setQueryString(String object, String name, String vhost) {
+ public void setQueryString(String object, String name, String vhost)
+ {
if (name != null && vhost == null)
querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,name=" + name + ",*";
else if (name != null && vhost != null)
- querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=" + vhost + ",name=" + name + ",*";
+ querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=" + vhost + ",name=" + name
+ + ",*";
else if (name == null && vhost != null)
querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=" + vhost + ",*";
else
querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,*";
-
}
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOption.java b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOption.java
index fb6afa6344..a443d6f789 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOption.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOption.java
@@ -18,52 +18,40 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
package org.apache.qpid.utils;
import java.util.ArrayList;
-public class CommandLineOption implements CommandLineOptionConstants {
+public class CommandLineOption implements CommandLineOptionConstants
+{
private String type;
private ArrayList optionValues;
- public CommandLineOption(String type, String[] values) {
+ public CommandLineOption(String type, String[] values)
+ {
setOptionType(type);
ArrayList arrayList = new ArrayList(values.length);
- for (int i = 0; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++)
+ {
arrayList.add(values[i]);
}
this.optionValues = arrayList;
}
- private void setOptionType(String type) {
- //cater for the long options first
- if (type.startsWith("--")) {
+ private void setOptionType(String type)
+ {
+ // cater for the long options first
+ if (type.startsWith("--"))
+ {
type = type.replaceFirst("--", "");
}
- if (type.startsWith("-")) {
+ if (type.startsWith("-"))
+ {
type = type.replaceFirst("-", "");
}
- //we do not change the case of the option!
+ // we do not change the case of the option!
this.type = type;
}
@@ -71,42 +59,46 @@ public class CommandLineOption implements CommandLineOptionConstants {
/**
* @param type
*/
- public CommandLineOption(String type, ArrayList values) {
+ public CommandLineOption(String type, ArrayList values)
+ {
setOptionType(type);
- if (null != values) {
+ if (null != values)
+ {
this.optionValues = values;
}
}
-
/**
* @return Returns the type.
* @see CommandLineOptionConstants
*/
- public String getOptionType() {
+ public String getOptionType()
+ {
return type;
}
-
/**
* @return Returns the optionValues.
*/
- public String getOptionValue() {
- if ((optionValues != null) && (optionValues.size() > 0)) {
+ public String getOptionValue()
+ {
+ if ((optionValues != null) && (optionValues.size() > 0))
+ {
return (String) optionValues.get(0);
- } else {
+ }
+ else
+ {
return null;
}
}
-
/**
* @return Returns the optionValues.
*/
- public ArrayList getOptionValues() {
+ public ArrayList getOptionValues()
+ {
return optionValues;
}
-
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionConstants.java b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionConstants.java
index da21c7663c..be82dbfcaa 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionConstants.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionConstants.java
@@ -18,30 +18,13 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
package org.apache.qpid.utils;
-
-public interface CommandLineOptionConstants {
- static interface JMXCommandLineOptionConstants {
+public interface CommandLineOptionConstants
+{
+ static interface JMXCommandLineOptionConstants
+ {
String HOST_OPTION = "h";
String PORT_OPTION = "p";
String INTERVAL_OPTION = "i";
@@ -51,5 +34,4 @@ public interface CommandLineOptionConstants {
}
-
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionParser.java b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionParser.java
index 33a117cad5..fbf87bac01 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionParser.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/CommandLineOptionParser.java
@@ -18,23 +18,6 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid.utils;
@@ -43,8 +26,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;
-
-public class CommandLineOptionParser {
+public class CommandLineOptionParser
+{
private static int STARTED = 0;
private static int NEW_OPTION = 1;
private static int SUB_PARAM_OF_OPTION = 2;
@@ -52,38 +35,43 @@ public class CommandLineOptionParser {
private Map commandlineoption;
private String commandname;
- public CommandLineOptionParser(Map commandlineoptions) {
+ public CommandLineOptionParser(Map commandlineoptions)
+ {
this.commandlineoption = commandlineoptions;
}
- public CommandLineOptionParser(String[] args) {
+ public CommandLineOptionParser(String[] args)
+ {
/* check whether user just type the enter key */
this.commandlineoption = this.parse(args);
}
- public CommandLineOptionParser(String[] args, String first) {
+ public CommandLineOptionParser(String[] args, String first)
+ {
this.commandname = first;
this.commandlineoption = this.parsefirst(args);
}
- public Map parse(String[] args) {
+ public Map parse(String[] args)
+ {
Map commandLineOptions = new HashMap();
- if (0 == args.length) {
+ if (0 == args.length)
+ {
return commandLineOptions;
- } else if (1 == args.length) {
+ }
+ else if (1 == args.length)
+ {
commandname = args[0];
return commandLineOptions;
}
/* when user is not giving the command line option with a "=" */
-// if (!args[2].startsWith("-"))
-// return commandLineOptions;
-
- //State 0 means started
- //State 1 means earlier one was a new -option
- //State 2 means earlier one was a sub param of a -option
-
+ // if (!args[2].startsWith("-"))
+ // return commandLineOptions;
+ // State 0 means started
+ // State 1 means earlier one was a new -option
+ // State 2 means earlier one was a sub param of a -option
int state = STARTED;
ArrayList optionBundle = null;
String optionType = null;
@@ -91,48 +79,60 @@ public class CommandLineOptionParser {
String newcommand = "";
String[] newargs;
int j;
- if (args[1].compareTo("list") == 0 || args[1].compareTo("info") == 0 || args[1].compareTo("delete") == 0 ||
- args[1].compareTo("move") == 0 || args[1].compareTo("view") == 0 || args[1].compareTo("viewcontent") == 0) {
+ if (args[1].compareTo("list") == 0 || args[1].compareTo("info") == 0 || args[1].compareTo("delete") == 0
+ || args[1].compareTo("move") == 0 || args[1].compareTo("view") == 0
+ || args[1].compareTo("viewcontent") == 0)
+ {
String object = args[0];
- for (j = 0; j < (args.length - 1); j++) {
+ for (j = 0; j < (args.length - 1); j++)
+ {
newcommand = newcommand + args[j + 1] + " ";
}
newcommand = newcommand + "-o " + object;
newargs = newcommand.split(" ");
args = newargs;
- } else
- if (!args[1].startsWith("-")) //if user give command like list queue or something without minus argument
- return commandLineOptions; //for the second wordxi
+ }
+ else if (!args[1].startsWith("-")) // if user give command like list
+ // queue or something without minus
+ // argument
+ return commandLineOptions; // for the second wordxi
commandname = args[0];
- for (int i = 0; i < args.length; i++) {
- if (args[i].startsWith("-")) {
- if (STARTED == state) {
+ for (int i = 0; i < args.length; i++)
+ {
+ if (args[i].startsWith("-"))
+ {
+ if (STARTED == state)
+ {
// fresh one
state = NEW_OPTION;
optionType = args[i];
- } else if (SUB_PARAM_OF_OPTION == state || NEW_OPTION == state) {
+ }
+ else if (SUB_PARAM_OF_OPTION == state || NEW_OPTION == state)
+ {
// new one but old one should be saved
- commandLineOption =
- new CommandLineOption(optionType, optionBundle);
- commandLineOptions.put(commandLineOption.getOptionType(),
- commandLineOption);
+ commandLineOption = new CommandLineOption(optionType, optionBundle);
+ commandLineOptions.put(commandLineOption.getOptionType(), commandLineOption);
state = NEW_OPTION;
optionType = args[i];
optionBundle = null;
}
- } else {
- if (NEW_OPTION == state) {
+ }
+ else
+ {
+ if (NEW_OPTION == state)
+ {
optionBundle = new ArrayList();
optionBundle.add(args[i]);
state = SUB_PARAM_OF_OPTION;
- } else if (SUB_PARAM_OF_OPTION == state) {
+ }
+ else if (SUB_PARAM_OF_OPTION == state)
+ {
optionBundle.add(args[i]);
}
-
}
}
commandLineOption = new CommandLineOption(optionType, optionBundle);
@@ -141,21 +141,23 @@ public class CommandLineOptionParser {
}
- public Map parsefirst(String[] args) {
+ public Map parsefirst(String[] args)
+ {
Map commandLineOptions = new HashMap();
- if (0 == args.length) {
+ if (0 == args.length)
+ {
return commandLineOptions;
- } else if (1 == args.length) {
+ }
+ else if (1 == args.length)
+ {
return commandLineOptions;
}
/* when user is not giving the command line option with a "=" */
-// if (!args[2].startsWith("-"))
-// return commandLineOptions;
-
- //State 0 means started
- //State 1 means earlier one was a new -option
- //State 2 means earlier one was a sub param of a -option
-
+ // if (!args[2].startsWith("-"))
+ // return commandLineOptions;
+ // State 0 means started
+ // State 1 means earlier one was a new -option
+ // State 2 means earlier one was a sub param of a -option
int state = STARTED;
ArrayList optionBundle = null;
String optionType = null;
@@ -164,34 +166,41 @@ public class CommandLineOptionParser {
String[] newargs;
int j;
- for (int i = 0; i < args.length; i++) {
- if (args[i].startsWith("-")) {
- if (STARTED == state) {
+ for (int i = 0; i < args.length; i++)
+ {
+ if (args[i].startsWith("-"))
+ {
+ if (STARTED == state)
+ {
// fresh one
state = NEW_OPTION;
optionType = args[i];
- } else if (SUB_PARAM_OF_OPTION == state || NEW_OPTION == state) {
+ }
+ else if (SUB_PARAM_OF_OPTION == state || NEW_OPTION == state)
+ {
// new one but old one should be saved
- commandLineOption =
- new CommandLineOption(optionType, optionBundle);
- commandLineOptions.put(commandLineOption.getOptionType(),
- commandLineOption);
+ commandLineOption = new CommandLineOption(optionType, optionBundle);
+ commandLineOptions.put(commandLineOption.getOptionType(), commandLineOption);
state = NEW_OPTION;
optionType = args[i];
optionBundle = null;
}
- } else {
- if (NEW_OPTION == state) {
+ }
+ else
+ {
+ if (NEW_OPTION == state)
+ {
optionBundle = new ArrayList();
optionBundle.add(args[i]);
state = SUB_PARAM_OF_OPTION;
- } else if (SUB_PARAM_OF_OPTION == state) {
+ }
+ else if (SUB_PARAM_OF_OPTION == state)
+ {
optionBundle.add(args[i]);
}
-
}
}
commandLineOption = new CommandLineOption(optionType, optionBundle);
@@ -200,18 +209,22 @@ public class CommandLineOptionParser {
}
- public Map getAlloptions() {
+ public Map getAlloptions()
+ {
return this.commandlineoption;
}
- public String getcommandname() {
+ public String getcommandname()
+ {
return this.commandname;
}
- private static String removeSpaces(String s) {
+ private static String removeSpaces(String s)
+ {
StringTokenizer st = new StringTokenizer(s, " ", false);
String t = "";
- while (st.hasMoreElements()) t += st.nextElement();
+ while (st.hasMoreElements())
+ t += st.nextElement();
return t;
}
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfigProperty.java b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfigProperty.java
index 27e4527619..55240054a9 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfigProperty.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfigProperty.java
@@ -1,45 +1,27 @@
/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*
*/
-
package org.apache.qpid.utils;
-
-public class JMXConfigProperty {
+public class JMXConfigProperty
+{
private static final String DEFAULT_HOST_NAME = "localhost";
private static final String DEFAULT_PORT = "8999";
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfiguration.java b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfiguration.java
index 20c6c28291..76aab11e25 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfiguration.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXConfiguration.java
@@ -18,31 +18,12 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
package org.apache.qpid.utils;
-import org.apache.qpid.Command;
-
import java.util.Map;
-public class JMXConfiguration {
+public class JMXConfiguration
+{
private String hostname = "localhost";
private String port = "8999";
private String interval = "40000";
@@ -52,63 +33,81 @@ public class JMXConfiguration {
private String username = null;
private String password = null;
- public JMXConfiguration(Map map) {
- if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.HOST_OPTION, map)) {
+ public JMXConfiguration(Map map)
+ {
+ if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.HOST_OPTION, map))
+ {
this.hostname = optionchecker(CommandLineOptionConstants.JMXCommandLineOptionConstants.HOST_OPTION, map);
}
- if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.PORT_OPTION, map)) {
+ if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.PORT_OPTION, map))
+ {
this.port = optionchecker(CommandLineOptionConstants.JMXCommandLineOptionConstants.PORT_OPTION, map);
}
- if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.REPORT_OPTION, map)) {
+ if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.REPORT_OPTION, map))
+ {
- this.report_file = optionchecker(CommandLineOptionConstants.JMXCommandLineOptionConstants.REPORT_OPTION, map);
+ this.report_file = optionchecker(CommandLineOptionConstants.JMXCommandLineOptionConstants.REPORT_OPTION,
+ map);
}
- if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.USER_OPTION, map)) {
+ if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.USER_OPTION, map))
+ {
this.setUsername(optionchecker(CommandLineOptionConstants.JMXCommandLineOptionConstants.USER_OPTION, map));
}
- if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.PASSWORD_OPTION, map)) {
- this.setPassword(optionchecker(CommandLineOptionConstants.JMXCommandLineOptionConstants.PASSWORD_OPTION, map));
+ if (checkoptionsetting(CommandLineOptionConstants.JMXCommandLineOptionConstants.PASSWORD_OPTION, map))
+ {
+ this.setPassword(optionchecker(CommandLineOptionConstants.JMXCommandLineOptionConstants.PASSWORD_OPTION,
+ map));
}
}
- public void sethostname(String hostname) {
+ public void sethostname(String hostname)
+ {
this.hostname = hostname;
}
- public void setport(String port) {
+ public void setport(String port)
+ {
this.port = port;
}
- public void setinterval(String interval) {
+ public void setinterval(String interval)
+ {
this.interval = interval;
}
- public void setoutputpath(String output) {
+ public void setoutputpath(String output)
+ {
this.outputpath = output;
}
- public String gethostname() {
+ public String gethostname()
+ {
return this.hostname;
}
- public String getport() {
+ public String getport()
+ {
return this.port;
}
- public String getinterval() {
+ public String getinterval()
+ {
return this.interval;
}
- public String getoutputpath() {
+ public String getoutputpath()
+ {
return this.outputpath;
}
- public CommandLineOption loadoption(String option, Map options) {
+ public CommandLineOption loadoption(String option, Map options)
+ {
CommandLineOption op = null;
- if (option != null) {
+ if (option != null)
+ {
op = (CommandLineOption) options.get(option);
}
@@ -116,21 +115,25 @@ public class JMXConfiguration {
}
- public void setreportfile(String reportfile) {
+ public void setreportfile(String reportfile)
+ {
this.report_file = reportfile;
this.isreport_mode = true;
}
- public boolean isreportmode() {
+ public boolean isreportmode()
+ {
return this.isreport_mode;
}
- public String getreportfile() {
+ public String getreportfile()
+ {
return this.report_file;
}
- public String optionchecker(String option_letter, Map map) {
+ public String optionchecker(String option_letter, Map map)
+ {
if (map == null)
return null;
@@ -141,7 +144,8 @@ public class JMXConfiguration {
return value;
}
- public boolean checkoptionsetting(String option_letter, Map map) {
+ public boolean checkoptionsetting(String option_letter, Map map)
+ {
if (map == null)
return false;
CommandLineOption option = (CommandLineOption) map.get(option_letter);
diff --git a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXinfo.java b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXinfo.java
index af3e5c7be0..09de4a248f 100644
--- a/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXinfo.java
+++ b/java/management/tools/qpid-cli/src/org/apache/qpid/utils/JMXinfo.java
@@ -1,4 +1,4 @@
- /*
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,55 +18,36 @@
* under the License.
*
*/
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package org.apache.qpid.utils;
import javax.management.remote.JMXConnector;
import javax.management.MBeanServerConnection;
-/**
- * Created by IntelliJ IDEA.
- * User: lahiru
- * Date: Jun 3, 2008
- * Time: 9:21:08 PM
- * To change this template use File | Settings | File Templates.
- */
-public class JMXinfo {
+public class JMXinfo
+{
private JMXConnector jmxconnector;
private CommandLineOptionParser input;
private MBeanServerConnection mbserverconnector;
- public JMXinfo(JMXConnector jmxc, CommandLineOptionParser input, MBeanServerConnection mbsc) {
+ public JMXinfo(JMXConnector jmxc, CommandLineOptionParser input, MBeanServerConnection mbsc)
+ {
this.jmxconnector = jmxc;
this.input = input;
this.mbserverconnector = mbsc;
}
- public JMXConnector getjmxconnectot() {
+ public JMXConnector getjmxconnectot()
+ {
return jmxconnector;
}
- public CommandLineOptionParser getCommandLineOptionParser() {
+ public CommandLineOptionParser getCommandLineOptionParser()
+ {
return input;
}
- public MBeanServerConnection getmbserverconnector() {
+ public MBeanServerConnection getmbserverconnector()
+ {
return mbserverconnector;
}
}