activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r375519 [1/3] - in /incubator/activemq/trunk: ./ activemq-console/ activemq-console/src/ activemq-console/src/main/ activemq-console/src/main/java/ activemq-console/src/main/java/org/ activemq-console/src/main/java/org/apache/ activemq-cons...
Date Tue, 07 Feb 2006 06:48:31 GMT
Author: aco
Date: Mon Feb  6 22:48:24 2006
New Revision: 375519

URL: http://svn.apache.org/viewcvs?rev=375519&view=rev
Log:
- Move AMQ command console to separate module (activemq-console)
- Move Main.java to console module
- Move maven goal "run:broker" from core to console.

Added:
    incubator/activemq/trunk/activemq-console/
    incubator/activemq/trunk/activemq-console/maven.xml
    incubator/activemq/trunk/activemq-console/pom.xml
    incubator/activemq/trunk/activemq-console/project.properties
    incubator/activemq/trunk/activemq-console/project.xml
    incubator/activemq/trunk/activemq-console/src/
    incubator/activemq/trunk/activemq-console/src/main/
    incubator/activemq/trunk/activemq-console/src/main/java/
    incubator/activemq/trunk/activemq-console/src/main/java/org/
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/Main.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractAmqCommand.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractCommand.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractJmxCommand.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/BrowseCommand.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/Command.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ListCommand.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/StartCommand.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/AbstractQueryFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/GroupPropertiesViewFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansAttributeQueryFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansObjectNameQueryFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansRegExQueryFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MapTransformFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MessagesQueryFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/PropertiesViewFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/QueryFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/RegExQueryFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/ResultTransformFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/StubQueryFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/WildcardToMsgSelectorTransformFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/WildcardToRegExTransformFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/WildcardTransformFilter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/CommandShellOutputFormatter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/GlobalWriter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/OutputFormatter.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/util/
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/util/AmqMessagesUtil.java
    incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/util/JmxMBeansUtil.java
    incubator/activemq/trunk/activemq-console/src/test/
    incubator/activemq/trunk/activemq-console/src/test/java/
    incubator/activemq/trunk/activemq-console/src/test/java/org/
    incubator/activemq/trunk/activemq-console/src/test/java/org/apache/
    incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/
    incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/
    incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/simple/
    incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/simple/Consumer.java
    incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/simple/Producer.java
Removed:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/Main.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/console/
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/simple/
Modified:
    incubator/activemq/trunk/activemq-core/maven.xml
    incubator/activemq/trunk/assembly/maven.xml
    incubator/activemq/trunk/assembly/pom.xml
    incubator/activemq/trunk/assembly/project.properties
    incubator/activemq/trunk/assembly/project.xml
    incubator/activemq/trunk/etc/project.properties
    incubator/activemq/trunk/pom.xml
    incubator/activemq/trunk/project.properties

Added: incubator/activemq/trunk/activemq-console/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/maven.xml?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/maven.xml (added)
+++ incubator/activemq/trunk/activemq-console/maven.xml Mon Feb  6 22:48:24 2006
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project default="default" xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:license="license" xmlns:util="jelly:util" xmlns:maven="jelly:maven" xmlns:artifact="artifact">
+
+  <goal name="default" prereqs="jar:install"/>
+
+  <postGoal name="clean">
+    <delete dir="${basedir}/activemq-data" />
+    <delete dir="${basedir}/foo" />
+  </postGoal>
+
+  
+  <!-- ================================================================ -->
+  <!-- GOALS for running benchmarks -->
+  <!-- ================================================================ -->
+
+  <goal name="run:broker" description="Runs the broker" prereqs="setclasspath">
+    <j:if test="${empty(uri)}">
+      <j:set var="uri" value="broker://(tcp://localhost:61616)?useJmx=true" />
+    </j:if>
+
+    <echo>Running the ActiveMQ broker for the URI ${uri}</echo>
+    <java classname="org.apache.activemq.console.Main" fork="true">
+      <classpath refid="test.classpath" />
+      <arg value="${uri}" />
+      <sysproperty key="com.sun.management.jmxremote.port" value="5001" />
+      <sysproperty key="com.sun.management.jmxremote.authenticate" value="false" />
+      <sysproperty key="com.sun.management.jmxremote.ssl" value="false" />
+    </java>
+  </goal>
+
+  <goal name="run:consumer" description="Runs the broker" prereqs="setclasspath">
+    <j:if test="${empty(uri)}">
+      <j:set var="uri" value="tcp://localhost:61616" />
+    </j:if>
+
+    <echo>Running the ActiveMQ consumer for the URI ${uri}</echo>
+    <java classname="org.apache.activemq.console.simple.Consumer" fork="false">
+      <classpath refid="test.classpath" />
+      <arg value="${uri}" />
+    </java>
+  </goal>
+
+  <goal name="setclasspath" prereqs="java:compile">
+    <path id="test.classpath">
+      <pathelement path="${maven.build.dest}" />
+      <pathelement path="target/classes" />
+      <pathelement path="target/test-classes" />
+      <path refid="maven.dependency.classpath" />
+    </path>
+  </goal>
+
+  <goal name="reports:site">
+    <attainGoal name="site" />
+  </goal>
+
+  <goal name="jar:deploy-javadoc" 
+      description="Deploys javadoc binary" prereqs="javadoc:install">
+        
+      <artifact:deploy
+        artifact="${basedir}/target/${pom.artifactId}-${pom.currentVersion}_javadoc.jar"
+        type="jar"
+        project="${pom}"
+      />
+  </goal>
+
+</project>

