activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r375519 [3/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
Added: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/GlobalWriter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/GlobalWriter.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/GlobalWriter.java
(added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/GlobalWriter.java
Mon Feb  6 22:48:24 2006
@@ -0,0 +1,232 @@
+/**
+ *
+ * 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.formatter;
+
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.AttributeList;
+import javax.jms.Message;
+import java.util.Map;
+import java.util.Collection;
+import java.io.OutputStream;
+
+public class GlobalWriter {
+    private static OutputFormatter formatter;
+
+    /**
+     * Creates a singleton global writer
+     */
+    private GlobalWriter() {
+    }
+
+    /**
+     * Maintains a global output formatter
+     * @param formatter - the output formatter to use
+     */
+    public static void instantiate(OutputFormatter formatter) {
+        if (GlobalWriter.formatter == null) {
+            GlobalWriter.formatter = formatter;
+        }
+    }
+
+    /**
+     * Retrieve the output stream being used by the global formatter
+     * @return
+     */
+    public static OutputStream getOutputStream() {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        return formatter.getOutputStream();
+    }
+
+    /**
+     * Print an ObjectInstance format of an mbean
+     * @param mbean - mbean to print
+     */
+    public static void printMBean(ObjectInstance mbean) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printMBean(mbean);
+    }
+
+    /**
+     * Print an ObjectName format of an mbean
+     * @param mbean - mbean to print
+     */
+    public static void printMBean(ObjectName mbean) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printMBean(mbean);
+    }
+
+    /**
+     * Print an AttributeList format of an mbean
+     * @param mbean - mbean to print
+     */
+    public static void printMBean(AttributeList mbean) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printMBean(mbean);
+    }
+
+    /**
+     * Print a Map format of an mbean
+     * @param mbean
+     */
+    public static void printMBean(Map mbean) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printMBean(mbean);
+    }
+
+    /**
+     * Print a Collection format of mbeans
+     * @param mbean - collection of mbeans
+     */
+    public static void printMBean(Collection mbean) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printMBean(mbean);
+    }
+
+    /**
+     * Print a Map format of a JMS message
+     * @param msg
+     */
+    public static void printMessage(Map msg) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printMessage(msg);
+    }
+
+    /**
+     * Print a Message format of a JMS message
+     * @param msg - JMS message to print
+     */
+    public static void printMessage(Message msg) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printMessage(msg);
+    }
+
+    /**
+     * Print a collection of JMS messages
+     * @param msg - collection of JMS messages
+     */
+    public static void printMessage(Collection msg) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printMessage(msg);
+    }
+
+    /**
+     * Print help messages
+     * @param helpMsgs - help messages to print
+     */
+    public static void printHelp(String[] helpMsgs) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printHelp(helpMsgs);
+    }
+
+    /**
+     * Print an information message
+     * @param info - information message to print
+     */
+    public static void printInfo(String info) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printInfo(info);
+    }
+
+    /**
+     * Print an exception message
+     * @param e - exception to print
+     */
+    public static void printException(Exception e) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printException(e);
+    }
+
+    /**
+     * Print a version information
+     * @param version - version info to print
+     */
+    public static void printVersion(String version) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.printVersion(version);
+    }
+
+    /**
+     * Print a generic key value mapping
+     * @param map to print
+     */
+    public static void print(Map map) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.print(map);
+    }
+
+    /**
+     * Print a generic array of strings
+     * @param strings - string array to print
+     */
+    public static void print(String[] strings) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.print(strings);
+    }
+
+    /**
+     * Print a collection of objects
+     * @param collection - collection to print
+     */
+    public static void print(Collection collection) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.print(collection);
+    }
+
+    /**
+     * Print a java string
+     * @param string - string to print
+     */
+    public static void print(String string) {
+        if (formatter == null) {
+            throw new IllegalStateException("No OutputFormatter specified. Use GlobalWriter.instantiate(OutputFormatter).");
+        }
+        formatter.print(string);
+    }
+}

