You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2006/12/19 23:58:02 UTC

svn commit: r488847 [2/7] - in /incubator/qpid/branches/new_persistence/java/client: ./ src/old_test/ src/old_test/java/ src/old_test/java/org/ src/old_test/java/org/apache/ src/old_test/java/org/apache/qpid/ src/old_test/java/org/apache/qpid/IBMPerfTe...

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/bin/jmscts.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/bin/jmscts.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/bin/setenv.sh
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/bin/setenv.sh?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/bin/setenv.sh (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/bin/setenv.sh Tue Dec 19 14:57:56 2006
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+# ---------------------------------------------------------------------------
+# Sample environment script for JMS CTS
+#
+# This is invoked by jmscts.sh to configure:
+# . the CLASSPATH, for JMS provider jars
+# . JVM options
+#
+# The following configures the JMS CTS for OpenJMS 0.7.6
+# ---------------------------------------------------------------------------
+
+# Configure the CLASSPATH
+#
+DISTDIR="$IBASE/amqp/dist"
+LIBDIR="$IBASE/amqp/lib"
+
+CLASSPATH="$LIBDIR/jakarta-commons/commons-collections-3.1.jar:$LIBDIR/util-concurrent/backport-util-concurrent.jar:$LIBDIR/mina/mina-0.7.3.jar:$LIBDIR/jms/jms.jar:$LIBDIR/logging-log4j/log4j-1.2.9.jar:$DISTDIR/amqp-common.jar:$DISTDIR/amqp-jms.jar"
+
+# Configure JVM options
+#
+JAVA_OPTS=-Xmx512m -Xms512m
+JAVA_OPTS="$JAVA_OPTS \
+           -Damqj.logging.level=WARN"

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/bin/setenv.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/bin/setenv.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/jmscts.policy
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/jmscts.policy?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/jmscts.policy (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/jmscts.policy Tue Dec 19 14:57:56 2006
@@ -0,0 +1,22 @@
+// 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.
+//
+// grant all users all permissions. This is only for test cases
+// and should be modified for deployment
+grant {
+	permission java.security.AllPermission;
+};

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/jmscts.properties
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/jmscts.properties?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/jmscts.properties (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/jmscts.properties Tue Dec 19 14:57:56 2006
@@ -0,0 +1,71 @@
+#
+# 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.
+#
+
+# =============================================================================
+# General properties         
+# -----------------------------------------------------------------------------
+
+#
+# Username & password
+#   A user name and password for creating Connection instances via
+#   TopicConnectionFactory.createTopicConnection(...) etc
+#
+valid.username=guest
+valid.password=guest
+
+#
+# Invalid user name and password
+#   As above, but guaranteed to fail.
+#
+invalid.username=guest
+invalid.password=guest
+
+#
+# Message receipt timeout
+#   The default time to wait for messages, in milliseconds
+#
+org.exolab.jmscts.core.MessagingBehaviour.timeout=2000
+
+
+# =============================================================================
+# Compliance test properties
+# -----------------------------------------------------------------------------
+
+#
+# Expiration interval
+#   Time in milliseconds to wait for the JMS provider to collect expired
+#   messages. 
+#   This can be set for providers which collect expired messages periodically,
+#   rather than at the moment they expire.
+#   NOTE: for OpenJMS 0.7.6, this should be set to 5000
+org.exolab.jmscts.test.producer.ttl.ExpirationTest.expirationInterval=0
+
+
+# =============================================================================
+# Stress test properties
+# -----------------------------------------------------------------------------
+
+#
+# Each of the following properties determines the no. of messages that
+# will be sent by stress tests
+#
+org.exolab.jmscts.stress.Send0KTest.count=1000
+org.exolab.jmscts.stress.ReceiveSize0KTest.count=1000
+org.exolab.jmscts.stress.SendReceive0KTest.count=1000
+org.exolab.jmscts.stress.SendReceive2Size0KTest.count=1000

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/jmscts.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/providers.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/providers.xml?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/providers.xml (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/providers.xml Tue Dec 19 14:57:56 2006
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+
+<!-- ====================================================================== -->
+<!-- Sample provider configuration file                                     -->
+<!--                                                                        -->
+<!-- This configures JMS CTS to test OpenJMS                                -->
+<!-- ====================================================================== -->
+
+<configuration>
+
+  <provider>
+    <name>AMQP</name>
+    <class>org.exolab.jmscts.amqp.AMQPProvider</class>
+    <paths>
+      <path>/home/guso/harness/jmscts-0.5-b2/lib/amqp-provider-0.0a1.jar</path>
+    </paths>
+    <config>
+    </config>
+  </provider>
+
+</configuration>

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/config/providers.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/readme.txt
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/readme.txt?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/readme.txt (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/readme.txt Tue Dec 19 14:57:56 2006
@@ -0,0 +1,5 @@
+The files present in the bin, config and src directories should be copied over a complete copy of jms-cts-0.5-b2.
+
+The path entries on the config/providers.xml and src/compile.sh files should be changed before attempting to run.
+
+The scripts expect a properly configured IBASE environment. Before attempting to run, the amqp provider classes must be packaged and installed. The src/compile.sh script will help to achieve that.
\ No newline at end of file

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/readme.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/compile.sh
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/compile.sh?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/compile.sh (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/compile.sh Tue Dec 19 14:57:56 2006
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# 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.
+#
+
+
+JMSCTS_PATH=/home/guso/harness/jmscts-0.5-b2
+
+distjms="$IBASE/amqp/dist"
+lib="$IBASE/amqp/lib"
+lib2="$JMSCTS_PATH/lib/"
+libs="$lib/jakarta-commons/commons-collections-3.1.jar:$lib/util-concurrent/backport-util-concurrent.jar:$lib/mina/mina-0.7.3.jar:$lib/jms/jms.jar:$lib/logging-log4j/log4j-1.2.9.jar:$distjms/amqp-common.jar:$distjms/amqp-jms.jar"
+libs2="$lib2/ant-1.5.3-1.jar:$lib2/junit-3.8.1.jar:$lib2/ant-optional-1.5.3-1.jar:$lib2/log4j-1.2.7.jar:$lib2/castor-0.9.5.jar:$lib2/openjms-provider-0.5-b2.jar:$lib2/commons-cli-1.0.jar:$lib2/oro-2.0.7.jar:$lib2/commons-collections-2.1.jar:$lib2/xalan-2.5.1.jar:$lib2/commons-logging-1.0.2.jar:$lib2/xdoclet-1.2b2.jar:$lib2/concurrent-1.3.2.jar:$lib2/xdoclet-xdoclet-module-1.2b2.jar:$lib2/exolabcore-0.3.7.jar:$lib2/xdoclet-xjavadoc-uc-1.2b2.jar:$lib2/jms-1.0.2a.jar:$lib2/xerces-2.3.0.jar:$lib2/jmscts-0.5-b2.jar:$lib2/xml-apis-1.0.b2.jar"
+
+javac -classpath $libs:$libs2 $JMSCTS_PATH/src/providers/amqp/org/exolab/jmscts/amqp/*.java
+cd $JMSCTS_PATH/src/providers/amqp
+jar cvf amqp-provider-0.0a1.jar org/exolab/jmscts/amqp/*.class
+mv amqp-provider-0.0a1.jar $lib2
+

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/compile.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/compile.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,242 @@
+/**
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright
+ *    statements and notices.  Redistributions must also contain a
+ *    copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the
+ *    above copyright notice, this list of conditions and the
+ *    following disclaimer in the documentation and/or other
+ *    materials provided with the distribution.
+ *
+ * 3. The name "Exolab" must not be used to endorse or promote
+ *    products derived from this Software without prior written
+ *    permission of Exoffice Technologies.  For written permission,
+ *    please contact jima@intalio.com.
+ *
+ * 4. Products derived from this Software may not be called "Exolab"
+ *    nor may "Exolab" appear in their names without prior written
+ *    permission of Exoffice Technologies. Exolab is a registered
+ *    trademark of Exoffice Technologies.
+ *
+ * 5. Due credit should be given to the Exolab Project
+ *    (http://www.exolab.org/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
+ * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Copyright 2001, 2003 (C) Exoffice Technologies Inc. All Rights Reserved.
+ *
+ */
+package org.apache.qpid.cts.src.providers.amqp.org.exolab.jmscts.amqp;
+
+import org.apache.qpid.client.*;
+import org.exolab.jmscts.provider.Administrator;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+import java.net.InetAddress;
+import java.util.HashMap;
+
+/**
+ * This class provides methods for obtaining and manipulating administered
+ * objects managed by the Sonicmq implementation of JMS
+ *
+ */
+class AMQPAdministrator implements Administrator {
+    // AMQ Connection configuration
+    private int port = 5672;
+    private String host = "localhost";
+    private String user = "guest";
+    private String pass = "guest";
+    private String vhost = "/test";
+
+    // The cached broker connection & session
+    private AMQConnection _connection = null;
+    private Session _session = null;
+
+    // Factory request names
+    private static final String QUEUE_CONNECTION_FACTORY = "QueueConnectionFactory";
+    private static final String TOPIC_CONNECTION_FACTORY = "TopicConnectionFactory";
+
+    /**
+     * The cache of known administered objects
+     */
+    private HashMap<String, Object> _directory = new HashMap<String, Object>();
+
+    /**
+     * Returns the name of the QueueConnectionFactory bound in JNDI
+     *
+     * @return the default QueueConnectionFactory name
+     */
+    public String getQueueConnectionFactory() {
+        return QUEUE_CONNECTION_FACTORY;
+    }
+
+    /**
+     * Returns the name of the TopicConnectionFactory bound in JNDI
+     *
+     * @return the default TopicConnectionFactory name
+     */
+    public String getTopicConnectionFactory() {
+        return TOPIC_CONNECTION_FACTORY;
+    }
+
+    /**
+     * Returns the name of the XAQueueConnectionFactory bound in JNDI
+     *
+     * @return the default XAQueueConnectionFactory name
+     */
+    public String getXAQueueConnectionFactory() {
+        return null;
+    }
+
+    /**
+     * Returns the name of the XATopicConnectionFactory bound in JNDI
+     *
+     * @return the default XATopicConnectionFactory name
+     */
+    public String getXATopicConnectionFactory() {
+        return null;
+    }
+
+    /**
+     * Look up the named administered object
+     *
+     * @param name the name that the administered object is bound to
+     * @return the administered object bound to name
+     * @throws NamingException if the object is not bound, or the lookup fails
+     */
+    public Object lookup(String name) throws NamingException {
+        Object result = _directory.get(name);
+        if (result == null) {
+            if (name.equals(QUEUE_CONNECTION_FACTORY)) {
+                _directory.put(QUEUE_CONNECTION_FACTORY, new AMQConnectionFactory(host, port, user, pass, vhost));
+            } else if (name.equals(TOPIC_CONNECTION_FACTORY)) {
+                _directory.put(TOPIC_CONNECTION_FACTORY, new AMQConnectionFactory(host, port, user, pass, vhost));
+            } else {
+                throw new NameNotFoundException("Name not found: " + name);
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Create an administered destination
+     *
+     * @param name the destination name
+     * @param queue if true, create a queue, else create a topic
+     * @throws JMSException if the destination cannot be created
+     */
+    public void createDestination(String name, boolean queue)
+        throws JMSException {
+        AMQDestination destination = null;
+
+        try {
+            if (queue) {
+                destination = new AMQQueue(name);
+                createConsumer(destination);
+            } else {
+                destination = new AMQTopic(name);
+                createConsumer(destination);
+            }
+
+            _directory.put(name, destination);
+        } catch (Exception exception) {
+            JMSException error = new JMSException(exception.getMessage());
+            error.setLinkedException(exception);
+            throw error;
+        }
+    }
+
+    /**
+     * Destroy an administered destination
+     *
+     * @param name the destination name
+     * @throws JMSException if the destination cannot be destroyed
+     */
+    public void destroyDestination(String name)
+        throws JMSException {
+
+        try {
+            Destination destination = (Destination) lookup(name);
+            _directory.remove(name);
+        } catch (NamingException exception) {
+            JMSException error = new JMSException(exception.getMessage());
+            error.setLinkedException(exception);
+            throw error;
+        } catch (Exception exception) {
+            JMSException error = new JMSException(exception.getMessage());
+            error.setLinkedException(exception);
+            throw error;
+        }
+    }
+
+    /**
+     * Returns true if an administered destination exists
+     *
+     * @param name the destination name
+     * @throws JMSException for any internal JMS provider error
+     */
+    public boolean destinationExists(String name)
+        throws JMSException {
+
+        boolean exists = false;
+        try {
+            lookup(name);
+            exists = true;
+        } catch (NameNotFoundException ignore) {
+        } catch (Exception exception) {
+            JMSException error = new JMSException(exception.getMessage());
+            error.setLinkedException(exception);
+            throw error;
+        }
+        return exists;
+    }
+
+    public void initialise() throws JMSException {
+        try {
+            InetAddress address = InetAddress.getLocalHost();
+            _connection = new AMQConnection(host, port, user, pass,
+                                                  address.getHostName(), vhost);
+            _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        } catch (Exception exception) {
+            JMSException error = new JMSException(exception.getMessage());
+            error.setLinkedException(exception);
+            throw error;
+        }
+    }
+
+    public synchronized void cleanup() {
+        try {
+            _connection.close();
+        } catch (JMSException e) {
+            e.printStackTrace();
+        }
+        _connection = null;
+        _session = null;
+        _directory.clear();
+    }
+
+    MessageConsumer createConsumer(AMQDestination destination) throws JMSException
+    {
+        return ((AMQSession)_session).createConsumer(destination, /*pre-fetch*/0, false, /*exclusive*/false, null);
+    }
+} //-- AMQPAdministrator

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,95 @@
+/**
+ * Redistribution and use of this software and associated documentation
+ * ("Software"), with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain copyright
+ *    statements and notices.  Redistributions must also contain a
+ *    copy of this document.
+ *
+ * 2. Redistributions in binary form must reproduce the
+ *    above copyright notice, this list of conditions and the
+ *    following disclaimer in the documentation and/or other
+ *    materials provided with the distribution.
+ *
+ * 3. The name "Exolab" must not be used to endorse or promote
+ *    products derived from this Software without prior written
+ *    permission of Exoffice Technologies.  For written permission,
+ *    please contact jima@intalio.com.
+ *
+ * 4. Products derived from this Software may not be called "Exolab"
+ *    nor may "Exolab" appear in their names without prior written
+ *    permission of Exoffice Technologies. Exolab is a registered
+ *    trademark of Exoffice Technologies.
+ *
+ * 5. Due credit should be given to the Exolab Project
+ *    (http://www.exolab.org/).
+ *
+ * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
+ * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Copyright 2001, 2003 (C) Exoffice Technologies Inc. All Rights Reserved.
+ *
+ */
+package org.apache.qpid.cts.src.providers.amqp.org.exolab.jmscts.amqp;
+
+import javax.jms.JMSException;
+
+import org.exolab.jmscts.provider.Administrator;
+import org.exolab.jmscts.provider.Provider;
+
+
+/**
+ * This class enables test cases to be run against the SonicMQ provider
+ *
+ * @see         AMQPAdministrator
+ */
+public class AMQPProvider implements Provider {
+
+    /**
+     * The administration interface
+     */
+    private AMQPAdministrator _admin = new AMQPAdministrator();
+
+    /**
+     * Construct an instance of the interface to the AMQP provider
+     */
+    public AMQPProvider() {
+    }
+
+    /**
+     * Initialises the administation interface
+     *
+     * @throws JMSException if the administration interface can't be 
+     * initialised 
+     */
+    public void initialise(boolean start) throws JMSException {
+        _admin.initialise();
+    }
+
+    /**
+     * Returns the administration interface 
+     */
+    public Administrator getAdministrator() {
+        return _admin;
+    }
+
+    /**
+     * This method cleans up the administrator
+     */
+    public void cleanup(boolean stop) {
+        _admin.cleanup();
+        _admin = null;
+    }
+
+} //-- AMQPProvider

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/log4j.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/log4j.xml?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/log4j.xml (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/log4j.xml Tue Dec 19 14:57:56 2006
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+    <appender name="FileAppender" class="org.apache.log4j.FileAppender">
+        <param name="File" value="ams_messaging.log"/>
+        <param name="Append" value="false"/>
+
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
+        </layout>
+    </appender>
+
+    <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
+
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
+        </layout>
+    </appender>
+
+    <root>
+        <priority value="debug"/>
+        <appender-ref ref="STDOUT"/>
+        <appender-ref ref="FileAppender"/>
+    </root>
+</log4j:configuration>
\ No newline at end of file

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/log4j.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.example.publisher;
+
+import org.apache.log4j.Logger;
+
+import java.io.File;
+
+import org.apache.qpid.example.shared.FileUtils;
+import org.apache.qpid.example.shared.Statics;
+
+import javax.jms.JMSException;
+
+/**
+ * Class that sends message files to the Publisher to distribute
+ * using files as input
+ * Must set properties for host in properties file or uses in vm broker
+ */
+public class FileMessageDispatcher {
+
+    protected static final Logger _logger = Logger.getLogger(FileMessageDispatcher.class);
+
+    protected static Publisher _publisher = null;
+
+    /**
+     * To use this main method you need to specify a path or file to use for input
+     * This class then uses file contents from the dir/file specified to generate
+     * messages to publish
+     * Intended to be a very simple way to get going with publishing using the broker
+     * @param args - must specify one value, the path to file(s) for publisher
+     */
+    public static void main(String[] args)
+    {
+
+        //Check command line args ok - must provide a path or file for us to dispatch
+        if (args.length == 0)
+        {
+            System.err.println("Usage: FileMessageDispatcher <filesToDispatch>" + "");
+        }
+        else
+        {
+            try
+            {
+                //publish message(s) from file(s) to configured queue
+                publish(args[0]);
+
+                //Move payload file(s) to archive location as no error
+                FileUtils.moveFileToNewDir(args[0], System.getProperties().getProperty(Statics.ARCHIVE_PATH));
+            }
+            catch(Exception e)
+            {
+                //log error and exit
+                _logger.error("Error trying to dispatch message: " + e);
+                System.exit(1);
+            }
+            finally
+            {
+                //clean up before exiting
+                if (getPublisher() != null)
+                {
+                    getPublisher().cleanup();
+                }
+            }
+        }
+
+        if (_logger.isDebugEnabled())
+        {
+            _logger.debug("Finished dispatching message");
+        }
+
+        System.exit(0);
+    }
+
+    /**
+     * Publish the content of a file or files from a directory as messages
+     * @param path - from main args
+     * @throws JMSException
+     * @throws MessageFactoryException - if cannot create message from file content
+     */
+    public static void publish(String path) throws JMSException, MessageFactoryException
+    {
+        File tempFile = new File(path);
+        if (tempFile.isDirectory())
+        {
+            //while more files in dir publish them
+            File[] files = tempFile.listFiles();
+
+            if (files == null || files.length == 0)
+            {
+                _logger.info("FileMessageDispatcher - No files to publish in input directory: " + tempFile);
+            }
+            else
+            {
+                for (File file : files)
+                {
+                    //Create message factory passing in payload path
+                    FileMessageFactory factory = new FileMessageFactory(getPublisher().getSession(), file.toString());
+
+                    //Send the message generated from the payload using the _publisher
+                    getPublisher().sendMessage(factory.createEventMessage());
+
+                }
+            }
+        }
+        else
+        {
+            //handle a single file
+            //Create message factory passing in payload path
+            FileMessageFactory factory = new FileMessageFactory(getPublisher().getSession(),tempFile.toString());
+
+            //Send the message generated from the payload using the _publisher
+            getPublisher().sendMessage(factory.createEventMessage());
+        }
+    }
+
+    /**
+     * Cleanup before exit
+     */
+    public static void cleanup()
+    {
+        if (getPublisher() != null)
+        {
+            getPublisher().cleanup();
+        }
+    }
+
+    /**
+     * @return A Publisher instance
+     */
+    private static Publisher getPublisher()
+    {
+       if (_publisher != null)
+       {
+           return _publisher;
+       }
+
+       //Create a _publisher
+       _publisher = new Publisher();
+
+       return _publisher;
+    }
+
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/FileMessageFactory.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/FileMessageFactory.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/FileMessageFactory.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/FileMessageFactory.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,134 @@
+/*
+ * 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.
+ */
+
+package org.apache.qpid.example.publisher;
+
+import org.apache.qpid.example.shared.FileUtils;
+import org.apache.qpid.example.shared.Statics;
+
+import java.io.*;
+import javax.jms.*;
+
+public class FileMessageFactory
+{
+    protected final Session _session;
+    protected final String _payload;
+    protected final String _filename;
+
+    /**
+     * Contructs and instance using a filename from which content will be used to create message
+     * @param session
+     * @param filename
+     * @throws MessageFactoryException
+     */
+    public FileMessageFactory(Session session, String filename) throws MessageFactoryException
+    {
+        try
+        {
+            _filename = filename;
+            _payload = FileUtils.getFileContent(filename);
+            _session = session;
+        }
+        catch (IOException e)
+        {
+            throw new MessageFactoryException(e.toString());
+        }
+    }
+
+    /**
+     * Creates a text message and sets filename property on it
+     * The filename property is purely intended to provide visibility
+     * of file content passing trhough the broker using example classes
+     * @return  Message - a TextMessage with content from file
+     * @throws JMSException
+     */
+    public Message createEventMessage() throws JMSException
+    {
+        TextMessage msg = _session.createTextMessage();
+        msg.setText(_payload);
+        msg.setStringProperty(Statics.FILENAME_PROPERTY,new File(_filename).getName());
+        return msg;
+    }
+
+    /**
+     * Creates message from a string for use by the monitor
+     * @param session
+     * @param textMsg - message content
+     * @return Message - TextMessage with content from String
+     * @throws JMSException
+     */
+    public static Message createSimpleEventMessage(Session session, String textMsg) throws JMSException
+    {
+        TextMessage msg = session.createTextMessage();
+        msg.setText(textMsg);
+        return msg;
+    }
+
+    public Message createShutdownMessage() throws JMSException
+    {
+        return _session.createTextMessage("SHUTDOWN");
+    }
+
+    public Message createReportRequestMessage() throws JMSException
+    {
+        return _session.createTextMessage("REPORT");
+    }
+
+    public Message createReportResponseMessage(String msg) throws JMSException
+    {
+        return _session.createTextMessage(msg);
+    }
+
+    public boolean isShutdown(Message m)
+    {
+        return checkText(m, "SHUTDOWN");
+    }
+
+    public boolean isReport(Message m)
+    {
+        return checkText(m, "REPORT");
+    }
+
+    public Object getReport(Message m)
+    {
+        try
+        {
+            return ((TextMessage) m).getText();
+        }
+        catch (JMSException e)
+        {
+            e.printStackTrace(System.out);
+            return e.toString();
+        }
+    }
+
+    private static boolean checkText(Message m, String s)
+    {
+        try
+        {
+            return m instanceof TextMessage && ((TextMessage) m).getText().equals(s);
+        }
+        catch (JMSException e)
+        {
+            e.printStackTrace(System.out);
+            return false;
+        }
+    }
+}
+

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/FileMessageFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MessageFactoryException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MessageFactoryException.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MessageFactoryException.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MessageFactoryException.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.example.publisher;
+
+import org.apache.log4j.Logger;
+
+public class MessageFactoryException extends Exception {
+
+    private int _errorCode;
+
+    public MessageFactoryException(String message)
+    {
+        super(message);
+    }
+
+    public MessageFactoryException(String msg, Throwable t)
+    {
+        super(msg, t);
+    }
+
+    public MessageFactoryException(int errorCode, String msg, Throwable t)
+    {
+        super(msg + " [error code " + errorCode + ']', t);
+        _errorCode = errorCode;
+    }
+
+    public MessageFactoryException(int errorCode, String msg)
+    {
+        super(msg + " [error code " + errorCode + ']');
+        _errorCode = errorCode;
+    }
+
+    public MessageFactoryException(Logger logger, String msg, Throwable t)
+    {
+        this(msg, t);
+        logger.error(getMessage(), this);
+    }
+
+    public MessageFactoryException(Logger logger, String msg)
+    {
+        this(msg);
+        logger.error(getMessage(), this);
+    }
+
+    public MessageFactoryException(Logger logger, int errorCode, String msg)
+    {
+        this(errorCode, msg);
+        logger.error(getMessage(), this);
+    }
+
+    public int getErrorCode()
+    {
+        return _errorCode;
+    }
+}
+

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MessageFactoryException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,134 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.example.publisher;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.BasicConfigurator;
+
+import javax.jms.*;
+
+import java.util.Properties;
+
+/**
+ * Class that sends heartbeat messages to allow monitoring of message consumption
+ * Sends regular (currently 20 seconds apart) heartbeat message
+ */
+public class MonitorMessageDispatcher {
+
+    private static final Logger _logger = Logger.getLogger(MonitorMessageDispatcher.class);
+
+    protected static MonitorPublisher _monitorPublisher = null;
+
+    protected static final String DEFAULT_MONITOR_PUB_NAME = "MonitorPublisher";
+
+    /**
+     * Easy entry point for running a message dispatcher for monitoring consumption
+     * @param args
+     */
+    public static void main(String[] args)
+    {
+
+        //Switch on logging appropriately for your app
+        BasicConfigurator.configure();
+
+        try
+        {
+            while(true)
+            {
+                try
+                {
+                    //endlessly publish messages to monitor queue
+                    publish();
+
+                    if (_logger.isDebugEnabled())
+                    {
+                        _logger.debug("Dispatched monitor message");
+                    }
+
+                    //sleep for twenty seconds and then publish again - change if appropriate
+                    Thread.sleep(20000);
+                }
+                catch(UndeliveredMessageException a)
+                {
+                    //trigger application specific failure handling here
+                    _logger.error("Problem delivering monitor message");
+                    break;
+                }
+            }
+        }
+        catch(Exception e)
+        {
+            _logger.error("Error trying to dispatch AMS monitor message: " + e);
+            System.exit(1);
+        }
+        finally
+        {
+            if (getMonitorPublisher() != null)
+            {
+               getMonitorPublisher().cleanup();
+            }
+        }
+
+        System.exit(1);
+    }
+
+    /**
+     * Publish heartbeat message
+     * @throws JMSException
+     * @throws UndeliveredMessageException
+     */
+    public static void publish() throws JMSException, UndeliveredMessageException
+    {
+        //Send the message generated from the payload using the _publisher
+        getMonitorPublisher().sendImmediateMessage
+          (FileMessageFactory.createSimpleEventMessage(getMonitorPublisher().getSession(),"monitor:" +System.currentTimeMillis()));
+    }
+
+    /**
+     * Cleanup publishers
+     */
+    public static void cleanup()
+    {
+        if (getMonitorPublisher() != null)
+        {
+            getMonitorPublisher().cleanup();
+        }
+
+        if (getMonitorPublisher() != null)
+        {
+            getMonitorPublisher().cleanup();
+        }
+    }
+
+    //Returns a _publisher for the monitor queue
+    private static MonitorPublisher getMonitorPublisher()
+    {
+       if (_monitorPublisher != null)
+       {
+           return _monitorPublisher;
+       }
+
+       //Create a _publisher using failover details and constant for monitor queue
+       _monitorPublisher = new MonitorPublisher();
+
+       _monitorPublisher.setName(MonitorMessageDispatcher.DEFAULT_MONITOR_PUB_NAME);
+       return _monitorPublisher;
+    }
+
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MonitorPublisher.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MonitorPublisher.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MonitorPublisher.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MonitorPublisher.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.example.publisher;
+
+import javax.jms.Message;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import org.apache.qpid.client.BasicMessageProducer;
+import org.apache.log4j.Logger;
+
+/**
+ * Subclass of Publisher which uses QPID functionality to send a heartbeat message
+ * Note immediate flag not available via JMS MessageProducer
+ */
+public class MonitorPublisher extends Publisher
+{
+
+    private static final Logger _log = Logger.getLogger(Publisher.class);
+
+    BasicMessageProducer _producer;
+
+    public MonitorPublisher()
+    {
+        super();
+    }
+
+     /*
+     * Publishes a non-persistent message using transacted session
+     */
+    public boolean sendImmediateMessage(Message message) throws UndeliveredMessageException
+    {
+        try
+        {
+             _producer = (BasicMessageProducer)_session.createProducer(_destination);
+
+            //Send message via our producer which is not persistent and is immediate
+            //NB: not available via jms interface MessageProducer
+            _producer.send(message, DeliveryMode.NON_PERSISTENT, true);
+
+            //commit the message send and close the transaction
+            _session.commit();
+
+        }
+        catch (JMSException e)
+        {
+            //Have to assume our commit failed but do not rollback here as channel closed
+            _log.error(e);
+            e.printStackTrace();
+            throw new UndeliveredMessageException("Cannot deliver immediate message",e);
+        }
+
+        _log.info(_name + " finished sending message: " + message);
+        return true;
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/MonitorPublisher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/Publisher.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/Publisher.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/Publisher.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/Publisher.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.example.publisher;
+
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.client.AMQConnectionFactory;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.DeliveryMode;
+import javax.jms.Queue;
+import javax.jms.MessageProducer;
+import javax.jms.Connection;
+import javax.jms.Session;
+
+import javax.naming.InitialContext;
+
+import org.apache.qpid.example.shared.InitialContextHelper;
+
+public class Publisher
+{
+    private static final Logger _log = Logger.getLogger(Publisher.class);
+
+    protected InitialContextHelper _contextHelper;
+
+    protected Connection _connection;
+
+    protected Session _session;
+
+    protected MessageProducer _producer;
+
+    protected String _destinationDir;
+
+    protected String _name = "Publisher";
+
+    protected Queue _destination;
+
+    protected static final String _defaultDestinationDir = "/tmp";
+
+    /**
+     * Creates a Publisher instance using properties from example.properties
+     * See InitialContextHelper for details of how context etc created
+     */
+    public Publisher()
+    {
+        try
+        {
+            //get an initial context from default properties
+            _contextHelper = new InitialContextHelper(null);
+            InitialContext ctx = _contextHelper.getInitialContext();
+
+            //then create a connection using the AMQConnectionFactory
+            AMQConnectionFactory cf = (AMQConnectionFactory) ctx.lookup("local");
+            _connection = cf.createConnection();
+
+            //create a transactional session
+            _session = _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+
+            //lookup the example queue and use it
+            //Queue is non-exclusive and not deleted when last consumer detaches
+            _destination = _session.createQueue((String)ctx.lookup("MyQueue"));
+
+            //create a message producer
+            _producer = _session.createProducer(_destination);
+
+            //set destination dir for files that have been processed
+            _destinationDir = _defaultDestinationDir;
+
+            _connection.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            _log.error(e);
+        }
+    }
+
+    /**
+     * Publishes a non-persistent message using transacted session
+     * Note that persistent is the default mode for send - so need to specify for transient
+     */
+    public boolean sendMessage(Message message)
+    {
+        try
+        {
+            //Send message via our producer which is not persistent
+            _producer.send(message, DeliveryMode.NON_PERSISTENT, _producer.getPriority(), _producer.getTimeToLive());
+
+            //commit the message send and close the transaction
+            _session.commit();
+
+        }
+        catch (JMSException e)
+        {
+            //Have to assume our commit failed and rollback here
+            try
+            {
+                _session.rollback();
+                _log.error(e);
+                e.printStackTrace();
+                return false;
+            }
+            catch (JMSException j)
+            {
+                _log.error("Unable to rollback publish transaction ",e);
+                return false;
+            }
+        }
+
+        _log.info(_name + " finished sending message: " + message);
+        return true;
+    }
+
+    /**
+     * Cleanup resources before exit
+     */
+    public void cleanup()
+    {
+        try
+        {
+            if (_connection != null)
+            {
+                _connection.stop();
+                _connection.close();
+            }
+            _connection = null;
+            _producer = null;
+        }
+        catch(Exception e)
+        {
+            _log.error("Error trying to cleanup publisher " + e);
+            System.exit(1);
+        }
+    }
+
+    /**
+     * Exposes session
+     * @return  Session
+     */
+    public Session getSession()
+    {
+        return _session;
+    }
+
+    public String getDestinationDir()
+    {
+        return _destinationDir;
+    }
+
+    public void setDestinationDir(String destinationDir)
+    {
+        _destinationDir = destinationDir;
+    }
+
+    public String getName()
+    {
+        return _name;
+    }
+
+    public void setName(String _name) {
+        this._name = _name;
+    }
+}
+

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/Publisher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.example.publisher;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Exception thrown by monitor when cannot send a message marked for immediate delivery
+ */
+public class UndeliveredMessageException extends Exception {
+
+    private int _errorCode;
+
+    public UndeliveredMessageException(String message)
+    {
+        super(message);
+    }
+
+    public UndeliveredMessageException(String msg, Throwable t)
+    {
+        super(msg, t);
+    }
+
+    public UndeliveredMessageException(int errorCode, String msg, Throwable t)
+    {
+        super(msg + " [error code " + errorCode + ']', t);
+        _errorCode = errorCode;
+    }
+
+    public UndeliveredMessageException(int errorCode, String msg)
+    {
+        super(msg + " [error code " + errorCode + ']');
+        _errorCode = errorCode;
+    }
+
+    public UndeliveredMessageException(Logger logger, String msg, Throwable t)
+    {
+        this(msg, t);
+        logger.error(getMessage(), this);
+    }
+
+    public UndeliveredMessageException(Logger logger, String msg)
+    {
+        this(msg);
+        logger.error(getMessage(), this);
+    }
+
+    public UndeliveredMessageException(Logger logger, int errorCode, String msg)
+    {
+        this(errorCode, msg);
+        logger.error(getMessage(), this);
+    }
+
+    public int getErrorCode()
+    {
+        return _errorCode;
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/ConnectionException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/ConnectionException.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/ConnectionException.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/ConnectionException.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.example.shared;
+
+import org.apache.log4j.Logger;
+
+public class ConnectionException extends Exception {
+
+    private int _errorCode;
+
+    public ConnectionException(String message)
+    {
+        super(message);
+    }
+
+    public ConnectionException(String msg, Throwable t)
+    {
+        super(msg, t);
+    }
+
+    public ConnectionException(int errorCode, String msg, Throwable t)
+    {
+        super(msg + " [error code " + errorCode + ']', t);
+        _errorCode = errorCode;
+    }
+
+    public ConnectionException(int errorCode, String msg)
+    {
+        super(msg + " [error code " + errorCode + ']');
+        _errorCode = errorCode;
+    }
+
+    public ConnectionException(Logger logger, String msg, Throwable t)
+    {
+        this(msg, t);
+        logger.error(getMessage(), this);
+    }
+
+    public ConnectionException(Logger logger, String msg)
+    {
+        this(msg);
+        logger.error(getMessage(), this);
+    }
+
+    public ConnectionException(Logger logger, int errorCode, String msg)
+    {
+        this(errorCode, msg);
+        logger.error(getMessage(), this);
+    }
+
+    public int getErrorCode()
+    {
+        return _errorCode;
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/ConnectionException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/ContextException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/ContextException.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/ContextException.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/ContextException.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.example.shared;
+
+import org.apache.log4j.Logger;
+
+public class ContextException extends Exception {
+
+    private int _errorCode;
+
+    public ContextException(String message)
+    {
+        super(message);
+    }
+
+    public ContextException(String msg, Throwable t)
+    {
+        super(msg, t);
+    }
+
+    public ContextException(int errorCode, String msg, Throwable t)
+    {
+        super(msg + " [error code " + errorCode + ']', t);
+        _errorCode = errorCode;
+    }
+
+    public ContextException(int errorCode, String msg)
+    {
+        super(msg + " [error code " + errorCode + ']');
+        _errorCode = errorCode;
+    }
+
+    public ContextException(Logger logger, String msg, Throwable t)
+    {
+        this(msg, t);
+        logger.error(getMessage(), this);
+    }
+
+    public ContextException(Logger logger, String msg)
+    {
+        this(msg);
+        logger.error(getMessage(), this);
+    }
+
+    public ContextException(Logger logger, int errorCode, String msg)
+    {
+        this(errorCode, msg);
+        logger.error(getMessage(), this);
+    }
+
+    public int getErrorCode()
+    {
+        return _errorCode;
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/ContextException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/FileUtils.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/FileUtils.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/FileUtils.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,168 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.example.shared;
+
+import java.io.*;
+
+/**
+ * Class that provides file related utility methods for utility use
+ */
+public class FileUtils {
+
+
+    //Reads file content into String
+    public static String getFileContent(String filePath) throws IOException
+    {
+
+        BufferedReader reader = null;
+        String tempData = "";
+        String eol = "\n\r";
+
+        try
+        {
+            String line;
+            reader = new BufferedReader(new FileReader(filePath));
+            while ((line = reader.readLine()) != null)
+            {
+                if (!tempData.equals(""))
+                {
+                    tempData = tempData + eol + line;
+                }
+                else
+                {
+                    tempData = line;
+                }
+            }
+        }
+        finally
+        {
+            if (reader != null)
+            {
+                reader.close();
+            }
+        }
+        return tempData;
+    }
+
+     /*
+     * Reads xml from a file and returns it as an array of chars
+     */
+    public static char[] getFileAsCharArray(String filePath) throws IOException
+    {
+        BufferedReader reader = null;
+        char[] tempChars = null;
+        String tempData = "";
+
+        try
+        {
+            String line;
+            reader = new BufferedReader(new FileReader(filePath));
+            while ((line = reader.readLine()) != null)
+            {
+                tempData = tempData + line;
+            }
+            tempChars = tempData.toCharArray();
+        }
+        finally
+        {
+            if (reader != null)
+            {
+                reader.close();
+            }
+        }
+        return tempChars;
+    }
+
+    /*
+    * Write String content to filename provided
+    */
+    public static void writeStringToFile(String content, String path) throws IOException
+    {
+
+        BufferedWriter writer = new BufferedWriter(new FileWriter(new File(path)));
+        writer.write(content);
+        writer.flush();
+        writer.close();
+    }
+
+    /*
+    * Allows moving of files to a new dir and preserves the last bit of the name only
+    */
+    public static void moveFileToNewDir(String path, String newDir) throws IOException
+    {
+        //get file name from current path
+        //while more files in dir publish them
+        File pathFile = new File(path);
+        if (pathFile.isDirectory())
+        {
+            File[] files = pathFile.listFiles();
+            for (File file : files)
+            {
+                moveFileToNewDir(file,newDir);
+            }
+        }
+    }
+
+    /*
+    * Allows moving of a file to a new dir and preserves the last bit of the name only
+    */
+    public static void moveFileToNewDir(File fileToMove, String newDir) throws IOException
+    {
+        moveFile(fileToMove,getArchiveFileName(fileToMove,newDir));
+    }
+
+    /*
+    * Moves file from a given path to a new path with String params
+    */
+    public static void moveFile(String fromPath, String dest) throws IOException
+    {
+        moveFile(new File(fromPath),new File(dest));
+    }
+
+    /*
+    * Moves file from a given path to a new path with mixed params
+    */
+    public static void moveFile(File fileToMove, String dest) throws IOException
+    {
+        moveFile(fileToMove,new File(dest));
+    }
+
+    /*
+    * Moves file from a given path to a new path with File params
+    */
+    public static void moveFile(File fileToMove, File dest) throws IOException
+    {
+        fileToMove.renameTo(dest);
+    }
+
+    /*
+    * Deletes a given file
+    */
+    public static void deleteFile(String filePath) throws IOException
+    {
+        new File(filePath).delete();
+    }
+
+    private static String getArchiveFileName(File fileToMove, String archiveDir)
+    {
+         //get file name from current path
+        String fileName = fileToMove.getName();
+        return archiveDir + File.separator + fileName;
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/FileUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/InitialContextHelper.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/InitialContextHelper.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/InitialContextHelper.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/InitialContextHelper.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,78 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.example.shared;
+
+import org.apache.log4j.Logger;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.Properties;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * Class that provides helper methods for JNDI
+ */
+public class InitialContextHelper {
+
+    public static final String _defaultPropertiesName = "example.properties";
+    protected static Properties _fileProperties;
+    protected static InitialContext _initialContext;
+    protected static final Logger _log = Logger.getLogger(InitialContextHelper.class);
+
+    public InitialContextHelper(String propertiesName) throws ContextException
+    {
+        try
+        {
+            if (propertiesName == null || propertiesName.length() == 0)
+            {
+                propertiesName = _defaultPropertiesName;
+            }
+
+            _fileProperties = new Properties();
+            ClassLoader cl = this.getClass().getClassLoader();
+
+            //NB: Need to change path to reflect package if moving classes around !
+            InputStream is = cl.getResourceAsStream("org/apache/qpid/example/shared/" + propertiesName);
+            _fileProperties.load(is);
+            _initialContext = new InitialContext(_fileProperties);
+        }
+        catch (IOException e)
+        {
+            throw new ContextException(_log, e.toString());
+        }
+        catch (NamingException n)
+        {
+            throw new ContextException(_log, n.toString());
+        }
+    }
+
+    public Properties getFileProperties()
+    {
+        return _fileProperties;
+    }
+
+    public InitialContext getInitialContext()
+    {
+        return _initialContext;
+    }
+
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/InitialContextHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/Statics.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/Statics.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/Statics.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/Statics.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.example.shared;
+
+/**
+ * Constants used by AMS Publisher/Subscriber classes
+ */
+public class Statics {
+
+    public static final String TOPIC_NAME = "EXAMPLE_TOPIC";
+
+    public static final String QUEUE_NAME = "EXAMPLE_QUEUE";
+
+    public static final String MONITOR_QUEUE_SUFFIX = "_MONITOR";
+
+    public static final String HOST_PROPERTY = "host";
+
+    public static final String PORT_PROPERTY = "port";
+
+    public static final String USER_PROPERTY = "user";
+
+    public static final String PWD_PROPERTY = "pwd";
+
+    public static final String TOPIC_PROPERTY = "topic";
+
+    public static final String QUEUE_PROPERTY = "queue";
+
+    public static final String VIRTUAL_PATH_PROPERTY = "virtualpath";
+
+    public static final String ARCHIVE_PATH = "archivepath";
+
+    public static final String CLIENT_PROPERTY = "client";
+
+    public static final String FILENAME_PROPERTY = "filename";
+
+    public static final String DEFAULT_USER = "guest";
+
+    public static final String DEFAULT_PWD = "guest";
+
+
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/Statics.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/example.properties
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/example.properties?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/example.properties (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/example.properties Tue Dec 19 14:57:56 2006
@@ -0,0 +1,21 @@
+java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory
+
+# use the following property to configure the default connector
+#java.naming.provider.url - ignored.
+
+# register some connection factories
+# connectionfactory.[jndiname] = [ConnectionURL]
+connectionfactory.local = amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.MyQueue = example.MyQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+topic.ibmStocks = stocks.nyse.ibm
+
+# Register an AMQP destination in JNDI
+#   NOTE: Qpid currently only supports direct,topics and headers
+# destination.[jniName] = [BindingURL]
+destination.direct = direct://amq.direct//directQueue

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/shared/example.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java?view=auto&rev=488847
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java Tue Dec 19 14:57:56 2006
@@ -0,0 +1,139 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.example.subscriber;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.example.shared.Statics;
+
+import javax.jms.*;
+
+/**
+ * Subclass of Subscriber which consumes a heartbeat message
+ */
+
+public class MonitoredSubscriber extends Subscriber
+{
+    protected String _monitorDestinationName;
+
+    private static final Logger _logger = Logger.getLogger(MonitoredSubscriber.class);
+
+    private static MessageConsumer _monitorConsumer;
+
+    public MonitoredSubscriber()
+    {
+        super();
+        //lookup queue name and append suffix
+        _monitorDestinationName = _destinationName + Statics.MONITOR_QUEUE_SUFFIX;
+    }
+
+    /**
+     * MessageListener implementation for this subscriber
+     */
+    public static class MonitorMessageListener implements MessageListener
+    {
+        private String _name;
+
+        public MonitorMessageListener(String name)
+        {
+            _name = name;
+
+        }
+
+        /**
+         * Listens for heartbeat messages and acknowledges them
+         * @param message
+         */
+        public void onMessage(javax.jms.Message message)
+        {
+            _logger.info(_name + " monitor got message '" + message + "'");
+
+            try
+            {
+               _logger.debug("Monitor acknowledging recieved message");
+
+                //Now acknowledge the message to clear it from our queue
+                message.acknowledge();
+            }
+            catch(JMSException j)
+            {
+                _logger.error("Monitor caught JMSException trying to acknowledge message receipt");
+                j.printStackTrace();
+            }
+            catch(Exception e)
+            {
+                _logger.error("Monitor caught unexpected exception trying to handle message");
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * Subscribes to Queue and attaches additional monitor listener
+     */
+    public void subscribeAndMonitor()
+    {
+        try
+        {
+            _connection = _connectionFactory.createConnection();
+
+             //create a transactional session
+            Session session =  _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+
+            //Queue is non-exclusive and not deleted when last consumer detaches
+            Destination destination = session.createQueue(_monitorDestinationName);
+
+            //Create a consumer with a destination of our queue which will use defaults for prefetch etc
+            _monitorConsumer = session.createConsumer(destination);
+
+            //give the monitor message listener a name of it's own
+            _monitorConsumer.setMessageListener(new MonitoredSubscriber.MonitorMessageListener
+                ("MonitorListener " + System.currentTimeMillis()));
+
+            MonitoredSubscriber._logger.info("Starting monitored subscription ...");
+
+            MonitoredSubscriber._connection.start();
+
+            //and now start ordinary consumption too
+            subscribe();
+        }
+        catch (Throwable t)
+        {
+            _logger.error("Fatal error: " + t);
+            t.printStackTrace();
+        }
+    }
+
+    /**
+     * Stop consuming
+     */
+    public void stopMonitor()
+    {
+        try
+        {
+            _monitorConsumer.close();
+            _monitorConsumer = null;
+            stop();
+        }
+        catch(JMSException j)
+        {
+            _logger.error("JMSException trying to Subscriber.stop: " + j.getStackTrace());
+        }
+    }
+
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/old_test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java
------------------------------------------------------------------------------
    svn:eol-style = native