Added: incubator/activemq/trunk/activemq-console/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/pom.xml?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/pom.xml (added)
+++ incubator/activemq/trunk/activemq-console/pom.xml Mon Feb  6 22:48:24 2006
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<model>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.activemq</groupId>
+    <artifactId>activemq-project</artifactId>
+    <version>4.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+
+  <artifactId>activemq-console</artifactId>
+  <packaging>jar</packaging>
+  <name>ActiveMQ :: Console</name>
+  <description>ActiveMQ Management Console</description>
+
+  <dependencies>
+  
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+    </dependency>
+             
+    <dependency>
+      <groupId>backport-util-concurrent</groupId>
+      <artifactId>backport-util-concurrent</artifactId>
+    </dependency>
+ 
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>geronimo-spec</groupId>
+      <artifactId>geronimo-spec-jms</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>geronimo-spec</groupId>
+      <artifactId>geronimo-spec-jta</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>geronimo-spec</groupId>
+      <artifactId>geronimo-spec-j2ee-management</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>geronimo-spec</groupId>
+      <artifactId>geronimo-spec-j2ee-jacc</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring</artifactId>
+    </dependency>
+     
+    <dependency>
+      <groupId>org.apache.derby</groupId>
+      <artifactId>derby</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>axion</groupId>
+      <artifactId>axion</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-primitives</groupId>
+      <artifactId>commons-primitives</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>regexp</groupId>
+      <artifactId>regexp</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>mx4j</groupId>
+      <artifactId>mx4j</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mx4j</groupId>
+      <artifactId>mx4j-jmx</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mx4j</groupId>
+      <artifactId>mx4j-remote</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mx4j</groupId>
+      <artifactId>mx4j-tools</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mx4j</groupId>
+      <artifactId>mx4j-impl</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>commons-pool</groupId>
+      <artifactId>commons-pool</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>xbean</groupId>
+      <artifactId>xbean-spring</artifactId>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+
+    <plugins>
+
+      <!-- Configure which tests are included/excuded -->
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.1.2-SNAPSHOT</version>
+        <configuration>
+          <forkMode>pertest</forkMode>
+          <childDelegation>false</childDelegation>
+          <useFile>true</useFile>
+          <excludes>
+
+          </excludes>
+          <includes>
+            <include>**/*Test.*</include>
+          </includes>
+        </configuration>
+      </plugin>
+
+      <!-- generate the attached tests jar -->
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+    </plugins>
+  </build>
+
+</model>

Added: incubator/activemq/trunk/activemq-console/project.properties
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/project.properties?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/project.properties (added)
+++ incubator/activemq/trunk/activemq-console/project.properties Mon Feb  6 22:48:24 2006
@@ -0,0 +1,6 @@
+# -------------------------------------------------------------------
+# Build Properties
+# -------------------------------------------------------------------
+maven.multiproject.type=jar
+
+maven.changelog.range=730

Added: incubator/activemq/trunk/activemq-console/project.xml
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/project.xml?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/project.xml (added)
+++ incubator/activemq/trunk/activemq-console/project.xml Mon Feb  6 22:48:24 2006
@@ -0,0 +1,266 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project>
+<!--
+    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.
+-->
+<project>
+    <pomVersion>3</pomVersion>
+    <extend>${basedir}/../etc/project.xml</extend>
+
+    <name>ActiveMQ :: Console</name>
+    <artifactId>activemq-console</artifactId>
+
+    <description>ActiveMQ Console is an open source management console that is use to monitor a JMX enabled ActiveMQ broker.</description>
+    <shortDescription>ActiveMQ Management Console</shortDescription>
+
+    <package>org.apache.activemq.console</package>
+    <packageGroups>
+        <packageGroup>
+            <title>Console Commands</title>
+            <packages>org.apache.activemq.console.command</packages>
+        </packageGroup>
+        <packageGroup>
+            <title>Query Filters</title>
+            <packages>org.apache.activemq.console.filter</packages>
+        </packageGroup>
+        <packageGroup>
+            <title>Console Output Formatter</title>
+            <packages>org.apache.activemq.console.formatter</packages>
+        </packageGroup>
+        <packageGroup>
+            <title>Utilities</title>
+            <packages>org.apache.activemq.console.util</packages>
+        </packageGroup>
+    </packageGroups>
+    <!-- ============ -->
+    <!-- Dependencies -->
+    <!-- ============ -->
+    <dependencies>
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>activemq-core</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>activemq-core-test</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>activeio</groupId>
+            <artifactId>activeio</artifactId>
+            <version>${activeio_version}</version>
+        </dependency>
+        
+        <!-- used to support optional transport configuration via URI query strings -->
+        <dependency>
+            <groupId>commons-beanutils</groupId>
+            <artifactId>commons-beanutils</artifactId>
+            <version>${commons_beanutils_version}</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>${commons_collections_version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>${commons_httpclient_version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>xbean</groupId>
+            <artifactId>xbean-spring</artifactId>
+            <version>${xbean_spring_version}</version>
+            <url>http://www.gbean.org</url>
+        </dependency>
+
+        <dependency>
+            <id>springframework</id>
+            <artifactId>spring</artifactId>
+            <version>${spring_version}</version>
+            <url>http://www.springframework.org</url>
+        </dependency>
+        
+        <dependency>
+            <groupId>mx4j</groupId>
+            <artifactId>mx4j</artifactId>
+            <version>${mx4j_version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>mx4j</groupId>
+            <artifactId>mx4j-remote</artifactId>
+            <version>${mx4j_remote_version}</version>
+        </dependency>
+        
+        <!-- Derby DB used for testing JDBC message store -->
+        <dependency>
+          <groupId>org.apache.derby</groupId>
+          <artifactId>derby</artifactId>
+          <version>${derby_version}</version>
+        </dependency>
+        <dependency>
+          <groupId>org.apache.derby</groupId>
+          <artifactId>derbynet</artifactId>
+          <version>${derbynet_version}</version>
+        </dependency>
+    
+        <dependency>
+          <groupId>xerces</groupId>
+          <artifactId>xercesImpl</artifactId>
+          <version>${xercesImpl_version}</version>
+        </dependency>
+        <dependency>
+          <groupId>xerces</groupId>
+          <artifactId>xmlParserAPIs</artifactId>
+          <version>${xercesImpl_version}</version>
+        </dependency>
+                
+    </dependencies>
+
+    <build>
+        <nagEmailAddress>dev@activemq.codehaus.org</nagEmailAddress>
+        <sourceDirectory>src/main/java</sourceDirectory>
+        <unitTestSourceDirectory>src/test/java</unitTestSourceDirectory>
+        <unitTest>
+            <resources>
+                <resource>
+                    <directory>src/test/resources</directory>
+                    <includes>
+                        <include>**/*.properties</include>
+                        <include>**/*.xml</include>
+                    </includes>
+                    <filtering>false</filtering>
+                </resource>
+            </resources>
+            <includes>
+                <include>**/*Test.*</include>
+            </includes>
+            <excludes>
+               
+            </excludes>
+        </unitTest>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+                <filtering>false</filtering>
+            </resource>
+            <resource>
+                <directory>target/generated</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+                <filtering>false</filtering>
+            </resource>
+        </resources>
+    </build>
+    
+    <developers>
+        <developer>
+            <name>James Strachan</name>
+            <id>jstrachan</id>
+            <email>jstrachan@logicblaze.com</email>
+        </developer>
+        <developer>
+            <name>Hiram Chirino</name>
+            <id>chirino</id>
+            <email>hiram@logicblaze.com</email>
+        </developer>
+        <developer>
+            <name>Rob Davies</name>
+            <id>Rob</id>
+            <email>rajdavies@gmail.com</email>
+        </developer>
+        <developer>
+            <name>Jonas Lim</name>
+            <id>jlim</id>
+            <email>jlim@exist.com</email>
+        </developer>
+        <developer>
+            <name>Frederick Oconer</name>
+            <id>foconer</id>
+            <email>foconer@exist.com</email>
+        </developer>
+        <developer>
+            <name>Joseph Gapuz</name>
+            <id>jgapuz</id>
+            <email>jgapuz@exist.com</email>
+        </developer>
+        <developer>
+            <name>Patrick Villacorta</name>
+            <id>pvillacorta</id>
+            <email>pvillacorta@exist.com</email>
+        </developer>
+        <developer>
+            <name>Darwin Flores</name>
+            <id>dflores</id>
+            <email>dflores@exist.com</email>
+        </developer>
+        <developer>
+            <name>Merwin Yap</name>
+            <id>myap</id>
+            <email>myap@exist.com</email>
+        </developer>
+        <developer>
+            <name>Adrian Co</name>
+            <id>aco</id>
+            <email>aco@exist.com</email>
+        </developer>
+        <developer>
+            <name>Dennis Cook</name>
+            <id>dcook</id>
+            <email>dennis@bevocal.com</email>
+        </developer>
+        <developer>
+            <name>Dag Liodden</name>
+            <id>daggerrz</id>
+            <email>dag.liodden@giantleap.no</email>
+        </developer>
+        <developer>
+            <name>Peter Brooke</name>
+            <id>pbrooke</id>
+        </developer>  
+        <developer>
+            <name>Ramzi Saba</name>
+            <id>rsaba</id>
+            <email>rsaba@optaros.com</email>
+        </developer>
+        <developer>
+            <name>Brian McCallister</name>
+            <id>brianm</id>
+            <email>brianm@apache.org</email>
+        </developer>              
+    </developers>
+    
+    <reports>
+      <report>maven-javadoc-plugin</report>
+      <report>maven-junit-report-plugin</report>
+    </reports>
+    
+    <repository>
+       <connection>scm:svn:svn://svn.activemq.org/activemq/scm/branches/activemq-4-0/activemq</connection>
+       <developerConnection>scm:svn:svn://svn.activemq.org/activemq/branches/activemq-4-0/activemq</developerConnection>
+       <url>https://svn.activemq.org/activemq/branches/activemq-4-0/activemq/</url>
+    </repository>  
+</project>
+