Added: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/OutputFormatter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/OutputFormatter.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/OutputFormatter.java
(added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/formatter/OutputFormatter.java
Mon Feb  6 22:48:24 2006
@@ -0,0 +1,130 @@
+/**
+ *
+ * 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.formatter;
+
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.AttributeList;
+import javax.jms.Message;
+import java.util.Collection;
+import java.util.Map;
+import java.io.OutputStream;
+
+public interface OutputFormatter {
+
+    /**
+     * Retrieve the output stream being used by the formatter
+     * @return
+     */
+    public OutputStream getOutputStream();
+
+    /**
+     * Print an ObjectInstance format of an mbean
+     * @param mbean - mbean to print
+     */
+    public void printMBean(ObjectInstance mbean);
+
+    /**
+     * Print an ObjectName format of an mbean
+     * @param mbean - mbean to print
+     */
+    public void printMBean(ObjectName mbean);
+
+    /**
+     * Print an AttributeList format of an mbean
+     * @param mbean - mbean to print
+     */
+    public void printMBean(AttributeList mbean);
+
+    /**
+     * Print a Map format of an mbean
+     * @param mbean - mbean to print
+     */
+    public void printMBean(Map mbean);
+
+    /**
+     * Print a Collection format of mbeans
+     * @param mbean - collection of mbeans
+     */
+    public void printMBean(Collection mbean);
+
+    /**
+     * Print a Map format of a JMS message
+     * @param msg
+     */
+    public void printMessage(Map msg);
+
+    /**
+     * Print a Message format of a JMS message
+     * @param msg - JMS message to print
+     */
+    public void printMessage(Message msg);
+
+    /**
+     * Print a Collection format of JMS messages
+     * @param msg - collection of JMS messages
+     */
+    public void printMessage(Collection msg);
+
+    /**
+     * Print help messages
+     * @param helpMsgs - help messages to print
+     */
+    public void printHelp(String[] helpMsgs);
+
+    /**
+     * Print an information message
+     * @param info - information message to print
+     */
+    public void printInfo(String info);
+
+    /**
+     * Print an exception message
+     * @param e - exception to print
+     */
+    public void printException(Exception e);
+
+    /**
+     * Print a version information
+     * @param version - version info to print
+     */
+    public void printVersion(String version);
+
+    /**
+     * Print a generic key value mapping
+     * @param map to print
+     */
+    public void print(Map map);
+
+    /**
+     * Print a generic array of strings
+     * @param strings - string array to print
+     */
+    public void print(String[] strings);
+
+    /**
+     * Print a collection of objects
+     * @param collection - collection to print
+     */
+    public void print(Collection collection);
+
+    /**
+     * Print a java string
+     * @param string - string to print
+     */
+    public void print(String string);
+}

