From 60646c955b91eb3949bc227a5e02e738a394cf36 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Thu, 8 Nov 2012 17:35:58 +0000 Subject: [PATCH] Moved the amp-store related command to the activemq-amqp-store module. Hand to introduce dynamic Command discovery to get this working and remove the compile time dependency on activemq-spring from the activemq-console module. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1407178 13f79535-47bb-0310-9956-ffa450edef68 --- activemq-amq-store/pom.xml | 173 +----------------- .../command/store/amq/AMQJournalTool.java | 0 .../store/amq/AMQJournalToolCommand.java | 10 + .../store/amq/CustomResourceLoader.java | 0 .../console/command/store/amq/Entry.java | 0 .../store/amq/MessageBodyFormatter.java | 0 .../command/store/amq/reader/AMQIterator.java | 0 .../command/store/amq/reader/AMQReader.java | 0 .../store/amq/reader/MessageLocation.java | 0 .../activemq/store/amq/AMQJournalTool.java | 0 .../store/amq/AMQJournalToolCommand.java | 10 + .../store/amq/CommandLineSupport.java | 0 .../store/amq/CustomResourceLoader.java | 0 .../org/apache/activemq/store/amq/Entry.java | 0 .../store/amq/MessageBodyFormatter.java | 0 .../store/amq/reader/AMQIterator.java | 0 .../activemq/store/amq/reader/AMQReader.java | 0 .../store/amq/reader/MessageLocation.java | 0 ...rg.apache.activemq.console.command.Command | 17 ++ .../org/apache/activemq/store/amq/help.txt | 0 .../console/command/AMQJournalToolTest.java | 0 .../apache/activemq/broker/BrokerFactory.java | 16 ++ activemq-console/pom.xml | 16 +- .../console/command/AmqBrowseCommand.java | 11 ++ .../console/command/BrowseCommand.java | 10 + .../console/command/BstatCommand.java | 12 +- .../activemq/console/command/Command.java | 6 +- .../console/command/CreateCommand.java | 10 + .../console/command/DecryptCommand.java | 10 + .../console/command/EncryptCommand.java | 10 + .../activemq/console/command/ListCommand.java | 10 + .../console/command/PurgeCommand.java | 10 + .../console/command/QueryCommand.java | 10 + .../console/command/ShellCommand.java | 140 +++++++------- .../console/command/ShutdownCommand.java | 10 + .../console/command/StartCommand.java | 10 + .../command/StopGracefullyCommand.java | 10 + .../console/command/StoreExportCommand.java | 10 + .../console/command/store/StoreExporter.java | 5 +- ...rg.apache.activemq.console.command.Command | 27 +++ .../command/DummyConnectionFactory.java | 0 .../command/InvalidConnectionFactory.java | 0 .../command/LowercasingPasswordFactory.java | 0 .../activemq/console/command/TestAMQ3410.java | 2 +- .../activemq/console/command/TestAMQ3411.java | 2 +- .../console/command/TestPurgeCommand.java | 2 +- .../activemq/console/command}/activemq.xml | 26 +-- activemq-optional/pom.xml | 8 - .../activemq/xbean/XBeanBrokerFactory.java | 16 -- .../activemq/xbean/XBeanBrokerService.java | 3 +- 50 files changed, 327 insertions(+), 285 deletions(-) rename {activemq-console => activemq-amq-store}/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalTool.java (100%) rename {activemq-console => activemq-amq-store}/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalToolCommand.java (87%) rename {activemq-console => activemq-amq-store}/src/main/java/org/apache/activemq/console/command/store/amq/CustomResourceLoader.java (100%) rename {activemq-console => activemq-amq-store}/src/main/java/org/apache/activemq/console/command/store/amq/Entry.java (100%) rename {activemq-console => activemq-amq-store}/src/main/java/org/apache/activemq/console/command/store/amq/MessageBodyFormatter.java (100%) rename {activemq-console => activemq-amq-store}/src/main/java/org/apache/activemq/console/command/store/amq/reader/AMQIterator.java (100%) rename {activemq-console => activemq-amq-store}/src/main/java/org/apache/activemq/console/command/store/amq/reader/AMQReader.java (100%) rename {activemq-console => activemq-amq-store}/src/main/java/org/apache/activemq/console/command/store/amq/reader/MessageLocation.java (100%) rename {activemq-optional => activemq-amq-store}/src/main/java/org/apache/activemq/store/amq/AMQJournalTool.java (100%) rename {activemq-optional => activemq-amq-store}/src/main/java/org/apache/activemq/store/amq/AMQJournalToolCommand.java (87%) rename {activemq-optional => activemq-amq-store}/src/main/java/org/apache/activemq/store/amq/CommandLineSupport.java (100%) rename {activemq-optional => activemq-amq-store}/src/main/java/org/apache/activemq/store/amq/CustomResourceLoader.java (100%) rename {activemq-optional => activemq-amq-store}/src/main/java/org/apache/activemq/store/amq/Entry.java (100%) rename {activemq-optional => activemq-amq-store}/src/main/java/org/apache/activemq/store/amq/MessageBodyFormatter.java (100%) rename {activemq-optional => activemq-amq-store}/src/main/java/org/apache/activemq/store/amq/reader/AMQIterator.java (100%) rename {activemq-optional => activemq-amq-store}/src/main/java/org/apache/activemq/store/amq/reader/AMQReader.java (100%) rename {activemq-optional => activemq-amq-store}/src/main/java/org/apache/activemq/store/amq/reader/MessageLocation.java (100%) create mode 100644 activemq-amq-store/src/main/resources/META-INF/services/org.apache.activemq.console.command.Command rename {activemq-optional => activemq-amq-store}/src/main/resources/org/apache/activemq/store/amq/help.txt (100%) rename {activemq-console => activemq-amq-store}/src/test/java/org/apache/activemq/console/command/AMQJournalToolTest.java (100%) create mode 100644 activemq-console/src/main/resources/META-INF/services/org.apache.activemq.console.command.Command rename {activemq-console => activemq-core}/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java (100%) rename {activemq-console => activemq-core}/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java (100%) rename {activemq-console => activemq-core}/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java (100%) rename {activemq-console => activemq-core}/src/test/java/org/apache/activemq/console/command/TestAMQ3410.java (98%) rename {activemq-console => activemq-core}/src/test/java/org/apache/activemq/console/command/TestAMQ3411.java (98%) rename {activemq-console => activemq-core}/src/test/java/org/apache/activemq/console/command/TestPurgeCommand.java (99%) rename {activemq-console/src/test/resources => activemq-core/src/test/resources/org/apache/activemq/console/command}/activemq.xml (98%) diff --git a/activemq-amq-store/pom.xml b/activemq-amq-store/pom.xml index e639aed4e8..bf69baf6b9 100755 --- a/activemq-amq-store/pom.xml +++ b/activemq-amq-store/pom.xml @@ -42,96 +42,29 @@ org.apache.activemq activemq-broker - ${project.groupId} activeio-core - true - - - org.apache.activemq.protobuf - activemq-protobuf - false - - - org.fusesource.mqtt-client - mqtt-client + - org.osgi - org.osgi.core - provided + ${project.groupId} + activemq-console true - org.apache.activemq - activemq-jaas + org.apache.velocity + velocity true - org.apache.geronimo.specs - geronimo-jta_1.0.1B_spec - true - - - org.apache.geronimo.specs - geronimo-j2ee-management_1.1_spec - - - org.apache.geronimo.specs - geronimo-annotation_1.0_spec - true - - - org.apache.geronimo.specs - geronimo-jacc_1.1_spec - true - - - com.thoughtworks.xstream - xstream - true - - - org.codehaus.jettison - jettison - true - - - - - org.apache.xbean - xbean-spring - true - - - org.springframework - spring-context - - - org.apache.derby - derby - true - - - xalan - xalan - true - - - commons-net - commons-net - - - - - org.apache.activemq - activemq-openwire-generator + org.apache.servicemix.bundles + org.apache.servicemix.bundles.josql true @@ -148,101 +81,11 @@ slf4j-log4j12 test - - log4j - log4j - test - + - - - ${project.basedir}/src/main/resources - - **/* - - - - ${project.basedir}/src/main/filtered-resources - true - - **/* - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.activemq.protobuf - activemq-protobuf - [0.0.0,) - - compile - - - - - - - - - - - - - - maven-surefire-plugin - - always - ${surefire.argLine} - alphabetical - - - - org.apache.activemq.default.directory.prefix - target/ - - - - - - **/*Test.* - - - - - org.apache.activemq.protobuf - activemq-protobuf - - - - compile - - - - diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalTool.java b/activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalTool.java similarity index 100% rename from activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalTool.java rename to activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalTool.java diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalToolCommand.java b/activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalToolCommand.java similarity index 87% rename from activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalToolCommand.java rename to activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalToolCommand.java index c522cb446d..db983bad3f 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalToolCommand.java +++ b/activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalToolCommand.java @@ -26,6 +26,16 @@ public class AMQJournalToolCommand implements Command { private CommandContext context; + @Override + public String getName() { + return "journal-audit"; + } + + @Override + public String getOneLineDescription() { + return "Allows you to view records stored in the persistent journal."; + } + public void execute(List tokens) throws Exception { AMQJournalTool consumerTool = new AMQJournalTool(); String args[] = new String[tokens.size()]; diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/CustomResourceLoader.java b/activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/CustomResourceLoader.java similarity index 100% rename from activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/CustomResourceLoader.java rename to activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/CustomResourceLoader.java diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/Entry.java b/activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/Entry.java similarity index 100% rename from activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/Entry.java rename to activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/Entry.java diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/MessageBodyFormatter.java b/activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/MessageBodyFormatter.java similarity index 100% rename from activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/MessageBodyFormatter.java rename to activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/MessageBodyFormatter.java diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/reader/AMQIterator.java b/activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/reader/AMQIterator.java similarity index 100% rename from activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/reader/AMQIterator.java rename to activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/reader/AMQIterator.java diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/reader/AMQReader.java b/activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/reader/AMQReader.java similarity index 100% rename from activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/reader/AMQReader.java rename to activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/reader/AMQReader.java diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/reader/MessageLocation.java b/activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/reader/MessageLocation.java similarity index 100% rename from activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/reader/MessageLocation.java rename to activemq-amq-store/src/main/java/org/apache/activemq/console/command/store/amq/reader/MessageLocation.java diff --git a/activemq-optional/src/main/java/org/apache/activemq/store/amq/AMQJournalTool.java b/activemq-amq-store/src/main/java/org/apache/activemq/store/amq/AMQJournalTool.java similarity index 100% rename from activemq-optional/src/main/java/org/apache/activemq/store/amq/AMQJournalTool.java rename to activemq-amq-store/src/main/java/org/apache/activemq/store/amq/AMQJournalTool.java diff --git a/activemq-optional/src/main/java/org/apache/activemq/store/amq/AMQJournalToolCommand.java b/activemq-amq-store/src/main/java/org/apache/activemq/store/amq/AMQJournalToolCommand.java similarity index 87% rename from activemq-optional/src/main/java/org/apache/activemq/store/amq/AMQJournalToolCommand.java rename to activemq-amq-store/src/main/java/org/apache/activemq/store/amq/AMQJournalToolCommand.java index e3fb5a2609..6cd7f36180 100644 --- a/activemq-optional/src/main/java/org/apache/activemq/store/amq/AMQJournalToolCommand.java +++ b/activemq-amq-store/src/main/java/org/apache/activemq/store/amq/AMQJournalToolCommand.java @@ -26,6 +26,16 @@ public class AMQJournalToolCommand implements Command { private CommandContext context; + @Override + public String getName() { + return "journal-audit"; + } + + @Override + public String getOneLineDescription() { + return "Allows you to view records stored in the persistent journal."; + } + public void execute(List tokens) throws Exception { AMQJournalTool consumerTool = new AMQJournalTool(); String args[] = new String[tokens.size()]; diff --git a/activemq-optional/src/main/java/org/apache/activemq/store/amq/CommandLineSupport.java b/activemq-amq-store/src/main/java/org/apache/activemq/store/amq/CommandLineSupport.java similarity index 100% rename from activemq-optional/src/main/java/org/apache/activemq/store/amq/CommandLineSupport.java rename to activemq-amq-store/src/main/java/org/apache/activemq/store/amq/CommandLineSupport.java diff --git a/activemq-optional/src/main/java/org/apache/activemq/store/amq/CustomResourceLoader.java b/activemq-amq-store/src/main/java/org/apache/activemq/store/amq/CustomResourceLoader.java similarity index 100% rename from activemq-optional/src/main/java/org/apache/activemq/store/amq/CustomResourceLoader.java rename to activemq-amq-store/src/main/java/org/apache/activemq/store/amq/CustomResourceLoader.java diff --git a/activemq-optional/src/main/java/org/apache/activemq/store/amq/Entry.java b/activemq-amq-store/src/main/java/org/apache/activemq/store/amq/Entry.java similarity index 100% rename from activemq-optional/src/main/java/org/apache/activemq/store/amq/Entry.java rename to activemq-amq-store/src/main/java/org/apache/activemq/store/amq/Entry.java diff --git a/activemq-optional/src/main/java/org/apache/activemq/store/amq/MessageBodyFormatter.java b/activemq-amq-store/src/main/java/org/apache/activemq/store/amq/MessageBodyFormatter.java similarity index 100% rename from activemq-optional/src/main/java/org/apache/activemq/store/amq/MessageBodyFormatter.java rename to activemq-amq-store/src/main/java/org/apache/activemq/store/amq/MessageBodyFormatter.java diff --git a/activemq-optional/src/main/java/org/apache/activemq/store/amq/reader/AMQIterator.java b/activemq-amq-store/src/main/java/org/apache/activemq/store/amq/reader/AMQIterator.java similarity index 100% rename from activemq-optional/src/main/java/org/apache/activemq/store/amq/reader/AMQIterator.java rename to activemq-amq-store/src/main/java/org/apache/activemq/store/amq/reader/AMQIterator.java diff --git a/activemq-optional/src/main/java/org/apache/activemq/store/amq/reader/AMQReader.java b/activemq-amq-store/src/main/java/org/apache/activemq/store/amq/reader/AMQReader.java similarity index 100% rename from activemq-optional/src/main/java/org/apache/activemq/store/amq/reader/AMQReader.java rename to activemq-amq-store/src/main/java/org/apache/activemq/store/amq/reader/AMQReader.java diff --git a/activemq-optional/src/main/java/org/apache/activemq/store/amq/reader/MessageLocation.java b/activemq-amq-store/src/main/java/org/apache/activemq/store/amq/reader/MessageLocation.java similarity index 100% rename from activemq-optional/src/main/java/org/apache/activemq/store/amq/reader/MessageLocation.java rename to activemq-amq-store/src/main/java/org/apache/activemq/store/amq/reader/MessageLocation.java diff --git a/activemq-amq-store/src/main/resources/META-INF/services/org.apache.activemq.console.command.Command b/activemq-amq-store/src/main/resources/META-INF/services/org.apache.activemq.console.command.Command new file mode 100644 index 0000000000..7e264532a0 --- /dev/null +++ b/activemq-amq-store/src/main/resources/META-INF/services/org.apache.activemq.console.command.Command @@ -0,0 +1,17 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- +org.apache.activemq.console.command.store.amq.AMQJournalToolCommand diff --git a/activemq-optional/src/main/resources/org/apache/activemq/store/amq/help.txt b/activemq-amq-store/src/main/resources/org/apache/activemq/store/amq/help.txt similarity index 100% rename from activemq-optional/src/main/resources/org/apache/activemq/store/amq/help.txt rename to activemq-amq-store/src/main/resources/org/apache/activemq/store/amq/help.txt diff --git a/activemq-console/src/test/java/org/apache/activemq/console/command/AMQJournalToolTest.java b/activemq-amq-store/src/test/java/org/apache/activemq/console/command/AMQJournalToolTest.java similarity index 100% rename from activemq-console/src/test/java/org/apache/activemq/console/command/AMQJournalToolTest.java rename to activemq-amq-store/src/test/java/org/apache/activemq/console/command/AMQJournalToolTest.java diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerFactory.java b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerFactory.java index 34ae16b0be..cfc4bbe4be 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerFactory.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerFactory.java @@ -98,4 +98,20 @@ public final class BrokerFactory { return createBroker(new URI(brokerURI), startBroker); } + private static final ThreadLocal START_DEFAULT = new ThreadLocal(); + + public static void setStartDefault(boolean startDefault) { + START_DEFAULT.set(startDefault); + } + public static void resetStartDefault() { + START_DEFAULT.remove(); + } + + public static boolean getStartDefault() { + Boolean value = START_DEFAULT.get(); + if( value==null ) { + return true; + } + return value.booleanValue(); + } } diff --git a/activemq-console/pom.xml b/activemq-console/pom.xml index a6b6b75cad..ce9e797acf 100644 --- a/activemq-console/pom.xml +++ b/activemq-console/pom.xml @@ -47,14 +47,14 @@ - - ${project.groupId} - activemq-spring - - - ${project.groupId} - activemq-amq-store - + + + + + + + + ${project.groupId} activemq-kahadb-store diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/AmqBrowseCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/AmqBrowseCommand.java index 7dc0bacc89..725f743b1d 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/AmqBrowseCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/AmqBrowseCommand.java @@ -30,6 +30,7 @@ import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.console.util.AmqMessagesUtil; public class AmqBrowseCommand extends AbstractAmqCommand { + public static final String QUEUE_PREFIX = "queue:"; public static final String TOPIC_PREFIX = "topic:"; @@ -88,6 +89,16 @@ public class AmqBrowseCommand extends AbstractAmqCommand { private final Set groupViews = new HashSet(10); private final Set queryViews = new HashSet(10); + @Override + public String getName() { + return "browse"; + } + + @Override + public String getOneLineDescription() { + return "Display selected messages in a specified destination."; + } + /** * Execute the browse command, which allows you to browse the messages in a * given JMS destination diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/BrowseCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/BrowseCommand.java index 8730e7c335..aca0405edb 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/BrowseCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/BrowseCommand.java @@ -79,6 +79,16 @@ public class BrowseCommand extends AbstractJmxCommand { private final Set groupViews = new HashSet(10); private final Set queryViews = new HashSet(10); + @Override + public String getName() { + return "browse"; + } + + @Override + public String getOneLineDescription() { + return "Used to browse a destination"; + } + /** * Execute the browse command, which allows you to browse the messages in a * given JMS destination diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/BstatCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/BstatCommand.java index 61c7fed780..69cab1cbfb 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/BstatCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/BstatCommand.java @@ -40,7 +40,17 @@ public class BstatCommand extends QueryCommand { " activemq-admin bstat localhost", " - Display a summary of statistics for the broker 'localhost'" }; - + + @Override + public String getName() { + return "bstat"; + } + + @Override + public String getOneLineDescription() { + return "Performs a predefined query that displays useful statistics regarding the specified broker"; + } + /** * Performs a predefiend query option * @param tokens - command arguments diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/Command.java b/activemq-console/src/main/java/org/apache/activemq/console/command/Command.java index 5b62687287..c65682a5c9 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/Command.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/Command.java @@ -22,7 +22,11 @@ import java.util.List; import org.apache.activemq.console.CommandContext; public interface Command { - + + String getName(); + + String getOneLineDescription(); + void setCommandContext( CommandContext context ); /** diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/CreateCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/CreateCommand.java index f2519903bb..0e708e1d60 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/CreateCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/CreateCommand.java @@ -67,6 +67,16 @@ public class CreateCommand extends AbstractCommand { protected File amqHome; protected File targetAmqBase; + @Override + public String getName() { + return "create"; + } + + @Override + public String getOneLineDescription() { + return "Creates a runnable broker instance in the specified path."; + } + protected void runTask(List tokens) throws Exception { context.print("Running create broker task..."); amqHome = new File(System.getProperty("activemq.home")); diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/DecryptCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/DecryptCommand.java index 2bff397825..6ba22d3f10 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/DecryptCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/DecryptCommand.java @@ -34,6 +34,16 @@ public class DecryptCommand extends EncryptCommand { "" }; + @Override + public String getName() { + return "decrypt"; + } + + @Override + public String getOneLineDescription() { + return "Decrypts given text"; + } + @Override protected void runTask(List tokens) throws Exception { if (password == null || input == null) { diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/EncryptCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/EncryptCommand.java index d3d81fd18c..6d8172dcbc 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/EncryptCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/EncryptCommand.java @@ -38,6 +38,16 @@ public class EncryptCommand extends AbstractCommand { String input; String password; + @Override + public String getName() { + return "encrypt"; + } + + @Override + public String getOneLineDescription() { + return "Encrypts given text"; + } + @Override protected void printHelp() { context.printHelp(helpFile); diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/ListCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/ListCommand.java index 62d0165708..322c197647 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/ListCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/ListCommand.java @@ -39,6 +39,16 @@ public class ListCommand extends AbstractJmxCommand { "" }; + @Override + public String getName() { + return "list"; + } + + @Override + public String getOneLineDescription() { + return "Lists all available brokers in the specified JMX context"; + } + /** * List all running brokers registered in the specified JMX context * @param tokens - command arguments diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/PurgeCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/PurgeCommand.java index 77270258a4..8d4c29223d 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/PurgeCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/PurgeCommand.java @@ -70,6 +70,16 @@ public class PurgeCommand extends AbstractJmxCommand { private final List queryAddObjects = new ArrayList(10); private final List querySubObjects = new ArrayList(10); + @Override + public String getName() { + return "purge"; + } + + @Override + public String getOneLineDescription() { + return "Delete selected destination's messages that matches the message selector"; + } + /** * Execute the purge command, which allows you to purge the messages in a * given JMS destination diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java index e2267babc8..9a47f9fd16 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/QueryCommand.java @@ -98,6 +98,16 @@ public class QueryCommand extends AbstractJmxCommand { private final List querySubObjects = new ArrayList(10); private final Set queryViews = new HashSet(10); + @Override + public String getName() { + return "query"; + } + + @Override + public String getOneLineDescription() { + return "Display selected broker component's attributes and statistics."; + } + /** * Queries the mbeans registered in the specified JMX context * diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java index de9f6846f6..6c5ccd9963 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/ShellCommand.java @@ -16,15 +16,12 @@ */ package org.apache.activemq.console.command; +import org.apache.activemq.console.CommandContext; +import org.apache.activemq.console.formatter.CommandShellOutputFormatter; + import java.io.InputStream; import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.activemq.console.CommandContext; -import org.apache.activemq.console.command.store.amq.AMQJournalToolCommand; -import org.apache.activemq.console.formatter.CommandShellOutputFormatter; +import java.util.*; public class ShellCommand extends AbstractCommand { @@ -37,36 +34,52 @@ public class ShellCommand extends AbstractCommand { public ShellCommand(boolean interactive) { this.interactive = interactive; - this.helpFile = new String[] { - interactive ? "Usage: [task] [task-options] [task data]" : "Usage: Main [--extdir ] [task] [task-options] [task data]", - "", - "Tasks:", - " start - Creates and starts a broker using a configuration file, or a broker URI.", - " create - Creates a runnable broker instance in the specified path", - " 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.", - " journal-audit - Allows you to view records stored in the persistent journal.", - " export - Exports a stopped brokers data files to an archive file", - " purge - Delete selected destination's messages that matches the message selector", - " encrypt - Encrypts given text", - " decrypt - Decrypts given text", - "", - "Task Options (Options specific to each task):", - " --extdir - 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 " + (interactive ? "" : "Main ") + "[task] -h,-?,--help", - "", - "Task Data:", - " - Information needed by each specific task.", - "", - "JMX system property options:", - " -Dactivemq.jmx.url= (default is: 'service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi')", - " -Dactivemq.jmx.user=", - " -Dactivemq.jmx.password=", - "" - }; + ArrayList help = new ArrayList(); + help.addAll(Arrays.asList(new String[] { + interactive ? "Usage: [task] [task-options] [task data]" : "Usage: Main [--extdir ] [task] [task-options] [task data]", + "", + "Tasks:"})); + + ArrayList commands = getCommands(); + Collections.sort(commands, new Comparator() { + @Override + public int compare(Command command, Command command1) { + return command.getName().compareTo(command1.getName()); + } + }); + + for( Command command: commands) { + help.add(String.format(" %-24s - %s", command.getName(), command.getOneLineDescription())); + } + + help.addAll(Arrays.asList(new String[] { + "", + "Task Options (Options specific to each task):", + " --extdir - 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 " + (interactive ? "" : "Main ") + "[task] -h,-?,--help", + "", + "Task Data:", + " - Information needed by each specific task.", + "", + "JMX system property options:", + " -Dactivemq.jmx.url= (default is: 'service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi')", + " -Dactivemq.jmx.user=", + " -Dactivemq.jmx.password=", + "" + })); + + this.helpFile = help.toArray(new String[help.size()]); + } + + @Override + public String getName() { + return "shell"; + } + + @Override + public String getOneLineDescription() { + return "Runs the activemq sub shell"; } /** @@ -116,36 +129,22 @@ public class ShellCommand extends AbstractCommand { if (tokens.size() > 0) { Command command=null; String taskToken = (String)tokens.remove(0); - if (taskToken.equals("start")) { - command = new StartCommand(); - } else if (taskToken.equals("create")) { - command = new CreateCommand(); - } else if (taskToken.equals("stop")) { - command = new ShutdownCommand(); - } else if (taskToken.equals("list")) { - command = new ListCommand(); - } else if (taskToken.equals("query")) { - command = new QueryCommand(); - } else if (taskToken.equals("bstat")) { - command = new BstatCommand(); - } else if (taskToken.equals("browse")) { - command = new AmqBrowseCommand(); - } else if (taskToken.equals("purge")) { - command = new PurgeCommand(); - } else if (taskToken.equals("journal-audit")) { - command = new AMQJournalToolCommand(); - } else if (taskToken.equals("encrypt")) { - command = new EncryptCommand(); - } else if (taskToken.equals("decrypt")) { - command = new DecryptCommand(); - } else if (taskToken.equals("export")) { - command = new StoreExportCommand(); - } else if (taskToken.equals("help")) { - printHelp(); - } else { - printHelp(); + + + for( Command c: getCommands() ) { + if( taskToken.equals(c.getName()) ) { + command = c; + break; + } } - + if( command == null ) { + if (taskToken.equals("help")) { + printHelp(); + } else { + printHelp(); + } + } + if( command!=null ) { command.setCommandContext(context); command.execute(tokens); @@ -156,6 +155,15 @@ public class ShellCommand extends AbstractCommand { } + ArrayList getCommands() { + ServiceLoader loader = ServiceLoader.load(Command.class); + ArrayList rc = new ArrayList(); + for( Command command: loader ) { + rc.add(command); + } + return rc; + } + /** * Print the help messages for the browse command */ diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java index a88c9351c3..0e3061f88c 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/ShutdownCommand.java @@ -52,6 +52,16 @@ public class ShutdownCommand extends AbstractJmxCommand { private boolean isStopAllBrokers; + @Override + public String getName() { + return "stop"; + } + + @Override + public String getOneLineDescription() { + return "Stops a running broker specified by the broker name."; + } + /** * Shuts down the specified broker or brokers * diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/StartCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/StartCommand.java index 89eacf7034..0fe42e624f 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/StartCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/StartCommand.java @@ -61,6 +61,16 @@ public class StartCommand extends AbstractCommand { private URI configURI; private List brokers = new ArrayList(5); + @Override + public String getName() { + return "start"; + } + + @Override + public String getOneLineDescription() { + return "Creates and starts a broker using a configuration file, or a broker URI."; + } + /** * The default task to start a broker or a group of brokers * diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/StopGracefullyCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/StopGracefullyCommand.java index 75de2fdd8e..56e3b482e9 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/StopGracefullyCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/StopGracefullyCommand.java @@ -32,6 +32,16 @@ import javax.management.ObjectName; */ public class StopGracefullyCommand extends ShutdownCommand { + @Override + public String getName() { + return "stop-gracefully"; + } + + @Override + public String getOneLineDescription() { + return "Stops a running broker gracefully."; + } + protected String connectorName, queueName; protected long timeout; protected long pollInterval; diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/StoreExportCommand.java b/activemq-console/src/main/java/org/apache/activemq/console/command/StoreExportCommand.java index 21f03d9110..c53add7039 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/StoreExportCommand.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/StoreExportCommand.java @@ -35,6 +35,16 @@ public class StoreExportCommand implements Command { this.context = context; } + @Override + public String getName() { + return "export"; + } + + @Override + public String getOneLineDescription() { + return "Exports a stopped brokers data files to an archive file"; + } + @Override public void execute(List tokens) throws Exception { StoreExporter exporter = new StoreExporter(); diff --git a/activemq-console/src/main/java/org/apache/activemq/console/command/store/StoreExporter.java b/activemq-console/src/main/java/org/apache/activemq/console/command/store/StoreExporter.java index eef25f6afd..c6bc8bd6ff 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/command/store/StoreExporter.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/command/store/StoreExporter.java @@ -24,7 +24,6 @@ import org.apache.activemq.console.command.store.proto.QueueEntryPB; import org.apache.activemq.console.command.store.proto.QueuePB; import org.apache.activemq.openwire.OpenWireFormat; import org.apache.activemq.store.*; -import org.apache.activemq.xbean.XBeanBrokerFactory; import org.codehaus.jackson.map.ObjectMapper; import org.fusesource.hawtbuf.AsciiBuffer; import org.fusesource.hawtbuf.DataByteArrayOutputStream; @@ -70,9 +69,9 @@ public class StoreExporter { throw new Exception("required --file option missing"); } System.out.println("Loading: " + config); - XBeanBrokerFactory.setStartDefault(false); // to avoid the broker auto-starting.. + BrokerFactory.setStartDefault(false); // to avoid the broker auto-starting.. BrokerService broker = BrokerFactory.createBroker(config); - XBeanBrokerFactory.resetStartDefault(); + BrokerFactory.resetStartDefault(); PersistenceAdapter store = broker.getPersistenceAdapter(); System.out.println("Starting: " + store); store.start(); diff --git a/activemq-console/src/main/resources/META-INF/services/org.apache.activemq.console.command.Command b/activemq-console/src/main/resources/META-INF/services/org.apache.activemq.console.command.Command new file mode 100644 index 0000000000..ec377fabe6 --- /dev/null +++ b/activemq-console/src/main/resources/META-INF/services/org.apache.activemq.console.command.Command @@ -0,0 +1,27 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- +org.apache.activemq.console.command.CreateCommand +org.apache.activemq.console.command.StartCommand +org.apache.activemq.console.command.ShutdownCommand +org.apache.activemq.console.command.ListCommand +org.apache.activemq.console.command.AmqBrowseCommand +org.apache.activemq.console.command.QueryCommand +org.apache.activemq.console.command.BstatCommand +org.apache.activemq.console.command.EncryptCommand +org.apache.activemq.console.command.DecryptCommand +org.apache.activemq.console.command.StoreExportCommand +org.apache.activemq.console.command.PurgeCommand diff --git a/activemq-console/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java b/activemq-core/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java similarity index 100% rename from activemq-console/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java rename to activemq-core/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java diff --git a/activemq-console/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java b/activemq-core/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java similarity index 100% rename from activemq-console/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java rename to activemq-core/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java diff --git a/activemq-console/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java b/activemq-core/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java similarity index 100% rename from activemq-console/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java rename to activemq-core/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java diff --git a/activemq-console/src/test/java/org/apache/activemq/console/command/TestAMQ3410.java b/activemq-core/src/test/java/org/apache/activemq/console/command/TestAMQ3410.java similarity index 98% rename from activemq-console/src/test/java/org/apache/activemq/console/command/TestAMQ3410.java rename to activemq-core/src/test/java/org/apache/activemq/console/command/TestAMQ3410.java index d8c01875ea..04a6708d5b 100644 --- a/activemq-console/src/test/java/org/apache/activemq/console/command/TestAMQ3410.java +++ b/activemq-core/src/test/java/org/apache/activemq/console/command/TestAMQ3410.java @@ -52,7 +52,7 @@ public class TestAMQ3410 extends TestCase { } protected AbstractApplicationContext createApplicationContext() { - return new ClassPathXmlApplicationContext("activemq.xml"); + return new ClassPathXmlApplicationContext("org/apache/activemq/console/command/activemq.xml"); } protected void tearDown() throws Exception { diff --git a/activemq-console/src/test/java/org/apache/activemq/console/command/TestAMQ3411.java b/activemq-core/src/test/java/org/apache/activemq/console/command/TestAMQ3411.java similarity index 98% rename from activemq-console/src/test/java/org/apache/activemq/console/command/TestAMQ3411.java rename to activemq-core/src/test/java/org/apache/activemq/console/command/TestAMQ3411.java index a950ec8b60..2dd19efe4f 100644 --- a/activemq-console/src/test/java/org/apache/activemq/console/command/TestAMQ3411.java +++ b/activemq-core/src/test/java/org/apache/activemq/console/command/TestAMQ3411.java @@ -51,7 +51,7 @@ public class TestAMQ3411 extends TestCase { } protected AbstractApplicationContext createApplicationContext() { - return new ClassPathXmlApplicationContext("activemq.xml"); + return new ClassPathXmlApplicationContext("org/apache/activemq/console/command/activemq.xml"); } protected void tearDown() throws Exception { diff --git a/activemq-console/src/test/java/org/apache/activemq/console/command/TestPurgeCommand.java b/activemq-core/src/test/java/org/apache/activemq/console/command/TestPurgeCommand.java similarity index 99% rename from activemq-console/src/test/java/org/apache/activemq/console/command/TestPurgeCommand.java rename to activemq-core/src/test/java/org/apache/activemq/console/command/TestPurgeCommand.java index 86d8fa9841..3a00ab4bad 100644 --- a/activemq-console/src/test/java/org/apache/activemq/console/command/TestPurgeCommand.java +++ b/activemq-core/src/test/java/org/apache/activemq/console/command/TestPurgeCommand.java @@ -118,7 +118,7 @@ public class TestPurgeCommand extends TestCase { } protected AbstractApplicationContext createApplicationContext() { - return new ClassPathXmlApplicationContext("activemq.xml"); + return new ClassPathXmlApplicationContext("org/apache/activemq/console/command/activemq.xml"); } protected void tearDown() throws Exception { diff --git a/activemq-console/src/test/resources/activemq.xml b/activemq-core/src/test/resources/org/apache/activemq/console/command/activemq.xml similarity index 98% rename from activemq-console/src/test/resources/activemq.xml rename to activemq-core/src/test/resources/org/apache/activemq/console/command/activemq.xml index e80f32292a..b2aaf16a09 100644 --- a/activemq-console/src/test/resources/activemq.xml +++ b/activemq-core/src/test/resources/org/apache/activemq/console/command/activemq.xml @@ -6,9 +6,9 @@ The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,10 +24,10 @@ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> - + - + @@ -35,10 +35,10 @@ - + - @@ -48,7 +48,7 @@ - + @@ -57,21 +57,21 @@ - + - - + + diff --git a/activemq-optional/pom.xml b/activemq-optional/pom.xml index e1a9adef8d..32f1269bb4 100755 --- a/activemq-optional/pom.xml +++ b/activemq-optional/pom.xml @@ -177,14 +177,6 @@ jettison test - - org.apache.velocity - velocity - - - org.apache.servicemix.bundles - org.apache.servicemix.bundles.josql -