Added: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/Main.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/Main.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/Main.java (added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/Main.java Mon Feb  6 22:48:24 2006
@@ -0,0 +1,221 @@
+/**
+ *
+ * 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;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Main class that can bootstrap an ActiveMQ broker console. Handles command line
+ * argument parsing to set up and run broker tasks.
+ *
+ * @version $Revision$
+ */
+public class Main {
+
+    public static final String TASK_DEFAULT_CLASS  = "org.apache.activemq.console.command.ShellCommand";
+
+    private File          activeMQHome;
+    private ClassLoader   classLoader;
+    private List          extensions = new ArrayList(5);
+
+    private static boolean useDefExt = true;
+
+    public static void main(String[] args) {
+        Main app = new Main();
+
+        // Convert arguments to collection for easier management
+        List tokens =  new LinkedList(Arrays.asList(args));
+        // Parse for extension directory option
+        app.parseExtensions(tokens);
+
+        // Add default extension directories
+        if(useDefExt && app.canUseExtdir()) {
+            app.addExtensionDirectory(new File(app.getActiveMQHome(), "conf"));
+            app.addExtensionDirectory(new File(app.getActiveMQHome(), "lib"));
+            app.addExtensionDirectory(new File(new File(app.getActiveMQHome(), "lib"), "optional"));
+        }
+
+        try {
+            app.runTaskClass(tokens);
+        } catch (Throwable e) {
+            System.out.println("Failed to execute main task. Reason: " + e);
+        }
+    }
+
+    public void parseExtensions(List tokens) {
+        if (tokens.isEmpty()) {
+            return;
+        }
+
+        int count = tokens.size();
+        int i = 0;
+
+        // Parse for all --extdir and --noDefExt options
+        while (i < count) {
+            String token = (String)tokens.get(i);
+            // If token is an extension dir option
+            if (token.equals("--extdir")) {
+                // Process token
+                count--;
+                tokens.remove(i);
+
+                // If no extension directory is specified, or next token is another option
+                if (i >= count || ((String)tokens.get(i)).startsWith("-")) {
+                    System.out.println("Extension directory not specified.");
+                    System.out.println("Ignoring extension directory option.");
+                    continue;
+                }
+
+                // Process extension dir token
+                count--;
+                File extDir = new File((String)tokens.remove(i));
+
+                if(!canUseExtdir()) {
+                    System.out.println("Extension directory feature not available due to the system classpath being able to load: " + TASK_DEFAULT_CLASS);
+                    System.out.println("Ignoring extension directory option.");
+                    continue;
+                }
+
+                if (!extDir.isDirectory()) {
+                    System.out.println("Extension directory specified is not valid directory: " + extDir);
+                    System.out.println("Ignoring extension directory option.");
+                    continue;
+                }
+
+                addExtensionDirectory(extDir);
+            } else if (token.equals("--noDefExt")) { // If token is --noDefExt option
+                count--;
+                tokens.remove(i);
+                useDefExt = false;
+            } else {
+                i++;
+            }
+		}
+
+    }
+
+    public void runTaskClass(List tokens) throws Throwable {
+        System.out.println("ACTIVEMQ_HOME: "+ getActiveMQHome());
+
+        ClassLoader cl = getClassLoader();
+
+        // Use reflection to run the task.
+        try {
+            String[] args = (String[]) tokens.toArray(new String[tokens.size()]);
+            Class task = cl.loadClass(TASK_DEFAULT_CLASS);
+            Method runTask = task.getMethod("main", new Class[] { String[].class, InputStream.class, PrintStream.class });
+            runTask.invoke(task.newInstance(), new Object[] { args, System.in, System.out });
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    public void addExtensionDirectory(File directory) {
+        extensions.add(directory);
+    }
+
+    /**
+     * The extension directory feature will not work if the broker factory is already in the classpath
+     * since we have to load him from a child ClassLoader we build for it to work correctly.
+     *
+     * @return
+     */
+    public boolean canUseExtdir() {
+        try {
+            Main.class.getClassLoader().loadClass(TASK_DEFAULT_CLASS);
+            return false;
+        } catch (ClassNotFoundException e) {
+            return true;
+        }
+    }
+
+    public ClassLoader getClassLoader() throws MalformedURLException {
+        if(classLoader==null) {
+            // Setup the ClassLoader
+            classLoader = Main.class.getClassLoader();
+            if (!extensions.isEmpty()) {
+
+                ArrayList urls = new ArrayList();
+                for (Iterator iter = extensions.iterator(); iter.hasNext();) {
+                    File dir = (File) iter.next();
+                    try{ System.out.println("Adding to classpath: " + dir.getCanonicalPath()); }catch(Exception e){}
+                    urls.add(dir.toURL());
+                    File[] files = dir.listFiles();
+                    if( files!=null ) {
+                        for (int j = 0; j < files.length; j++) {
+                            if( files[j].getName().endsWith(".zip") || files[j].getName().endsWith(".jar") ) {
+                                try{ System.out.println("Adding to classpath: " + files[j].getCanonicalPath()); }catch(Exception e){}
+                                urls.add(files[j].toURL());
+                            }
+                        }
+                    }
+                }
+
+                URL u[] = new URL[urls.size()];
+                urls.toArray(u);
+                classLoader = new URLClassLoader(u, classLoader);
+            }
+            Thread.currentThread().setContextClassLoader(classLoader);
+        }
+        return classLoader;
+    }
+
+    public void setActiveMQHome(File activeMQHome) {
+        this.activeMQHome = activeMQHome;
+    }
+
+    public File getActiveMQHome() {
+        if(activeMQHome==null) {
+            if(System.getProperty("activemq.home") != null) {
+                activeMQHome = new File(System.getProperty("activemq.home"));
+            }
+
+            if(activeMQHome==null){
+                // guess from the location of the jar
+                URL url = Main.class.getClassLoader().getResource("org/apache/activemq/broker/Main.class");
+                if (url != null) {
+                    try {
+                        JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
+                        url = jarConnection.getJarFileURL();
+                        URI baseURI = new URI(url.toString()).resolve("..");
+                        activeMQHome = new File(baseURI).getCanonicalFile();
+                    } catch (Exception ignored) {
+                    }
+                }
+            }
+
+            if(activeMQHome==null){
+                activeMQHome = new File(".");
+            }
+        }
+        return activeMQHome;
+    }
+}

Added: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractAmqCommand.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractAmqCommand.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractAmqCommand.java (added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractAmqCommand.java Mon Feb  6 22:48:24 2006
@@ -0,0 +1,156 @@
+/**
+ *
+ * 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.ActiveMQConnectionFactory;
+import org.apache.activemq.console.formatter.GlobalWriter;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public abstract class AbstractAmqCommand extends AbstractCommand {
+    private URI brokerUrl;
+    private ConnectionFactory factory;
+    private final List connections = new ArrayList();
+
+    /**
+     * Establishes a connection to the remote broker specified by the broker url.
+     * @return - connection to the broker
+     * @throws JMSException
+     */
+    protected Connection createConnection() throws JMSException {
+        if (getBrokerUrl() == null) {
+            GlobalWriter.printException(new IllegalStateException("You must specify a broker URL to connect to using the --amqurl option."));
+            return null;
+        }
+
+        if (factory == null) {
+            factory = new ActiveMQConnectionFactory(getBrokerUrl());
+        }
+
+        Connection conn = factory.createConnection();
+        connections.add(conn);
+
+        return conn;
+    }
+
+    /**
+     * Establishes a connection to the remote broker specified by the broker url.
+     * @param username - username for the connection
+     * @param password - password for the connection
+     * @return - connection to the broker
+     * @throws JMSException
+     */
+    protected Connection createConnection(String username, String password) throws JMSException {
+        if (getBrokerUrl() == null) {
+            GlobalWriter.printException(new IllegalStateException("You must specify a broker URL to connect to using the --amqurl option."));
+            return null;
+        }
+
+        if (factory == null) {
+            factory = new ActiveMQConnectionFactory(getBrokerUrl());
+        }
+
+        Connection conn = factory.createConnection(username, password);
+        connections.add(conn);
+        conn.start();
+
+        return conn;
+    }
+
+    /**
+     * Close all created connections.
+     */
+    protected void closeAllConnections() {
+        for (Iterator i=connections.iterator(); i.hasNext();) {
+            try {
+                ((Connection)i.next()).close();
+            } catch (Exception e) { }
+        }
+
+        connections.clear();
+    }
+
+    /**
+     * Handle the --amqurl option.
+     * @param token - current option
+     * @param tokens - succeeding list of arguments
+     * @throws Exception
+     */
+    protected void handleOption(String token, List tokens) throws Exception {
+        // Try to handle the options first
+        if (token.equals("--amqurl")) {
+            // If no broker url specified, or next token is a new option
+            if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) {
+                GlobalWriter.printException(new IllegalArgumentException("Broker URL not specified."));
+                tokens.clear();
+                return;
+            }
+
+            // If broker url already specified
+            if (getBrokerUrl() != null) {
+                GlobalWriter.printException(new IllegalArgumentException("Multiple broker URL cannot be specified."));
+                tokens.clear();
+                return;
+            }
+
+            String strBrokerUrl = (String)tokens.remove(0);
+
+            try {
+                setBrokerUrl(new URI(strBrokerUrl));
+            } catch (URISyntaxException e) {
+                GlobalWriter.printException(e);
+                tokens.clear();
+                return;
+            }
+        } else {
+            // Let the super class handle the option
+            super.handleOption(token, tokens);
+        }
+    }
+
+    /**
+     * Set the broker url.
+     * @param brokerUrl - new broker url
+     */
+    protected void setBrokerUrl(URI brokerUrl) {
+        this.brokerUrl = brokerUrl;
+    }
+
+    /**
+     * Set the broker url.
+     * @param address - address of the new broker url
+     * @throws URISyntaxException
+     */
+    protected void setBrokerUrl(String address) throws URISyntaxException {
+        this.brokerUrl = new URI(address);
+    }
+
+    /**
+     * Get the current broker url.
+     * @return current broker url
+     */
+    protected URI getBrokerUrl() {
+        return brokerUrl;
+    }
+}

Added: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractCommand.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractCommand.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractCommand.java (added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractCommand.java Mon Feb  6 22:48:24 2006
@@ -0,0 +1,120 @@
+/**
+ *
+ * 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.ActiveMQConnectionMetaData;
+import org.apache.activemq.console.formatter.GlobalWriter;
+
+import java.util.List;
+
+public abstract class AbstractCommand implements Command {
+    public static final String COMMAND_OPTION_DELIMETER = ",";
+
+    private boolean isPrintHelp    = false;
+    private boolean isPrintVersion = false;
+
+    /**
+     * Exceute a generic command, which includes parsing the options for the command and running the specific task.
+     * @param tokens - command arguments
+     * @throws Exception
+     */
+    public void execute(List tokens) throws Exception {
+        // Parse the options specified by "-"
+        parseOptions(tokens);
+
+        // Print the help file of the task
+        if (isPrintHelp) {
+            printHelp();
+
+        // Print the AMQ version
+        } else if (isPrintVersion) {
+            GlobalWriter.printVersion(ActiveMQConnectionMetaData.PROVIDER_VERSION);
+
+        // Run the specified task
+        } else {
+            runTask(tokens);
+        }
+    }
+
+    /**
+     * Parse any option parameters in the command arguments specified by a '-' as the first character of the token.
+     * @param tokens - command arguments
+     * @throws Exception
+     */
+    protected void parseOptions(List tokens) throws Exception {
+        while (!tokens.isEmpty()) {
+            String token = (String)tokens.remove(0);
+            if (token.startsWith("-")) {
+                // Token is an option
+                handleOption(token, tokens);
+            } else {
+                // Push back to list of tokens
+                tokens.add(0, token);
+                return;
+            }
+        }
+    }
+
+    /**
+     * Handle the general options for each command, which includes -h, -?, --help, -D, --version.
+     * @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 help option
+        if (token.equals("-h") || token.equals("-?") || token.equals("--help")) {
+            isPrintHelp = true;
+            tokens.clear();
+
+        // If token is a version option
+        } else if (token.equals("--version")) {
+            isPrintVersion = true;
+            tokens.clear();
+        }
+
+        // If token is a system property define option
+        else if (token.startsWith("-D")) {
+            String key = token.substring(2);
+            String value = "";
+            int pos = key.indexOf("=");
+            if (pos >= 0) {
+                value = key.substring(pos + 1);
+                key = key.substring(0, pos);
+            }
+            System.setProperty(key, value);
+
+        }
+
+        // Token is unrecognized
+        else {
+            GlobalWriter.printInfo("Ignoring unrecognized option: " + token);
+        }
+    }
+
+    /**
+     * Run the specific task.
+     * @param tokens - command arguments
+     * @throws Exception
+     */
+    abstract protected void runTask(List tokens) throws Exception;
+
+    /**
+     * Print the help messages for the specific task
+     */
+    abstract protected void printHelp();
+}

Added: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractJmxCommand.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractJmxCommand.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractJmxCommand.java (added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractJmxCommand.java Mon Feb  6 22:48:24 2006
@@ -0,0 +1,135 @@
+/**
+ *
+ * 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 javax.management.remote.JMXServiceURL;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import java.util.List;
+import java.net.MalformedURLException;
+import java.io.IOException;
+
+public abstract class AbstractJmxCommand extends AbstractCommand {
+    public static final String DEFAULT_JMX_URL    = "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi";
+
+    private JMXServiceURL jmxServiceUrl;
+    private JMXConnector  jmxConnector;
+
+    /**
+     * Get the current specified JMX service url.
+     * @return JMX service url
+     */
+    protected JMXServiceURL getJmxServiceUrl() {
+        return jmxServiceUrl;
+    }
+
+    /**
+     * Get the current JMX service url being used, or create a default one if no JMX service url has been specified.
+     * @return JMX service url
+     * @throws MalformedURLException
+     */
+    protected JMXServiceURL useJmxServiceUrl() throws MalformedURLException {
+        if (getJmxServiceUrl() == null) {
+            setJmxServiceUrl(DEFAULT_JMX_URL);
+        }
+
+        return getJmxServiceUrl();
+    }
+
+    /**
+     * Sets the JMX service url to use.
+     * @param jmxServiceUrl - new JMX service url to use
+     */
+    protected void setJmxServiceUrl(JMXServiceURL jmxServiceUrl) {
+        this.jmxServiceUrl = jmxServiceUrl;
+    }
+
+    /**
+     * Sets the JMX service url to use.
+     * @param jmxServiceUrl - new JMX service url to use
+     * @throws MalformedURLException
+     */
+    protected void setJmxServiceUrl(String jmxServiceUrl) throws MalformedURLException {
+        setJmxServiceUrl(new JMXServiceURL(jmxServiceUrl));
+    }
+
+    /**
+     * Create a JMX connector using the current specified JMX service url. If there is an existing connection,
+     * it tries to reuse this connection.
+     * @return created JMX connector
+     * @throws IOException
+     */
+    protected JMXConnector createJmxConnector() throws IOException {
+        // Reuse the previous connection
+        if (jmxConnector != null) {
+            jmxConnector.connect();
+            return jmxConnector;
+        }
+
+        // Create a new JMX connector
+        jmxConnector = JMXConnectorFactory.connect(useJmxServiceUrl());
+        return jmxConnector;
+    }
+
+    /**
+     * Close the current JMX connector
+     */
+    protected void closeJmxConnector() {
+        try {
+            if (jmxConnector != null) {
+                jmxConnector.close();
+                jmxConnector = null;
+            }
+        } catch (IOException e) {
+        }
+    }
+
+    /**
+     * Handle the --jmxurl 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("--jmxurl")) {
+            // If no jmx url specified, or next token is a new option
+            if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) {
+                GlobalWriter.printException(new IllegalArgumentException("JMX URL not specified."));
+            }
+
+            // If jmx url already specified
+            if (getJmxServiceUrl() != null) {
+                GlobalWriter.printException(new IllegalArgumentException("Multiple JMX URL cannot be specified."));
+                tokens.clear();
+            }
+
+            String strJmxUrl = (String)tokens.remove(0);
+            try {
+                this.setJmxServiceUrl(new JMXServiceURL(strJmxUrl));
+            } catch (MalformedURLException e) {
+                GlobalWriter.printException(e);
+                tokens.clear();
+            }
+        } else {
+            // Let the super class handle the option
+            super.handleOption(token, tokens);
+        }
+    }
+}

Added: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/BrowseCommand.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/BrowseCommand.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/BrowseCommand.java (added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/BrowseCommand.java Mon Feb  6 22:48:24 2006
@@ -0,0 +1,240 @@
+/**
+ *
+ * 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.AmqMessagesUtil;
+import org.apache.activemq.console.formatter.GlobalWriter;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTopic;
+
+import javax.jms.Destination;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.StringTokenizer;
+import java.util.Iterator;
+
+public class BrowseCommand extends AbstractAmqCommand {
+    public static final String QUEUE_PREFIX = "queue:";
+    public static final String TOPIC_PREFIX = "topic:";
+
+    public static final String VIEW_GROUP_HEADER = "header:";
+    public static final String VIEW_GROUP_CUSTOM = "custom:";
+    public static final String VIEW_GROUP_BODY   = "body:";
+
+    private final List queryAddObjects = new ArrayList(10);
+    private final List querySubObjects = new ArrayList(10);
+    private final Set  groupViews      = new HashSet(10);
+    private final Set  queryViews      = new HashSet(10);
+
+    /**
+     * Execute the browse command, which allows you to browse the messages in a given JMS destination
+     * @param tokens - command arguments
+     * @throws Exception
+     */
+    protected void runTask(List tokens) throws Exception {
+        try {
+            // If no destination specified
+            if (tokens.isEmpty()) {
+                GlobalWriter.printException(new IllegalArgumentException("No JMS destination specified."));
+                return;
+            }
+
+            // If no broker url specified
+            if (getBrokerUrl() == null) {
+                GlobalWriter.printException(new IllegalStateException("No broker url specified. Use the --amqurl option to specify a broker url."));
+                return;
+            }
+
+            // Display the messages for each destination
+            for (Iterator i=tokens.iterator(); i.hasNext();) {
+                String destName = (String)i.next();
+                Destination dest;
+
+                // If destination has been explicitly specified as a queue
+                if (destName.startsWith(QUEUE_PREFIX)) {
+                    dest = new ActiveMQQueue(destName.substring(QUEUE_PREFIX.length()));
+
+                // If destination has been explicitly specified as a topic
+                } else if (destName.startsWith(TOPIC_PREFIX)) {
+                    dest = new ActiveMQTopic(destName.substring(TOPIC_PREFIX.length()));
+
+                // By default destination is assumed to be a queue
+                } else {
+                    dest = new ActiveMQQueue(destName);
+                }
+
+                // Query for the messages to view
+                List addMsgs = AmqMessagesUtil.getMessages(getBrokerUrl(), dest, queryAddObjects);
+
+                // Query for the messages to remove from view
+                if (querySubObjects.size() > 0) {
+                    List subMsgs = AmqMessagesUtil.getMessages(getBrokerUrl(), dest, querySubObjects);
+                    addMsgs.removeAll(subMsgs);
+                }
+
+                // Display the messages
+                GlobalWriter.printMessage(AmqMessagesUtil.filterMessagesView(addMsgs, groupViews, queryViews));
+            }
+
+        } catch (Exception e) {
+            GlobalWriter.printException(new RuntimeException("Failed to execute browse task. Reason: " + e));
+            throw new Exception(e);
+        }
+    }
+
+    /**
+     * Handle the --msgsel, --xmsgsel, --view, -V 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 an additive message selector option
+        if (token.startsWith("--msgsel")) {
+
+            // If no message selector is specified, or next token is a new option
+            if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) {
+                GlobalWriter.printException(new IllegalArgumentException("Message selector 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 message selector option
+        else if (token.startsWith("--xmsgsel")) {
+
+            // If no message selector is specified, or next token is a new option
+            if (tokens.isEmpty() || ((String)tokens.get(0)).startsWith("-")) {
+                GlobalWriter.printException(new IllegalArgumentException("Message selector 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
+            StringTokenizer viewTokens = new StringTokenizer((String)tokens.remove(0), COMMAND_OPTION_DELIMETER);
+            while (viewTokens.hasMoreTokens()) {
+                String viewToken = viewTokens.nextToken();
+
+                // If view is explicitly specified to belong to the JMS header
+                if (viewToken.equals(VIEW_GROUP_HEADER)) {
+                    queryViews.add(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + viewToken.substring(VIEW_GROUP_HEADER.length()));
+
+                // If view is explicitly specified to belong to the JMS custom header
+                } else if (viewToken.equals(VIEW_GROUP_CUSTOM)) {
+                    queryViews.add(AmqMessagesUtil.JMS_MESSAGE_CUSTOM_PREFIX + viewToken.substring(VIEW_GROUP_CUSTOM.length()));
+
+                // If view is explicitly specified to belong to the JMS body
+                } else if (viewToken.equals(VIEW_GROUP_BODY)) {
+                    queryViews.add(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + viewToken.substring(VIEW_GROUP_BODY.length()));
+
+                // If no view explicitly specified, let's check the view for each group
+                } else {
+                    queryViews.add(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + viewToken);
+                    queryViews.add(AmqMessagesUtil.JMS_MESSAGE_CUSTOM_PREFIX + viewToken);
+                    queryViews.add(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX   + viewToken);
+                }
+            }
+        }
+
+        // If token is a predefined group view option
+        else if (token.startsWith("-V")) {
+            String viewGroup = token.substring(2);
+            // If option is a header group view
+            if (viewGroup.equals("header")) {
+                groupViews.add(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX);
+
+            // If option is a custom header group view
+            } else if (viewGroup.equals("custom")) {
+                groupViews.add(AmqMessagesUtil.JMS_MESSAGE_CUSTOM_PREFIX);
+
+            // If option is a body group view
+            } else if (viewGroup.equals("body")) {
+                groupViews.add(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX);
+
+            // Unknown group view
+            } else {
+                GlobalWriter.printInfo("Unknown group view: " + viewGroup + ". Ignoring group view option.");
+            }
+        }
+
+        // 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 browse --amqurl <broker url> [browse-options] <destinations>",
+        "Description: Display selected destination's messages.",
+        "",
+        "Browse Options:",
+        "    --amqurl <url>                Set the broker URL to connect to.",
+        "    --msgsel <msgsel1,msglsel2>   Add to the search list messages matched by the query similar to",
+        "                                  the messages selector format.",
+        "    -V<header|custom|body>        Predefined view that allows you to view the message header, custom",
+        "                                  message header, or the message body.",
+        "    --view <attr1>,<attr2>,...    Select the specific attribute of the message to view.",
+        "    --version                     Display the version information.",
+        "    -h,-?,--help                  Display the browse broker help information.",
+        "",
+        "Examples:",
+        "    Main browse --amqurl tcp://localhost:61616 FOO.BAR",
+        "        - Print the message header, custom message header, and message body of all messages in the",
+        "          queue FOO.BAR",
+        "",
+        "    Main browse --amqurl tcp://localhost:61616 -Vheader,body queue:FOO.BAR",
+        "        - Print only the message header and message body of all messages in the queue FOO.BAR",
+        "",
+        "    Main browse --amqurl tcp://localhost:61616 -Vheader --view custom:MyField queue:FOO.BAR",
+        "        - Print the message header and the custom field 'MyField' of all messages in the queue FOO.BAR",
+        "",
+        "    Main browse --amqurl tcp://localhost:61616 --msgsel JMSMessageID='*:10',JMSPriority>5 FOO.BAR",
+        "        - Print all the message fields that has a JMSMessageID in the header field that matches the",
+        "          wildcard *:10, and has a JMSPriority field > 5 in the queue FOO.BAR",
+        "        * To use wildcard queries, the field must be a string and the query enclosed in ''",
+        "",
+    };
+}

Added: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/Command.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/Command.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/Command.java (added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/Command.java Mon Feb  6 22:48:24 2006
@@ -0,0 +1,29 @@
+/**
+ *
+ * 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 java.util.List;
+
+public interface Command {
+    /**
+     * Execute the specified command
+     * @param tokens - arguments to the command
+     * @throws Exception
+     */
+    public void execute(List tokens) throws Exception;
+}

Added: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ListCommand.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ListCommand.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ListCommand.java (added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ListCommand.java Mon Feb  6 22:48:24 2006
@@ -0,0 +1,61 @@
+/**
+ *
+ * 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.util.JmxMBeansUtil;
+
+import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
+
+public class ListCommand extends AbstractJmxCommand {
+
+    /**
+     * List all running brokers registered in the specified JMX context
+     * @param tokens - command arguments
+     * @throws Exception
+     */
+    protected void runTask(List tokens) throws Exception {
+        try {
+            Set propsView = new HashSet();
+            propsView.add("BrokerName");
+            GlobalWriter.printMBean(JmxMBeansUtil.filterMBeansView(JmxMBeansUtil.getAllBrokers(useJmxServiceUrl()), propsView));
+        } catch (Exception e) {
+            GlobalWriter.printException(new RuntimeException("Failed to execute list task. Reason: " + e));
+            throw new Exception(e);
+        }
+    }
+    
+    /**
+     * Print the help messages for the browse command
+     */
+    protected void printHelp() {
+        GlobalWriter.printHelp(helpFile);
+    }
+
+    protected String[] helpFile = new String[] {
+        "Task Usage: Main list [list-options]",
+        "Description:  Lists all available broker in the specified JMX context.",
+        "",
+        "List Options:",
+        "    --jmxurl <url>      Set the JMX URL to connect to.",
+        "    --version           Display the version information.",
+        "    -h,-?,--help        Display the stop broker help information.",
+        ""
+    };
+}

Added: 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=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java (added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java Mon Feb  6 22:48:24 2006
@@ -0,0 +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.",
+        "",
+    };
+}

Added: 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=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java (added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java Mon Feb  6 22:48:24 2006
@@ -0,0 +1,110 @@
+/**
+ *
+ * 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 BrowseCommand().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.",
+        ""
+    };
+}

Added: 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=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java (added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java Mon Feb  6 22:48:24 2006
@@ -0,0 +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.",
+        ""
+    };
+}



Mime
View raw message