Added: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/util/AmqMessagesUtil.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/util/AmqMessagesUtil.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/util/AmqMessagesUtil.java
(added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/util/AmqMessagesUtil.java
Mon Feb  6 22:48:24 2006
@@ -0,0 +1,64 @@
+/**
+ *
+ * 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.util;
+
+import org.apache.activemq.console.filter.QueryFilter;
+import org.apache.activemq.console.filter.WildcardToMsgSelectorTransformFilter;
+import org.apache.activemq.console.filter.MessagesQueryFilter;
+import org.apache.activemq.console.filter.PropertiesViewFilter;
+import org.apache.activemq.console.filter.StubQueryFilter;
+import org.apache.activemq.console.filter.MapTransformFilter;
+import org.apache.activemq.console.filter.GroupPropertiesViewFilter;
+
+import javax.jms.Destination;
+import java.net.URI;
+import java.util.List;
+import java.util.Set;
+
+public class AmqMessagesUtil {
+    public static final String JMS_MESSAGE_HEADER_PREFIX = "JMS_HEADER_FIELD:";
+    public static final String JMS_MESSAGE_CUSTOM_PREFIX = "JMS_CUSTOM_FIELD:";
+    public static final String JMS_MESSAGE_BODY_PREFIX   = "JMS_BODY_FIELD:";
+
+    public static List getAllMessages(URI brokerUrl, Destination dest) throws Exception {
+       return getMessages(brokerUrl, dest, "");
+    }
+
+    public static List getMessages(URI brokerUrl, Destination dest, String selector) throws
Exception {
+        return createMessageQueryFilter(brokerUrl, dest).query(selector);
+    }
+
+    public static List getMessages(URI brokerUrl, Destination dest, List selectors) throws
Exception {
+        return createMessageQueryFilter(brokerUrl, dest).query(selectors);
+    }
+
+    public static List filterMessagesView(List messages, Set groupViews, Set attributeViews)
throws Exception {
+        return (new PropertiesViewFilter(attributeViews,
+            new GroupPropertiesViewFilter(groupViews,
+                new MapTransformFilter(
+                    new StubQueryFilter(messages)
+                )
+            )
+        )).query("");
+    }
+
+    public static QueryFilter createMessageQueryFilter(URI brokerUrl, Destination dest) {
+        return new WildcardToMsgSelectorTransformFilter(
+            new MessagesQueryFilter(brokerUrl, dest)
+        );
+    }
+}

Added: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/util/JmxMBeansUtil.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/util/JmxMBeansUtil.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/util/JmxMBeansUtil.java
(added)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/util/JmxMBeansUtil.java
Mon Feb  6 22:48:24 2006
@@ -0,0 +1,116 @@
+/**
+ *
+ * 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.util;
+
+import org.apache.activemq.console.filter.QueryFilter;
+import org.apache.activemq.console.filter.MBeansObjectNameQueryFilter;
+import org.apache.activemq.console.filter.WildcardToRegExTransformFilter;
+import org.apache.activemq.console.filter.MBeansRegExQueryFilter;
+import org.apache.activemq.console.filter.MBeansAttributeQueryFilter;
+import org.apache.activemq.console.filter.PropertiesViewFilter;
+import org.apache.activemq.console.filter.StubQueryFilter;
+import org.apache.activemq.console.filter.MapTransformFilter;
+
+import javax.management.remote.JMXServiceURL;
+import java.util.Set;
+import java.util.List;
+import java.util.Iterator;
+
+public class JmxMBeansUtil {
+
+    public static List getAllBrokers(JMXServiceURL jmxUrl) throws Exception {
+        return (new MBeansObjectNameQueryFilter(jmxUrl)).query("Type=Broker");
+    }
+
+    public static List getBrokersByName(JMXServiceURL jmxUrl, String brokerName) throws Exception
{
+        return (new MBeansObjectNameQueryFilter(jmxUrl)).query("Type=Broker,BrokerName="
+ brokerName);
+    }
+
+    public static List getAllBrokers(JMXServiceURL jmxUrl, Set attributes) throws Exception
{
+        return (new MBeansAttributeQueryFilter(jmxUrl, attributes, new MBeansObjectNameQueryFilter(jmxUrl))).query("Type=Broker");
+    }
+
+    public static List getBrokersByName(JMXServiceURL jmxUrl, String brokerName, Set attributes)
throws Exception {
+        return (new MBeansAttributeQueryFilter(jmxUrl, attributes, new MBeansObjectNameQueryFilter(jmxUrl))).query("Type=Broker,BrokerName="
+ brokerName);
+    }
+
+    public static List queryMBeans(JMXServiceURL jmxUrl, List queryList) throws Exception
{
+        // If there is no query defined get all mbeans
+        if (queryList==null || queryList.size()==0) {
+            return createMBeansObjectNameQuery(jmxUrl).query("");
+
+        // Parse through all the query strings
+        } else {
+            return createMBeansObjectNameQuery(jmxUrl).query(queryList);
+        }
+    }
+
+    public static List queryMBeans(JMXServiceURL jmxUrl, List queryList, Set attributes)
throws Exception {
+        // If there is no query defined get all mbeans
+        if (queryList==null || queryList.size()==0) {
+            return createMBeansAttributeQuery(jmxUrl, attributes).query("");
+
+        // Parse through all the query strings
+        } else {
+            return createMBeansAttributeQuery(jmxUrl, attributes).query(queryList);
+        }
+    }
+
+    public static List queryMBeans(JMXServiceURL jmxUrl, String queryString) throws Exception
{
+        return createMBeansObjectNameQuery(jmxUrl).query(queryString);
+    }
+
+    public static List queryMBeans(JMXServiceURL jmxUrl, String queryString, Set attributes)
throws Exception {
+        return createMBeansAttributeQuery(jmxUrl, attributes).query(queryString);
+    }
+
+    public static List filterMBeansView(List mbeans, Set viewFilter) throws Exception {
+        return (new PropertiesViewFilter(viewFilter, new MapTransformFilter(new StubQueryFilter(mbeans))).query(""));
+    }
+
+    public static String createQueryString(String query, String param) {
+        return query.replaceAll("%1", param);
+    }
+
+    public static String createQueryString(String query, List params) {
+
+        int count = 1;
+        for (Iterator i=params.iterator();i.hasNext();) {
+            query.replaceAll("%" + count++, i.next().toString());
+        }
+
+        return query;
+    }
+
+    public static QueryFilter createMBeansObjectNameQuery(JMXServiceURL jmxUrl) {
+        return new WildcardToRegExTransformFilter(       // Let us be able to accept wildcard
queries
+            new MBeansRegExQueryFilter(                  // Use regular expressions to filter
the query results
+                new MBeansObjectNameQueryFilter(jmxUrl)  // Let us retrieve the mbeans object
name specified by the query
+            )
+        );
+    }
+
+    public static QueryFilter createMBeansAttributeQuery(JMXServiceURL jmxUrl, Set attributes)
{
+        return new WildcardToRegExTransformFilter(                  // Let use be able to
accept wildcard queries
+            new MBeansRegExQueryFilter(                             // Use regular expressions
to filter the query result
+                new MBeansAttributeQueryFilter(jmxUrl, attributes,  // Retrieve the attributes
needed
+                    new MBeansObjectNameQueryFilter(jmxUrl)         // Retrieve the mbeans
object name specified by the query
+                )
+            )
+        );
+    }
+}

Added: incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/simple/Consumer.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/simple/Consumer.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/simple/Consumer.java
(added)
+++ incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/simple/Consumer.java
Mon Feb  6 22:48:24 2006
@@ -0,0 +1,71 @@
+/**
+ *
+ * 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.
+ */
+
+/**
+ * The SimpleQueueSender class consists only of a main method,
+ * which sends several messages to a queue.
+ *
+ * Run this program in conjunction with SimpleQueueReceiver.
+ * Specify a queue name on the command line when you run the
+ * program.  By default, the program sends one message.  Specify
+ * a number after the queue name to send that number of messages.
+ */
+package org.apache.activemq.simple;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.command.ActiveMQQueue;
+
+public class Consumer {
+    
+    public static void main(String[] args) throws JMSException, InterruptedException {
+
+        String url = "tcp://localhost:61616";
+        if( args.length>0 ) {
+            url = args[0];
+        }
+        
+        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
+        Destination destination = new ActiveMQQueue("TEST.QUEUE");
+
+        Connection connection = connectionFactory.createConnection();
+        connection.start();
+        
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageConsumer consumer = session.createConsumer(destination);
+        
+        for( ;; ) {
+            System.out.println("Waiting for message.");
+            Message message = consumer.receive();
+            if( message == null ) {
+                break;
+            }
+            System.out.println("Got message: " + message);
+        }        
+        
+        connection.close();        
+    }
+}
+
+// END SNIPPET: demo

Added: incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/simple/Producer.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/simple/Producer.java?rev=375519&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/simple/Producer.java
(added)
+++ incubator/activemq/trunk/activemq-console/src/test/java/org/apache/activemq/console/simple/Producer.java
Mon Feb  6 22:48:24 2006
@@ -0,0 +1,69 @@
+/**
+ *
+ * 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.
+ */
+/**
+ * The SimpleQueueSender class consists only of a main method,
+ * which sends several messages to a queue.
+ *
+ * Run this program in conjunction with SimpleQueueReceiver.
+ * Specify a queue name on the command line when you run the
+ * program.  By default, the program sends one message.  Specify
+ * a number after the queue name to send that number of messages.
+ */
+package org.apache.activemq.simple;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.command.ActiveMQQueue;
+
+public class Producer {
+
+    private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory
+            .getLog(Producer.class);
+    
+    public static void main(String[] args) throws JMSException, InterruptedException {
+
+        String url = "peer://localhost1/groupA?persistent=false";
+        if( args.length>0 ) {
+            url = args[0];
+        }
+
+        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
+        Destination destination = new ActiveMQQueue("TEST.QUEUE");
+
+        Connection connection = connectionFactory.createConnection();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageProducer producer = session.createProducer(destination);
+        TextMessage message = session.createTextMessage();
+        for (int i = 0; i < 1000; i++) {
+            message.setText("This is message " + (i + 1));
+            log.info("Sending message: " + message.getText());
+            producer.send(message);
+            Thread.sleep(1000);
+        }
+        connection.close();
+        
+    }
+}
+
+// END SNIPPET: demo

Modified: incubator/activemq/trunk/activemq-core/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/maven.xml?rev=375519&r1=375518&r2=375519&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/maven.xml (original)
+++ incubator/activemq/trunk/activemq-core/maven.xml Mon Feb  6 22:48:24 2006
@@ -149,50 +149,6 @@
       <path refid="maven.dependency.classpath" />
     </path>
   </goal>
-
-  <!-- ================================================================ -->
-  <!-- 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.broker.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.simple.Consumer" fork="false">
-      <classpath refid="test.classpath" />
-      <arg value="${uri}" />
-    </java>
-  </goal>
-
-  <goal name="setclasspath" prereqs="java:compile, test: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>
   
   <!-- ================================================================== -->
   <!-- GOALs for deploying resources -->

Modified: incubator/activemq/trunk/assembly/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/assembly/maven.xml?rev=375519&r1=375518&r2=375519&view=diff
==============================================================================
--- incubator/activemq/trunk/assembly/maven.xml (original)
+++ incubator/activemq/trunk/assembly/maven.xml Mon Feb  6 22:48:24 2006
@@ -107,9 +107,9 @@
     </ant:chmod>
 
     <ant:jar destfile="${maven.dist.bin.assembly.dir}/bin/run.jar" basedir="${maven.build.dir}/classes">
-      <ant:include name="org/apache/activemq/broker/Main*.class"/>
+      <ant:include name="org/apache/activemq/console/Main*.class"/>
       <ant:manifest>
-        <ant:attribute name="Main-Class" value="org.apache.activemq.broker.Main"/>
+        <ant:attribute name="Main-Class" value="org.apache.activemq.console.Main"/>
       </ant:manifest>
     </ant:jar>
     <ant:copy todir="${maven.dist.bin.assembly.dir/conf}">
@@ -254,7 +254,7 @@
         </j:if>
 
         <echo>Running an ActiveMQ server with $$config = ${config}</echo>
-        <java classname="org.apache.activemq.broker.Main" fork="yes" maxmemory="512M">
+        <java classname="org.apache.activemq.console.Main" fork="yes" maxmemory="512M">
           <classpath refid="test.classpath"/>
           <arg value="${config}"/>
           <j:if test="${!empty(debug)}">
@@ -274,7 +274,7 @@
         <!-- run simple server using just a URL -->
 
         <echo>Running an ActiveMQ server at $$url = ${url}</echo>
-        <java classname="org.apache.activemq.broker.Main" fork="yes" maxmemory="512M">
+        <java classname="org.apache.activemq.console.Main" fork="yes" maxmemory="512M">
           <classpath refid="test.classpath"/>
           <arg value="${url}"/>
 
@@ -319,7 +319,7 @@
           <jvmarg value="-Xbootclasspath/a:${OPTIT_HOME}/lib/oibcp.jar"/>
           <jvmarg value="-Xnoclassgc"/>
           <arg value="-pause"/>
-          <arg value="org.apache.activemq.spring.Main"/>
+          <arg value="org.apache.activemq.console.Main"/>
           <arg value="${config}"/>
         </java>
       </j:when>
@@ -336,7 +336,7 @@
           <jvmarg value="-Xbootclasspath/a:${OPTIT_HOME}/lib/oibcp.jar"/>
           <jvmarg value="-Xnoclassgc"/>
           <arg value="-pause"/>
-          <arg value="org.apache.activemq.broker.Main"/>
+          <arg value="org.apache.activemq.console.Main"/>
           <arg value="${url}"/>
           <sysproperty key="derby.system.home" value="target/derby"/>
           <sysproperty key="derby.storage.fileSyncTransactionLog" value="true"/>

Modified: incubator/activemq/trunk/assembly/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/assembly/pom.xml?rev=375519&r1=375518&r2=375519&view=diff
==============================================================================
--- incubator/activemq/trunk/assembly/pom.xml (original)
+++ incubator/activemq/trunk/assembly/pom.xml Mon Feb  6 22:48:24 2006
@@ -44,6 +44,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-console</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
       <artifactId>activemq-optional</artifactId>
       <version>${version}</version>
     </dependency>

Modified: incubator/activemq/trunk/assembly/project.properties
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/assembly/project.properties?rev=375519&r1=375518&r2=375519&view=diff
==============================================================================
--- incubator/activemq/trunk/assembly/project.properties (original)
+++ incubator/activemq/trunk/assembly/project.properties Mon Feb  6 22:48:24 2006
@@ -18,6 +18,6 @@
 http://cvs.apache.org/repository,\
 http://www.openejb.org/maven
 
-maven.jar.mainclass = org.apache.activemq.broker.Main
+maven.jar.mainclass = org.apache.activemq.console.Main
 
 maven.eclipse.classpath.include=src/test/resources

Modified: incubator/activemq/trunk/assembly/project.xml
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/assembly/project.xml?rev=375519&r1=375518&r2=375519&view=diff
==============================================================================
--- incubator/activemq/trunk/assembly/project.xml (original)
+++ incubator/activemq/trunk/assembly/project.xml Mon Feb  6 22:48:24 2006
@@ -66,6 +66,16 @@
       <artifactId>activemq-core-test</artifactId>
       <version>${pom.currentVersion}</version>
     </dependency>
+    
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>activemq-console</artifactId>
+      <version>${pom.currentVersion}</version>
+      <properties>
+          <activemq.module>true</activemq.module>
+          <lib>true</lib>
+        </properties>
+    </dependency>
 
     <dependency>
       <groupId>${pom.groupId}</groupId>

Modified: incubator/activemq/trunk/etc/project.properties
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/etc/project.properties?rev=375519&r1=375518&r2=375519&view=diff
==============================================================================
--- incubator/activemq/trunk/etc/project.properties (original)
+++ incubator/activemq/trunk/etc/project.properties Mon Feb  6 22:48:24 2006
@@ -24,7 +24,7 @@
 maven.junit.jvmargs=-Xmx256m 
 
 activemq.store.dir = target/MessageStore
-activemq.persistenceAdapterFactory = org.activemq.broker.impl.DefaultPersistenceAdapterFactory
+activemq.persistenceAdapterFactory = org.apache.activemq.store.DefaultPersistenceAdapterFactory
 derby.system.home = target/derby
 derby.storage.fileSyncTransactionLog=true
 java.security.auth.login.config=src/test/resources/login.config

Modified: incubator/activemq/trunk/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/pom.xml?rev=375519&r1=375518&r2=375519&view=diff
==============================================================================
--- incubator/activemq/trunk/pom.xml (original)
+++ incubator/activemq/trunk/pom.xml Mon Feb  6 22:48:24 2006
@@ -102,6 +102,7 @@
   <modules>
 
     <module>activemq-core</module>
+    <module>activemq-console</module>
     <module>activemq-ra</module>
     <module>activemq-jaas</module>
     <module>activemq-optional</module>

Modified: incubator/activemq/trunk/project.properties
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/project.properties?rev=375519&r1=375518&r2=375519&view=diff
==============================================================================
--- incubator/activemq/trunk/project.properties (original)
+++ incubator/activemq/trunk/project.properties Mon Feb  6 22:48:24 2006
@@ -12,6 +12,7 @@
 activemq-jaas/project.xml,\
 activemq-ra/project.xml,\
 activemq-web/project.xml,\
+activemq-console/project.xml,\
 assembly/project.xml
 #activeio/project.xml,\
 #activemq-systest/project.xml,\
@@ -19,7 +20,7 @@
 maven.multiproject.excludes=\
 etc/project.xml
 
-maven.jar.mainclass=org.activemq.broker.impl.Main
+maven.jar.mainclass=org.apache.activemq.console.Main
 
 # -------------------------------------------------------------------
 # ChangeLog Properties (Reports)



Mime
View raw message