activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r379619 [18/30] - in /incubator/activemq/trunk: ./ activecluster/ activecluster/src/java/org/apache/activecluster/ activecluster/src/java/org/apache/activecluster/election/ activecluster/src/java/org/apache/activecluster/election/impl/ acti...
Date Tue, 21 Feb 2006 23:14:17 GMT
Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java Tue Feb 21 15:12:56 2006
@@ -1,229 +1,229 @@
-/**
- *
- * Copyright 2005-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.activemq.console.command;
-
-import org.apache.activemq.console.util.JmxMBeansUtil;
-import org.apache.activemq.console.formatter.GlobalWriter;
-
-import java.util.List;
-import java.util.Properties;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.StringTokenizer;
-import java.util.Set;
-import java.util.HashSet;
-
-public class QueryCommand extends AbstractJmxCommand {
-    // Predefined type=identifier query
-    private static final Properties PREDEFINED_OBJNAME_QUERY = new Properties();
-
-    static {
-        PREDEFINED_OBJNAME_QUERY.setProperty("Broker",           "Type=Broker,BrokerName=%1,*");
-        PREDEFINED_OBJNAME_QUERY.setProperty("Connection",       "Type=Connection,Connection=%1,*");
-        PREDEFINED_OBJNAME_QUERY.setProperty("Connector",        "Type=Connector,ConnectorName=%1,*");
-        PREDEFINED_OBJNAME_QUERY.setProperty("NetworkConnector", "Type=NetworkConnector,BrokerName=%1,*");
-        PREDEFINED_OBJNAME_QUERY.setProperty("Queue",            "Type=Queue,Destination=%1,*");
-        PREDEFINED_OBJNAME_QUERY.setProperty("Topic",            "Type=Topic,Destination=%1,*");
-    };
-
-    private final List queryAddObjects = new ArrayList(10);
-    private final List querySubObjects = new ArrayList(10);
-    private final Set  queryViews      = new HashSet(10);
-
-    /**
-     * Queries the mbeans registered in the specified JMX context
-     * @param tokens - command arguments
-     * @throws Exception
-     */
-    protected void runTask(List tokens) throws Exception {
-        try {
-            // Query for the mbeans to add
-            List addMBeans = JmxMBeansUtil.queryMBeans(useJmxServiceUrl(), queryAddObjects, queryViews);
-
-            // Query for the mbeans to sub
-            if (querySubObjects.size() > 0) {
-                List subMBeans = JmxMBeansUtil.queryMBeans(useJmxServiceUrl(), querySubObjects, queryViews);
-                addMBeans.removeAll(subMBeans);
-            }
-
-
-            GlobalWriter.printMBean(JmxMBeansUtil.filterMBeansView(addMBeans, queryViews));
-
-        } catch (Exception e) {
-            GlobalWriter.printException(new RuntimeException("Failed to execute query task. Reason: " + e));
-            throw new Exception(e);
-        }
-    }
-
-    /**
-     * Handle the -Q, -xQ, --objname, --xobjname, --view options.
-     * @param token - option token to handle
-     * @param tokens - succeeding command arguments
-     * @throws Exception
-     */
-    protected void handleOption(String token, List tokens) throws Exception {
-        // If token is a additive predefined query define option
-        if (token.startsWith("-Q")) {
-            String key = token.substring(2);
-            String value = "";
-            int pos = key.indexOf("=");
-            if (pos >= 0) {
-                value = key.substring(pos + 1);
-                key = key.substring(0, pos);
-            }
-
-            // If additive query
-            String predefQuery = PREDEFINED_OBJNAME_QUERY.getProperty(key);
-            if (predefQuery == null) {
-                GlobalWriter.printException(new IllegalArgumentException("Unknown query object type: " + key));
-                return;
-            }
-            String queryStr = JmxMBeansUtil.createQueryString(predefQuery, value);
-            queryAddObjects.add(queryStr);
-        }
-
-        // If token is a substractive predefined query define option
-        else if (token.startsWith("-xQ")) {
-            String key = token.substring(3);
-            String value = "";
-            int pos = key.indexOf("=");
-            if (pos >= 0) {
-                value = key.substring(pos + 1);
-                key = key.substring(0, pos);
-            }
-
-            // If subtractive query
-            String predefQuery = PREDEFINED_OBJNAME_QUERY.getProperty(key);
-            if (predefQuery == null) {
-                GlobalWriter.printException(new IllegalArgumentException("Unknown query object type: " + key));
-                return;
-            }
-            String queryStr = JmxMBeansUtil.createQueryString(predefQuery, value);
-            querySubObjects.add(queryStr);
-        }
-
-        // If token is an additive object name query option
-        else if (token.startsWith("--objname")) {
-
-            // If no object name query is specified, or next token is a new option
-            if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) {
-                GlobalWriter.printException(new IllegalArgumentException("Object name query not specified"));
-                return;
-            }
-
-            StringTokenizer queryTokens = new StringTokenizer((String)tokens.remove(0), COMMAND_OPTION_DELIMETER);
-            while (queryTokens.hasMoreTokens()) {
-                queryAddObjects.add(queryTokens.nextToken());
-            }
-        }
-
-        // If token is a substractive object name query option
-        else if (token.startsWith("--xobjname")) {
-
-            // If no object name query is specified, or next token is a new option
-            if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) {
-                GlobalWriter.printException(new IllegalArgumentException("Object name query not specified"));
-                return;
-            }
-
-            StringTokenizer queryTokens = new StringTokenizer((String)tokens.remove(0), COMMAND_OPTION_DELIMETER);
-            while (queryTokens.hasMoreTokens()) {
-                querySubObjects.add(queryTokens.nextToken());
-            }
-        }
-
-        // If token is a view option
-        else if (token.startsWith("--view")) {
-
-            // If no view specified, or next token is a new option
-            if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) {
-                GlobalWriter.printException(new IllegalArgumentException("Attributes to view not specified"));
-                return;
-            }
-
-            // Add the attributes to view
-            Enumeration viewTokens = new StringTokenizer((String)tokens.remove(0), COMMAND_OPTION_DELIMETER);
-            while (viewTokens.hasMoreElements()) {
-                queryViews.add(viewTokens.nextElement());
-            }
-        }
-
-        // Let super class handle unknown option
-        else {
-            super.handleOption(token, tokens);
-        }
-    }
-
-    /**
-     * Print the help messages for the browse command
-     */
-    protected void printHelp() {
-        GlobalWriter.printHelp(helpFile);
-    }
-    
-    protected String[] helpFile = new String[] {
-        "Task Usage: Main query [query-options]",
-        "Description: Display selected broker component's attributes and statistics.",
-        "",
-        "Query Options:",
-        "    -Q<type>=<name>               Add to the search list the specific object type matched",
-        "                                  by the defined object identifier.",
-        "    -xQ<type>=<name>              Remove from the search list the specific object type",
-        "                                  matched by the object identifier.",
-        "    --objname <query>             Add to the search list objects matched by the query similar",
-        "                                  to the JMX object name format.",
-        "    --xobjname <query>            Remove from the search list objects matched by the query",
-        "                                  similar to the JMX object name format.",
-        "    --view <attr1>,<attr2>,...    Select the specific attribute of the object to view.",
-        "                                  By default all attributes will be displayed.",
-        "    --jmxurl <url>                Set the JMX URL to connect to.",
-        "    --version                     Display the version information.",
-        "    -h,-?,--help                  Display the query broker help information.",
-        "",
-        "Examples:",
-        "    Main query",
-        "        - Print all the attributes of all registered objects queues, topics, connections, etc).",
-        "",
-        "    Main query -QQueue=TEST.FOO",
-        "        - Print all the attributes of the queue with destination name TEST.FOO.",
-        "",
-        "    Main query -QTopic=*",
-        "        - Print all the attributes of all registered topics.",
-        "",
-        "    Main query --view EnqueueCount,DequeueCount",
-        "        - Print the attributes EnqueueCount and DequeueCount of all registered objects.",
-        "",
-        "    Main -QTopic=* --view EnqueueCount,DequeueCount",
-        "        - Print the attributes EnqueueCount and DequeueCount of all registered topics.",
-        "",
-        "    Main -QTopic=* -QQueue=* --view EnqueueCount,DequeueCount",
-        "        - Print the attributes EnqueueCount and DequeueCount of all registered topics and",
-        "          queues.",
-        "",
-        "    Main -QTopic=* -xQTopic=ActiveMQ.Advisory.*",
-        "        - Print all attributes of all topics except those that has a name that begins",
-        "          with \"ActiveMQ.Advisory\".",
-        "",
-        "    Main --objname Type=*Connect*,BrokerName=local* -xQNetworkConnector=*",
-        "        - Print all attributes of all connectors, connections excluding network connectors",
-        "          that belongs to the broker that begins with local.",
-        "",
-        "    Main -QQueue=* -xQQueue=????",
-        "        - Print all attributes of all queues except those that are 4 letters long.",
-        "",
-    };
-}
+/**
+ *
+ * Copyright 2005-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.activemq.console.command;
+
+import org.apache.activemq.console.util.JmxMBeansUtil;
+import org.apache.activemq.console.formatter.GlobalWriter;
+
+import java.util.List;
+import java.util.Properties;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.Set;
+import java.util.HashSet;
+
+public class QueryCommand extends AbstractJmxCommand {
+    // Predefined type=identifier query
+    private static final Properties PREDEFINED_OBJNAME_QUERY = new Properties();
+
+    static {
+        PREDEFINED_OBJNAME_QUERY.setProperty("Broker",           "Type=Broker,BrokerName=%1,*");
+        PREDEFINED_OBJNAME_QUERY.setProperty("Connection",       "Type=Connection,Connection=%1,*");
+        PREDEFINED_OBJNAME_QUERY.setProperty("Connector",        "Type=Connector,ConnectorName=%1,*");
+        PREDEFINED_OBJNAME_QUERY.setProperty("NetworkConnector", "Type=NetworkConnector,BrokerName=%1,*");
+        PREDEFINED_OBJNAME_QUERY.setProperty("Queue",            "Type=Queue,Destination=%1,*");
+        PREDEFINED_OBJNAME_QUERY.setProperty("Topic",            "Type=Topic,Destination=%1,*");
+    };
+
+    private final List queryAddObjects = new ArrayList(10);
+    private final List querySubObjects = new ArrayList(10);
+    private final Set  queryViews      = new HashSet(10);
+
+    /**
+     * Queries the mbeans registered in the specified JMX context
+     * @param tokens - command arguments
+     * @throws Exception
+     */
+    protected void runTask(List tokens) throws Exception {
+        try {
+            // Query for the mbeans to add
+            List addMBeans = JmxMBeansUtil.queryMBeans(useJmxServiceUrl(), queryAddObjects, queryViews);
+
+            // Query for the mbeans to sub
+            if (querySubObjects.size() > 0) {
+                List subMBeans = JmxMBeansUtil.queryMBeans(useJmxServiceUrl(), querySubObjects, queryViews);
+                addMBeans.removeAll(subMBeans);
+            }
+
+
+            GlobalWriter.printMBean(JmxMBeansUtil.filterMBeansView(addMBeans, queryViews));
+
+        } catch (Exception e) {
+            GlobalWriter.printException(new RuntimeException("Failed to execute query task. Reason: " + e));
+            throw new Exception(e);
+        }
+    }
+
+    /**
+     * Handle the -Q, -xQ, --objname, --xobjname, --view options.
+     * @param token - option token to handle
+     * @param tokens - succeeding command arguments
+     * @throws Exception
+     */
+    protected void handleOption(String token, List tokens) throws Exception {
+        // If token is a additive predefined query define option
+        if (token.startsWith("-Q")) {
+            String key = token.substring(2);
+            String value = "";
+            int pos = key.indexOf("=");
+            if (pos >= 0) {
+                value = key.substring(pos + 1);
+                key = key.substring(0, pos);
+            }
+
+            // If additive query
+            String predefQuery = PREDEFINED_OBJNAME_QUERY.getProperty(key);
+            if (predefQuery == null) {
+                GlobalWriter.printException(new IllegalArgumentException("Unknown query object type: " + key));
+                return;
+            }
+            String queryStr = JmxMBeansUtil.createQueryString(predefQuery, value);
+            queryAddObjects.add(queryStr);
+        }
+
+        // If token is a substractive predefined query define option
+        else if (token.startsWith("-xQ")) {
+            String key = token.substring(3);
+            String value = "";
+            int pos = key.indexOf("=");
+            if (pos >= 0) {
+                value = key.substring(pos + 1);
+                key = key.substring(0, pos);
+            }
+
+            // If subtractive query
+            String predefQuery = PREDEFINED_OBJNAME_QUERY.getProperty(key);
+            if (predefQuery == null) {
+                GlobalWriter.printException(new IllegalArgumentException("Unknown query object type: " + key));
+                return;
+            }
+            String queryStr = JmxMBeansUtil.createQueryString(predefQuery, value);
+            querySubObjects.add(queryStr);
+        }
+
+        // If token is an additive object name query option
+        else if (token.startsWith("--objname")) {
+
+            // If no object name query is specified, or next token is a new option
+            if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) {
+                GlobalWriter.printException(new IllegalArgumentException("Object name query not specified"));
+                return;
+            }
+
+            StringTokenizer queryTokens = new StringTokenizer((String)tokens.remove(0), COMMAND_OPTION_DELIMETER);
+            while (queryTokens.hasMoreTokens()) {
+                queryAddObjects.add(queryTokens.nextToken());
+            }
+        }
+
+        // If token is a substractive object name query option
+        else if (token.startsWith("--xobjname")) {
+
+            // If no object name query is specified, or next token is a new option
+            if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) {
+                GlobalWriter.printException(new IllegalArgumentException("Object name query not specified"));
+                return;
+            }
+
+            StringTokenizer queryTokens = new StringTokenizer((String)tokens.remove(0), COMMAND_OPTION_DELIMETER);
+            while (queryTokens.hasMoreTokens()) {
+                querySubObjects.add(queryTokens.nextToken());
+            }
+        }
+
+        // If token is a view option
+        else if (token.startsWith("--view")) {
+
+            // If no view specified, or next token is a new option
+            if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) {
+                GlobalWriter.printException(new IllegalArgumentException("Attributes to view not specified"));
+                return;
+            }
+
+            // Add the attributes to view
+            Enumeration viewTokens = new StringTokenizer((String)tokens.remove(0), COMMAND_OPTION_DELIMETER);
+            while (viewTokens.hasMoreElements()) {
+                queryViews.add(viewTokens.nextElement());
+            }
+        }
+
+        // Let super class handle unknown option
+        else {
+            super.handleOption(token, tokens);
+        }
+    }
+
+    /**
+     * Print the help messages for the browse command
+     */
+    protected void printHelp() {
+        GlobalWriter.printHelp(helpFile);
+    }
+    
+    protected String[] helpFile = new String[] {
+        "Task Usage: Main query [query-options]",
+        "Description: Display selected broker component's attributes and statistics.",
+        "",
+        "Query Options:",
+        "    -Q<type>=<name>               Add to the search list the specific object type matched",
+        "                                  by the defined object identifier.",
+        "    -xQ<type>=<name>              Remove from the search list the specific object type",
+        "                                  matched by the object identifier.",
+        "    --objname <query>             Add to the search list objects matched by the query similar",
+        "                                  to the JMX object name format.",
+        "    --xobjname <query>            Remove from the search list objects matched by the query",
+        "                                  similar to the JMX object name format.",
+        "    --view <attr1>,<attr2>,...    Select the specific attribute of the object to view.",
+        "                                  By default all attributes will be displayed.",
+        "    --jmxurl <url>                Set the JMX URL to connect to.",
+        "    --version                     Display the version information.",
+        "    -h,-?,--help                  Display the query broker help information.",
+        "",
+        "Examples:",
+        "    Main query",
+        "        - Print all the attributes of all registered objects queues, topics, connections, etc).",
+        "",
+        "    Main query -QQueue=TEST.FOO",
+        "        - Print all the attributes of the queue with destination name TEST.FOO.",
+        "",
+        "    Main query -QTopic=*",
+        "        - Print all the attributes of all registered topics.",
+        "",
+        "    Main query --view EnqueueCount,DequeueCount",
+        "        - Print the attributes EnqueueCount and DequeueCount of all registered objects.",
+        "",
+        "    Main -QTopic=* --view EnqueueCount,DequeueCount",
+        "        - Print the attributes EnqueueCount and DequeueCount of all registered topics.",
+        "",
+        "    Main -QTopic=* -QQueue=* --view EnqueueCount,DequeueCount",
+        "        - Print the attributes EnqueueCount and DequeueCount of all registered topics and",
+        "          queues.",
+        "",
+        "    Main -QTopic=* -xQTopic=ActiveMQ.Advisory.*",
+        "        - Print all attributes of all topics except those that has a name that begins",
+        "          with \"ActiveMQ.Advisory\".",
+        "",
+        "    Main --objname Type=*Connect*,BrokerName=local* -xQNetworkConnector=*",
+        "        - Print all attributes of all connectors, connections excluding network connectors",
+        "          that belongs to the broker that begins with local.",
+        "",
+        "    Main -QQueue=* -xQQueue=????",
+        "        - Print all attributes of all queues except those that are 4 letters long.",
+        "",
+    };
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java Tue Feb 21 15:12:56 2006
@@ -1,112 +1,112 @@
-/**
- *
- * Copyright 2005-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.activemq.console.command;
-
-import org.apache.activemq.console.formatter.GlobalWriter;
-import org.apache.activemq.console.formatter.CommandShellOutputFormatter;
-
-import java.util.List;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-public class ShellCommand extends AbstractCommand {
-
-    /**
-     * Main method to run a command shell client.
-     * @param args - command line arguments
-     * @param in - input stream to use
-     * @param out - output stream to use
-     * @return 0 for a successful run, -1 if there are any exception
-     */
-    public static int main(String[] args, InputStream in, PrintStream out) {
-        GlobalWriter.instantiate(new CommandShellOutputFormatter(out));
-
-        // Convert arguments to list for easier management
-        List tokens = new ArrayList(Arrays.asList(args));
-
-        ShellCommand main = new ShellCommand();
-        try {
-            main.execute(tokens);
-            return 0;
-        } catch (Exception e) {
-            GlobalWriter.printException(e);
-            return -1;
-        }
-    }
-
-    /**
-     * Parses for specific command task, default task is a start task.
-     * @param tokens - command arguments
-     * @throws Exception
-     */
-    protected void runTask(List tokens) throws Exception {
-        
-        // Process task token
-        if( tokens.size() > 0 ) {
-            String taskToken = (String)tokens.remove(0);
-            if (taskToken.equals("start")) {
-                new StartCommand().execute(tokens);
-            } else if (taskToken.equals("stop")) {
-                new ShutdownCommand().execute(tokens);
-            } else if (taskToken.equals("list")) {
-                new ListCommand().execute(tokens);
-            } else if (taskToken.equals("query")) {
-                new QueryCommand().execute(tokens);
-            } else if (taskToken.equals("browse")) {
-                new AmqBrowseCommand().execute(tokens);
-            } else if (taskToken.equals("purge")) {
-                new PurgeCommand().execute(tokens);
-            } else {
-                // If not valid task, push back to list
-                tokens.add(0, taskToken);
-                new StartCommand().execute(tokens);
-            }
-        } else {
-            new StartCommand().execute(tokens);
-        }
-        
-    }
-
-    /**
-     * Print the help messages for the browse command
-     */
-    protected void printHelp() {
-        GlobalWriter.printHelp(helpFile);
-    }
-
-    protected String[] helpFile = new String[] {
-        "Usage: Main [--extdir <dir>] [task] [task-options] [task data]",
-        "",
-        "Tasks (default task is start):",
-        "    start           - Creates and starts a broker using a configuration file, or a broker URI.",
-        "    stop            - Stops a running broker specified by the broker name.",
-        "    list            - Lists all available brokers in the specified JMX context.",
-        "    query           - Display selected broker component's attributes and statistics.",
-        "    browse          - Display selected messages in a specified destination.",
-        "",
-        "Task Options (Options specific to each task):",
-        "    --extdir <dir>  - Add the jar files in the directory to the classpath.",
-        "    --version       - Display the version information.",
-        "    -h,-?,--help    - Display this help information. To display task specific help, use Main [task] -h,-?,--help",
-        "",
-        "Task Data:",
-        "    - Information needed by each specific task.",
-        ""
-    };
-}
+/**
+ *
+ * Copyright 2005-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.activemq.console.command;
+
+import org.apache.activemq.console.formatter.GlobalWriter;
+import org.apache.activemq.console.formatter.CommandShellOutputFormatter;
+
+import java.util.List;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.io.InputStream;
+import java.io.PrintStream;
+
+public class ShellCommand extends AbstractCommand {
+
+    /**
+     * Main method to run a command shell client.
+     * @param args - command line arguments
+     * @param in - input stream to use
+     * @param out - output stream to use
+     * @return 0 for a successful run, -1 if there are any exception
+     */
+    public static int main(String[] args, InputStream in, PrintStream out) {
+        GlobalWriter.instantiate(new CommandShellOutputFormatter(out));
+
+        // Convert arguments to list for easier management
+        List tokens = new ArrayList(Arrays.asList(args));
+
+        ShellCommand main = new ShellCommand();
+        try {
+            main.execute(tokens);
+            return 0;
+        } catch (Exception e) {
+            GlobalWriter.printException(e);
+            return -1;
+        }
+    }
+
+    /**
+     * Parses for specific command task, default task is a start task.
+     * @param tokens - command arguments
+     * @throws Exception
+     */
+    protected void runTask(List tokens) throws Exception {
+        
+        // Process task token
+        if( tokens.size() > 0 ) {
+            String taskToken = (String)tokens.remove(0);
+            if (taskToken.equals("start")) {
+                new StartCommand().execute(tokens);
+            } else if (taskToken.equals("stop")) {
+                new ShutdownCommand().execute(tokens);
+            } else if (taskToken.equals("list")) {
+                new ListCommand().execute(tokens);
+            } else if (taskToken.equals("query")) {
+                new QueryCommand().execute(tokens);
+            } else if (taskToken.equals("browse")) {
+                new AmqBrowseCommand().execute(tokens);
+            } else if (taskToken.equals("purge")) {
+                new PurgeCommand().execute(tokens);
+            } else {
+                // If not valid task, push back to list
+                tokens.add(0, taskToken);
+                new StartCommand().execute(tokens);
+            }
+        } else {
+            new StartCommand().execute(tokens);
+        }
+        
+    }
+
+    /**
+     * Print the help messages for the browse command
+     */
+    protected void printHelp() {
+        GlobalWriter.printHelp(helpFile);
+    }
+
+    protected String[] helpFile = new String[] {
+        "Usage: Main [--extdir <dir>] [task] [task-options] [task data]",
+        "",
+        "Tasks (default task is start):",
+        "    start           - Creates and starts a broker using a configuration file, or a broker URI.",
+        "    stop            - Stops a running broker specified by the broker name.",
+        "    list            - Lists all available brokers in the specified JMX context.",
+        "    query           - Display selected broker component's attributes and statistics.",
+        "    browse          - Display selected messages in a specified destination.",
+        "",
+        "Task Options (Options specific to each task):",
+        "    --extdir <dir>  - Add the jar files in the directory to the classpath.",
+        "    --version       - Display the version information.",
+        "    -h,-?,--help    - Display this help information. To display task specific help, use Main [task] -h,-?,--help",
+        "",
+        "Task Data:",
+        "    - Information needed by each specific task.",
+        ""
+    };
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java Tue Feb 21 15:12:56 2006
@@ -1,161 +1,161 @@
-/**
- *
- * Copyright 2005-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.activemq.console.command;
-
-import org.apache.activemq.console.util.JmxMBeansUtil;
-import org.apache.activemq.console.formatter.GlobalWriter;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.ObjectInstance;
-import javax.management.remote.JMXServiceURL;
-import java.util.List;
-import java.util.Iterator;
-import java.util.Collection;
-import java.util.HashSet;
-
-public class ShutdownCommand extends AbstractJmxCommand {
-    private boolean isStopAllBrokers = false;
-
-    /**
-     * Shuts down the specified broker or brokers
-     * @param brokerNames - names of brokers to shutdown
-     * @throws Exception
-     */
-    protected void runTask(List brokerNames) throws Exception {
-        try {
-            Collection mbeans;
-
-            // Stop all brokers
-            if (isStopAllBrokers) {
-                mbeans = JmxMBeansUtil.getAllBrokers(useJmxServiceUrl());
-                brokerNames.clear();
-            }
-
-            // Stop the default broker
-            else if (brokerNames.isEmpty()) {
-                mbeans = JmxMBeansUtil.getAllBrokers(useJmxServiceUrl());
-
-                // If there is no broker to stop
-                if (mbeans.isEmpty()) {
-                    GlobalWriter.printInfo("There are no brokers to stop.");
-                    return;
-
-                // There should only be one broker to stop
-                } else if (mbeans.size() > 1) {
-                    GlobalWriter.printInfo("There are multiple brokers to stop. Please select the broker(s) to stop or use --all to stop all brokers.");
-                    return;
-
-                // Get the first broker only
-                } else {
-                    Object firstBroker = mbeans.iterator().next();
-                    mbeans.clear();
-                    mbeans.add(firstBroker);
-                }
-            }
-
-            // Stop each specified broker
-            else {
-                String brokerName;
-                mbeans = new HashSet();
-                while (!brokerNames.isEmpty()) {
-                    brokerName = (String)brokerNames.remove(0);
-                    Collection matchedBrokers = JmxMBeansUtil.getBrokersByName(useJmxServiceUrl(), brokerName);
-                    if (matchedBrokers.isEmpty()) {
-                        GlobalWriter.printInfo(brokerName + " did not match any running brokers.");
-                    } else {
-                        mbeans.addAll(matchedBrokers);
-                    }
-                }
-            }
-
-            // Stop all brokers in set
-            stopBrokers(useJmxServiceUrl(), mbeans);
-        } catch (Exception e) {
-            GlobalWriter.printException(new RuntimeException("Failed to execute stop task. Reason: " + e));
-            throw new Exception(e);
-        }
-    }
-
-    /**
-     * Stops the list of brokers.
-     * @param jmxServiceUrl - JMX service url to connect to
-     * @param brokerBeans - broker mbeans to stop
-     * @throws Exception
-     */
-    protected void stopBrokers(JMXServiceURL jmxServiceUrl, Collection brokerBeans) throws Exception {
-        MBeanServerConnection server = createJmxConnector().getMBeanServerConnection();
-
-        ObjectName brokerObjName;
-        for (Iterator i=brokerBeans.iterator(); i.hasNext();) {
-            brokerObjName = ((ObjectInstance)i.next()).getObjectName();
-
-            String brokerName = brokerObjName.getKeyProperty("BrokerName");
-            GlobalWriter.print("Stopping broker: " + brokerName);
-
-            try {
-                server.invoke(brokerObjName, "terminateJVM", new Object[] {new Integer(0)}, new String[] {"int"});
-                GlobalWriter.print("Succesfully stopped broker: " + brokerName);
-            } catch (Exception e) {
-                // TODO: Check exceptions throwned
-                //System.out.println("Failed to stop broker: [ " + brokerName + " ]. Reason: " + e.getMessage());
-            }
-        }
-
-        closeJmxConnector();
-    }
-
-    /**
-     * Handle the --all option.
-     * @param token - option token to handle
-     * @param tokens - succeeding command arguments
-     * @throws Exception
-     */
-    protected void handleOption(String token, List tokens) throws Exception {
-        // Try to handle the options first
-        if (token.equals("--all")) {
-            isStopAllBrokers = true;
-        } else {
-            // Let the super class handle the option
-            super.handleOption(token, tokens);
-        }
-    }
-
-    /**
-     * Print the help messages for the browse command
-     */
-    protected void printHelp() {
-        GlobalWriter.printHelp(helpFile);
-    }
-
-    protected String[] helpFile = new String[] {
-        "Task Usage: Main stop [stop-options] [broker-name1] [broker-name2] ...",
-        "Description: Stops a running broker.",
-        "",
-        "Stop Options:",
-        "    --jmxurl <url>      Set the JMX URL to connect to.",
-        "    --all               Stop all brokers.",
-        "    --version           Display the version information.",
-        "    -h,-?,--help        Display the stop broker help information.",
-        "",
-        "Broker Names:",
-        "    Name of the brokers that will be stopped.",
-        "    If omitted, it is assumed that there is only one broker running, and it will be stopped.",
-        "    Use -all to stop all running brokers.",
-        ""
-    };
-}
+/**
+ *
+ * Copyright 2005-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.activemq.console.command;
+
+import org.apache.activemq.console.util.JmxMBeansUtil;
+import org.apache.activemq.console.formatter.GlobalWriter;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.ObjectInstance;
+import javax.management.remote.JMXServiceURL;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Collection;
+import java.util.HashSet;
+
+public class ShutdownCommand extends AbstractJmxCommand {
+    private boolean isStopAllBrokers = false;
+
+    /**
+     * Shuts down the specified broker or brokers
+     * @param brokerNames - names of brokers to shutdown
+     * @throws Exception
+     */
+    protected void runTask(List brokerNames) throws Exception {
+        try {
+            Collection mbeans;
+
+            // Stop all brokers
+            if (isStopAllBrokers) {
+                mbeans = JmxMBeansUtil.getAllBrokers(useJmxServiceUrl());
+                brokerNames.clear();
+            }
+
+            // Stop the default broker
+            else if (brokerNames.isEmpty()) {
+                mbeans = JmxMBeansUtil.getAllBrokers(useJmxServiceUrl());
+
+                // If there is no broker to stop
+                if (mbeans.isEmpty()) {
+                    GlobalWriter.printInfo("There are no brokers to stop.");
+                    return;
+
+                // There should only be one broker to stop
+                } else if (mbeans.size() > 1) {
+                    GlobalWriter.printInfo("There are multiple brokers to stop. Please select the broker(s) to stop or use --all to stop all brokers.");
+                    return;
+
+                // Get the first broker only
+                } else {
+                    Object firstBroker = mbeans.iterator().next();
+                    mbeans.clear();
+                    mbeans.add(firstBroker);
+                }
+            }
+
+            // Stop each specified broker
+            else {
+                String brokerName;
+                mbeans = new HashSet();
+                while (!brokerNames.isEmpty()) {
+                    brokerName = (String)brokerNames.remove(0);
+                    Collection matchedBrokers = JmxMBeansUtil.getBrokersByName(useJmxServiceUrl(), brokerName);
+                    if (matchedBrokers.isEmpty()) {
+                        GlobalWriter.printInfo(brokerName + " did not match any running brokers.");
+                    } else {
+                        mbeans.addAll(matchedBrokers);
+                    }
+                }
+            }
+
+            // Stop all brokers in set
+            stopBrokers(useJmxServiceUrl(), mbeans);
+        } catch (Exception e) {
+            GlobalWriter.printException(new RuntimeException("Failed to execute stop task. Reason: " + e));
+            throw new Exception(e);
+        }
+    }
+
+    /**
+     * Stops the list of brokers.
+     * @param jmxServiceUrl - JMX service url to connect to
+     * @param brokerBeans - broker mbeans to stop
+     * @throws Exception
+     */
+    protected void stopBrokers(JMXServiceURL jmxServiceUrl, Collection brokerBeans) throws Exception {
+        MBeanServerConnection server = createJmxConnector().getMBeanServerConnection();
+
+        ObjectName brokerObjName;
+        for (Iterator i=brokerBeans.iterator(); i.hasNext();) {
+            brokerObjName = ((ObjectInstance)i.next()).getObjectName();
+
+            String brokerName = brokerObjName.getKeyProperty("BrokerName");
+            GlobalWriter.print("Stopping broker: " + brokerName);
+
+            try {
+                server.invoke(brokerObjName, "terminateJVM", new Object[] {new Integer(0)}, new String[] {"int"});
+                GlobalWriter.print("Succesfully stopped broker: " + brokerName);
+            } catch (Exception e) {
+                // TODO: Check exceptions throwned
+                //System.out.println("Failed to stop broker: [ " + brokerName + " ]. Reason: " + e.getMessage());
+            }
+        }
+
+        closeJmxConnector();
+    }
+
+    /**
+     * Handle the --all option.
+     * @param token - option token to handle
+     * @param tokens - succeeding command arguments
+     * @throws Exception
+     */
+    protected void handleOption(String token, List tokens) throws Exception {
+        // Try to handle the options first
+        if (token.equals("--all")) {
+            isStopAllBrokers = true;
+        } else {
+            // Let the super class handle the option
+            super.handleOption(token, tokens);
+        }
+    }
+
+    /**
+     * Print the help messages for the browse command
+     */
+    protected void printHelp() {
+        GlobalWriter.printHelp(helpFile);
+    }
+
+    protected String[] helpFile = new String[] {
+        "Task Usage: Main stop [stop-options] [broker-name1] [broker-name2] ...",
+        "Description: Stops a running broker.",
+        "",
+        "Stop Options:",
+        "    --jmxurl <url>      Set the JMX URL to connect to.",
+        "    --all               Stop all brokers.",
+        "    --version           Display the version information.",
+        "    -h,-?,--help        Display the stop broker help information.",
+        "",
+        "Broker Names:",
+        "    Name of the brokers that will be stopped.",
+        "    If omitted, it is assumed that there is only one broker running, and it will be stopped.",
+        "    Use -all to stop all running brokers.",
+        ""
+    };
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/StartCommand.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/StartCommand.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/StartCommand.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/StartCommand.java Tue Feb 21 15:12:56 2006
@@ -1,168 +1,168 @@
-/**
- *
- * Copyright 2005-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.activemq.console.command;
-
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.console.formatter.GlobalWriter;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-public class StartCommand extends AbstractCommand {
-
-    public static final String DEFAULT_CONFIG_URI   = "xbean:activemq.xml";
-
-    private URI  configURI;
-    private List brokers = new ArrayList(5);
-
-    /**
-     * The default task to start a broker or a group of brokers
-     * @param brokerURIs
-     */
-    protected void runTask(List brokerURIs) throws Exception {
-        try {
-            // If no config uri, use default setting
-            if (brokerURIs.isEmpty()) {
-                setConfigUri(new URI(DEFAULT_CONFIG_URI));
-                startBroker(getConfigUri());
-
-            // Set configuration data, if available, which in this case would be the config URI
-            } else {
-                String strConfigURI;
-
-                while (!brokerURIs.isEmpty()) {
-                    strConfigURI = (String)brokerURIs.remove(0);
-
-                    try {
-                        setConfigUri(new URI(strConfigURI));
-                    } catch (URISyntaxException e) {
-                        GlobalWriter.printException(e);
-                        return;
-                    }
-
-                    startBroker(getConfigUri());
-                }
-            }
-
-            // Prevent the main thread from exiting unless it is terminated elsewhere
-            waitForShutdown();
-        } catch (Exception e) {
-            GlobalWriter.printException(new RuntimeException("Failed to execute start task. Reason: " + e));
-            throw new Exception(e);
-        }
-    }
-
-    /**
-     * Create and run a broker specified by the given configuration URI
-     * @param configURI
-     * @throws Exception
-     */
-    public void startBroker(URI configURI) throws Exception {
-        System.out.println("Loading message broker from: " + configURI);
-        BrokerService broker = BrokerFactory.createBroker(configURI);
-        brokers.add(broker);
-
-        broker.start();
-    }
-
-    /**
-     * Wait for a shutdown invocation elsewhere
-     * @throws Exception
-     */
-    protected void waitForShutdown() throws Exception {
-        final boolean[] shutdown = new boolean[] {false};
-        Runtime.getRuntime().addShutdownHook(new Thread() {
-            public void run() {
-                synchronized(shutdown) {
-                    shutdown[0]=true;
-                    shutdown.notify();
-                }
-            }
-        });
-
-        // Wait for any shutdown event
-        synchronized(shutdown) {
-            while( !shutdown[0] ) {
-                try {
-                    shutdown.wait();
-                } catch (InterruptedException e) {
-                }
-            }
-        }
-
-        // Stop each broker
-        for (Iterator i=brokers.iterator(); i.hasNext();) {
-            BrokerService broker = (BrokerService)i.next();
-            broker.stop();
-        }
-    }
-
-    /**
-     * Sets the current configuration URI used by the start task
-     * @param uri
-     */
-    public void setConfigUri(URI uri) {
-        configURI = uri;
-    }
-
-    /**
-     * Gets the current configuration URI used by the start task
-     * @return current configuration URI
-     */
-    public URI getConfigUri() {
-        return configURI;
-    }
-
-    /**
-     * Print the help messages for the browse command
-     */
-    protected void printHelp() {
-        GlobalWriter.printHelp(helpFile);
-    }
-
-    protected String[] helpFile = new String[] {
-        "Task Usage: Main start [start-options] [uri]",
-        "Description: Creates and starts a broker using a configuration file, or a broker URI.",
-        "",
-        "Start Options:",
-        "    -D<name>=<value>      Define a system property.",
-        "    --version             Display the version information.",
-        "    -h,-?,--help          Display the start broker help information.",
-        "",
-        "URI:",
-        "",
-        "    XBean based broker configuration:",
-        "",
-        "        Example: Main xbean:file:activemq.xml",
-        "            Loads the xbean configuration file from the current working directory",
-        "        Example: Main xbean:activemq.xml",
-        "            Loads the xbean configuration file from the classpath",
-        "",
-        "    URI Parameter based broker configuration:",
-        "",
-        "        Example: Main broker:(tcp://localhost:61616, tcp://localhost:5000)?useJmx=true",
-        "            Configures the broker with 2 transport connectors and jmx enabled",
-        "        Example: Main broker:(tcp://localhost:61616, network:tcp://localhost:5000)?persistent=false",
-        "            Configures the broker with 1 transport connector, and 1 network connector and persistence disabled",
-        ""
-    };
-}
+/**
+ *
+ * Copyright 2005-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.activemq.console.command;
+
+import org.apache.activemq.broker.BrokerFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.console.formatter.GlobalWriter;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class StartCommand extends AbstractCommand {
+
+    public static final String DEFAULT_CONFIG_URI   = "xbean:activemq.xml";
+
+    private URI  configURI;
+    private List brokers = new ArrayList(5);
+
+    /**
+     * The default task to start a broker or a group of brokers
+     * @param brokerURIs
+     */
+    protected void runTask(List brokerURIs) throws Exception {
+        try {
+            // If no config uri, use default setting
+            if (brokerURIs.isEmpty()) {
+                setConfigUri(new URI(DEFAULT_CONFIG_URI));
+                startBroker(getConfigUri());
+
+            // Set configuration data, if available, which in this case would be the config URI
+            } else {
+                String strConfigURI;
+
+                while (!brokerURIs.isEmpty()) {
+                    strConfigURI = (String)brokerURIs.remove(0);
+
+                    try {
+                        setConfigUri(new URI(strConfigURI));
+                    } catch (URISyntaxException e) {
+                        GlobalWriter.printException(e);
+                        return;
+                    }
+
+                    startBroker(getConfigUri());
+                }
+            }
+
+            // Prevent the main thread from exiting unless it is terminated elsewhere
+            waitForShutdown();
+        } catch (Exception e) {
+            GlobalWriter.printException(new RuntimeException("Failed to execute start task. Reason: " + e));
+            throw new Exception(e);
+        }
+    }
+
+    /**
+     * Create and run a broker specified by the given configuration URI
+     * @param configURI
+     * @throws Exception
+     */
+    public void startBroker(URI configURI) throws Exception {
+        System.out.println("Loading message broker from: " + configURI);
+        BrokerService broker = BrokerFactory.createBroker(configURI);
+        brokers.add(broker);
+
+        broker.start();
+    }
+
+    /**
+     * Wait for a shutdown invocation elsewhere
+     * @throws Exception
+     */
+    protected void waitForShutdown() throws Exception {
+        final boolean[] shutdown = new boolean[] {false};
+        Runtime.getRuntime().addShutdownHook(new Thread() {
+            public void run() {
+                synchronized(shutdown) {
+                    shutdown[0]=true;
+                    shutdown.notify();
+                }
+            }
+        });
+
+        // Wait for any shutdown event
+        synchronized(shutdown) {
+            while( !shutdown[0] ) {
+                try {
+                    shutdown.wait();
+                } catch (InterruptedException e) {
+                }
+            }
+        }
+
+        // Stop each broker
+        for (Iterator i=brokers.iterator(); i.hasNext();) {
+            BrokerService broker = (BrokerService)i.next();
+            broker.stop();
+        }
+    }
+
+    /**
+     * Sets the current configuration URI used by the start task
+     * @param uri
+     */
+    public void setConfigUri(URI uri) {
+        configURI = uri;
+    }
+
+    /**
+     * Gets the current configuration URI used by the start task
+     * @return current configuration URI
+     */
+    public URI getConfigUri() {
+        return configURI;
+    }
+
+    /**
+     * Print the help messages for the browse command
+     */
+    protected void printHelp() {
+        GlobalWriter.printHelp(helpFile);
+    }
+
+    protected String[] helpFile = new String[] {
+        "Task Usage: Main start [start-options] [uri]",
+        "Description: Creates and starts a broker using a configuration file, or a broker URI.",
+        "",
+        "Start Options:",
+        "    -D<name>=<value>      Define a system property.",
+        "    --version             Display the version information.",
+        "    -h,-?,--help          Display the start broker help information.",
+        "",
+        "URI:",
+        "",
+        "    XBean based broker configuration:",
+        "",
+        "        Example: Main xbean:file:activemq.xml",
+        "            Loads the xbean configuration file from the current working directory",
+        "        Example: Main xbean:activemq.xml",
+        "            Loads the xbean configuration file from the classpath",
+        "",
+        "    URI Parameter based broker configuration:",
+        "",
+        "        Example: Main broker:(tcp://localhost:61616, tcp://localhost:5000)?useJmx=true",
+        "            Configures the broker with 2 transport connectors and jmx enabled",
+        "        Example: Main broker:(tcp://localhost:61616, network:tcp://localhost:5000)?persistent=false",
+        "            Configures the broker with 1 transport connector, and 1 network connector and persistence disabled",
+        ""
+    };
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/StartCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/AbstractQueryFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/AbstractQueryFilter.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/AbstractQueryFilter.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/AbstractQueryFilter.java Tue Feb 21 15:12:56 2006
@@ -1,45 +1,45 @@
-/**
- *
- * Copyright 2005-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.activemq.console.filter;
-
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.Collections;
-
-public abstract class AbstractQueryFilter implements QueryFilter {
-    protected QueryFilter next;
-
-    /**
-     * Creates a query filter, with the next filter specified by next.
-     * @param next - the next query filter
-     */
-    protected AbstractQueryFilter(QueryFilter next) {
-        this.next = next;
-    }
-
-    /**
-     * Performs a query given the query string
-     * @param query - query string
-     * @return objects that matches the query
-     * @throws Exception
-     */
-    public List query(String query) throws Exception {
-        // Converts string query to map query
-        StringTokenizer tokens = new StringTokenizer(query, QUERY_DELIMETER);
-        return query(Collections.list(tokens));
-    }
-}
+/**
+ *
+ * Copyright 2005-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.activemq.console.filter;
+
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.Collections;
+
+public abstract class AbstractQueryFilter implements QueryFilter {
+    protected QueryFilter next;
+
+    /**
+     * Creates a query filter, with the next filter specified by next.
+     * @param next - the next query filter
+     */
+    protected AbstractQueryFilter(QueryFilter next) {
+        this.next = next;
+    }
+
+    /**
+     * Performs a query given the query string
+     * @param query - query string
+     * @return objects that matches the query
+     * @throws Exception
+     */
+    public List query(String query) throws Exception {
+        // Converts string query to map query
+        StringTokenizer tokens = new StringTokenizer(query, QUERY_DELIMETER);
+        return query(Collections.list(tokens));
+    }
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/AbstractQueryFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/AmqMessagesQueryFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/AmqMessagesQueryFilter.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/AmqMessagesQueryFilter.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/AmqMessagesQueryFilter.java Tue Feb 21 15:12:56 2006
@@ -1,152 +1,152 @@
-/**
- *
- * Copyright 2005-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.activemq.console.filter;
-
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.ActiveMQConnectionFactory;
-
-import javax.jms.Destination;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Session;
-import javax.jms.QueueBrowser;
-import java.net.URI;
-import java.util.Collections;
-import java.util.List;
-import java.util.Iterator;
-
-public class AmqMessagesQueryFilter extends AbstractQueryFilter {
-
-    private URI brokerUrl;
-    private Destination destination;
-
-    /**
-     * Create a JMS message query filter
-     * @param brokerUrl - broker url to connect to
-     * @param destination - JMS destination to query
-     */
-    public AmqMessagesQueryFilter(URI brokerUrl, Destination destination) {
-        super(null);
-        this.brokerUrl   = brokerUrl;
-        this.destination = destination;
-    }
-
-    /**
-     * Queries the specified destination using the message selector format query
-     * @param queries - message selector queries
-     * @return list messages that matches the selector
-     * @throws Exception
-     */
-    public List query(List queries) throws Exception {
-        String selector = "";
-
-        // Convert to message selector
-        for (Iterator i=queries.iterator(); i.hasNext();) {
-            selector = selector + "(" + i.next().toString() + ") AND ";
-        }
-
-        // Remove last AND
-        if (selector != "") {
-            selector = selector.substring(0, selector.length() - 5);
-        }
-
-        if (destination instanceof ActiveMQQueue) {
-            return queryMessages((ActiveMQQueue)destination, selector);
-        } else {
-            return queryMessages((ActiveMQTopic)destination, selector);
-        }
-    }
-
-    /**
-     * Query the messages of a queue destination using a queue browser
-     * @param queue - queue destination
-     * @param selector - message selector
-     * @return list of messages that matches the selector
-     * @throws Exception
-     */
-    protected List queryMessages(ActiveMQQueue queue, String selector) throws Exception {
-        Connection conn = createConnection(getBrokerUrl());
-
-        Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        QueueBrowser browser = sess.createBrowser(queue, selector);
-
-        List messages = Collections.list(browser.getEnumeration());
-
-        conn.close();
-
-        return messages;
-    }
-
-    /**
-     * Query the messages of a topic destination using a message consumer
-     * @param topic - topic destination
-     * @param selector - message selector
-     * @return list of messages that matches the selector
-     * @throws Exception
-     */
-    protected List queryMessages(ActiveMQTopic topic, String selector) throws Exception {
-        // TODO: should we use a durable subscriber or a retroactive non-durable subscriber?
-        // TODO: if a durable subscriber is used, how do we manage it? subscribe/unsubscribe tasks?
-        return null;
-    }
-
-    /**
-     * Create and start a JMS connection
-     * @param brokerUrl - broker url to connect to.
-     * @return JMS connection
-     * @throws JMSException
-     */
-    protected Connection createConnection(URI brokerUrl) throws JMSException {
-        Connection conn = (new ActiveMQConnectionFactory(brokerUrl)).createConnection();
-        conn.start();
-        return conn;
-    }
-
-    /**
-     * Get the broker url being used.
-     * @return broker url
-     */
-    public URI getBrokerUrl() {
-        return brokerUrl;
-    }
-
-    /**
-     * Set the broker url to use.
-     * @param brokerUrl - broker url
-     */
-    public void setBrokerUrl(URI brokerUrl) {
-        this.brokerUrl = brokerUrl;
-    }
-
-    /**
-     * Get the destination being used.
-     * @return - JMS destination
-     */
-    public Destination getDestination() {
-        return destination;
-    }
-
-    /**
-     * Set the destination to use.
-     * @param destination - JMS destination
-     */
-    public void setDestination(Destination destination) {
-        this.destination = destination;
-    }
-
-}
+/**
+ *
+ * Copyright 2005-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.activemq.console.filter;
+
+import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+import javax.jms.Destination;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.jms.QueueBrowser;
+import java.net.URI;
+import java.util.Collections;
+import java.util.List;
+import java.util.Iterator;
+
+public class AmqMessagesQueryFilter extends AbstractQueryFilter {
+
+    private URI brokerUrl;
+    private Destination destination;
+
+    /**
+     * Create a JMS message query filter
+     * @param brokerUrl - broker url to connect to
+     * @param destination - JMS destination to query
+     */
+    public AmqMessagesQueryFilter(URI brokerUrl, Destination destination) {
+        super(null);
+        this.brokerUrl   = brokerUrl;
+        this.destination = destination;
+    }
+
+    /**
+     * Queries the specified destination using the message selector format query
+     * @param queries - message selector queries
+     * @return list messages that matches the selector
+     * @throws Exception
+     */
+    public List query(List queries) throws Exception {
+        String selector = "";
+
+        // Convert to message selector
+        for (Iterator i=queries.iterator(); i.hasNext();) {
+            selector = selector + "(" + i.next().toString() + ") AND ";
+        }
+
+        // Remove last AND
+        if (selector != "") {
+            selector = selector.substring(0, selector.length() - 5);
+        }
+
+        if (destination instanceof ActiveMQQueue) {
+            return queryMessages((ActiveMQQueue)destination, selector);
+        } else {
+            return queryMessages((ActiveMQTopic)destination, selector);
+        }
+    }
+
+    /**
+     * Query the messages of a queue destination using a queue browser
+     * @param queue - queue destination
+     * @param selector - message selector
+     * @return list of messages that matches the selector
+     * @throws Exception
+     */
+    protected List queryMessages(ActiveMQQueue queue, String selector) throws Exception {
+        Connection conn = createConnection(getBrokerUrl());
+
+        Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        QueueBrowser browser = sess.createBrowser(queue, selector);
+
+        List messages = Collections.list(browser.getEnumeration());
+
+        conn.close();
+
+        return messages;
+    }
+
+    /**
+     * Query the messages of a topic destination using a message consumer
+     * @param topic - topic destination
+     * @param selector - message selector
+     * @return list of messages that matches the selector
+     * @throws Exception
+     */
+    protected List queryMessages(ActiveMQTopic topic, String selector) throws Exception {
+        // TODO: should we use a durable subscriber or a retroactive non-durable subscriber?
+        // TODO: if a durable subscriber is used, how do we manage it? subscribe/unsubscribe tasks?
+        return null;
+    }
+
+    /**
+     * Create and start a JMS connection
+     * @param brokerUrl - broker url to connect to.
+     * @return JMS connection
+     * @throws JMSException
+     */
+    protected Connection createConnection(URI brokerUrl) throws JMSException {
+        Connection conn = (new ActiveMQConnectionFactory(brokerUrl)).createConnection();
+        conn.start();
+        return conn;
+    }
+
+    /**
+     * Get the broker url being used.
+     * @return broker url
+     */
+    public URI getBrokerUrl() {
+        return brokerUrl;
+    }
+
+    /**
+     * Set the broker url to use.
+     * @param brokerUrl - broker url
+     */
+    public void setBrokerUrl(URI brokerUrl) {
+        this.brokerUrl = brokerUrl;
+    }
+
+    /**
+     * Get the destination being used.
+     * @return - JMS destination
+     */
+    public Destination getDestination() {
+        return destination;
+    }
+
+    /**
+     * Set the destination to use.
+     * @param destination - JMS destination
+     */
+    public void setDestination(Destination destination) {
+        this.destination = destination;
+    }
+
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/AmqMessagesQueryFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/GroupPropertiesViewFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/GroupPropertiesViewFilter.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/GroupPropertiesViewFilter.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/GroupPropertiesViewFilter.java Tue Feb 21 15:12:56 2006
@@ -1,79 +1,79 @@
-/**
- *
- * Copyright 2005-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.activemq.console.filter;
-
-import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
-
-public class GroupPropertiesViewFilter extends PropertiesViewFilter {
-
-    /**
-     * Creates a group properties filter that is able to filter the display result based on a group prefix
-     * @param next - the next query filter
-     */
-    public GroupPropertiesViewFilter(QueryFilter next) {
-        super(next);
-    }
-
-    /**
-     * Creates a group properties filter that is able to filter the display result based on a group prefix
-     * @param groupView - the group filter to use
-     * @param next - the next query filter
-     */
-    public GroupPropertiesViewFilter(Set groupView, QueryFilter next) {
-        super(groupView, next);
-    }
-
-    /**
-     * Filter the properties that matches the group prefix only.
-     * @param data - map data to filter
-     * @return - filtered map data
-     */
-    protected Map filterView(Map data) {
-        // If no view specified, display all attributes
-        if (viewFilter == null || viewFilter.isEmpty()) {
-            return data;
-        }
-
-        Map newData;
-        try {
-            // Lets try to use the same class as the original
-            newData = (Map)data.getClass().newInstance();
-        } catch (Exception e) {
-            // Lets use a default HashMap
-            newData = new HashMap();
-        }
-
-        // Filter the keys to view
-        for (Iterator i=data.keySet().iterator(); i.hasNext();) {
-            String key = (String)i.next();
-
-            // Checks if key matches any of the group filter
-            for (Iterator j=viewFilter.iterator(); j.hasNext();) {
-                String group = (String)j.next();
-                if (key.startsWith(group)) {
-                    newData.put(key, data.get(key));
-                    break;
-                }
-            }
-        }
-
-        return newData;
-    }
-}
+/**
+ *
+ * Copyright 2005-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.activemq.console.filter;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+
+public class GroupPropertiesViewFilter extends PropertiesViewFilter {
+
+    /**
+     * Creates a group properties filter that is able to filter the display result based on a group prefix
+     * @param next - the next query filter
+     */
+    public GroupPropertiesViewFilter(QueryFilter next) {
+        super(next);
+    }
+
+    /**
+     * Creates a group properties filter that is able to filter the display result based on a group prefix
+     * @param groupView - the group filter to use
+     * @param next - the next query filter
+     */
+    public GroupPropertiesViewFilter(Set groupView, QueryFilter next) {
+        super(groupView, next);
+    }
+
+    /**
+     * Filter the properties that matches the group prefix only.
+     * @param data - map data to filter
+     * @return - filtered map data
+     */
+    protected Map filterView(Map data) {
+        // If no view specified, display all attributes
+        if (viewFilter == null || viewFilter.isEmpty()) {
+            return data;
+        }
+
+        Map newData;
+        try {
+            // Lets try to use the same class as the original
+            newData = (Map)data.getClass().newInstance();
+        } catch (Exception e) {
+            // Lets use a default HashMap
+            newData = new HashMap();
+        }
+
+        // Filter the keys to view
+        for (Iterator i=data.keySet().iterator(); i.hasNext();) {
+            String key = (String)i.next();
+
+            // Checks if key matches any of the group filter
+            for (Iterator j=viewFilter.iterator(); j.hasNext();) {
+                String group = (String)j.next();
+                if (key.startsWith(group)) {
+                    newData.put(key, data.get(key));
+                    break;
+                }
+            }
+        }
+
+        return newData;
+    }
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/GroupPropertiesViewFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message