NO-JIRA : AMQP-1-0 sandbox updates - merge from trunk

git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/rg-amqp-1-0-sandbox@1299257 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/AbstractConfiguration.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/AbstractConfiguration.java
index a684e52..f04dd38 100644
--- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/AbstractConfiguration.java
+++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/AbstractConfiguration.java
@@ -27,10 +27,10 @@
 
 public abstract class AbstractConfiguration implements ConfigurationFile
 {
-    protected static final Logger _logger = Logger.getLogger(ConfigurationFile.class);
+    private static final Logger _logger = Logger.getLogger(ConfigurationFile.class);
     
-    protected File _file;
-    protected RuleSet _config;
+    private File _file;
+    private RuleSet _config;
     
     public AbstractConfiguration(File file)
     {
diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/Action.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/Action.java
index fdbd96e..b887d1e 100644
--- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/Action.java
+++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/Action.java
@@ -21,8 +21,6 @@
 package org.apache.qpid.server.security.access.config;
 
 import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
 
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
@@ -35,7 +33,7 @@
 /**
  * An access control v2 rule action.
  * 
- * An action consists of an {@link Operation} on an {@link ObjectType} with certain properties, stored in a {@link Map}.
+ * An action consists of an {@link Operation} on an {@link ObjectType} with certain properties, stored in a {@link java.util.Map}.
  * The operation and object should be an allowable combination, based on the {@link ObjectType#isAllowed(Operation)}
  * method of the object, which is exposed as the {@link #isAllowed()} method here. The internal {@link #propertiesMatch(Map)}
  * and {@link #valueMatches(String, String)} methods are used to determine wildcarded matching of properties, with
@@ -111,10 +109,9 @@
     /** @see Comparable#compareTo(Object) */
     public boolean matches(Action a)
     {
-        return (Operation.ALL == a.getOperation()
-                || (getOperation() == a.getOperation()
-                    && getObjectType() == a.getObjectType()
-                    && _properties.matches(a.getProperties())));
+        return ((Operation.ALL == a.getOperation() || getOperation() == a.getOperation())
+                    && (ObjectType.ALL == a.getObjectType() || getObjectType() == a.getObjectType())
+                    && _properties.matches(a.getProperties()));
     }
 
     /**
@@ -136,12 +133,6 @@
             }
             else if (a.getOperation() == b.getOperation())
             {
-                // Same operator, compare rest of action
-                
-//                    || (getOperation() == a.getOperation()
-//                        && getObjectType() == a.getObjectType()
-//                        && _properties.matches(a.getProperties())));
-
                 return 1; // b is more specific
             }
             else // Different operations
diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/PlainConfiguration.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/PlainConfiguration.java
index 9f2168a..b299b62 100644
--- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/PlainConfiguration.java
+++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/PlainConfiguration.java
@@ -78,7 +78,7 @@
         
         try
         {
-            _st = new StreamTokenizer(new BufferedReader(new FileReader(_file)));
+            _st = new StreamTokenizer(new BufferedReader(new FileReader(getFile())));
             _st.resetSyntax(); // setup the tokenizer
                 
             _st.commentChar(COMMENT); // single line comments
diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/RuleSet.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/RuleSet.java
index 402b991..815df99 100644
--- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/RuleSet.java
+++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/RuleSet.java
@@ -312,9 +312,9 @@
         return true;
     }
 
-    // C++ broker authorise function prototype
+    // CPP broker authorise function prototype
     // virtual bool authorise(const std::string& id, const Action& action, const ObjectType& objType,
-    //        const std::string& name, std::map<Property, std::string>* params=0);
+    //        const std::string& name, std::map<Property, std::string>* params=0)
 
     // Possibly add a String name paramater?
 
diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControl.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControl.java
index a97b66a..d8a5bd4 100644
--- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControl.java
+++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControl.java
@@ -109,7 +109,7 @@
     {
         super.configure(config);
 
-        AccessControlConfiguration accessConfig = (AccessControlConfiguration) _config;
+        AccessControlConfiguration accessConfig = (AccessControlConfiguration) getConfig();
 
         _ruleSet = accessConfig.getRuleSet();
     }
diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControlActivator.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControlActivator.java
index 72eac7d..7c83446 100644
--- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControlActivator.java
+++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControlActivator.java
@@ -23,10 +23,9 @@
 import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
 import org.apache.qpid.server.security.SecurityPluginActivator;
 import org.apache.qpid.server.security.SecurityPluginFactory;
-import org.osgi.framework.BundleActivator;
 
 /**
- * The OSGi {@link BundleActivator} for {@link AccessControl}.
+ * The OSGi {@link org.osgi.framework.BundleActivator} for {@link AccessControl}.
  */
 public class AccessControlActivator extends SecurityPluginActivator
 {
diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControlConfiguration.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControlConfiguration.java
index b5c8991..c4db6db 100644
--- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControlConfiguration.java
+++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/AccessControlConfiguration.java
@@ -58,7 +58,7 @@
 
     public String getFileName()
     {
-        return _configuration.getString("");
+        return getConfig().getString("");
     }
 
     public void validateConfiguration() throws ConfigurationException
diff --git a/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/AccessControlTest.java b/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/AccessControlTest.java
index 09d26e5..61e867f 100644
--- a/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/AccessControlTest.java
+++ b/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/AccessControlTest.java
@@ -24,6 +24,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.commons.configuration.ConfigurationException;
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.logging.UnitTestMessageLogger;
 import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -52,10 +53,20 @@
     private AccessControl _plugin = null;  // Class under test
     private final UnitTestMessageLogger messageLogger = new UnitTestMessageLogger();
 
-    protected void setUp() throws Exception
+    private void setUpGroupAccessControl() throws ConfigurationException
     {
-        super.setUp();
+        configureAccessControl(createGroupRuleSet());
+    }
 
+    private void configureAccessControl(final RuleSet rs) throws ConfigurationException
+    {
+        _plugin = (AccessControl) AccessControl.FACTORY.newInstance(createConfiguration(rs));
+        SecurityManager.setThreadSubject(null);
+        CurrentActor.set(new TestLogActor(messageLogger));
+    }
+
+    private RuleSet createGroupRuleSet()
+    {
         final RuleSet rs = new RuleSet();
         rs.addGroup("aclGroup1", Arrays.asList(new String[] {"member1", "member2"}));
 
@@ -68,11 +79,7 @@
         // Catch all rule
         rs.grant(3, Rule.ALL, Permission.DENY_LOG, Operation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY);
 
-        _plugin = (AccessControl) AccessControl.FACTORY.newInstance(createConfiguration(rs));
-
-        SecurityManager.setThreadSubject(null);
-        
-        CurrentActor.set(new TestLogActor(messageLogger));
+        return rs;
     }
 
     protected void tearDown() throws Exception
@@ -81,68 +88,238 @@
         SecurityManager.setThreadSubject(null);
     }
 
-    /** 
+    /**
      * ACL plugin must always abstain if there is no  subject attached to the thread.
      */
-    public void testNoSubjectAlwaysAbstains()
+    public void testNoSubjectAlwaysAbstains() throws ConfigurationException
     {
+        setUpGroupAccessControl();
         SecurityManager.setThreadSubject(null);
 
         final Result result = _plugin.authorise(Operation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY);
         assertEquals(Result.ABSTAIN, result);
     }
 
-    /** 
+    /**
      * Tests that an allow rule expressed with a username allows an operation performed by a thread running
      * with the same username.
      */
-    public void testUsernameAllowsOperation()
+    public void testUsernameAllowsOperation() throws ConfigurationException
     {
+        setUpGroupAccessControl();
         SecurityManager.setThreadSubject(TestPrincipalUtils.createTestSubject("user1"));
 
         final Result result = _plugin.authorise(Operation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY);
         assertEquals(Result.ALLOWED, result);
     }
 
-    /** 
+    /**
      * Tests that an allow rule expressed with an <b>ACL groupname</b> allows an operation performed by a thread running
      * by a user who belongs to the same group..
      */
-    public void testAclGroupMembershipAllowsOperation()
+    public void testAclGroupMembershipAllowsOperation() throws ConfigurationException
     {
+        setUpGroupAccessControl();
         SecurityManager.setThreadSubject(TestPrincipalUtils.createTestSubject("member1"));
 
         final Result result = _plugin.authorise(Operation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY);
         assertEquals(Result.ALLOWED, result);
     }
 
-    /** 
+    /**
      * Tests that a deny rule expressed with an <b>External groupname</b> denies an operation performed by a thread running
      * by a user who belongs to the same group.
      */
-    public void testExternalGroupMembershipDeniesOperation()
+    public void testExternalGroupMembershipDeniesOperation() throws ConfigurationException
     {
+        setUpGroupAccessControl();
         SecurityManager.setThreadSubject(TestPrincipalUtils.createTestSubject("user3", "extGroup1"));
-        
+
         final Result result = _plugin.authorise(Operation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY);
         assertEquals(Result.DENIED, result);
     }
 
-    /** 
+    /**
      * Tests that the catch all deny denies the operation and logs with the logging actor.
      */
-    public void testCatchAllRuleDeniesUnrecognisedUsername()
+    public void testCatchAllRuleDeniesUnrecognisedUsername() throws ConfigurationException
     {
+        setUpGroupAccessControl();
         SecurityManager.setThreadSubject(TestPrincipalUtils.createTestSubject("unknown", "unkgroup1", "unkgroup2"));
-        
+
         assertEquals("Expecting zero messages before test", 0, messageLogger.getLogMessages().size());
         final Result result = _plugin.authorise(Operation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY);
         assertEquals(Result.DENIED, result);
-        
+
         assertEquals("Expecting one message before test", 1, messageLogger.getLogMessages().size());
         assertTrue("Logged message does not contain expected string", messageLogger.messageContains(0, "ACL-1002"));
     }
-    
+
+    /**
+     * Tests that a grant access method rule allows any access operation to be performed on any component
+     */
+    public void testAuthoriseAccessMethodWhenAllAccessOperationsAllowedOnAllComponents() throws ConfigurationException
+    {
+        final RuleSet rs = new RuleSet();
+
+        // grant user4 access right on any method in any component
+        rs.grant(1, "user4", Permission.ALLOW, Operation.ACCESS, ObjectType.METHOD, new ObjectProperties(ObjectProperties.STAR));
+        configureAccessControl(rs);
+        SecurityManager.setThreadSubject(TestPrincipalUtils.createTestSubject("user4"));
+
+        ObjectProperties actionProperties = new ObjectProperties("getName");
+        actionProperties.put(ObjectProperties.Property.COMPONENT, "Test");
+
+        final Result result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, actionProperties);
+        assertEquals(Result.ALLOWED, result);
+    }
+
+    /**
+     * Tests that a grant access method rule allows any access operation to be performed on a specified component
+     */
+    public void testAuthoriseAccessMethodWhenAllAccessOperationsAllowedOnSpecifiedComponent() throws ConfigurationException
+    {
+        final RuleSet rs = new RuleSet();
+
+        // grant user5 access right on any methods in "Test" component
+        ObjectProperties ruleProperties = new ObjectProperties(ObjectProperties.STAR);
+        ruleProperties.put(ObjectProperties.Property.COMPONENT, "Test");
+        rs.grant(1, "user5", Permission.ALLOW, Operation.ACCESS, ObjectType.METHOD, ruleProperties);
+        configureAccessControl(rs);
+        SecurityManager.setThreadSubject(TestPrincipalUtils.createTestSubject("user5"));
+
+        ObjectProperties actionProperties = new ObjectProperties("getName");
+        actionProperties.put(ObjectProperties.Property.COMPONENT, "Test");
+        Result result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, actionProperties);
+        assertEquals(Result.ALLOWED, result);
+
+        actionProperties.put(ObjectProperties.Property.COMPONENT, "Test2");
+        result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, actionProperties);
+        assertEquals(Result.DEFER, result);
+    }
+
+    /**
+     * Tests that a grant access method rule allows any access operation to be performed on a specified component
+     */
+    public void testAuthoriseAccessMethodWhenSpecifiedAccessOperationsAllowedOnSpecifiedComponent() throws ConfigurationException
+    {
+        final RuleSet rs = new RuleSet();
+
+        // grant user6 access right on "getAttribute" method in "Test" component
+        ObjectProperties ruleProperties = new ObjectProperties("getAttribute");
+        ruleProperties.put(ObjectProperties.Property.COMPONENT, "Test");
+        rs.grant(1, "user6", Permission.ALLOW, Operation.ACCESS, ObjectType.METHOD, ruleProperties);
+        configureAccessControl(rs);
+        SecurityManager.setThreadSubject(TestPrincipalUtils.createTestSubject("user6"));
+
+        ObjectProperties properties = new ObjectProperties("getAttribute");
+        properties.put(ObjectProperties.Property.COMPONENT, "Test");
+        Result result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, properties);
+        assertEquals(Result.ALLOWED, result);
+
+        properties.put(ObjectProperties.Property.COMPONENT, "Test2");
+        result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, properties);
+        assertEquals(Result.DEFER, result);
+
+        properties = new ObjectProperties("getAttribute2");
+        properties.put(ObjectProperties.Property.COMPONENT, "Test");
+        result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, properties);
+        assertEquals(Result.DEFER, result);
+    }
+
+    /**
+     * Tests that granting of all method rights on a method allows a specified operation to be performed on any component
+     */
+    public void testAuthoriseAccessUpdateMethodWhenAllRightsGrantedOnSpecifiedMethodForAllComponents() throws ConfigurationException
+    {
+        final RuleSet rs = new RuleSet();
+
+        // grant user8 all rights on method queryNames in all component
+        rs.grant(1, "user8", Permission.ALLOW, Operation.ALL, ObjectType.METHOD, new ObjectProperties("queryNames"));
+        configureAccessControl(rs);
+        SecurityManager.setThreadSubject(TestPrincipalUtils.createTestSubject("user8"));
+
+        ObjectProperties properties = new ObjectProperties();
+        properties.put(ObjectProperties.Property.COMPONENT, "Test");
+        properties.put(ObjectProperties.Property.NAME, "queryNames");
+
+        Result result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, properties);
+        assertEquals(Result.ALLOWED, result);
+
+        result = _plugin.authorise(Operation.UPDATE, ObjectType.METHOD, properties);
+        assertEquals(Result.ALLOWED, result);
+
+        properties = new ObjectProperties("getAttribute");
+        properties.put(ObjectProperties.Property.COMPONENT, "Test");
+        result = _plugin.authorise(Operation.UPDATE, ObjectType.METHOD, properties);
+        assertEquals(Result.DEFER, result);
+
+        result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, properties);
+        assertEquals(Result.DEFER, result);
+    }
+
+    /**
+     * Tests that granting of all method rights allows any operation to be performed on any component
+     */
+    public void testAuthoriseAccessUpdateMethodWhenAllRightsGrantedOnAllMethodsInAllComponents() throws ConfigurationException
+    {
+        final RuleSet rs = new RuleSet();
+
+        // grant user9 all rights on any method in all component
+        rs.grant(1, "user9", Permission.ALLOW, Operation.ALL, ObjectType.METHOD, new ObjectProperties());
+        configureAccessControl(rs);
+        SecurityManager.setThreadSubject(TestPrincipalUtils.createTestSubject("user9"));
+
+        ObjectProperties properties = new ObjectProperties("queryNames");
+        properties.put(ObjectProperties.Property.COMPONENT, "Test");
+
+        Result result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, properties);
+        assertEquals(Result.ALLOWED, result);
+
+        result = _plugin.authorise(Operation.UPDATE, ObjectType.METHOD, properties);
+        assertEquals(Result.ALLOWED, result);
+
+        properties = new ObjectProperties("getAttribute");
+        properties.put(ObjectProperties.Property.COMPONENT, "Test");
+        result = _plugin.authorise(Operation.UPDATE, ObjectType.METHOD, properties);
+        assertEquals(Result.ALLOWED, result);
+
+        result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, properties);
+        assertEquals(Result.ALLOWED, result);
+    }
+
+    /**
+     * Tests that granting of access method rights with mask allows matching operations to be performed on the specified component
+     */
+    public void testAuthoriseAccessMethodWhenMatchingAcessOperationsAllowedOnSpecifiedComponent() throws ConfigurationException
+    {
+        final RuleSet rs = new RuleSet();
+
+        // grant user9 all rights on "getAttribute*" methods in Test component
+        ObjectProperties ruleProperties = new ObjectProperties();
+        ruleProperties.put(ObjectProperties.Property.COMPONENT, "Test");
+        ruleProperties.put(ObjectProperties.Property.NAME, "getAttribute*");
+
+        rs.grant(1, "user9", Permission.ALLOW, Operation.ACCESS, ObjectType.METHOD, ruleProperties);
+        configureAccessControl(rs);
+        SecurityManager.setThreadSubject(TestPrincipalUtils.createTestSubject("user9"));
+
+        ObjectProperties properties = new ObjectProperties("getAttributes");
+        properties.put(ObjectProperties.Property.COMPONENT, "Test");
+        Result result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, properties);
+        assertEquals(Result.ALLOWED, result);
+
+        properties = new ObjectProperties("getAttribute");
+        properties.put(ObjectProperties.Property.COMPONENT, "Test");
+        result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, properties);
+        assertEquals(Result.ALLOWED, result);
+
+        properties = new ObjectProperties("getAttribut");
+        properties.put(ObjectProperties.Property.COMPONENT, "Test");
+        result = _plugin.authorise(Operation.ACCESS, ObjectType.METHOD, properties);
+        assertEquals(Result.DEFER, result);
+    }
+
     /**
      * Creates a configuration plugin for the {@link AccessControl} plugin.
      */
@@ -150,6 +327,7 @@
     {
         final ConfigurationPlugin cp = new ConfigurationPlugin()
         {
+            @SuppressWarnings("unchecked")
             public AccessControlConfiguration  getConfiguration(final String plugin)
             {
                 return new AccessControlConfiguration()
diff --git a/qpid/java/broker-plugins/experimental/info/MANIFEST.MF b/qpid/java/broker-plugins/experimental/info/MANIFEST.MF
deleted file mode 100644
index f213104..0000000
--- a/qpid/java/broker-plugins/experimental/info/MANIFEST.MF
+++ /dev/null
@@ -1,16 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: QpidPlugin
-Bundle-SymbolicName: qpid_info_plugin;singleton:=true
-Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
-Bundle-Version: 1.0.0
-Bundle-Activator: org.apache.qpid.info.Activator
-Import-Package: org.apache.qpid.server.configuration,
- org.osgi.framework,
- org.apache.qpid.common,
- org.apache.qpid.server.registry
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ClassPath: .
-Bundle-ActivationPolicy: lazy
-Export-Package: org.apache.qpid.info;uses:="org.osgi.framework"
-
diff --git a/qpid/java/broker-plugins/experimental/info/build.properties b/qpid/java/broker-plugins/experimental/info/build.properties
deleted file mode 100644
index bdbbe1c..0000000
--- a/qpid/java/broker-plugins/experimental/info/build.properties
+++ /dev/null
@@ -1,31 +0,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.
-#
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
-               .,\
-               plugin.xml,\
-               lib/eventTrackerClient-2.7.0.jar,\
-               lib/commons-logging-1.0.4.jar
-src.includes = src/,\
-               plugin.xml,\
-               lib/,\
-               build.properties,\
-               bin/,\
-               META-INF/
diff --git a/qpid/java/broker-plugins/experimental/info/build.xml b/qpid/java/broker-plugins/experimental/info/build.xml
deleted file mode 100644
index 8f91adc..0000000
--- a/qpid/java/broker-plugins/experimental/info/build.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<!--
- -
- - Licensed to the Apache Software Foundation (ASF) under one
-nn - or more contributor license agreements.  See the NOTICE file
- -n 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.
- -
- -->
-<project name="AMQ Broker Info Plugin" default="build">
-
-    <condition property="info-plugin.optional.depends" value="bdbstore" else="">
-        <and>
-            <contains string="${modules.opt}" substring="bdbstore"/>
-            <contains string="${profile}" substring="bdb"/>
-        </and>
-    </condition>
-
-    <property name="module.depends" value="common broker broker-plugins ${info-plugin.optional.depends}"/>
-    <property name="module.test.depends" value="test broker/test management/common client systests common/test"/>
-    <property name="module.manifest" value="MANIFEST.MF"/>
-    <property name="module.plugin" value="true"/>
-
-    <import file="../../../module.xml"/>
-
-    <target name="bundle" depends="bundle-tasks"/>
-
-</project>
diff --git a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Activator.java b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Activator.java
deleted file mode 100644
index 21e7be2..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Activator.java
+++ /dev/null
@@ -1,211 +0,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.
- *
- */
-
-package org.apache.qpid.info;
-
-import org.apache.qpid.info.util.HttpPoster;
-import org.apache.qpid.info.util.IniFileReader;
-import org.apache.qpid.info.util.SoapClient;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-/** The Activator class for the OSGI info service */
-public class Activator implements BundleActivator
-{
-
-    private final List<String> _soapPropList = Arrays.asList("soap.hostname",
-                                                             "soap.port", "soap.path", "soap.action", "soap.envelope");
-
-    private final List<String> _httpPropList = Arrays.asList("http.url",
-                                                             "http.envelope");
-
-    InfoServiceImpl _service = null;
-
-    BundleContext _ctx = null;
-
-    /**
-     * Start bundle method
-     *
-     * @param ctx the bundle context
-     */
-    public void start(BundleContext ctx) throws Exception
-    {
-        if (null != ctx)
-        {
-            _ctx = ctx;
-            _service = new InfoServiceImpl();
-            ctx.registerService(InfoService.class.getName(), _service, null);
-
-            new Thread(new Runnable()
-            {
-                public void run()
-                {
-                    sendInfo("STARTUP");
-                }
-            }).start();
-        }
-    }
-
-    /**
-     * Stop the bundle method
-     *
-     * @param ctx the bundle context
-     */
-    public void stop(BundleContext ctx) throws Exception
-    {
-        sendInfo("SHUTDOWN");
-    }
-
-    /**
-     * Sends the information message
-     *
-     * @param action label that identifies if we are starting up or shutting down
-     */
-    private void sendInfo(String action)
-    {
-        if ((null == _ctx) && (null == _service))
-        {
-            // invalid state
-            return;
-        }
-
-        IniFileReader ifr = new IniFileReader();
-        try
-        {
-            String QPID_HOME = System.getProperty("QPID_HOME");
-            String cfgFilePath = QPID_HOME + File.separator + "etc"
-                                 + File.separator + "qpidinfo.ini";
-            ifr.load(cfgFilePath);
-        }
-        catch (Throwable ex)
-        {
-            // drop everything to be silent
-            return;
-        }
-
-        // Only send Messages if we have some sections.
-        if (ifr.getSections().size() != 0)
-        {
-            Info<? extends Map<String, ?>> info = _service.invoke(action);
-            String protocol = ifr.getSections().get("").getProperty("protocol");
-            sendMessages(protocol, ifr, info);
-        }
-    }
-
-    /**
-     * Sends all the messages configured in the properties file
-     *
-     * @param protocol indicates what protocol to be used: http and soap implemented
-     *                 for now
-     * @param ifr      an instance of IniFileReader class
-     * @param info     an instance of an Info object, encapsulating the information
-     *                 we want to send
-     */
-    private void sendMessages(String protocol, IniFileReader ifr,
-                              Info<? extends Map<String, ?>> info)
-    {
-        if (null != protocol)
-        {
-            // Set the global properties first (as they are the defaults)
-            Properties defaultProps = ifr.getSections().get("");
-            if (protocol.toLowerCase().startsWith("http"))
-            {
-                for (String section : ifr.getSections().keySet())
-                {
-                    // Skip the defaults
-                    if (section.equals(""))
-                    {
-                        continue;
-                    }
-                    Properties props = new Properties();
-                    props.putAll(defaultProps);
-                    props.putAll(ifr.getSections().get(section));
-                    if (isValid(protocol, props))
-                    {
-                        new HttpPoster(props, info.toXML()).run();
-                    }
-                }
-
-            }
-            else if (protocol.toLowerCase().startsWith("soap"))
-            {
-                for (String section : ifr.getSections().keySet())
-                {
-                    Properties props = new Properties();
-                    props.putAll(defaultProps);
-                    props.putAll(ifr.getSections().get(section));
-                    if (isValid(protocol, props))
-                    {
-                        new SoapClient(info.toMap(), props).sendSOAPMessage();
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Checks if the properties for a specified protocol are valid
-     *
-     * @param protocol String representing the protocol
-     * @param props    The properties associate with the specified protocol
-     * @return boolean
-     */
-    private boolean isValid(String protocol, Properties props)
-    {
-        if (null == protocol)
-        {
-            return false;
-        }
-        String value = "";
-        if (protocol.toLowerCase().startsWith("http"))
-        {
-            for (String prop : _httpPropList)
-            {
-                if (null == props.get(prop))
-                {
-                    return false;
-                }
-            }
-            return true;
-        }
-
-        if (protocol.toLowerCase().startsWith("soap"))
-        {
-            for (String prop : _soapPropList)
-            {
-                value = props.getProperty(prop);
-                if (null == value)
-                {
-                    return false;
-                }
-            }
-            return true;
-        }
-        return false;
-    }
-} // end class
-
diff --git a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/AppInfo.java b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/AppInfo.java
deleted file mode 100644
index c8e9805..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/AppInfo.java
+++ /dev/null
@@ -1,92 +0,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.
- *
- */
-
-package org.apache.qpid.info;
-
-import org.apache.qpid.common.QpidProperties;
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.TreeMap;
-
-/** AppInfo class is gathering application specific information */
-public class AppInfo
-{
-
-    private static final List<String> appProps = Arrays.asList("QPID_HOME",
-                                                               "QPID_WORK");
-
-    private static Map<String, String> appInfoMap = new TreeMap<String, String>();
-
-    /**
-     * getInfo method retrieves a key-value map for specific application properties
-     *
-     * @return Map<String,String>
-     */
-    public static Map<String, String> getInfo()
-    {
-
-        // Gather the selected app props
-        Properties sysprops = System.getProperties();
-        String propName;
-        for (Iterator<Entry<Object, Object>> it = sysprops.entrySet()
-                .iterator(); it.hasNext();)
-        {
-            Entry<Object, Object> en = it.next();
-            propName = en.getKey().toString();
-            if (appProps.indexOf(propName) >= 0)
-            {
-                appInfoMap.put(propName, en.getValue().toString());
-            }
-        }
-
-        ServerConfiguration sc;
-        try
-        {
-            sc = ApplicationRegistry.getInstance().getConfiguration();
-            if (null != sc)
-            {
-                appInfoMap.put("jmxport", sc.getJMXPortRegistryServer() + "");
-                appInfoMap.put("port", sc.getPorts().toString());
-                appInfoMap.put("version", QpidProperties.getReleaseVersion());
-                appInfoMap.put("vhosts", "standalone");
-                appInfoMap.put("KeystorePath", sc.getConnectorKeyStorePath());
-                appInfoMap.put("PluginDirectory", sc.getPluginDirectory());
-                appInfoMap.put("CertType", sc.getConnectorCertType());
-                appInfoMap.put("QpidWork", sc.getQpidWork());
-                appInfoMap.put("Bind", sc.getBind());
-            }
-        }
-        catch (Exception e)
-        {
-            // drop everything to be silent
-        }
-        return appInfoMap;
-
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Info.java b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Info.java
deleted file mode 100644
index 2fb9382..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/Info.java
+++ /dev/null
@@ -1,143 +0,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.
- *
- */
-
-/**
- *
- * @author sorin
- *
- *  Info object
- */
-
-package org.apache.qpid.info;
-
-import org.apache.qpid.info.util.XMLWriter;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * The Info class encapsulates all the information we are collecting
- * and it is able to render it in different data representations
- */
-public class Info<T extends Map<String, ?>>
-{
-    private T _info;
-
-    /**
-     * Constructor.
-     *
-     * @param info instantiates the object with a Map<String,?>
-     */
-    public Info(T info)
-    {
-        _info = info;
-    }
-
-    @Override
-    public String toString()
-    {
-        String result = "";
-        for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();)
-        {
-            String str = it.next();
-            result += str + "=" + _info.get(str).toString() + "\n";
-        }
-        return result;
-    }
-
-    /**
-     * Renders Info map to a property object
-     *
-     * @return A Properties object representing the Info map
-     */
-    public Properties toProps()
-    {
-        Properties props = new Properties();
-        if (null == _info)
-        {
-            return null;
-        }
-        for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();)
-        {
-            String key = it.next();
-            props.put(key, _info.get(key));
-        }
-        return props;
-    }
-
-    /**
-     * Renders Info map to a StringBuffer
-     *
-     * @return A StringBuffer object representing the Info map
-     */
-    public StringBuffer toStringBuffer()
-    {
-        StringBuffer sb = new StringBuffer();
-        for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();)
-        {
-            String str = it.next();
-            sb.append(str + "=" + _info.get(str).toString() + "\n");
-        }
-        return sb;
-    }
-
-    /**
-     * Renders Info map to a StringBuffer containing an XML string
-     *
-     * @return A StringBuffer object containing an XML representation of the Info map
-     */
-    public StringBuffer toXML()
-    {
-        XMLWriter xw = new XMLWriter(new StringBuffer());
-        xw.writeXMLHeader();
-        Map<String, String> attr = new HashMap<String, String>();
-        xw.writeOpenTag("qpidinfo", attr);
-        String key;
-        for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();)
-        {
-            attr.clear();
-            key = it.next();
-            xw.writeTag(key, attr, _info.get(key).toString());
-        }
-        xw.writeCloseTag("qpidinfo");
-        return xw.getXML();
-    }
-
-    /**
-     * Renders Info map to a HashMap
-     *
-     * @return A HashMap object representing the Info map
-     */
-    public HashMap<String, String> toMap()
-    {
-        String key;
-        HashMap<String, String> infoMap = new HashMap<String, String>();
-        for (Iterator<String> it = _info.keySet().iterator(); it.hasNext();)
-        {
-            key = it.next();
-            infoMap.put(key, _info.get(key).toString());
-        }
-        return infoMap;
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/InfoService.java b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/InfoService.java
deleted file mode 100644
index 2804dfb..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/InfoService.java
+++ /dev/null
@@ -1,30 +0,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.
- *
- */
-
-    /**
-     * Interface exposing the service methods    
-     */
-    package org.apache.qpid.info;
-    
-    public interface InfoService
-    {
-        public Info<?> invoke(String action);
-    }
diff --git a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/InfoServiceImpl.java b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/InfoServiceImpl.java
deleted file mode 100644
index 5522f27..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/InfoServiceImpl.java
+++ /dev/null
@@ -1,66 +0,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.
- *
- */
-
-/**
- *
- * @author sorin
- *
- *  Implementation for Info service
- */
-
-package org.apache.qpid.info;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-
-public class InfoServiceImpl implements InfoService
-{
-
-    SortedMap<String, String> infoMap = new TreeMap<String, String>();
-
-    /**
-     * invoke method collects all the information from System and Application
-     * and encapsulates them in an Info object
-     * @return An instance of an Info object
-     */
-    public Info<? extends Map<String,?>> invoke(String action)
-    {
-        // Record the action (STARTUP/SHUTDOWN)
-        infoMap.put("action",action);
-
-        // Record the current time stamp
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
-        infoMap.put("time", sdf.format(Calendar.getInstance().getTime()));
-
-        // Add the system specific properties 
-        infoMap.putAll(SystemInfo.getInfo());
-        
-        // Add the application specific properties
-        infoMap.putAll(AppInfo.getInfo());
-
-        return new Info<SortedMap<String, String>>(infoMap);
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/SystemInfo.java b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/SystemInfo.java
deleted file mode 100644
index 8bd94fe..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/SystemInfo.java
+++ /dev/null
@@ -1,91 +0,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.
- *
- */
-
-package org.apache.qpid.info;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TreeMap;
-import java.util.Map.Entry;
-
-/**
- * Collector for system specific information
- */
-public class SystemInfo
-{
-
-    private static Map<String, String> sysInfoMap = new TreeMap<String, String>();
-
-    private static final List<String> sysProps = Arrays.asList(
-            "java.class.path", "java.home", "java.vm.name", "java.vm.vendor",
-            "java.vm.version", "java.class.version", "java.runtime.version",
-            "os.arch", "os.name", "os.version", "sun.arch.data.model",
-            "user.home", "user.dir", "user.name", "user.timezone");
-
-    /**
-     * getInfo collects all the properties specified in sysprops list
-     * @return A Map<String,String>
-     */
-    public static Map<String, String> getInfo()
-    {
-
-        // Get the hostname
-        try
-        {
-            InetAddress addr = InetAddress.getLocalHost();
-            String hostname = addr.getHostName();
-            sysInfoMap.put("hostname", hostname);
-            sysInfoMap.put("ip", addr.getHostAddress());
-        }
-        catch (UnknownHostException e)
-        {
-            // drop everything to be silent
-        }
-        // Get the runtime info
-        sysInfoMap.put("CPUCores", Runtime.getRuntime().availableProcessors()
-                + "");
-        sysInfoMap.put("Maximum_Memory", Runtime.getRuntime().maxMemory() + "");
-        sysInfoMap.put("Free_Memory", Runtime.getRuntime().freeMemory() + "");
-
-        // Gather the selected system props
-        Properties sysprops = System.getProperties();
-        String propName;
-        for (Iterator<Entry<Object, Object>> it = sysprops.entrySet()
-                .iterator(); it.hasNext();)
-        {
-            Entry<Object, Object> en = it.next();
-            propName = en.getKey().toString();
-            if (sysProps.indexOf(propName) >= 0)
-            {
-                sysInfoMap.put(propName, en.getValue().toString());
-            }
-        }
-
-        return sysInfoMap;
-
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/HttpPoster.java b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/HttpPoster.java
deleted file mode 100644
index d27980b..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/HttpPoster.java
+++ /dev/null
@@ -1,130 +0,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.

- *

- */

-

-package org.apache.qpid.info.util;

-

-import java.util.ArrayList;

-import java.util.Hashtable;

-import java.util.Iterator;

-import java.util.List;

-import java.util.Properties;

-import java.io.BufferedReader;

-import java.io.InputStreamReader;

-import java.io.OutputStreamWriter;

-import java.net.InetAddress;

-import java.net.URL;

-import java.net.URLConnection;

-import java.net.UnknownHostException;

-

-/**

- * 

- *  An simple Http post class for qpid info service

- */

-public class HttpPoster implements Runnable

-{

-    private final String _url;

-

-    private final Hashtable<String, String> _header;

-

-    private final List<String> _response = new ArrayList<String>();

-

-    private final StringBuffer _buf;

-

-    /**

-     * Constructor

-     *

-     * @param props Properties containing the URL

-     * @param buf   Buffer containing the message to be posted

-     */

-    public HttpPoster(Properties props, StringBuffer buf)

-    {

-        _buf = buf;

-        if (null != props)

-        {

-            _url = props.getProperty("http.url");

-            _header = new Hashtable<String, String>();

-            try

-            {

-                String hostname = InetAddress.getLocalHost().getHostName();

-                _header.put("hostname", hostname);

-            }

-            catch (UnknownHostException e)

-            {

-                // Silently ignoring the error ;)

-            }

-        }

-        else

-        {

-            _url = null;

-            _header = null;

-        }

-    }

-

-    /** Posts the message from the _buf StringBuffer to the http server */

-    public void run()

-    {

-        if (null == _url)

-        {

-            return;

-        }

-        String line;

-        URL urlDest;

-        URLConnection urlConn;

-        try

-        {

-            urlDest = new URL(_url);

-            urlConn = urlDest.openConnection();

-            urlConn.setDoOutput(true);

-            urlConn.setUseCaches(false);

-            for (Iterator<String> it = _header.keySet().iterator(); it.hasNext();)

-            {

-                String prop = it.next();

-                urlConn.setRequestProperty(prop, _header.get(prop));

-            }

-            OutputStreamWriter wr =

-                    new OutputStreamWriter(urlConn.getOutputStream());

-            wr.write(_buf.toString());

-            wr.flush();

-            // Get the response

-            BufferedReader rd = new BufferedReader(new InputStreamReader(

-                    urlConn.getInputStream()));

-            while ((line = rd.readLine()) != null)

-            {

-                _response.add(line);

-            }

-        }

-        catch (Exception ex)

-        {

-            // Silently ignoring the error ;)

-        }

-    }

-

-    /**

-     * Retrieves the response from the http server

-     *

-     * @return List<String> response received from the http server

-     */

-    public List<String> get_response()

-    {

-        return _response;

-    }

-

-}

diff --git a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/IniFileReader.java b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/IniFileReader.java
deleted file mode 100644
index 60a025d..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/IniFileReader.java
+++ /dev/null
@@ -1,193 +0,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.
- *
- */
-
-package org.apache.qpid.info.util;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * This class is simple implementation of an ini file reader. It expects a
- * file with the following structure:
- *
- * ; global values, can be overwritten in sections
- * key1=value1
- * key2=value2
- *
- * [Section1]
- * key1=value1_new  ; overwriting the global key1
- * key3=value3
- * key4=value4
- *
- * [Section2]
- * key5=value5
- * key6=value6
- * key7=value7
- *
- * Note: Commentaries are preceded by ; or # and are supported throughout
- * A commentary line at the end of section is interpreted as
- * a section end marker
- *
- * A structure <String,Properties> (section name, associated properties)
- * is generated as a result of processing the ini file.
- */
-public class IniFileReader
-{
-    private final Map<String, Properties> _sections;
-
-    private final String COMMENT_SEMICOLON = ";";
-
-    private final String COMMENT_HASH = "#";
-
-    enum State
-    {
-        IN_SECTION, OFF_SECTION, GLOBAL
-    }
-
-    /*
-     * IniFileReader constructor
-     */
-
-    public IniFileReader()
-    {
-        _sections = new HashMap<String, Properties>();
-    }
-
-    /**
-     * Cleans up the after comments or the empty spaces/tabs surrounding the given string
-     *
-     * @param str The String to be cleaned
-     *
-     * @return String Cleanup Version
-     */
-    private String cleanUp(String str)
-    {
-        if (str.contains(COMMENT_SEMICOLON))
-        {
-            str = str.substring(0, str.indexOf(COMMENT_SEMICOLON));
-        }
-        if (str.contains(COMMENT_HASH))
-        {
-            str = str.substring(0, str.indexOf(COMMENT_HASH));
-        }
-        return str.trim();
-    }
-
-    /**
-     * Loads and parses the ini file with the full path specified in the argument
-     *
-     * @param fileName Full path to the ini file
-     *
-     * @throws IllegalArgumentException If the file cannot be processed
-     */
-    public void load(String fileName) throws IllegalArgumentException
-    {
-        if (!new File(fileName).isFile())
-        {
-            throw new IllegalArgumentException("File: " + fileName + " does not exist or cannot be read.");
-        }
-        State state = State.GLOBAL;
-        String line;
-        Properties sectionProps = new Properties();
-        String sectionName = "";
-        try
-        {
-            BufferedReader in = new BufferedReader(new FileReader(fileName));
-            while ((line = in.readLine()) != null)
-            {
-                String str = cleanUp(line);
-
-                // Did we get a section header?
-                if (str.startsWith("["))
-                {
-                    if (!str.endsWith("]"))
-                    {
-                        // Index of 1 to skip '['
-                        throw new IllegalArgumentException(str.substring(1)
-                                                           + " is not closed");
-                    }
-
-                    // We encountered a new section header
-                    if (state != State.IN_SECTION)
-                    {
-                        _sections.put(sectionName, sectionProps);
-                        sectionProps = new Properties();
-                        sectionName = str.replace("[", "").replace("]", "")
-                                .trim();
-                        state = State.IN_SECTION;
-                    }
-                }
-
-                // Any other line tested separately, ignore if out of a section
-                // and add if in section
-                if (str.length() == 0)
-                {
-                    // We encountered a commented or an empty line, both cases
-                    // mean we are off the section
-                    if (state == State.IN_SECTION)
-                    {
-                        _sections.put(sectionName, sectionProps);
-                        state = State.OFF_SECTION;
-                    }
-                }
-                else
-                {
-                    // proper line, add it to the props
-                    if (state != State.OFF_SECTION)
-                    {
-                        if (str.contains("="))
-                        {
-                            int ix = str.indexOf("=");
-                            sectionProps.put(str.substring(0, ix).trim(), str
-                                    .substring(ix + 1).trim());
-                        }
-                    }
-                }
-            }
-            in.close();
-        }
-        catch (IOException e)
-        {
-            _sections.clear();
-            return;
-        }
-        if (state != State.OFF_SECTION)
-        {
-            _sections.put(sectionName, sectionProps);
-        }
-    }
-
-    /**
-     * Getter for the Sections Map
-     *
-     * @return Map<String,Properties> The parsed content of the ini file in this structure
-     */
-    public Map<String, Properties> getSections()
-    {
-        return _sections;
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/SoapClient.java b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/SoapClient.java
deleted file mode 100644
index 0f66085..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/SoapClient.java
+++ /dev/null
@@ -1,155 +0,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.
- *
- */
-/**
- *
- * @author sorin
- *
- *  An simple SOAP client for qpid info service
- */
-package org.apache.qpid.info.util;
-
-import java.io.BufferedWriter;
-import java.io.OutputStreamWriter;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.util.HashMap;
-import java.util.Properties;
-
-public class SoapClient
-{
-
-    private final StringBuffer _xmlData;
-
-    private final Properties _destprops;
-
-    private final String _hostname;
-
-    private final int _port;
-
-    private final String _urlpath;
-
-    private final String _soapenvelope;
-    
-    private final String _soapaction;
-    
-    private final StringBuffer _soapMessage = new StringBuffer();
-    
-
-    public SoapClient(HashMap<String, String> map, Properties destprops)
-    {
-        _destprops = destprops;
-        _hostname = (String) _destprops.get("soap.hostname");
-        _port = Integer.parseInt((String) _destprops.get("soap.port"));
-        _urlpath = (String) destprops.get("soap.path");
-        _soapenvelope = (String) destprops.get("soap.envelope");
-        _soapaction = (String) destprops.get("soap.action");
-        _xmlData = new StringBuffer(_soapenvelope);
-        replaceVariables(map);
-    }
-
-    public StringBuffer getXMLData()
-    {
-        return _xmlData;
-    }
-
-    public StringBuffer getSoapMessage() {
-        return _soapMessage;
-    }
-   
-    public String getSoapEnvelope() {
-        return _soapenvelope;
-    }
-
-    /**
-     * Clears and sets new XML data
-     * @param sb the new data to set
-     */
-    public void setXMLData(StringBuffer sb)
-    {
-        _xmlData.delete(0, _xmlData.length());
-        _xmlData.append(sb);
-    }
-    
-
-    public void replaceVariables(HashMap<String, String> vars)
-    {
-        int ix = 0;
-        for (String var : vars.keySet())
-        {
-            while ((ix = _xmlData.indexOf("@" + var.toUpperCase())) >= 0)
-            {
-                _xmlData.replace(ix, ix + 1 + var.length(), vars.get(var));
-            }
-        }
-    }
-
-    public void replaceVariables(Properties varProps)
-    {
-        if (varProps == null)
-        {
-            return;
-        }
-        int ix = 0;
-        for (Object var : varProps.keySet())
-        {
-            while ((ix = _xmlData.indexOf("@" + var)) >= 0)
-            {
-                _xmlData.replace(ix, ix + 1 + var.toString().length(), varProps
-                        .get(var).toString());
-            }
-        }
-    }
-    
-
-    public void sendSOAPMessage()
-    {
-
-        try
-        {
-            InetAddress addr = InetAddress.getByName(_hostname);
-            Socket sock = new Socket(addr, _port);
-            StringBuffer sb = new StringBuffer();
-            sb.append("POST " + _urlpath + " HTTP/1.1\r\n");
-            sb.append("Host: " + _hostname + ":" + _port + "\r\n");
-            sb.append("Content-Length: " + _xmlData.length() + "\r\n");
-            sb.append("Content-Type: text/xml; charset=\"utf-8\"\r\n");
-            sb.append("SOAPAction: \"urn:"+ _soapaction +"\"\r\n");
-            sb.append("User-Agent: Axis2\r\n");
-            sb.append("\r\n");
-            // Send header
-            BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(sock
-                    .getOutputStream(), "UTF-8"));
-            synchronized(_soapMessage) {
-                _soapMessage.setLength(0);
-                _soapMessage.append(sb);
-                _soapMessage.append(_xmlData);
-            }
-            // Send data
-            wr.write(_soapMessage.toString());
-            wr.flush();
-            wr.close();
-            
-        } catch (Exception ex)
-        {
-            // Drop any exception
-        }
-    }
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/XMLWriter.java b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/XMLWriter.java
deleted file mode 100644
index a266eda..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/util/XMLWriter.java
+++ /dev/null
@@ -1,100 +0,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.
- *
- */
-
-package org.apache.qpid.info.util;
-
-import java.util.Map;
-
-/**
- * 
- *  Naive and rudimentary XML writer
- *  It has methods to write the header, a tag with attributes 
- *  and values. It escapes the XML special characters 
- */
-public class XMLWriter
-{
-
-    private final StringBuffer _sb;
-
-    private final String INDENT = "    ";
-
-    public XMLWriter(StringBuffer sb)
-    {
-        _sb = sb;
-    }
-
-    public StringBuffer getXML()
-    {
-        return _sb;
-    }
-
-    public void writeXMLHeader()
-    {
-        _sb.append("<?xml version=\"1.0\"?>\n");
-    }
-
-    public void writeTag(String tagName, Map<String, String> attributes,
-            String value)
-    {
-        writeOpenTag(tagName, attributes);
-        writeValue(value);
-        writeCloseTag(tagName);
-    }
-
-    public void writeOpenTag(String tagName, Map<String, String> attributes)
-    {
-        _sb.append("<").append(tagName);
-        if (null == attributes)
-        {
-            _sb.append(">\n");
-            return;
-        }
-        for (String key : attributes.keySet())
-        {
-            _sb.append(" ").append(key + "=\"" + attributes.get(key) + "\"");
-        }
-        _sb.append(">\n");
-
-    }
-
-    private void writeValue(String val)
-    {
-        _sb.append(INDENT).append(escapeXML(val) + "\n");
-    }
-
-    public void writeCloseTag(String tagName)
-    {
-        _sb.append("</" + tagName + ">\n");
-    }
-
-    private String escapeXML(String xmlStr)
-    {
-        if (null == xmlStr)
-            return null;
-        xmlStr = xmlStr.replaceAll("&", "&amp;");
-        xmlStr = xmlStr.replace("<", "&lt;");
-        xmlStr = xmlStr.replace(">", "&gt;");
-        xmlStr = xmlStr.replace("\"", "&quot;");
-        xmlStr = xmlStr.replace("'", "&apos;");
-        return xmlStr;
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/systest/InfoPluginTest.java b/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/systest/InfoPluginTest.java
deleted file mode 100644
index 348e860..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/systest/InfoPluginTest.java
+++ /dev/null
@@ -1,277 +0,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.
- *
- */
-package org.apache.qpid.info.systest;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-public class InfoPluginTest extends QpidBrokerTestCase
-{
-    private String QPID_HOME = null;
-
-    private ServerSocket _server = null;
-
-    private int _port;
-
-    private static final String CR = System.getProperty("line.separator");
-
-    private static final String FS = File.separator;
-
-    private final String _cfgRelPath = "etc" + FS + "qpidinfo.ini";
-
-    private File _tmpCfgFile;
-
-    private final String _soapEnvelopeHead = "<?xml version=\"1.0\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\" soap:encodingStyle=\"http://www.w3.org/2001/12/soap-encoding\">";
-
-    private final String _soapEnvelopeTail = "</soap:Envelope>";
-
-    private String _soapMessage1 = "@ACTION" + "-" + "@VERSION";
-
-    private String _soapMessage2 = "@VERSION" + "-" + "@ACTION";
-
-    private CountDownLatch _latch = new CountDownLatch(2);
-
-    final List<List<String>> _recv = new ArrayList<List<String>>();
-
-    Thread _socketAcceptor;
-
-    public void setUp() throws Exception
-    {
-        QPID_HOME = System.getProperty("QPID_HOME");
-        if (QPID_HOME != null)
-        {
-            System.out.println("QPID_HOME=" + QPID_HOME);
-        }
-        else
-        {
-            fail("QPID_HOME not set");
-        }
-
-        startSoapServer();
-        // Must start the server first to identify a free port.
-        createConfigFile();
-    }
-
-    public void tearDown() throws Exception
-    {
-        System.out.println("*** Stopping socket server...");
-        _socketAcceptor.join(2000);
-
-        System.out.println("*** Deleting the config file...");
-        if (_tmpCfgFile.isFile())
-        {
-            _tmpCfgFile.delete();
-        }
-        super.tearDown();
-    }
-
-    private void createConfigFile()
-    {
-        try
-        {
-            _tmpCfgFile = new File(QPID_HOME + FS + _cfgRelPath);
-            _tmpCfgFile.deleteOnExit();
-            if (_tmpCfgFile.isFile())
-            {
-                _tmpCfgFile.delete();
-            }
-            assertTrue("Unable to create file.", _tmpCfgFile.createNewFile());
-            assertTrue(_tmpCfgFile.isFile());
-            FileWriter fwriter = new FileWriter(_tmpCfgFile);
-            BufferedWriter writer = new BufferedWriter(fwriter);
-            writer.write("protocol=soap");
-            writer.write(CR);
-            writer.write("soap.hostname=localhost");
-            writer.write(CR);
-            writer.write("soap.port=" + _port);
-            writer.write(CR);
-            writer.write(CR);
-            writer.write("[MSG1]");
-            writer.write(CR);
-            writer.write("soap.path=/info1");
-            writer.write(CR);
-            writer.write("soap.action=submitinfo1");
-            writer.write(CR);
-            writer.write("soap.envelope=" + _soapEnvelopeHead + _soapMessage1
-                         + _soapEnvelopeTail);
-            writer.write(CR);
-            writer.write(CR);
-            writer.write("[MSG2]");
-            writer.write(CR);
-            writer.write("soap.path=/info2");
-            writer.write(CR);
-            writer.write("soap.action=submitinfo2");
-            writer.write(CR);
-            writer.write("soap.envelope=" + _soapEnvelopeHead + _soapMessage2
-                         + _soapEnvelopeTail);
-            writer.write(CR);
-            writer.write(CR);
-            writer.close();
-            assertTrue("Config file size is zero", _tmpCfgFile.length() > 0);
-        }
-        catch (IOException e)
-        {
-            fail("Unable to create the qpidinfo.properties due to: "
-                 + e.getMessage());
-        }
-    }
-
-    private void startSoapServer() throws Exception
-    {
-        try
-        {
-            _server = new ServerSocket(0);
-            _port = _server.getLocalPort();
-            assertTrue("Server not yet bound.", _port != -1);
-
-            assertNotNull("SocketServer is null", _server);
-        }
-        catch (Exception ex)
-        {
-            fail("Unable to start the socket server due to: " + ex.getMessage());
-        }
-
-        _socketAcceptor = new Thread()
-        {
-            public void run()
-            {
-                while (true)
-                {
-                    try
-                    {
-                        Socket socket = _server.accept();
-                        new ConnectionHandler(socket);
-                    }
-                    catch (IOException e)
-                    {
-                        fail("Error opening the socket in accept mode");
-                    }
-                }
-            }
-        };
-        _socketAcceptor.start();
-        System.out.println("*** Socket server started...");
-    }
-
-    class ConnectionHandler implements Runnable
-    {
-        private Socket _socket;
-
-        public ConnectionHandler(Socket socket)
-        {
-            _socket = socket;
-            Thread t = new Thread(this);
-            t.start();
-        }
-
-        public void run()
-        {
-            System.out.println("*** Connection handler running...");
-            List<String> buf = new ArrayList<String>();
-            String line;
-            try
-            {
-                BufferedReader br = new BufferedReader(new InputStreamReader(
-                        _socket.getInputStream()));
-                assertNotNull(br);
-                while ((line = br.readLine()) != null)
-                {
-                    buf.add(line);
-                }
-                br.close();
-                System.out.println("*** Received buffer: " + buf);
-                synchronized (_recv)
-                {
-                    _recv.add(buf);
-                }
-
-                System.out.println("*** Latch countdown");
-                _latch.countDown();
-            }
-            catch (Exception ex)
-            {
-                ex.printStackTrace();
-                fail("Exception while reading from the socket");
-            }
-
-        }
-
-    }
-
-    public void testInfoPlugin() throws Exception
-    {
-        //Start the broker
-        super.setUp();
-        if (!_latch.await(10, TimeUnit.SECONDS))
-        {
-            fail("Timeout awaiting for the latch, upon startup");
-        }
-
-        validateResponses("STARTUP");
-
-        _recv.clear();
-        _latch = new CountDownLatch(2);
-
-        stopBroker();
-
-        if (!_latch.await(10, TimeUnit.SECONDS))
-        {
-            fail("Timeout awaiting for the latch, upon shutdown");
-        }
-
-        validateResponses("SHUTDOWN");
-
-    }
-
-    /**
-     * Check the responses from the server to ensure they contain the required messages.
-     * @param action String to match for the SHUTDOWN or STARTUP action.
-     */
-    private void validateResponses(String action)
-    {
-        assertTrue("Received less than 2 messages", _recv.size() > 1);
-
-        // Message 1
-        assertTrue("Message does not contain Host: localhost:" + _port + "\n" + _recv.get(0), _recv.get(0).contains("Host: localhost:" + _port));
-        assertTrue("Message does not contain: User-Agent: Axis2 " + "\n" + _recv.get(0), _recv.get(0).contains("User-Agent: Axis2"));
-        assertTrue("Message does not contain: SOAPAction: \"urn:submitinfo\"" + "\n" + _recv.get(0).get(4), _recv.get(0).get(4).startsWith("SOAPAction: \"urn:submitinfo"));
-        assertTrue("Message does not contain '" + action + "' in the soap envelope" + "\n" + _recv.get(0).get(7), _recv.get(0).get(7).contains(action));
-
-        // Message 2
-        assertTrue("Message does not contain Host: localhost:" + _port + "\n" + _recv.get(1), _recv.get(1).contains("Host: localhost:" + _port));
-        assertTrue("Message does not contain: User-Agent: Axis2 " + "\n" + _recv.get(1), _recv.get(1).contains("User-Agent: Axis2"));
-        assertTrue("Message does not contain: SOAPAction: \"urn:submitinfo\"" + "\n" + _recv.get(1).get(4), _recv.get(1).get(4).startsWith("SOAPAction: \"urn:submitinfo"));
-        assertTrue("Message does not contain '" + action + "' in the soap envelope" + "\n" + _recv.get(1).get(7), _recv.get(1).get(7).contains(action));
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/HttpPosterTest.java b/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/HttpPosterTest.java
deleted file mode 100644
index 4f76fea..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/HttpPosterTest.java
+++ /dev/null
@@ -1,107 +0,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.
- * 
- */
-package org.apache.qpid.info.test;
-
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.qpid.info.util.HttpPoster;
-import org.mortbay.jetty.testing.ServletTester;
-
-import junit.framework.TestCase;
-
-/*
- * This test verifies that the plugin posts correctly to a webserver 
- * We use an embedded jetty container to mimic the webserver
- */
-public class HttpPosterTest extends TestCase
-{
-
-    private ServletTester tester;
-
-    private String baseURL;
-
-    private final String contextPath = "/info";
-
-    /*
-     * This method generates a dummy HttpPoster with a dummy body containing a
-     * single line. The url we are posting to can be controlled by the parameter
-     * url
-     * 
-     * @param url
-     */
-    private HttpPoster getHttpPoster(String url)
-    {
-        StringBuffer sb = new StringBuffer("test=TEST");
-        Properties props = new Properties();
-        props.put("http.url", url);
-        return new HttpPoster(props, sb);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        tester = new ServletTester();
-        tester.setContextPath("/");
-        tester.addServlet(InfoServlet.class, contextPath);
-        baseURL = tester.createSocketConnector(true);
-        tester.start();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see junit.framework.TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-        tester.stop();
-    }
-
-    /*
-     * This test is posting a string to an embedded Jetty Servlet and captures
-     * the response message. If the servlet receives the message ok, it will
-     * print Ok. A failure test is following where we post to a non-existent URL
-     */
-    public void testHttpPoster() throws Exception
-    {
-        // Test HttpPoster posts correctly to the servlet
-        HttpPoster hp = getHttpPoster(baseURL + contextPath);
-        assertNotNull(hp);
-        hp.run();
-        List<String> response = hp.get_response();
-        assertTrue(response.size() > 0);
-        assertEquals("OK <br>", response.get(0).toString());
-
-        // Failure Test
-        hp = getHttpPoster("http://localhost/nonexistent");
-        hp.run();
-        response = hp.get_response();
-        assertTrue(response.size() == 0);
-
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoServiceImplTest.java b/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoServiceImplTest.java
deleted file mode 100644
index 9f35958..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoServiceImplTest.java
+++ /dev/null
@@ -1,63 +0,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.
- *
- */
-
-package org.apache.qpid.info.test;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.qpid.info.Info;
-import org.apache.qpid.info.InfoServiceImpl;
-
-import junit.framework.TestCase;
-
-/*
- * This test verifies the invoke() method for the info service making sure that the parameters are returned
- */
-public class InfoServiceImplTest extends TestCase
-{
-
-    InfoServiceImpl _isi = null;
-
-    @SuppressWarnings("unchecked")
-    public void testInvoke()
-    {
-        _isi = new InfoServiceImpl();
-        assertNotNull(_isi);
-        Info<? extends Map<String, String>> info = (Info<? extends Map<String, String>>) _isi
-                .invoke("START");
-        assertNotNull(info);
-        Properties props = info.toProps();
-        assertNotNull(props);
-        List<String> infoProps = Arrays.asList("java.class.path",
-                "java.vm.name", "java.class.version", "os.arch", "os.name",
-                "os.version", "sun.arch.data.model", "user.dir", "user.name",
-                "user.timezone");
-        for (String tag : infoProps)
-        {
-            assertNotNull("Info.toProps() does not have the property: " + tag,
-                    props.getProperty(tag));
-        }
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoServlet.java b/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoServlet.java
deleted file mode 100644
index 6b12a2d..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoServlet.java
+++ /dev/null
@@ -1,57 +0,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.
- *
- */
-
-package org.apache.qpid.info.test;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import javax.servlet.GenericServlet;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-/*
- * This is a servlet used by the embedded Jetty to be able to receive http post
- * from the info plugin
- */
-
-public class InfoServlet extends GenericServlet
-{
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public void service(ServletRequest request, ServletResponse response)
-            throws ServletException, IOException
-    {
-        String line;
-        BufferedReader in = request.getReader();
-        while ((line = in.readLine()) != null)
-        {
-            System.out.println(line);
-        }
-        response.setContentType("text/html");
-        PrintWriter out = response.getWriter();
-        out.println("OK <br>\n");
-        System.out.println("ServletResponse: OK");
-    }
-
-}
\ No newline at end of file
diff --git a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoTest.java b/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoTest.java
deleted file mode 100644
index bb4965e..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/InfoTest.java
+++ /dev/null
@@ -1,112 +0,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.
- *
- */
-
-package org.apache.qpid.info.test;
-
-import java.util.HashMap;
-import java.util.Properties;
-import junit.framework.TestCase;
-import org.apache.qpid.info.Info;
-
-/*
- * This test verifies the toString(), toProps(), toXML() and toStringBuffer() methods of the Info object
- * 
- */
-public class InfoTest extends TestCase
-{
-    private HashMap<String, String> _infoPayLoad = null;
-
-    private Info<HashMap<String, String>> _info = null;
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        _infoPayLoad = new HashMap<String, String>();
-        _infoPayLoad.put("test", "Test");
-        _info = new Info<HashMap<String, String>>(_infoPayLoad);
-    }
-
-    /*
-     * Test the conversion toString() of the Info object
-     */
-    public void testToString()
-    {
-        assertNotNull("toString() returned null", _info.toString());
-        assertEquals("toString() did not return the proper string",
-                "test=Test\n", _info.toString());
-    }
-
-    /*
-     * Test the conversion toProps() of the Info object
-     */
-    public void testToProps()
-    {
-        Properties props = new Properties();
-        props.put("test", "Test");
-        assertNotNull("toProperties() returned null", _info.toProps());
-        assertEquals("toProperties not returned the proper object", props, _info
-                .toProps());
-    }
-
-    /*
-     * Test the conversion toStringBuffer() of the Info object
-     */
-    public void testToStringBuffer()
-    {
-        StringBuffer sb = new StringBuffer("test=Test\n");
-        assertNotNull(_info.toStringBuffer());
-        assertEquals(sb.toString(), _info.toStringBuffer().toString());
-    }
-
-    /*
-     * Test conversion toXML() of the info object
-     */
-    public void testToXML()
-    {
-        String INDENT = "    ";
-        StringBuffer sb = new StringBuffer();
-        sb.append("<?xml version=\"1.0\"?>\n");
-        sb.append("<qpidinfo>\n");
-        sb.append("<test>\n");
-        sb.append(INDENT + "Test\n");
-        sb.append("</test>\n");
-        sb.append("</qpidinfo>\n");
-        assertEquals("toString() does not return the proper string", _info
-                .toXML().toString(), sb.toString());
-    }
-
-    /*
-     * Test the conversion toMap() of the Info object
-     */
-    public void testToMap()
-    {
-        HashMap<String, String> thm = _info.toMap();
-        assertFalse("toMap() returned empty map", thm.isEmpty());
-        assertEquals("testToMap did not returned 1", 1, thm.size());
-        assertTrue("toMap() returned a map not containing expected key: test",
-                thm.containsKey("test"));
-        assertTrue(
-                "toMap() returned a map not containing the value for key test: Test",
-                thm.containsValue("Test"));
-
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/IniFileReaderTest.java b/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/IniFileReaderTest.java
deleted file mode 100644
index 77ecaa2..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/IniFileReaderTest.java
+++ /dev/null
@@ -1,136 +0,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.
- *
- */
-
-package org.apache.qpid.info.test;
-
-import junit.framework.TestCase;
-import org.apache.qpid.info.util.IniFileReader;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Test the Loading of the ini file reader by first writing
- * out a correct ini file.
- */
-public class IniFileReaderTest extends TestCase
-{
-
-    public void testLoad()
-    {
-        IniFileReader ifr = new IniFileReader();
-        File iniFile = null;
-        try
-        {
-            iniFile = File.createTempFile("temp", "ini");
-            iniFile.deleteOnExit();
-            BufferedWriter writer = new BufferedWriter(new FileWriter(iniFile));
-            writer.write("# Global Comment1\n");
-            writer.write("globalprop1=globalval1\n");
-            writer.write("globalprop2=globalval2\n");
-            writer.write("\n");
-            writer.write("[Section1] # Comment on Section\n");
-            writer.write("key1=val1 # Comment on Value\n");
-            writer.write("key2=val2\n");
-            writer.write("\n");
-            writer.write("#Section2 Comment\n");
-            writer.write("[Section2]\n");
-            writer.write("key3=val3\n");
-            writer.write("key4=val4\n");
-            writer.write("key5=val5\n");
-            writer.write("\n");
-            writer.write("[Section3]\n");
-            writer.write("key6=val6\n");
-            writer.write("key7=val7\n");
-            writer.write("\n");
-            writer.close();
-        }
-        catch (IOException e)
-        {
-            e.printStackTrace();
-            fail("Unable to create temporary File");
-        }
-        ifr.load(iniFile.getAbsolutePath());
-        Map<String, Properties> sections = ifr.getSections();
-        assertNotNull("Sections not null", sections);
-        assertEquals("Have 4 sections", sections.keySet().size(), 4);
-        assertTrue("Get globalprop1", sections.get("").getProperty("globalprop1").equals("globalval1"));
-        assertTrue("Get globalprop2", sections.get("").getProperty("globalprop2").equals("globalval2"));
-        assertNotNull("Section1 not null", sections.get("Section1"));
-        assertEquals("Section1 has 2 properties", sections.get("Section1").size(), 2);
-        assertTrue("Section1 key1 has val1", sections.get("Section1").getProperty("key1").equals("val1"));
-        assertTrue("Section1 key2 has val2", sections.get("Section1").getProperty("key2").equals("val2"));
-        assertEquals("Section2 has 3 properties", sections.get("Section2").size(), 3);
-        assertTrue("Section2 key3 has val3", sections.get("Section2").getProperty("key3").equals("val3"));
-        assertTrue("Section2 key4 has val4", sections.get("Section2").getProperty("key4").equals("val4"));
-        assertTrue("Section2 key5 has val5", sections.get("Section2").getProperty("key5").equals("val5"));
-        assertEquals("Section3 has 2 properties", sections.get("Section3").size(), 2);
-        assertTrue("Section3 key6 has val6", sections.get("Section3").getProperty("key6").equals("val6"));
-        assertTrue("Section3 key7 has val7", sections.get("Section3").getProperty("key7").equals("val7"));
-    }
-
-    /**
-     * Test to ensure that the loading of a file with an unclosed section header
-     * fails to parse.
-     *
-     * Section needs to be fully enclosed in square brackets '[<name>]'
-     */
-    public void testIncompleteSection1Load()
-    {
-        IniFileReader ifr = new IniFileReader();
-        File iniFile = null;
-        try
-        {
-            iniFile = File.createTempFile(getName(), "ini");
-            iniFile.deleteOnExit();
-            BufferedWriter writer = new BufferedWriter(new FileWriter(iniFile));
-            writer.write("# Global Comment1\n");
-            writer.write("globalprop1=globalval1\n");
-            writer.write("globalprop2=globalval2\n");
-            writer.write("\n");
-            writer.write("[Section1\n");  // Note '[Section1' not complete
-            writer.write("key1=val1\n");
-            writer.write("key2=val2\n");
-            writer.write("\n");
-            writer.close();            
-        }
-        catch (IOException e)
-        {
-            e.printStackTrace();
-            fail("Unable to create temporary File");
-        }
-        try
-        {
-            ifr.load(iniFile.getAbsolutePath());
-            fail("File should fail to parse");
-        }
-        catch (IllegalArgumentException iae)
-        {
-            assertEquals("Incorrect Exception", "Section1 is not closed", iae.getMessage());
-        }
-
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/SoapClientTest.java b/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/SoapClientTest.java
deleted file mode 100644
index a3d993a..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/SoapClientTest.java
+++ /dev/null
@@ -1,208 +0,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.
- *
- */
-
-package org.apache.qpid.info.test;
-
-import junit.framework.TestCase;
-import org.apache.qpid.info.util.SoapClient;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
-
-public class SoapClientTest extends TestCase
-{
-
-    private int _port;
-
-    private final String _hostName = "localhost";
-
-    private final String _urlPath = "/testSoap";
-
-    private ServerSocket _server = null;
-
-    /*
-     * Generate a soap client from a custom URL, hostname, port and soap context
-     * path to be derived
-     */
-    private SoapClient getSoapClient()
-    {
-        Properties destprops = new Properties();
-        destprops.setProperty("soap.hostname", _hostName);
-        destprops.setProperty("soap.port", _port + "");
-        destprops.setProperty("soap.urlpath", _urlPath);
-        destprops.setProperty("soap.envelope", "<ip>@IP</ip>");
-        destprops.setProperty("soap.action", "send");
-        HashMap<String, String> soapmap = new HashMap<String, String>();
-        soapmap.put("IP", "127.0.0.1");
-        return new SoapClient(soapmap, destprops);
-    }
-
-    /*
-     * A connection handler class that verifies the correct message is received
-     * 
-     */
-    class ConnectionHandler implements Runnable
-    {
-        private Socket socket;
-
-        public ConnectionHandler(Socket socket)
-        {
-            this.socket = socket;
-            Thread t = new Thread(this);
-            t.start();
-        }
-
-        public void run()
-        {
-            String line;
-            final List<String> response = new ArrayList<String>();
-            try
-            {
-                BufferedReader br = new BufferedReader(new InputStreamReader(
-                        socket.getInputStream()));
-                assertNotNull(br);
-                while ((line = br.readLine()) != null)
-                {
-                    response.add(line);
-                }
-                br.close();
-            }
-            catch (Exception ex)
-            {
-                ex.printStackTrace();
-                fail("Exception while reading from the socket");
-            }
-            assertTrue(response.contains("<ip>127.0.0.1</ip>"));
-            assertTrue(response.contains("SOAPAction: \"urn:send\""));
-            assertTrue(response
-                    .contains("Content-Type: text/xml; charset=\"utf-8\""));
-            assertTrue(response.contains("Host: localhost" + _port));
-            assertTrue(response.contains("User-Agent: Axis2"));
-        }
-
-    }
-
-    /*
-     * Test that the SOAP client sends the expected data to the socket We mock a
-     * simple SOAP envelope: <ip>127.0.0.1</ip>
-     */
-    public void testSoapClient() throws Exception
-    {
-        //
-        try
-        {
-            _server = new ServerSocket(0);
-            _port = _server.getLocalPort();
-            assertTrue("Server is not yet bound to a port", _port != -1);
-            assertNotNull(_server);
-        }
-        catch (Exception ex)
-        {
-            ex.printStackTrace();
-            fail("Unable to start the socket server");
-        }
-
-        Thread _socketAcceptor = new Thread()
-        {
-            public void run()
-            {
-                try
-                {
-                    Socket socket = _server.accept();
-                    new ConnectionHandler(socket);
-                }
-                catch (IOException e)
-                {
-                    e.printStackTrace();
-                }
-            }
-        };
-        _socketAcceptor.start();
-        // Sleep for 1 second to allow the ServerSocket readiness
-        Thread.sleep(1000);
-        SoapClient sc = getSoapClient();
-        assertNotNull(sc);
-        sc.sendSOAPMessage();
-
-        _socketAcceptor.join(2000);
-
-        assertFalse("Socket Acceptor not stopped.", _socketAcceptor.isAlive());
-    }
-
-    /**
-     * Test SoapClient correctly clears previously set values
-     */
-    public void testSoapClientXMLData()
-    {
-        SoapClient sc = getSoapClient();
-
-        StringBuffer initial = new StringBuffer("Initial Value");
-
-        sc.setXMLData(initial);
-
-        assertEquals("getXMLData is not set with initial value",
-                     initial.toString(), sc.getXMLData().toString());
-
-
-        StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?><ip=@IP><port=@PORT>");
-        sc.setXMLData(sb);
-        assertEquals(sc.getXMLData().length(), sb.length());
-        assertEquals("getXMLData does not return the same StringBuffer set by setXMLData",
-                     sb.toString(), sc.getXMLData().toString());
-    }
-
-    /**
-     * Test that variable replacement is performed on the soap.envelope.
-     * Create dummy soap message and validate that the variable have been replaced.
-     */
-    public void testReplaceVariablesMap()
-    {
-        Properties props = new Properties();
-        // Add dummy values as required to create a soap message
-        props.setProperty("soap.hostname", _hostName);
-        props.setProperty("soap.port", "0");
-        props.setProperty("soap.urlpath", _urlPath);
-        props.setProperty("soap.action", "send");
-
-        /// The envelope is what we care about
-        props.setProperty("soap.envelope", "<addr>@IP:@PORT</addr>");
-        HashMap<String, String> soapmap = new HashMap<String, String>();
-
-        /// Variables that should be replaced.
-        final String ip = "127.0.0.1";
-        soapmap.put("IP", ip);
-        final String port = "8080";
-        soapmap.put("PORT", port);
-
-        SoapClient sc = new SoapClient(soapmap, props);
-        assertNotNull("SoapClient is null", sc);
-
-        assertTrue("Replace variables did not work as expected", ("<addr>" + ip + ":" + port + "</addr>").equals(sc.getXMLData().toString()));
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/SystemInfoTest.java b/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/SystemInfoTest.java
deleted file mode 100644
index 6cb8e3a..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/SystemInfoTest.java
+++ /dev/null
@@ -1,56 +0,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.
- *
- */
-
-package org.apache.qpid.info.test;
-
-import junit.framework.TestCase;
-import org.apache.qpid.info.SystemInfo;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-/** Test the SystemInfo component */
-public class SystemInfoTest extends TestCase
-{
-
-    /**
-     * Ensure the list of required properties are returned by the
-     * SystemInfo.getInfo call
-     */
-    public void testGetInfo()
-    {
-        Map<String, String> sysInfoMap = SystemInfo.getInfo();
-        assertNotNull("SystemInfo.getInfo() returned null", sysInfoMap);
-        List<String> sysInfoProps = Arrays.asList(
-                "java.class.path",
-                "java.vm.name", "java.class.version", "os.arch", "os.name",
-                "os.version", "sun.arch.data.model", "user.dir", "user.name",
-                "user.timezone", "hostname", "ip", "CPUCores", "Maximum_Memory",
-                "Free_Memory");
-
-        for (String tag : sysInfoProps)
-        {
-            assertNotNull("Map does not contain the tag: " + tag, sysInfoMap.get(tag));
-        }
-    }
-
-}
\ No newline at end of file
diff --git a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/XMLWriterTest.java b/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/XMLWriterTest.java
deleted file mode 100644
index f352226..0000000
--- a/qpid/java/broker-plugins/experimental/info/src/test/java/org/apache/qpid/info/test/XMLWriterTest.java
+++ /dev/null
@@ -1,132 +0,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.
- *
- */
-
-package org.apache.qpid.info.test;
-
-import junit.framework.TestCase;
-import org.apache.qpid.info.util.XMLWriter;
-
-import java.util.HashMap;
-
-/*
- * This test verifies the XML writer custom class operations
- */
-
-public class XMLWriterTest extends TestCase
-{
-
-    private XMLWriter xw = null;
-
-    /** Test constructor arg is returned via getXML() */
-    public void testXMLWriter()
-    {
-        StringBuffer input = new StringBuffer("Test");
-        xw = new XMLWriter(input);
-        assertNotNull("XMLWriter could not instantiate", xw);
-        assertEquals("XMLWriter.getXML() failed", input, xw.getXML());
-    }
-
-    /** Test header generation */
-    public void testWriteXMLHeader()
-    {
-        xw = new XMLWriter(new StringBuffer());
-        assertNotNull(xw);
-        xw.writeXMLHeader();
-        assertEquals("XMLWriter.writeXMLHeader(...) failed", "<?xml version=\"1.0\"?>\n", xw.getXML().toString());
-    }
-
-    /** Test tag created and written correctly */
-    public void testWriteTag()
-    {
-        String INDENT = "    ";
-        xw = new XMLWriter(new StringBuffer());
-        assertNotNull("XMLWriter could not instantiate", xw);
-        xw.writeTag("test", new HashMap<String, String>(), "TEST");
-        assertEquals("XMLWriter.writeTag(...) failed", "<test>\n" + INDENT + "TEST\n" + "</test>\n", xw.getXML()
-                .toString());
-    }
-
-    /** Test tag created and written correctly */
-    public void testWriteTagWithNullAttribute()
-    {
-        String INDENT = "    ";
-        xw = new XMLWriter(new StringBuffer());
-        assertNotNull("XMLWriter could not instantiate", xw);
-        xw.writeTag("test", null, "TEST");
-        assertEquals("XMLWriter.writeTag(...) failed", "<test>\n" + INDENT + "TEST\n" + "</test>\n", xw.getXML()
-                .toString());
-    }
-
-    /** Test tag created and written correctly with attribute */
-    public void testWriteTagWithAttribute()
-    {
-        String INDENT = "    ";
-        xw = new XMLWriter(new StringBuffer());
-        assertNotNull("XMLWriter could not instantiate", xw);
-        HashMap<String, String> attr = new HashMap<String, String>();
-        attr.put("id", "1");
-
-        xw.writeTag("test", attr, "TEST");
-        assertEquals("XMLWriter.writeTag(...) failed", "<test id=\"1\">\n" + INDENT + "TEST\n" + "</test>\n", xw.getXML()
-                .toString());
-    }
-
-    /** Test open tag with an empty attribute map. Just creates an open tag */
-    public void testWriteOpenTag()
-    {
-        xw = new XMLWriter(new StringBuffer());
-        assertNotNull(xw);
-        HashMap<String, String> attr = new HashMap<String, String>();
-        xw.writeOpenTag("test", attr);
-        assertEquals("XMLWriter.writeOpenTag(...) failed", "<test>\n", xw.getXML().toString());
-    }
-
-    /** Test open tag with a null attribute map. Just creates an open tag */
-    public void testNullAtrributeOnTag()
-    {
-        xw = new XMLWriter(new StringBuffer());
-        assertNotNull(xw);
-        xw.writeOpenTag("test", null);
-        assertEquals("XMLWriter.writeOpenTag(...) failed", "<test>\n", xw.getXML().toString());
-    }
-
-    /** Test that setting an attribute value on the tag is correctly outputted. */
-    public void testAtrributeOnTag()
-    {
-        xw = new XMLWriter(new StringBuffer());
-        assertNotNull(xw);
-        HashMap<String, String> attr = new HashMap<String, String>();
-
-        attr.put("id", "1");
-        xw.writeOpenTag("test1", attr);
-        assertEquals("XMLWriter.writeOpenTag(...) failed", "<test1 id=\"1\">\n", xw.getXML().toString());
-    }
-
-    /** Test Close Tag is correctly written */
-    public void testWriteCloseTag()
-    {
-        xw = new XMLWriter(new StringBuffer());
-        assertNotNull(xw);
-        xw.writeCloseTag("test");
-        assertEquals("</test>\n", xw.getXML().toString());
-    }
-
-}
diff --git a/qpid/java/broker-plugins/experimental/shutdown/src/main/java/org/apache/qpid/shutdown/ShutdownMBean.java b/qpid/java/broker-plugins/experimental/shutdown/src/main/java/org/apache/qpid/shutdown/ShutdownMBean.java
index 48d2eab..5c54fb3 100644
--- a/qpid/java/broker-plugins/experimental/shutdown/src/main/java/org/apache/qpid/shutdown/ShutdownMBean.java
+++ b/qpid/java/broker-plugins/experimental/shutdown/src/main/java/org/apache/qpid/shutdown/ShutdownMBean.java
@@ -19,6 +19,8 @@
  */
 package org.apache.qpid.shutdown;
 
+import javax.management.MBeanOperationInfo;
+
 import org.apache.qpid.management.common.mbeans.annotations.MBeanOperation;
 import org.apache.qpid.management.common.mbeans.annotations.MBeanOperationParameter;
 
@@ -34,7 +36,7 @@
     /**
      * Broker will be shut down immediately.
      */
-    @MBeanOperation(name="shutdown", description="Shut down immediately")
+    @MBeanOperation(name="shutdown", description="Shut down immediately", impact = MBeanOperationInfo.ACTION)
     public void shutdown();
 
     /**
@@ -42,7 +44,7 @@
      * 
      * @param delay the number of ms to wait
      */
-    @MBeanOperation(name="shutdown", description="Shutdown after the specified delay (ms)")
+    @MBeanOperation(name="shutdown", description="Shutdown after the specified delay (ms)", impact = MBeanOperationInfo.ACTION)
     public void shutdown(@MBeanOperationParameter(name="when", description="delay (ms)")long delay);
 
     /**
@@ -50,6 +52,6 @@
      * 
      * @param when the date and time to shutdown
      */
-    @MBeanOperation(name="shutdownAt", description="Shutdown at the specified date and time (yyyy/MM/dd HH:mm:ss)")
+    @MBeanOperation(name="shutdownAt", description="Shutdown at the specified date and time (yyyy/MM/dd HH:mm:ss)", impact = MBeanOperationInfo.ACTION)
     public void shutdownAt(@MBeanOperationParameter(name="when", description="shutdown date/time (yyyy/MM/dd HH:mm:ss)")String when);
 }
diff --git a/qpid/java/broker-plugins/experimental/shutdown/src/main/java/shutdown.bnd b/qpid/java/broker-plugins/experimental/shutdown/src/main/java/shutdown.bnd
index c9e1371..60af4b8 100755
--- a/qpid/java/broker-plugins/experimental/shutdown/src/main/java/shutdown.bnd
+++ b/qpid/java/broker-plugins/experimental/shutdown/src/main/java/shutdown.bnd
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-ver: 0.15.0
+ver: 0.17.0
 
 Bundle-SymbolicName: qpid-shutdown-plugin
 Bundle-Version: ${ver}
diff --git a/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/Activator.java b/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/Activator.java
index ca6c05a..fa0ffb5 100644
--- a/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/Activator.java
+++ b/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/Activator.java
@@ -20,11 +20,12 @@
  */
 package org.apache.qpid.extras;
 
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
 import org.apache.qpid.extras.exchanges.diagnostic.DiagnosticExchangeType;
 import org.apache.qpid.extras.exchanges.example.TestExchangeType;
 import org.apache.qpid.server.exchange.ExchangeType;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
 
 /**
  * 
diff --git a/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchange.java b/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchange.java
index 5d2c0dd..6e1ea25 100644
--- a/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchange.java
+++ b/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchange.java
@@ -20,14 +20,8 @@
  */
 package org.apache.qpid.extras.exchanges.diagnostic;
 
-import java.util.ArrayList;
-import java.util.Map;
-
-import javax.management.JMException;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.TabularData;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
@@ -41,6 +35,12 @@
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import javax.management.JMException;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.TabularData;
+import java.util.ArrayList;
+import java.util.Map;
+
 /**
  * This is a special diagnostic exchange type which doesn't actually do anything
  * with messages. When it receives a message, it writes information about the
@@ -54,9 +54,6 @@
     public static final AMQShortString DIAGNOSTIC_EXCHANGE_CLASS = new AMQShortString("x-diagnostic");
     public static final AMQShortString DIAGNOSTIC_EXCHANGE_NAME = new AMQShortString("diagnostic");
 
-    /** The logger */
-    //private static final Logger _logger = Logger.getLogger(DiagnosticExchange.class);
-
     /**
      * MBean class implementing the management interfaces.
      */
@@ -83,7 +80,6 @@
          * @returns null
          * TODO or can there? Could this actually return all the information in one easy to read table?
          */
-        @Override
         public TabularData bindings() throws OpenDataException
         {
             return null;
@@ -197,13 +193,6 @@
     public ArrayList<AMQQueue> doRoute(InboundMessage payload)
     {
         //TODO shouldn't modify messages... perhaps put a new message on the queue?
-        /*
-        Long value = new Long(SizeOf.getUsedMemory());
-        AMQShortString key = new AMQShortString("memory");
-        FieldTable headers = ((BasicContentHeaderProperties)payload.getMessageHeader().properties).getHeaders();
-        headers.put(key, value);
-        ((BasicContentHeaderProperties)payload.getMessageHeader().properties).setHeaders(headers);
-        */
         AMQQueue q = getQueueRegistry().getQueue(new AMQShortString("diagnosticqueue"));
         ArrayList<AMQQueue> queues =  new ArrayList<AMQQueue>();
         queues.add(q);
diff --git a/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchange.java b/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchange.java
index def0b3f..cf79924 100644
--- a/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchange.java
+++ b/qpid/java/broker-plugins/extras/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchange.java
@@ -21,11 +21,6 @@
  */
 
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.UUID;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
@@ -41,6 +36,11 @@
 import org.apache.qpid.server.queue.BaseQueue;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.UUID;
+
 public class TestExchange implements Exchange
 {
 
@@ -80,6 +80,11 @@
         return false;
     }
 
+    public boolean isBound(String bindingKey, Map<String, Object> arguments, AMQQueue queue)
+    {
+        return false;
+    }
+
     public boolean isBound(String bindingKey)
     {
         return false;
diff --git a/qpid/java/broker-plugins/extras/src/test/java/org/apache/qpid/server/plugins/ExtrasTest.java b/qpid/java/broker-plugins/extras/src/test/java/org/apache/qpid/server/plugins/ExtrasTest.java
index db3ebfd..458f9a1 100644
--- a/qpid/java/broker-plugins/extras/src/test/java/org/apache/qpid/server/plugins/ExtrasTest.java
+++ b/qpid/java/broker-plugins/extras/src/test/java/org/apache/qpid/server/plugins/ExtrasTest.java
@@ -20,6 +20,7 @@
 
 import junit.framework.TestCase;
 import org.apache.commons.configuration.PropertiesConfiguration;
+
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.exchange.ExchangeType;
 import org.apache.qpid.server.registry.ApplicationRegistry;
@@ -35,7 +36,7 @@
     private static final String PLUGIN_DIRECTORY = System.getProperty("example.plugin.target");
     private static final String CACHE_DIRECTORY = System.getProperty("example.cache.target");
 
-    IApplicationRegistry _registry;
+    private IApplicationRegistry _registry;
 
     @Override
     public void setUp() throws Exception
diff --git a/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/config/FirewallRule.java b/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/config/FirewallRule.java
index f257b58..ecec4b0 100644
--- a/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/config/FirewallRule.java
+++ b/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/config/FirewallRule.java
@@ -20,6 +20,9 @@
  */
 package org.apache.qpid.server.security.access.config;
 
+import org.apache.qpid.server.security.Result;
+import org.apache.qpid.util.NetMatcher;
+
 import java.net.InetAddress;
 import java.util.List;
 import java.util.concurrent.Callable;
@@ -27,12 +30,8 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.FutureTask;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.regex.Pattern;
 
-import org.apache.qpid.server.security.Result;
-import org.apache.qpid.util.NetMatcher;
-
 public class FirewallRule 
 {
 	public static final String ALLOW = "ALLOW";
diff --git a/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/Firewall.java b/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/Firewall.java
index a6ea9d2..40a65fd 100644
--- a/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/Firewall.java
+++ b/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/Firewall.java
@@ -20,11 +20,9 @@
  */
 package org.apache.qpid.server.security.access.plugins;
 
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.security.AbstractPlugin;
 import org.apache.qpid.server.security.Result;
@@ -35,6 +33,9 @@
 import org.apache.qpid.server.security.access.config.FirewallException;
 import org.apache.qpid.server.security.access.config.FirewallRule;
 
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+
 public class Firewall extends AbstractPlugin
 {
     public static final SecurityPluginFactory<Firewall> FACTORY = new SecurityPluginFactory<Firewall>()
@@ -114,7 +115,7 @@
     public void configure(ConfigurationPlugin config)
     {
         super.configure(config);
-        FirewallConfiguration firewallConfiguration = (FirewallConfiguration) _config;
+        FirewallConfiguration firewallConfiguration = (FirewallConfiguration) getConfig();
 
         // Get default action
         _default = firewallConfiguration.getDefaultAction();
diff --git a/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/FirewallActivator.java b/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/FirewallActivator.java
index c20bba8..1669352 100644
--- a/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/FirewallActivator.java
+++ b/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/FirewallActivator.java
@@ -23,10 +23,9 @@
 import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
 import org.apache.qpid.server.security.SecurityPluginActivator;
 import org.apache.qpid.server.security.SecurityPluginFactory;
-import org.osgi.framework.BundleActivator;
 
 /**
- * The OSGi {@link BundleActivator} for {@link Firewall}.
+ * The OSGi {@link org.osgi.framework.BundleActivator} for {@link Firewall}.
  */
 public class FirewallActivator extends SecurityPluginActivator
 {
diff --git a/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/FirewallConfiguration.java b/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/FirewallConfiguration.java
index b10656d..010d165 100644
--- a/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/FirewallConfiguration.java
+++ b/qpid/java/broker-plugins/firewall/src/main/java/org/apache/qpid/server/security/access/plugins/FirewallConfiguration.java
@@ -20,21 +20,22 @@
  */
 package org.apache.qpid.server.security.access.plugins;
 
-import java.util.Arrays;
-import java.util.List;
-
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
 import org.apache.qpid.server.security.Result;
 import org.apache.qpid.server.security.access.config.FirewallRule;
 
+import java.util.Arrays;
+import java.util.List;
+
 public class FirewallConfiguration extends ConfigurationPlugin
 {
-    CompositeConfiguration _finalConfig;
+    private CompositeConfiguration _finalConfig;
 
     public static final ConfigurationPluginFactory FACTORY = new ConfigurationPluginFactory()
     {
@@ -63,7 +64,7 @@
 
     public Result getDefaultAction()
     {
-        String defaultAction = _configuration.getString("[@default-action]");
+        String defaultAction = getConfig().getString("[@default-action]");
         if (defaultAction == null)
         {
             return Result.ABSTAIN;
@@ -84,8 +85,8 @@
     public void validateConfiguration() throws ConfigurationException
     {
         // Valid Configuration either has xml links to new files
-        _finalConfig = new CompositeConfiguration(_configuration);
-        List subFiles = _configuration.getList("xml[@fileName]");
+        _finalConfig = new CompositeConfiguration(getConfig());
+        List subFiles = getConfig().getList("xml[@fileName]");
         for (Object subFile : subFiles)
         {
             _finalConfig.addConfiguration(new XMLConfiguration((String) subFile));
@@ -93,7 +94,7 @@
 
         // all rules must have an access attribute or a default value
         if (_finalConfig.getList("rule[@access]").size() == 0 &&
-            _configuration.getString("[@default-action]") == null)
+            getConfig().getString("[@default-action]") == null)
         {
             throw new ConfigurationException("No rules or default-action found in firewall configuration.");
         }
diff --git a/qpid/java/broker-plugins/firewall/src/test/java/org/apache/qpid/server/security/access/FirewallConfigurationTest.java b/qpid/java/broker-plugins/firewall/src/test/java/org/apache/qpid/server/security/access/FirewallConfigurationTest.java
index e078675..8969363 100644
--- a/qpid/java/broker-plugins/firewall/src/test/java/org/apache/qpid/server/security/access/FirewallConfigurationTest.java
+++ b/qpid/java/broker-plugins/firewall/src/test/java/org/apache/qpid/server/security/access/FirewallConfigurationTest.java
@@ -20,18 +20,18 @@
  */
 package org.apache.qpid.server.security.access;
 
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.net.InetSocketAddress;
-
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.net.InetSocketAddress;
+
 public class FirewallConfigurationTest extends QpidTestCase
 {
     @Override
diff --git a/qpid/java/broker-plugins/firewall/src/test/java/org/apache/qpid/server/security/access/FirewallPluginTest.java b/qpid/java/broker-plugins/firewall/src/test/java/org/apache/qpid/server/security/access/FirewallPluginTest.java
index 00077d9..2004852 100644
--- a/qpid/java/broker-plugins/firewall/src/test/java/org/apache/qpid/server/security/access/FirewallPluginTest.java
+++ b/qpid/java/broker-plugins/firewall/src/test/java/org/apache/qpid/server/security/access/FirewallPluginTest.java
@@ -18,15 +18,9 @@
  */
 package org.apache.qpid.server.security.access;
 
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.security.Result;
@@ -35,6 +29,13 @@
 import org.apache.qpid.server.util.TestApplicationRegistry;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+
 public class FirewallPluginTest extends QpidTestCase
 {
     public class RuleInfo
diff --git a/qpid/java/broker/bin/create-example-ssl-stores.bat b/qpid/java/broker/bin/create-example-ssl-stores.bat
deleted file mode 100644
index 5419c09..0000000
--- a/qpid/java/broker/bin/create-example-ssl-stores.bat
+++ /dev/null
@@ -1,36 +0,0 @@
-@REM

-@REM Licensed to the Apache Software Foundation (ASF) under one

-@REM or more contributor license agreements.  See the NOTICE file

-@REM distributed with this work for additional information

-@REM regarding copyright ownership.  The ASF licenses this file

-@REM to you under the Apache License, Version 2.0 (the

-@REM "License"); you may not use this file except in compliance

-@REM with the License.  You may obtain a copy of the License at

-@REM 

-@REM   http://www.apache.org/licenses/LICENSE-2.0

-@REM 

-@REM Unless required by applicable law or agreed to in writing,

-@REM software distributed under the License is distributed on an

-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

-@REM KIND, either express or implied.  See the License for the

-@REM specific language governing permissions and limitations

-@REM under the License.

-@REM

-

-@REM Create example keystore for broker and trust store for client/management console.

-@REM

-@REM Use generated qpid.keystore as the brokers keystore

-@REM Use generated qpid.truststore as client/consoles truststore

-@REM All passwords have value: password

-

-@REM Create Broker Keystore:

-keytool -genkey -alias qpidBroker -keyalg RSA -validity 365 -keystore qpid.keystore -storepass password -keypass password -dname "CN=hostname, OU=OrgUnit, O=Org, L=City, C=US"

-

-@REM Export Self Signed Cert:

-keytool -export -alias qpidBroker -keystore qpid.keystore -file qpidBroker.cer -storepass password

-

-@REM Import Broker Cert Into MC TrustStore:

-keytool -import -alias qpidBrokerCert -file qpidBroker.cer -keystore qpid.truststore -storepass password -noprompt

-

-@REM Delete the cert

-del qpidBroker.cer
\ No newline at end of file
diff --git a/qpid/java/broker/bin/create-example-ssl-stores.sh b/qpid/java/broker/bin/create-example-ssl-stores.sh
deleted file mode 100755
index bfcb3df..0000000
--- a/qpid/java/broker/bin/create-example-ssl-stores.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-
-# Create example keystore for broker and trust store for client/management console.
-#
-# Use generated qpid.keystore as the brokers keystore
-# Use generated qpid.truststore as client/consoles truststore
-# All passwords have value: password
-
-#Create Broker Keystore:
-keytool -genkey -alias qpidBroker -keyalg RSA -validity 365 -keystore qpid.keystore \
--storepass password -keypass password -dname "CN=hostname, OU=OrgUnit, O=Org, L=City, C=US"
-
-#Export Self Signed Cert:
-keytool -export -alias qpidBroker -keystore qpid.keystore -file qpidBroker.cer -storepass password
-
-#Import Broker Cert Into MC TrustStore:
-keytool -import -alias qpidBrokerCert -file qpidBroker.cer -keystore qpid.truststore -storepass password -noprompt
-
-#Delete the cert
-rm qpidBroker.cer
diff --git a/qpid/java/broker/bin/qpid-passwd b/qpid/java/broker/bin/qpid-passwd
index f432e00..6924697 100755
--- a/qpid/java/broker/bin/qpid-passwd
+++ b/qpid/java/broker/bin/qpid-passwd
@@ -18,9 +18,9 @@
 # under the License.
 #
 
-WHEREAMI=`dirname $0`
 if [ -z "$QPID_HOME" ]; then
-    export QPID_HOME=`cd $WHEREAMI/../ && pwd`
+    WHEREAMI=`dirname "$0"`
+    export QPID_HOME=`cd "$WHEREAMI/../" && pwd`
 fi
 
 # Set classpath to include Qpid jar with all required jars in manifest
@@ -32,4 +32,4 @@
        JAVA_MEM=-Xmx1024m \
        QPID_CLASSPATH=$QPID_LIBS
 
-. ${QPID_HOME}/bin/qpid-run org.apache.qpid.tools.security.Passwd "$@"
+. "${QPID_HOME}/bin/qpid-run" org.apache.qpid.tools.security.Passwd "$@"
diff --git a/qpid/java/broker/build.xml b/qpid/java/broker/build.xml
index 4a42e5c..9e8bf12 100644
--- a/qpid/java/broker/build.xml
+++ b/qpid/java/broker/build.xml
@@ -34,14 +34,7 @@
     <property name="qmf.output.file" value="BrokerSchema.java"/>
 
 
-    <target name="precompile" depends="gen_logging,gen_qmf">
-        <mkdir dir="${output.dir}"/>
-        <!-- Compile Selcector Code -->
-        <javacc target="src/main/grammar/SelectorParser.jj"
-                outputdirectory="${output.dir}"
-                javacchome="${project.root}/lib"/>
-    </target>
-
+    <target name="precompile" depends="gen_logging,gen_qmf"/>
 
   <target name="check_qmf_deps">
     <uptodate property="gen_qmf.notRequired" targetfile="${qmf.output.dir}/${qmf.output.file}">
diff --git a/qpid/java/broker/etc/broker_example.acl b/qpid/java/broker/etc/broker_example.acl
index 93955bb..aae4ee3 100644
--- a/qpid/java/broker/etc/broker_example.acl
+++ b/qpid/java/broker/etc/broker_example.acl
@@ -24,15 +24,32 @@
 #Define a 'messaging-users' group with users  'client' and  'server' in it
 GROUP messaging-users client server
 
+
 ### MANAGEMENT ####
 
-#Allow 'guest' to perform read operations on the Serverinformation mbean and view logger levels
-ACL ALLOW-LOG guest ACCESS METHOD component="ServerInformation"
-ACL ALLOW-LOG guest ACCESS METHOD component="LoggingManagement" name="viewEffectiveRuntimeLoggerLevels"
+# Allow everyone to perform read operations on the ServerInformation mbean
+# This is used for items such as querying the management API and broker release versions.
+ACL ALLOW-LOG ALL ACCESS METHOD component="ServerInformation"
 
-#Allow 'admin' all management operations
+# Allow 'admin' all management operations
 ACL ALLOW-LOG admin ALL METHOD
 
+# Deny access to Shutdown, UserManagement, ConfigurationManagement and LoggingManagement for all other users
+# You could grant specific users access to these beans by adding ALLOW-LOG rules above for them
+ACL DENY-LOG ALL ACCESS METHOD component="Shutdown"
+ACL DENY-LOG ALL ACCESS METHOD component="UserManagement"
+ACL DENY-LOG ALL ACCESS METHOD component="ConfigurationManagement"
+ACL DENY-LOG ALL ACCESS METHOD component="LoggingManagement"
+
+# Allow 'guest' to view logger levels, and use getter methods on LoggingManagement
+# These are examples of redundant rules! The DENY-LOG rule above will be invoked
+# first and will deny the access to all methods of LoggingManagement for guest
+ACL ALLOW-LOG guest ACCESS METHOD component="LoggingManagement" name="viewEffectiveRuntimeLoggerLevels"
+ACL ALLOW-LOG guest ACCESS METHOD component="LoggingManagement" name="get*"
+
+# Allow everyone to perform all read operations on the mbeans not listened in the DENY-LOG rules above
+ACL ALLOW-LOG ALL ACCESS METHOD
+
 ### MESSAGING ###
 
 #Example permissions for request-response based messaging.
diff --git a/qpid/java/broker/etc/config.xml b/qpid/java/broker/etc/config.xml
index 25fda69..e1aacd4 100644
--- a/qpid/java/broker/etc/config.xml
+++ b/qpid/java/broker/etc/config.xml
@@ -53,17 +53,13 @@
         </jmxport>
         <ssl>
             <enabled>false</enabled>
-            <!-- Update below path to your keystore location, or run the bin/create-example-ssl-stores(.sh|.bat)
-                 script from within the etc/ folder to generate an example store with self-signed cert -->
+            <!-- Update below path to your keystore location. -->
             <keyStorePath>${conf}/qpid.keystore</keyStorePath>
             <keyStorePassword>password</keyStorePassword>
         </ssl>
     </management>
     <advanced>
-        <filterchain enableExecutorPool="true"/>
         <framesize>65535</framesize>
-        <compressBufferOnQueue>false</compressBufferOnQueue>
-        <enableJMSXUserID>false</enableJMSXUserID>
         <locale>en_US</locale>	
     </advanced>
 
diff --git a/qpid/java/broker/src/main/grammar/SelectorParser.jj b/qpid/java/broker/src/main/grammar/SelectorParser.jj
deleted file mode 100644
index c9e01cd..0000000
--- a/qpid/java/broker/src/main/grammar/SelectorParser.jj
+++ /dev/null
@@ -1,621 +0,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.

- *

- */

-

- //

- // Original File from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>

- //

-

-// ----------------------------------------------------------------------------

-// OPTIONS

-// ----------------------------------------------------------------------------

-options {

-  STATIC = false;

-  UNICODE_INPUT = true;

-

-  // some performance optimizations

-  OPTIMIZE_TOKEN_MANAGER = true;

-  ERROR_REPORTING = false;

-}

-

-// ----------------------------------------------------------------------------

-// PARSER

-// ----------------------------------------------------------------------------

-

-PARSER_BEGIN(SelectorParser)

-/*

- *

- * 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.server.filter.jms.selector;

-

-import java.io.StringReader;

-import java.util.ArrayList;

-

-import org.apache.qpid.AMQInvalidArgumentException;

-import org.apache.qpid.server.filter.ArithmeticExpression;

-import org.apache.qpid.server.filter.BooleanExpression;

-import org.apache.qpid.server.filter.ComparisonExpression;

-import org.apache.qpid.server.filter.ConstantExpression;

-import org.apache.qpid.server.filter.Expression;

-import org.apache.qpid.server.filter.LogicExpression;

-import org.apache.qpid.server.filter.PropertyExpression;

-import org.apache.qpid.server.filter.UnaryExpression;

-

-/**

- * JMS Selector Parser generated by JavaCC

- *

- * Do not edit this .java file directly - it is autogenerated from SelectorParser.jj

- */

-public class SelectorParser {

-

-    public SelectorParser() {

-        this(new StringReader(""));

-    }

-

-    public BooleanExpression parse(String sql) throws AMQInvalidArgumentException {

-        this.ReInit(new StringReader(sql));

-

-        try {

-            return this.JmsSelector();

-        }

-        catch (Throwable e) {

-	        throw (AMQInvalidArgumentException)new AMQInvalidArgumentException(sql,e);

-        }

-

-    }

-

-    private BooleanExpression asBooleanExpression(Expression value) throws ParseException  {

-        if (value instanceof BooleanExpression) {

-            return (BooleanExpression) value;

-        }

-        if (value instanceof PropertyExpression) {

-            return UnaryExpression.createBooleanCast( value );

-        }

-        throw new ParseException("Expression will not result in a boolean value: " + value);

-    }

-

-

-}

-

-PARSER_END(SelectorParser)

-

-// ----------------------------------------------------------------------------

-// Tokens

-// ----------------------------------------------------------------------------

-

-/* White Space */

-SPECIAL_TOKEN :

-{

-  " " | "\t" | "\n" | "\r" | "\f"

-}

-

-/* Comments */

-SKIP:

-{

-  <LINE_COMMENT: "--" (~["\n","\r"])* ("\n"|"\r"|"\r\n") >

-}

-

-SKIP:

-{

-  <BLOCK_COMMENT: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">

-}

-

-/* Reserved Words */

-TOKEN [IGNORE_CASE] :

-{

-    <  NOT     : "NOT">

-  | <  AND     : "AND">

-  | <  OR      : "OR">

-  | <  BETWEEN : "BETWEEN">

-  | <  LIKE    : "LIKE">

-  | <  ESCAPE  : "ESCAPE">

-  | <  IN      : "IN">

-  | <  IS      : "IS">

-  | <  TRUE    : "TRUE" >

-  | <  FALSE   : "FALSE" >

-  | <  NULL    : "NULL" >

-  | <  XPATH   : "XPATH" >

-  | <  XQUERY  : "XQUERY" >

-}

-

-/* Literals */

-TOKEN [IGNORE_CASE] :

-{

-

-    < DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* (["l","L"])? >

-  | < HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >

-  | < OCTAL_LITERAL: "0" (["0"-"7"])* >

-  | < FLOATING_POINT_LITERAL:

-          (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? // matches: 5.5 or 5. or 5.5E10 or 5.E10

-        | "." (["0"-"9"])+ (<EXPONENT>)?              // matches: .5 or .5E10

-        | (["0"-"9"])+ <EXPONENT>                     // matches: 5E10

-    >

-  | < #EXPONENT: "E" (["+","-"])? (["0"-"9"])+ >

-  | < STRING_LITERAL: "'" ( ("''") | ~["'"] )*  "'" >

-}

-

-TOKEN [IGNORE_CASE] :

-{

-    < ID : ["a"-"z", "_", "$"] (["a"-"z","0"-"9","_", "$"])* >

-    | < QUOTED_ID : "\"" ( ("\"\"") | ~["\""] )*  "\""  >

-}

-

-// ----------------------------------------------------------------------------

-// Grammer

-// ----------------------------------------------------------------------------

-BooleanExpression JmsSelector() :

-{

-    Expression left=null;

-}

-{

-    (

-        left = orExpression()

-    )

-    {

-        return asBooleanExpression(left);

-    }

-

-}

-

-Expression orExpression() :

-{

-    Expression left;

-    Expression right;

-}

-{

-    (

-        left = andExpression()

-        (

-            <OR> right = andExpression()

-            {

-                left = LogicExpression.createOR(asBooleanExpression(left), asBooleanExpression(right));

-            }

-        )*

-    )

-    {

-        return left;

-    }

-

-}

-

-

-Expression andExpression() :

-{

-    Expression left;

-    Expression right;

-}

-{

-    (

-        left = equalityExpression()

-        (

-            <AND> right = equalityExpression()

-            {

-                left = LogicExpression.createAND(asBooleanExpression(left), asBooleanExpression(right));

-            }

-        )*

-    )

-    {

-        return left;

-    }

-}

-

-Expression equalityExpression() :

-{

-    Expression left;

-    Expression right;

-}

-{

-    (

-        left = comparisonExpression()

-        (

-

-            "=" right = comparisonExpression()

-            {

-                left = ComparisonExpression.createEqual(left, right);

-            }

-            |

-            "<>" right = comparisonExpression()

-            {

-                left = ComparisonExpression.createNotEqual(left, right);

-            }

-            |

-            LOOKAHEAD(2)

-            <IS> <NULL>

-            {

-                left = ComparisonExpression.createIsNull(left);

-            }

-            |

-            <IS> <NOT> <NULL>

-            {

-                left = ComparisonExpression.createIsNotNull(left);

-            }

-        )*

-    )

-    {

-        return left;

-    }

-}

-

-Expression comparisonExpression() :

-{

-    Expression left;

-    Expression right;

-    Expression low;

-    Expression high;

-    String t, u;

-	boolean not;

-	ArrayList list;

-}

-{

-    (

-        left = addExpression()

-        (

-

-                ">" right = addExpression()

-                {

-                    left = ComparisonExpression.createGreaterThan(left, right);

-                }

-            |

-                ">=" right = addExpression()

-                {

-                    left = ComparisonExpression.createGreaterThanEqual(left, right);

-                }

-            |

-                "<" right = addExpression()

-                {

-                    left = ComparisonExpression.createLessThan(left, right);

-                }

-            |

-                "<=" right = addExpression()

-                {

-                    left = ComparisonExpression.createLessThanEqual(left, right);

-                }

-           |

-				{

-					u=null;

-				}

-		        <LIKE> t = stringLitteral()

-		        	[ <ESCAPE> u = stringLitteral() ]

-		        {

-                    left = ComparisonExpression.createLike(left, t, u);

-		        }

-           |

-	        	LOOKAHEAD(2)

-				{

-					u=null;

-				}

-		        <NOT> <LIKE> t = stringLitteral() [ <ESCAPE> u = stringLitteral() ]

-		        {

-                    left = ComparisonExpression.createNotLike(left, t, u);

-		        }

-            |

-		        <BETWEEN> low = addExpression() <AND> high = addExpression()

-		        {

-					left = ComparisonExpression.createBetween(left, low, high);

-		        }

-	        |

-	        	LOOKAHEAD(2)

-		        <NOT> <BETWEEN> low = addExpression() <AND> high = addExpression()

-		        {

-					left = ComparisonExpression.createNotBetween(left, low, high);

-		        }

-            |

-				<IN>

-		        "("

-		            t = stringLitteral()

-		            {

-			            list = new ArrayList();

-			            list.add( t );

-		            }

-			        (

-			        	","

-			            t = stringLitteral()

-			            {

-				            list.add( t );

-			            }

-

-			        )*

-		        ")"

-		        {

-		           left = ComparisonExpression.createInFilter(left, list);

-		        }

-            |

-	        	LOOKAHEAD(2)

-	            <NOT> <IN>

-		        "("

-		            t = stringLitteral()

-		            {

-			            list = new ArrayList();

-			            list.add( t );

-		            }

-			        (

-			        	","

-			            t = stringLitteral()

-			            {

-				            list.add( t );

-			            }

-

-			        )*

-		        ")"

-		        {

-		           left = ComparisonExpression.createNotInFilter(left, list);

-		        }

-

-        )*

-    )

-    {

-        return left;

-    }

-}

-

-Expression addExpression() :

-{

-    Expression left;

-    Expression right;

-}

-{

-    left = multExpr()

-    (

-	    LOOKAHEAD( ("+"|"-") multExpr())

-	    (

-	        "+" right = multExpr()

-	        {

-	            left = ArithmeticExpression.createPlus(left, right);

-	        }

-	        |

-	        "-" right = multExpr()

-	        {

-	            left = ArithmeticExpression.createMinus(left, right);

-	        }

-        )

-

-    )*

-    {

-        return left;

-    }

-}

-

-Expression multExpr() :

-{

-    Expression left;

-    Expression right;

-}

-{

-    left = unaryExpr()

-    (

-        "*" right = unaryExpr()

-        {

-	        left = ArithmeticExpression.createMultiply(left, right);

-        }

-        |

-        "/" right = unaryExpr()

-        {

-	        left = ArithmeticExpression.createDivide(left, right);

-        }

-        |

-        "%" right = unaryExpr()

-        {

-	        left = ArithmeticExpression.createMod(left, right);

-        }

-

-    )*

-    {

-        return left;

-    }

-}

-

-

-Expression unaryExpr() :

-{

-    String s=null;

-    Expression left=null;

-}

-{

-	(

-		LOOKAHEAD( "+" unaryExpr() )

-	    "+" left=unaryExpr()

-	    |

-	    "-" left=unaryExpr()

-	    {

-	        left = UnaryExpression.createNegate(left);

-	    }

-	    |

-	    <NOT> left=unaryExpr()

-	    {

-		    left = UnaryExpression.createNOT( asBooleanExpression(left) );

-	    }

-	    |

-	    <XPATH> s=stringLitteral()

-	    {

-		    left = UnaryExpression.createXPath( s );

-	    }

-	    |

-	    <XQUERY> s=stringLitteral()

-	    {

-		    left = UnaryExpression.createXQuery( s );

-	    }

-	    |

-	    left = primaryExpr()

-    )

-    {

-        return left;

-    }

-

-}

-

-Expression primaryExpr() :

-{

-    Expression left=null;

-}

-{

-    (

-        left = literal()

-        |

-        left = variable()

-        |

-        "(" left = orExpression() ")"

-    )

-    {

-        return left;

-    }

-}

-

-

-

-ConstantExpression literal() :

-{

-    Token t;

-    String s;

-    ConstantExpression left=null;

-}

-{

-    (

-        (

-            s = stringLitteral()

-            {

-                left = new ConstantExpression(s);

-            }

-        )

-        |

-        (

-            t = <DECIMAL_LITERAL>

-            {

-            	left = ConstantExpression.createFromDecimal(t.image);

-            }

-        )

-        |

-        (

-            t = <HEX_LITERAL>

-            {

-            	left = ConstantExpression.createFromHex(t.image);

-            }

-        )

-        |

-        (

-            t = <OCTAL_LITERAL>

-            {

-            	left = ConstantExpression.createFromOctal(t.image);

-            }

-        )

-        |

-        (

-            t = <FLOATING_POINT_LITERAL>

-            {

-            	left = ConstantExpression.createFloat(t.image);

-            }

-        )

-        |

-        (

-            <TRUE>

-            {

-                left = ConstantExpression.TRUE;

-            }

-        )

-        |

-        (

-            <FALSE>

-            {

-                left = ConstantExpression.FALSE;

-            }

-        )

-        |

-        (

-            <NULL>

-            {

-                left = ConstantExpression.NULL;

-            }

-        )

-    )

-    {

-        return left;

-    }

-}

-

-String stringLitteral() :

-{

-    Token t;

-    StringBuffer rc = new StringBuffer();

-    boolean first=true;

-}

-{

-    t = <STRING_LITERAL>

-    {

-    	// Decode the sting value.

-    	String image = t.image;

-    	for( int i=1; i < image.length()-1; i++ ) {

-    		char c = image.charAt(i);

-    		if( c == '\'' )

-    			i++;

-   			rc.append(c);

-    	}

-	    return rc.toString();

-    }

-}

-

-PropertyExpression variable() :

-{

-    Token t;

-    StringBuffer rc = new StringBuffer();

-    PropertyExpression left=null;

-}

-{

-    (

-        t = <ID>

-        {

-            left = new PropertyExpression(t.image);

-        }

-        |

-        t = <QUOTED_ID>

-        {

-            // Decode the sting value.

-            String image = t.image;

-            for( int i=1; i < image.length()-1; i++ ) {

-                char c = image.charAt(i);

-                if( c == '"' )

-                    i++;

-                rc.append(c);

-            }

-            return new PropertyExpression(rc.toString());

-        }

-

-

-    )

-    {

-        return left;

-    }

-}

diff --git a/qpid/java/broker/src/main/java/broker.bnd b/qpid/java/broker/src/main/java/broker.bnd
index 25b0495..fa43384 100755
--- a/qpid/java/broker/src/main/java/broker.bnd
+++ b/qpid/java/broker/src/main/java/broker.bnd
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-ver: 0.15.0
+ver: 0.17.0
 
 Bundle-SymbolicName: qpid-broker
 Bundle-Version: ${ver}
diff --git a/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java b/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
index 4426a7a..54ca574 100644
--- a/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
+++ b/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
@@ -20,6 +20,11 @@
  */
 package org.apache.log4j;
 
+import org.apache.log4j.helpers.CountingQuietWriter;
+import org.apache.log4j.helpers.LogLog;
+import org.apache.log4j.helpers.OptionConverter;
+import org.apache.log4j.spi.LoggingEvent;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -33,11 +38,6 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.zip.GZIPOutputStream;
 
-import org.apache.log4j.helpers.CountingQuietWriter;
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.LoggingEvent;
-
 /**
  * <p>CompositeRollingAppender combines RollingFileAppender and DailyRollingFileAppender<br> It can function as either
  * or do both at the same time (making size based rolling files like RollingFileAppender until a data/time boundary is
@@ -99,59 +99,38 @@
     private long nextCheck = System.currentTimeMillis() - 1;
 
     /** Holds date of last roll over */
-    Date now = new Date();
+    private Date now = new Date();
 
-    SimpleDateFormat sdf;
+    private SimpleDateFormat sdf;
 
     /** Helper class to determine next rollover time */
-    RollingCalendar rc = new RollingCalendar();
+    private RollingCalendar rc = new RollingCalendar();
 
-    /** The default maximum file size is 10MB. */
-    protected long maxFileSize = 10 * 1024 * 1024;
+    private long maxFileSize = 10 * 1024 * 1024;
 
-    /** There is zero backup files by default. */
-    protected int maxSizeRollBackups = 0;
-    /** How many sized based backups have been made so far */
-    protected int curSizeRollBackups = 0;
+    private int maxSizeRollBackups = 0;
+    private int curSizeRollBackups = 0;
 
-    /** not yet implemented */
-    protected int maxTimeRollBackups = -1;
-    protected int curTimeRollBackups = 0;
+    private int maxTimeRollBackups = -1;
+    private int curTimeRollBackups = 0;
 
-    /**
-     * By default newer files have lower numbers. (countDirection < 0) ie. log.1 is most recent, log.5 is the 5th
-     * backup, etc... countDirection > 0 does the opposite ie. log.1 is the first backup made, log.5 is the 5th backup
-     * made, etc. For infinite backups use countDirection > 0 to reduce rollOver costs.
-     */
-    protected int countDirection = -1;
+    private int countDirection = -1;
 
-    /** Style of rolling to Use.  BY_SIZE (1), BY_DATE(2), BY COMPOSITE(3) */
-    protected int rollingStyle = BY_COMPOSITE;
-    protected boolean rollDate = true;
-    protected boolean rollSize = true;
+    private int rollingStyle = BY_COMPOSITE;
+    private boolean rollDate = true;
+    private boolean rollSize = true;
 
-    /**
-     * By default file.log is always the current file.  Optionally file.log.yyyy-mm-dd for current formated datePattern
-     * can by the currently logging file (or file.log.curSizeRollBackup or even file.log.yyyy-mm-dd.curSizeRollBackup)
-     * This will make time based roll overs with a large number of backups much faster -- it won't have to rename all
-     * the backups!
-     */
-    protected boolean staticLogFileName = true;
+    private boolean staticLogFileName = true;
 
-    /** FileName provided in configuration.  Used for rolling properly */
-    protected String baseFileName;
+    private String baseFileName;
 
-    /** Do we want to .gz our backup files. */
-    protected boolean compress = false;
+    private boolean compress = false;
 
-    /** Do we want to use a second thread when compressing our backup files. */
-    protected boolean compressAsync = false;
+    private boolean compressAsync = false;
 
-    /** Do we want to start numbering files at zero. */
-    protected boolean zeroBased = false;
+    private boolean zeroBased = false;
 
-    /** Path provided in configuration.  Used for moving backup files to */
-    protected String backupFilesToPath = null;
+    private String backupFilesToPath = null;
     private final ConcurrentLinkedQueue<CompressJob> _compress = new ConcurrentLinkedQueue<CompressJob>();
     private AtomicBoolean _compressing = new AtomicBoolean(false);
     private static final String COMPRESS_EXTENSION = ".gz";
@@ -219,7 +198,7 @@
         return datePattern;
     }
 
-    /** Returns the value of the <b>maxSizeRollBackups</b> option. */
+    /** There is zero backup files by default. */ /** Returns the value of the <b>maxSizeRollBackups</b> option. */
     public int getMaxSizeRollBackups()
     {
         return maxSizeRollBackups;
@@ -311,7 +290,6 @@
                 c.setType(i);
                 Date next = new Date(c.getNextCheckMillis(epoch));
                 String r1 = sdf.format(next);
-                // LogLog.debug("Type = "+i+", r0 = "+r0+", r1 = "+r1);
                 if ((r0 != null) && (r1 != null) && !r0.equals(r1))
                 {
                     return i;
@@ -379,6 +357,11 @@
         }
     }
 
+    /**
+     * By default newer files have lower numbers. (countDirection < 0) ie. log.1 is most recent, log.5 is the 5th
+     * backup, etc... countDirection > 0 does the opposite ie. log.1 is the first backup made, log.5 is the 5th backup
+     * made, etc. For infinite backups use countDirection > 0 to reduce rollOver costs.
+     */
     public int getCountDirection()
     {
         return countDirection;
@@ -389,6 +372,7 @@
         countDirection = direction;
     }
 
+    /** Style of rolling to Use.  BY_SIZE (1), BY_DATE(2), BY COMPOSITE(3) */
     public int getRollingStyle()
     {
         return rollingStyle;
@@ -420,19 +404,6 @@
         }
     }
 
-    /*
-        public void setRollingStyle(String style) {
-            if (style == S_BY_SIZE) {
-                rollingStyle = BY_SIZE;
-            }
-            else if (style == S_BY_DATE) {
-                rollingStyle = BY_DATE;
-            }
-            else if (style == S_BY_COMPOSITE) {
-                rollingStyle = BY_COMPOSITE;
-            }
-        }
-     */
     public boolean getStaticLogFileName()
     {
         return staticLogFileName;
@@ -484,6 +455,7 @@
         zeroBased = z;
     }
 
+    /** Path provided in configuration.  Used for moving backup files to */
     public String getBackupFilesToPath()
     {
         return backupFilesToPath;
@@ -549,7 +521,6 @@
             now.setTime(System.currentTimeMillis());
             sdf = new SimpleDateFormat(datePattern);
             int type = computeCheckPeriod();
-            // printPeriodicity(type);
             rc.setType(type);
             // next line added as this removes the name check in rollOver
             nextCheck = rc.getNextCheckMillis(now);
@@ -797,7 +768,9 @@
                     curSizeRollBackups--;
                 }
             }
-            // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
+            /*
+              map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}.
+            */
             for (int i = curSizeRollBackups; i >= 1; i--)
             {
                 String oldName = (fileName + "." + i);
@@ -1074,9 +1047,117 @@
         }
     }
 
+    /** The default maximum file size is 10MB. */
+    protected long getMaxFileSize()
+    {
+        return maxFileSize;
+    }
+
+    /** How many sized based backups have been made so far */
+    protected int getCurSizeRollBackups()
+    {
+        return curSizeRollBackups;
+    }
+
+    protected void setCurSizeRollBackups(int curSizeRollBackups)
+    {
+        this.curSizeRollBackups = curSizeRollBackups;
+    }
+
+    /** not yet implemented */
+    protected int getMaxTimeRollBackups()
+    {
+        return maxTimeRollBackups;
+    }
+
+    protected void setMaxTimeRollBackups(int maxTimeRollBackups)
+    {
+        this.maxTimeRollBackups = maxTimeRollBackups;
+    }
+
+    protected int getCurTimeRollBackups()
+    {
+        return curTimeRollBackups;
+    }
+
+    protected void setCurTimeRollBackups(int curTimeRollBackups)
+    {
+        this.curTimeRollBackups = curTimeRollBackups;
+    }
+
+    protected boolean isRollDate()
+    {
+        return rollDate;
+    }
+
+    protected void setRollDate(boolean rollDate)
+    {
+        this.rollDate = rollDate;
+    }
+
+    protected boolean isRollSize()
+    {
+        return rollSize;
+    }
+
+    protected void setRollSize(boolean rollSize)
+    {
+        this.rollSize = rollSize;
+    }
+
+    /**
+     * By default file.log is always the current file.  Optionally file.log.yyyy-mm-dd for current formated datePattern
+     * can by the currently logging file (or file.log.curSizeRollBackup or even file.log.yyyy-mm-dd.curSizeRollBackup)
+     * This will make time based roll overs with a large number of backups much faster -- it won't have to rename all
+     * the backups!
+     */
+    protected boolean isStaticLogFileName()
+    {
+        return staticLogFileName;
+    }
+
+    /** FileName provided in configuration.  Used for rolling properly */
+    protected String getBaseFileName()
+    {
+        return baseFileName;
+    }
+
+    protected void setBaseFileName(String baseFileName)
+    {
+        this.baseFileName = baseFileName;
+    }
+
+    /** Do we want to .gz our backup files. */
+    protected boolean isCompress()
+    {
+        return compress;
+    }
+
+    protected void setCompress(boolean compress)
+    {
+        this.compress = compress;
+    }
+
+    /** Do we want to use a second thread when compressing our backup files. */
+    protected boolean isCompressAsync()
+    {
+        return compressAsync;
+    }
+
+    /** Do we want to start numbering files at zero. */
+    protected boolean isZeroBased()
+    {
+        return zeroBased;
+    }
+
+    protected void setBackupFilesToPath(String backupFilesToPath)
+    {
+        this.backupFilesToPath = backupFilesToPath;
+    }
+
     private static class CompressJob
     {
-        File _from, _to;
+        private File _from, _to;
 
         CompressJob(File from, File to)
         {
@@ -1095,9 +1176,9 @@
         }
     }
 
-    Compressor compressor = null;
+    private Compressor compressor = null;
 
-    Executor executor;
+    private Executor executor;
 
     private class Compressor implements Runnable
     {
diff --git a/qpid/java/broker/src/main/java/org/apache/log4j/xml/QpidLog4JConfigurator.java b/qpid/java/broker/src/main/java/org/apache/log4j/xml/QpidLog4JConfigurator.java
index 1200ba6..dca62f3 100644
--- a/qpid/java/broker/src/main/java/org/apache/log4j/xml/QpidLog4JConfigurator.java
+++ b/qpid/java/broker/src/main/java/org/apache/log4j/xml/QpidLog4JConfigurator.java
@@ -20,21 +20,21 @@
  */
 package org.apache.log4j.xml;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-import java.util.concurrent.locks.ReentrantLock;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import org.apache.qpid.server.logging.management.LoggingManagementMBean;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.qpid.server.logging.management.LoggingManagementMBean;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
 
 /**
  * Substitute for the Log4J XMLWatchdog (as used by DOMConfigurator.configureAndWatch)
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/configuration/Configuration.java b/qpid/java/broker/src/main/java/org/apache/qpid/configuration/Configuration.java
deleted file mode 100644
index 0b63c68..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/configuration/Configuration.java
+++ /dev/null
@@ -1,188 +0,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.    
- * 
- */
-package org.apache.qpid.configuration;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-
-public class Configuration
-{
-    public static final String QPID_HOME = "QPID_HOME";
-
-    final String QPIDHOME = System.getProperty(QPID_HOME);
-
-    private static Logger _devlog = LoggerFactory.getLogger(Configuration.class);
-
-    public static final String DEFAULT_LOG_CONFIG_FILENAME = "log4j.xml";
-    public static final String DEFAULT_CONFIG_FILE = "etc/config.xml";
-
-    protected final Options _options = new Options();
-    protected CommandLine _commandLine;
-    protected File _configFile;
-
-
-    public Configuration()
-    {
-
-    }
-
-    public void processCommandline(String[] args) throws InitException
-    {
-        try
-        {
-            _commandLine = new PosixParser().parse(_options, args);
-        }
-        catch (ParseException e)
-        {
-            throw new InitException("Unable to parse commmandline", e);
-        }
-
-        final File defaultConfigFile = new File(QPIDHOME, DEFAULT_CONFIG_FILE);
-        setConfig(new File(_commandLine.getOptionValue("c", defaultConfigFile.getPath())));
-    }
-
-    public void setConfig(File file)
-    {
-        _configFile = file;
-    }
-
-    /**
-     * @param option The option to set.
-     */
-    public void setOption(Option option)
-    {
-        _options.addOption(option);
-    }
-
-    /**
-     * getOptionValue from the configuration
-     * @param option variable argument, first string is option to get, second if present is the default value.
-     * @return the String for the given option or null if not present (if default value not specified)
-     */
-    public String getOptionValue(String... option)
-    {
-        if (option.length == 1)
-        {
-            return _commandLine.getOptionValue(option[0]);
-        }
-        else if (option.length == 2)
-        {
-            return _commandLine.getOptionValue(option[0], option[1]);
-        }
-        return null;
-    }
-
-    public void loadConfig(File file) throws InitException
-    {
-        setConfig(file);
-        loadConfig();
-    }
-
-    private void loadConfig() throws InitException
-    {
-        if (!_configFile.exists())
-        {
-            String error = "File " + _configFile + " could not be found. Check the file exists and is readable.";
-
-            if (QPIDHOME == null)
-            {
-                error = error + "\nNote: " + QPID_HOME + " is not set.";
-            }
-
-            throw new InitException(error, null);
-        }
-        else
-        {
-            _devlog.debug("Using configuration file " + _configFile.getAbsolutePath());
-        }
-
-//        String logConfig = _commandLine.getOptionValue("l");
-//        String logWatchConfig = _commandLine.getOptionValue("w", "0");
-//        if (logConfig != null)
-//        {
-//            File logConfigFile = new File(logConfig);
-//            configureLogging(logConfigFile, logWatchConfig);
-//        }
-//        else
-//        {
-//            File configFileDirectory = _configFile.getParentFile();
-//            File logConfigFile = new File(configFileDirectory, DEFAULT_LOG_CONFIG_FILENAME);
-//            configureLogging(logConfigFile, logWatchConfig);
-//        }
-    }
-
-
-//    private void configureLogging(File logConfigFile, String logWatchConfig)
-//    {
-//        int logWatchTime = 0;
-//        try
-//        {
-//            logWatchTime = Integer.parseInt(logWatchConfig);
-//        }
-//        catch (NumberFormatException e)
-//        {
-//            _devlog.error("Log watch configuration value of " + logWatchConfig + " is invalid. Must be "
-//                          + "a non-negative integer. Using default of zero (no watching configured");
-//        }
-//
-//        if (logConfigFile.exists() && logConfigFile.canRead())
-//        {
-//            _devlog.info("Configuring logger using configuration file " + logConfigFile.getAbsolutePath());
-//            if (logWatchTime > 0)
-//            {
-//                _devlog.info("log file " + logConfigFile.getAbsolutePath() + " will be checked for changes every "
-//                             + logWatchTime + " seconds");
-//                // log4j expects the watch interval in milliseconds
-//                DOMConfigurator.configureAndWatch(logConfigFile.getAbsolutePath(), logWatchTime * 1000);
-//            }
-//            else
-//            {
-//                DOMConfigurator.configure(logConfigFile.getAbsolutePath());
-//            }
-//        }
-//        else
-//        {
-//            System.err.println("Logging configuration error: unable to read file " + logConfigFile.getAbsolutePath());
-//            System.err.println("Using basic log4j configuration");
-//            BasicConfigurator.configure();
-//        }
-//    }
-
-    public File getConfigFile()
-    {
-        return _configFile;
-    }
-
-
-    public static class InitException extends Exception
-    {
-        InitException(String msg, Throwable cause)
-        {
-            super(msg, cause);
-        }
-    }
-}
\ No newline at end of file
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/ManagementExchange.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/ManagementExchange.java
index b898e85..2d6f7e0 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/ManagementExchange.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/ManagementExchange.java
@@ -35,7 +35,6 @@
 import org.apache.qpid.server.exchange.topic.TopicMatcherResult;
 import org.apache.qpid.server.exchange.topic.TopicNormalizer;
 import org.apache.qpid.server.exchange.topic.TopicParser;
-import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.message.InboundMessage;
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.queue.AMQQueue;
@@ -50,7 +49,6 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-import java.util.TimerTask;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -412,6 +410,11 @@
         return queues;
     }
 
+    public boolean isBound(String bindingKey, Map<String, Object> arguments, AMQQueue queue)
+    {
+        return false;  //TODO
+    }
+
     public boolean isBound(AMQShortString routingKey, FieldTable arguments, AMQQueue queue)
     {
         return false;  //To change body of implemented methods use File | Settings | File Templates.
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFBrokerRequestCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFBrokerRequestCommand.java
index 709b595..69284ab 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFBrokerRequestCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFBrokerRequestCommand.java
@@ -22,17 +22,14 @@
 package org.apache.qpid.qmf;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.transport.codec.BBDecoder;
-import org.apache.qpid.transport.codec.BBEncoder;
-import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.message.MessageTransferMessage;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.queue.BaseQueue;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.management.common.mbeans.ManagedConnection;
 
-import java.util.ArrayList;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.transport.codec.BBDecoder;
+
 import java.util.List;
 
 public class QMFBrokerRequestCommand extends QMFCommand
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFBrokerResponseCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFBrokerResponseCommand.java
index ac01c47..34b2a85 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFBrokerResponseCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFBrokerResponseCommand.java
@@ -22,7 +22,6 @@
 package org.apache.qpid.qmf;
 
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.transport.codec.BBEncoder;
 
 public class QMFBrokerResponseCommand extends QMFCommand
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClass.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClass.java
index 3408ff0..7d56656 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClass.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClass.java
@@ -21,12 +21,10 @@
 
 package org.apache.qpid.qmf;
 
-import org.apache.qpid.server.configuration.ConfiguredObject;
-
 import java.util.Collection;
-import java.util.Map;
-import java.util.List;
 import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 
 abstract public class QMFClass
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClassIndicationCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClassIndicationCommand.java
index a956a9b..613e1e5 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClassIndicationCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClassIndicationCommand.java
@@ -21,8 +21,6 @@
 
 package org.apache.qpid.qmf;
 
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.transport.codec.BBEncoder;
 
 public class QMFClassIndicationCommand extends QMFCommand
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClassQueryCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClassQueryCommand.java
index 64edc2f..5676bb7 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClassQueryCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFClassQueryCommand.java
@@ -22,15 +22,15 @@
 package org.apache.qpid.qmf;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.transport.codec.BBDecoder;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.ServerMessage;
+
+import org.apache.qpid.AMQException;
 import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.queue.BaseQueue;
 import org.apache.qpid.server.registry.IApplicationRegistry;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.transport.codec.BBDecoder;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFCommandCompletionCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFCommandCompletionCommand.java
index 9a25201..397ad40 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFCommandCompletionCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFCommandCompletionCommand.java
@@ -21,8 +21,6 @@
 
 package org.apache.qpid.qmf;
 
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.transport.codec.BBEncoder;
 
 public class QMFCommandCompletionCommand extends QMFCommand
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFEventCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFEventCommand.java
index d70c12d..833ccfb 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFEventCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFEventCommand.java
@@ -20,8 +20,6 @@
  */
 package org.apache.qpid.qmf;
 
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.transport.codec.BBEncoder;
 
 public abstract class QMFEventCommand<T extends QMFEventClass> extends QMFCommand
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFGetQueryCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFGetQueryCommand.java
index c11e1a9..b1f958d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFGetQueryCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFGetQueryCommand.java
@@ -22,15 +22,21 @@
 package org.apache.qpid.qmf;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.transport.codec.BBDecoder;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.ServerMessage;
+
+import org.apache.qpid.AMQException;
 import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.queue.BaseQueue;
 import org.apache.qpid.server.registry.IApplicationRegistry;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.transport.codec.BBDecoder;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 public class QMFGetQueryCommand extends QMFCommand
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMessage.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMessage.java
index 3248a5a..97e74be 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMessage.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMessage.java
@@ -22,9 +22,13 @@
 package org.apache.qpid.qmf;
 
 import org.apache.commons.lang.NotImplementedException;
+
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.configuration.SessionConfig;
-import org.apache.qpid.server.message.*;
+import org.apache.qpid.server.message.AMQMessageHeader;
+import org.apache.qpid.server.message.InboundMessage;
+import org.apache.qpid.server.message.MessageReference;
+import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.store.StoredMessage;
 import org.apache.qpid.transport.codec.BBEncoder;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethod.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethod.java
index 63e8fa6..1d1cd24 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethod.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethod.java
@@ -21,12 +21,12 @@
 
 package org.apache.qpid.qmf;
 
-import org.apache.qpid.transport.codec.Encoder;
 import org.apache.qpid.transport.codec.BBDecoder;
+import org.apache.qpid.transport.codec.Encoder;
 
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.ArrayList;
 
 public abstract class QMFMethod<T extends QMFObject>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodRequestCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodRequestCommand.java
index 4001a2a..1a4ce22 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodRequestCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodRequestCommand.java
@@ -21,16 +21,16 @@
 package org.apache.qpid.qmf;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.transport.codec.BBDecoder;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.queue.BaseQueue;
+
 import org.apache.qpid.AMQException;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.transport.codec.BBDecoder;
 
 import java.util.List;
 import java.util.UUID;
-import java.util.ArrayList;
 
 public class QMFMethodRequestCommand extends QMFCommand
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackage.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackage.java
index 681e64b..63b4347 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackage.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackage.java
@@ -22,8 +22,8 @@
 package org.apache.qpid.qmf;
 
 import java.util.Collection;
-import java.util.Map;
 import java.util.HashMap;
+import java.util.Map;
 
 public class QMFPackage
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageIndicationCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageIndicationCommand.java
index 7053b80..9c8fa1e 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageIndicationCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageIndicationCommand.java
@@ -21,8 +21,6 @@
 
 package org.apache.qpid.qmf;
 
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.transport.codec.BBEncoder;
 
 public class QMFPackageIndicationCommand extends QMFCommand
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageQueryCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageQueryCommand.java
index 9cacbaf..c74c7da 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageQueryCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageQueryCommand.java
@@ -22,15 +22,15 @@
 package org.apache.qpid.qmf;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.transport.codec.BBDecoder;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.ServerMessage;
+
+import org.apache.qpid.AMQException;
 import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.queue.BaseQueue;
 import org.apache.qpid.server.registry.IApplicationRegistry;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.transport.codec.BBDecoder;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFProperty.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFProperty.java
index 5748722..5314466 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFProperty.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFProperty.java
@@ -23,9 +23,8 @@
 
 import org.apache.qpid.transport.codec.Encoder;
 
-import java.util.Map;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
+import java.util.Map;
 
 public class QMFProperty
 {
@@ -68,8 +67,6 @@
 
     public void setQMFClass(QMFClass qmfClass)
     {
- /*       _map.put(REF_CLASS, qmfClass.getName());
-        _map.put(REF_PACKAGE, qmfClass.getPackage().getName());*/
     }
 
     public void setReferencedClass(String refClass)
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaRequestCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaRequestCommand.java
index a1260ed..57c67fa 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaRequestCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaRequestCommand.java
@@ -22,16 +22,15 @@
 package org.apache.qpid.qmf;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.transport.codec.BBDecoder;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.registry.IApplicationRegistry;
-import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.queue.BaseQueue;
-import org.apache.qpid.AMQException;
 
-import java.util.Collection;
-import java.util.ArrayList;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.transport.codec.BBDecoder;
+
 import java.util.List;
 
 public class QMFSchemaRequestCommand extends QMFCommand
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaResponseCommand.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaResponseCommand.java
index fea2430..4bd0e41 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaResponseCommand.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaResponseCommand.java
@@ -21,8 +21,6 @@
 
 package org.apache.qpid.qmf;
 
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.transport.codec.BBEncoder;
 
 import java.util.Collection;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFService.java b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFService.java
index 27345f0..900b722 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFService.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFService.java
@@ -658,6 +658,11 @@
             return _obj.getStagingThreshold();
         }
 
+        public Boolean getMgmtPublish()
+        {
+            return true;
+        }
+
         public Integer getMgmtPubInterval()
         {
             return _obj.getManagementPublishInterval();
@@ -678,6 +683,204 @@
             return (System.currentTimeMillis() - _obj.getCreateTime()) * 1000000L;
         }
 
+        public Long getQueueCount()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgTotalEnqueues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgTotalDequeues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getByteTotalEnqueues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getByteTotalDequeues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgDepth()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getByteDepth()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgPersistEnqueues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgPersistDequeues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getBytePersistEnqueues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getBytePersistDequeues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgTxnEnqueues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgTxnDequeues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getByteTxnEnqueues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getByteTxnDequeues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgFtdEnqueues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgFtdDequeues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getByteFtdEnqueues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getByteFtdDequeues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgFtdDepth()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getByteFtdDepth()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getReleases()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getAcquires()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsNoRoute()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsTtl()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsRing()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsLvq()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsOverflow()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsSubscriber()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsPurge()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getReroutes()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getAbandoned()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getAbandonedViaAlt()
+        {
+            // TODO
+            return 0L;
+        }
+
         public BrokerSchema.BrokerClass.EchoMethodResponseCommand echo(final BrokerSchema.BrokerClass.EchoMethodResponseCommandFactory factory,
                                                                        final Long sequence,
                                                                        final String body)
@@ -1064,6 +1267,96 @@
             return _obj.getPersistentByteDequeues();
         }
 
+        public Long getMsgFtdEnqueues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgFtdDequeues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getByteFtdEnqueues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getByteFtdDequeues()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getMsgFtdDepth()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getByteFtdDepth()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getReleases()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getAcquires()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsTtl()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsRing()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsLvq()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsOverflow()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsSubscriber()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getDiscardsPurge()
+        {
+            // TODO
+            return 0L;
+        }
+
+        public Long getReroutes()
+        {
+            // TODO
+            return 0L;
+        }
+
         public Long getConsumerCount()
         {
             return (long) _obj.getConsumerCount();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java
index 01a0d99..265aa77 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java
@@ -18,16 +18,6 @@
  */
 package org.apache.qpid.server;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.management.JMException;
-import javax.management.MBeanException;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
@@ -39,6 +29,8 @@
 import org.apache.qpid.server.exchange.ExchangeFactory;
 import org.apache.qpid.server.exchange.ExchangeRegistry;
 import org.apache.qpid.server.exchange.ExchangeType;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.actors.ManagementActor;
 import org.apache.qpid.server.management.AMQManagedObject;
 import org.apache.qpid.server.management.ManagedObject;
 import org.apache.qpid.server.queue.AMQQueue;
@@ -48,8 +40,15 @@
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.virtualhost.VirtualHostImpl;
-import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.actors.ManagementActor;
+
+import javax.management.JMException;
+import javax.management.MBeanException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 /**
  * This MBean implements the broker management interface and exposes the
@@ -169,7 +168,7 @@
      */
     public void createNewExchange(String exchangeName, String type, boolean durable) throws JMException, MBeanException
     {
-        CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+        CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
         try
         {
             synchronized (_exchangeRegistry)
@@ -213,10 +212,10 @@
     {
         // TODO
         // Check if the exchange is in use.
-        // boolean inUse = false;
+
         // Check if there are queue-bindings with the exchange and unregister
         // when there are no bindings.
-        CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+        CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
         try
         {
             _exchangeRegistry.unregisterExchange(new AMQShortString(exchangeName), false);
@@ -256,7 +255,7 @@
             throw new JMException("The queue \"" + queueName + "\" already exists.");
         }
 
-        CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+        CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
         try
         {
             AMQShortString ownerShortString = null;
@@ -312,7 +311,7 @@
             throw new JMException("The Queue " + queueName + " is not a registered queue.");
         }
 
-        CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+        CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
         try
         {
             queue.delete();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java
index c0ecbb3..2d2bc5f 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java
@@ -20,8 +20,23 @@
  */
 package org.apache.qpid.server;
 
-import org.apache.log4j.Logger;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.log4j.Logger;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.framing.AMQMethodBody;
@@ -57,10 +72,10 @@
 import org.apache.qpid.server.message.MessageReference;
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.output.ProtocolOutputConverter;
+import org.apache.qpid.server.protocol.AMQConnectionModel;
 import org.apache.qpid.server.protocol.AMQProtocolEngine;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.protocol.AMQSessionModel;
-import org.apache.qpid.server.protocol.AMQConnectionModel;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.BaseQueue;
 import org.apache.qpid.server.queue.InboundMessageAdapter;
@@ -75,18 +90,11 @@
 import org.apache.qpid.server.subscription.SubscriptionFactoryImpl;
 import org.apache.qpid.server.subscription.SubscriptionImpl;
 import org.apache.qpid.server.txn.AsyncAutoCommitTransaction;
-import org.apache.qpid.server.txn.AutoCommitTransaction;
 import org.apache.qpid.server.txn.LocalTransaction;
 import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.transport.TransportException;
 
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
-
 public class AMQChannel implements SessionConfig, AMQSessionModel, AsyncAutoCommitTransaction.FutureRecorder
 {
     public static final int DEFAULT_PREFETCH = 4096;
@@ -122,7 +130,7 @@
     private IncomingMessage _currentMessage;
 
     /** Maps from consumer tag to subscription instance. Allows us to unsubscribe from a queue. */
-    protected final Map<AMQShortString, Subscription> _tag2SubscriptionMap = new HashMap<AMQShortString, Subscription>();
+    private final Map<AMQShortString, Subscription> _tag2SubscriptionMap = new HashMap<AMQShortString, Subscription>();
 
     private final MessageStore _messageStore;
 
@@ -148,7 +156,7 @@
     private final AMQProtocolSession _session;
     private AtomicBoolean _closing = new AtomicBoolean(false);
 
-    private final ConcurrentMap<AMQQueue, Boolean> _blockingQueues = new ConcurrentHashMap<AMQQueue, Boolean>();
+    private final Set<AMQQueue> _blockingQueues = new ConcurrentSkipListSet<AMQQueue>();
 
     private final AtomicBoolean _blocking = new AtomicBoolean(false);
 
@@ -267,7 +275,7 @@
         {
             throw new AMQSecurityException("Permission denied: " + e.getName());
         }
-        _currentMessage = new IncomingMessage(info);
+        _currentMessage = new IncomingMessage(info, getProtocolSession().getReference());
         _currentMessage.setExchange(e);
     }
 
@@ -289,26 +297,9 @@
 
             _currentMessage.setExpiration();
 
+            _currentMessage.headersReceived(getProtocolSession().getLastReceivedTime());
 
-            MessageMetaData mmd = _currentMessage.headersReceived(getProtocolSession().getLastReceivedTime());
-            final StoredMessage<MessageMetaData> handle = _messageStore.addMessage(mmd);
-            _currentMessage.setStoredMessage(handle);
-
-            routeCurrentMessage();
-
-
-            _transaction.addPostTransactionAction(new ServerTransaction.Action()
-            {
-
-                public void postCommit()
-                {
-                }
-
-                public void onRollback()
-                {
-                    handle.remove();
-                }
-            });
+            _currentMessage.route();
 
             deliverCurrentMessageIfComplete();
         }
@@ -340,17 +331,41 @@
                         {
                             _actor.message(ExchangeMessages.DISCARDMSG(_currentMessage.getExchange().asString(), _currentMessage.getRoutingKey()));
                         }
-
                     }
                     else
                     {
+                        final StoredMessage<MessageMetaData> handle = _messageStore.addMessage(_currentMessage.getMessageMetaData());
+                        _currentMessage.setStoredMessage(handle);
+                        int bodyCount = _currentMessage.getBodyCount();
+                        if(bodyCount > 0)
+                        {
+                            long bodyLengthReceived = 0;
+                            for(int i = 0 ; i < bodyCount ; i++)
+                            {
+                                ContentChunk contentChunk = _currentMessage.getContentChunk(i);
+                                handle.addContent((int)bodyLengthReceived, ByteBuffer.wrap(contentChunk.getData()));
+                                bodyLengthReceived += contentChunk.getSize();
+                            }
+                        }
+
+                        _transaction.addPostTransactionAction(new ServerTransaction.Action()
+                        {
+                            public void postCommit()
+                            {
+                            }
+
+                            public void onRollback()
+                            {
+                                handle.remove();
+                            }
+                        });
+
                         _transaction.enqueue(destinationQueues, _currentMessage, new MessageDeliveryAction(_currentMessage, destinationQueues), getProtocolSession().getLastReceivedTime());
                         incrementOutstandingTxnsIfNecessary();
-			            updateTransactionalActivity();
+                        updateTransactionalActivity();
+                        _currentMessage.getStoredMessage().flushToStore();
                     }
                 }
-                _currentMessage.getStoredMessage().flushToStore();
-
             }
             finally
             {
@@ -377,9 +392,6 @@
 
         try
         {
-
-            // returns true iff the message was delivered (i.e. if all data was
-            // received
             final ContentChunk contentChunk =
                     _session.getMethodRegistry().getProtocolVersionMethodConverter().convertToContentChunk(contentBody);
 
@@ -403,11 +415,6 @@
         }
     }
 
-    protected void routeCurrentMessage() throws AMQException
-    {
-        _currentMessage.route();
-    }
-
     public long getNextDeliveryTag()
     {
         return ++_deliveryTag;
@@ -777,20 +784,6 @@
 
             AMQQueue queue = message.getQueue();
 
-            // Our Java Client will always suspend the channel when resending!
-            // If the client has requested the messages be resent then it is
-            // their responsibility to ensure that thay are capable of receiving them
-            // i.e. The channel hasn't been server side suspended.
-            // if (isSuspended())
-            // {
-            // _logger.info("Channel is suspended so requeuing");
-            // //move this message to requeue
-            // msgToRequeue.add(message);
-            // }
-            // else
-            // {
-            // release to allow it to be delivered
-
             // Without any details from the client about what has been processed we have to mark
             // all messages in the unacked map as redelivered.
             message.setRedelivered();
@@ -1116,7 +1109,7 @@
         AMQMessage message = new AMQMessage(incomingMessage.getStoredMessage());
 
         message.setExpiration(incomingMessage.getExpiration());
-        message.setClientIdentifier(_session);
+        message.setConnectionIdentifier(_session.getReference());
         return message;
     }
 
@@ -1370,7 +1363,7 @@
 
     public void block(AMQQueue queue)
     {
-        if(_blockingQueues.putIfAbsent(queue, Boolean.TRUE) == null)
+        if(_blockingQueues.add(queue))
         {
 
             if(_blocking.compareAndSet(false,true))
@@ -1394,6 +1387,16 @@
         }
     }
 
+    public boolean onSameConnection(InboundMessage inbound)
+    {
+        if(inbound instanceof IncomingMessage)
+        {
+            IncomingMessage incoming = (IncomingMessage) inbound;
+            return getProtocolSession().getReference() == incoming.getConnectionReference();
+        }
+        return false;
+    }
+
     private void flow(boolean flow)
     {
         MethodRegistry methodRegistry = _session.getMethodRegistry();
@@ -1623,4 +1626,8 @@
         }
     }
 
+    public int compareTo(AMQSessionModel session)
+    {
+        return getId().toString().compareTo(session.getID().toString());
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
index e3d8747..da26fe1 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
@@ -20,24 +20,10 @@
  */
 package org.apache.qpid.server;
 
-import static org.apache.qpid.transport.ConnectionSettings.WILDCARD_ADDRESS;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.logging.*;
-
-import javax.net.ssl.SSLContext;
-
+import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 import org.apache.log4j.xml.QpidLog4JConfigurator;
+
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.configuration.ServerNetworkTransportConfiguration;
 import org.apache.qpid.server.configuration.management.ConfigurationManagementMBean;
@@ -58,10 +44,33 @@
 import org.apache.qpid.transport.network.IncomingNetworkTransport;
 import org.apache.qpid.transport.network.Transport;
 
+import static org.apache.qpid.transport.ConnectionSettings.WILDCARD_ADDRESS;
+
+import javax.net.ssl.SSLContext;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.FileHandler;
+import java.util.logging.Formatter;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
 public class Broker
 {
+    private static final Logger LOGGER = Logger.getLogger(Broker.class);
+
     private static final int IPV4_ADDRESS_LENGTH = 4;
     private static final char IPV4_LITERAL_SEPARATOR = '.';
+    private volatile Thread _shutdownHookThread;
 
     private java.util.logging.Logger FRAME_LOGGER;
     private java.util.logging.Logger RAW_LOGGER;
@@ -79,7 +88,14 @@
 
     public void shutdown()
     {
-        ApplicationRegistry.remove();
+        try
+        {
+            removeShutdownHook();
+        }
+        finally
+        {
+            ApplicationRegistry.remove();
+        }
     }
 
     public void startup() throws Exception
@@ -93,6 +109,7 @@
         {
             CurrentActor.set(new BrokerActor(new SystemOutMessageLogger()));
             startupImpl(options);
+            addShutdownHook();
         }
         finally
         {
@@ -185,32 +202,37 @@
                 bindAddr = serverConfig.getBind();
             }
 
-            InetAddress bindAddress = null;
+            InetAddress bindAddress;
             if (bindAddr.equals(WILDCARD_ADDRESS))
             {
-                bindAddress = new InetSocketAddress(0).getAddress();
+                bindAddress = null;
             }
             else
             {
-                bindAddress = InetAddress.getByAddress(parseIP(bindAddr));
+                bindAddress = InetAddress.getByName(bindAddr);
             }
-            String hostName = bindAddress.getCanonicalHostName();
+
+            final AmqpProtocolVersion defaultSupportedProtocolReply = serverConfig.getDefaultSupportedProtocolReply();
 
             if (!serverConfig.getSSLOnly())
             {
                 for(int port : ports)
                 {
+                    final InetSocketAddress inetSocketAddress = new InetSocketAddress(bindAddress, port);
+
                     final Set<AmqpProtocolVersion> supported =
-                                    getSupportedVersions(port, exclude_0_10, exclude_0_9_1, exclude_0_9, exclude_0_8);
+                                    getSupportedVersions(port, exclude_0_10, exclude_0_9_1, exclude_0_9, exclude_0_8, serverConfig);
+
                     final NetworkTransportConfiguration settings =
-                                    new ServerNetworkTransportConfiguration(serverConfig, port, bindAddress.getHostName(), Transport.TCP);
+                                    new ServerNetworkTransportConfiguration(serverConfig, inetSocketAddress, Transport.TCP);
 
                     final IncomingNetworkTransport transport = Transport.getIncomingTransportInstance();
                     final MultiVersionProtocolEngineFactory protocolEngineFactory =
-                                    new MultiVersionProtocolEngineFactory(hostName, supported);
+                                    new MultiVersionProtocolEngineFactory(supported, defaultSupportedProtocolReply);
 
                     transport.accept(settings, protocolEngineFactory, null);
-                    ApplicationRegistry.getInstance().addAcceptor(new InetSocketAddress(bindAddress, port),
+
+                    ApplicationRegistry.getInstance().addAcceptor(inetSocketAddress,
                                     new QpidAcceptor(transport,"TCP"));
                     CurrentActor.get().message(BrokerMessages.LISTENING("TCP", port));
                 }
@@ -220,22 +242,25 @@
             {
                 final String keystorePath = serverConfig.getConnectorKeyStorePath();
                 final String keystorePassword = serverConfig.getConnectorKeyStorePassword();
-                final String certType = serverConfig.getConnectorCertType();
-                final SSLContext sslContext = SSLContextFactory.buildServerContext(keystorePath, keystorePassword, certType);
+                final String keyManagerFactoryAlgorithm = serverConfig.getConnectorKeyManagerFactoryAlgorithm();
+                final SSLContext sslContext = SSLContextFactory.buildServerContext(keystorePath, keystorePassword, keyManagerFactoryAlgorithm);
 
                 for(int sslPort : sslPorts)
                 {
+                    final InetSocketAddress inetSocketAddress = new InetSocketAddress(bindAddress, sslPort);
+
                     final Set<AmqpProtocolVersion> supported =
-                                    getSupportedVersions(sslPort, exclude_0_10, exclude_0_9_1, exclude_0_9, exclude_0_8);
+                                    getSupportedVersions(sslPort, exclude_0_10, exclude_0_9_1, exclude_0_9, exclude_0_8, serverConfig);
                     final NetworkTransportConfiguration settings =
-                        new ServerNetworkTransportConfiguration(serverConfig, sslPort, bindAddress.getHostName(), Transport.TCP);
+                        new ServerNetworkTransportConfiguration(serverConfig, inetSocketAddress, Transport.TCP);
 
                     final IncomingNetworkTransport transport = Transport.getIncomingTransportInstance();
                     final MultiVersionProtocolEngineFactory protocolEngineFactory =
-                                    new MultiVersionProtocolEngineFactory(hostName, supported);
+                                    new MultiVersionProtocolEngineFactory(supported, defaultSupportedProtocolReply);
 
                     transport.accept(settings, protocolEngineFactory, sslContext);
-                    ApplicationRegistry.getInstance().addAcceptor(new InetSocketAddress(bindAddress, sslPort),
+
+                    ApplicationRegistry.getInstance().addAcceptor(inetSocketAddress,
                             new QpidAcceptor(transport,"TCP"));
                     CurrentActor.get().message(BrokerMessages.LISTENING("TCP/SSL", sslPort));
                 }
@@ -252,23 +277,24 @@
 
     private static Set<AmqpProtocolVersion> getSupportedVersions(final int port, final Set<Integer> exclude_0_10,
                                                                 final Set<Integer> exclude_0_9_1, final Set<Integer> exclude_0_9,
-                                                                final Set<Integer> exclude_0_8)
+                                                                final Set<Integer> exclude_0_8,
+                                                                final ServerConfiguration serverConfig)
     {
         final EnumSet<AmqpProtocolVersion> supported = EnumSet.allOf(AmqpProtocolVersion.class);
 
-        if(exclude_0_10.contains(port))
+        if(exclude_0_10.contains(port) || !serverConfig.isAmqp010enabled())
         {
             supported.remove(AmqpProtocolVersion.v0_10);
         }
-        if(exclude_0_9_1.contains(port))
+        if(exclude_0_9_1.contains(port) || !serverConfig.isAmqp091enabled())
         {
             supported.remove(AmqpProtocolVersion.v0_9_1);
         }
-        if(exclude_0_9.contains(port))
+        if(exclude_0_9.contains(port) || !serverConfig.isAmqp09enabled())
         {
             supported.remove(AmqpProtocolVersion.v0_9);
         }
-        if(exclude_0_8.contains(port))
+        if(exclude_0_8.contains(port) || !serverConfig.isAmqp08enabled())
         {
             supported.remove(AmqpProtocolVersion.v0_8);
         }
@@ -354,34 +380,6 @@
         }
     }
 
-    private byte[] parseIP(String address) throws Exception
-    {
-        char[] literalBuffer = address.toCharArray();
-        int byteCount = 0;
-        int currByte = 0;
-        byte[] ip = new byte[IPV4_ADDRESS_LENGTH];
-        for (int i = 0; i < literalBuffer.length; i++)
-        {
-            char currChar = literalBuffer[i];
-            if ((currChar >= '0') && (currChar <= '9'))
-            {
-                currByte = (currByte * 10) + (Character.digit(currChar, 10) & 0xFF);
-            }
-
-            if (currChar == IPV4_LITERAL_SEPARATOR || (i + 1 == literalBuffer.length))
-            {
-                ip[byteCount++] = (byte) currByte;
-                currByte = 0;
-            }
-        }
-
-        if (byteCount != 4)
-        {
-            throw new Exception("Invalid IP address: " + address);
-        }
-        return ip;
-    }
-
     private void configureLogging(File logConfigFile, long logWatchTime) throws InitException, IOException
     {
         if (logConfigFile.exists() && logConfigFile.canRead())
@@ -447,7 +445,59 @@
         blm.register();
     }
 
-    private java.util.logging.Logger updateLogger(final String logType, String logFileName) throws IOException
+    private void addShutdownHook()
+    {
+        Thread shutdownHookThread = new Thread(new ShutdownService());
+        shutdownHookThread.setName("QpidBrokerShutdownHook");
+
+        Runtime.getRuntime().addShutdownHook(shutdownHookThread);
+        _shutdownHookThread = shutdownHookThread;
+
+        LOGGER.debug("Added shutdown hook");
+    }
+
+    private void removeShutdownHook()
+    {
+        Thread shutdownThread = _shutdownHookThread;
+
+        //if there is a shutdown thread and we aren't it, we should remove it
+        if(shutdownThread != null && !(Thread.currentThread() == shutdownThread))
+        {
+            LOGGER.debug("Removing shutdown hook");
+
+            _shutdownHookThread = null;
+
+            boolean removed = false;
+            try
+            {
+                removed = Runtime.getRuntime().removeShutdownHook(shutdownThread);
+            }
+            catch(IllegalStateException ise)
+            {
+                //ignore, means the JVM is already shutting down
+            }
+
+            if(LOGGER.isDebugEnabled())
+            {
+                LOGGER.debug("Removed shutdown hook: " + removed);
+            }
+        }
+        else
+        {
+            LOGGER.debug("Skipping shutdown hook removal as there either isnt one, or we are it.");
+        }
+    }
+
+    private class ShutdownService implements Runnable
+    {
+        public void run()
+        {
+            LOGGER.debug("Shutdown hook running");
+            Broker.this.shutdown();
+        }
+    }
+
+        private java.util.logging.Logger updateLogger(final String logType, String logFileName) throws IOException
     {
         java.util.logging.Logger logger = java.util.logging.Logger.getLogger(logType);
         logger.setLevel(Level.FINE);
@@ -479,4 +529,5 @@
         logger.addHandler(handler);
         return logger;
     }
+
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java
index 3defd82..a6b1809 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java
@@ -20,23 +20,28 @@
  */
 package org.apache.qpid.server;
 
+import org.osgi.framework.BundleContext;
+
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import org.osgi.framework.BundleContext;
-
 public class BrokerOptions
 {
-    /** serialVersionUID */
-    private static final long serialVersionUID = 8051825964945442234L;
-
     public static final String DEFAULT_CONFIG_FILE = "etc/config.xml";
     public static final String DEFAULT_LOG_CONFIG_FILE = "etc/log4j.xml";
     public static final String QPID_HOME = "QPID_HOME";
 
+    public static final String PORTS = "p";
+    public static final String SSL_PORTS = "s";
+    public static final String BIND = "b";
+    public static final String MANAGEMENT = "m";
+    public static final String LOG_CONFIG = "l";
+    public static final String WATCH = "w";
+    public static final String CONFIG = "c";
+
     private final Set<Integer> _ports = new HashSet<Integer>();
     private final Set<Integer> _sslPorts = new HashSet<Integer>();
     private final Map<ProtocolExclusion,Set<Integer>> _exclusionMap = new HashMap<ProtocolExclusion, Set<Integer>>();
@@ -50,7 +55,6 @@
 
     private Integer _logWatchFrequency = 0;
 
-
     public void addPort(final int port)
     {
         _ports.add(port);
@@ -110,7 +114,6 @@
     {
         _jmxPortConnectorServer = jmxPortConnectorServer;
     }
-
     public String getQpidHome()
     {
         return System.getProperty(QPID_HOME);
@@ -157,6 +160,7 @@
         _logWatchFrequency = logWatchFrequency;
     }
 
+
     public BundleContext getBundleContext()
     {
         return _bundleContext ;
@@ -166,5 +170,4 @@
     {
         _bundleContext = bundleContext;
     }
-
 }
\ No newline at end of file
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/ExtractResendAndRequeue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/ExtractResendAndRequeue.java
index 9765636..0c0b1cf 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/ExtractResendAndRequeue.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/ExtractResendAndRequeue.java
@@ -20,14 +20,15 @@
  */
 package org.apache.qpid.server;
 
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.AMQException;
 import org.apache.qpid.server.ack.UnacknowledgedMessageMap;
 import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.subscription.Subscription;
-import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.txn.AutoCommitTransaction;
-import org.apache.qpid.AMQException;
-import org.apache.log4j.Logger;
+import org.apache.qpid.server.txn.ServerTransaction;
 
 import java.util.Map;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
index 2bfdd93..5fcd8a7 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
@@ -28,6 +28,8 @@
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.cli.PosixParser;
 import org.apache.log4j.Logger;
+import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.server.Broker.InitException;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 
@@ -124,7 +126,7 @@
         OPTIONS.addOption(OPTION_JMX_PORT_CONNECTOR_SERVER);
     }
 
-    private CommandLine commandLine;
+    protected CommandLine _commandLine;
 
     public static void main(String[] args)
     {
@@ -160,7 +162,7 @@
     {
         try
         {
-            commandLine = new PosixParser().parse(OPTIONS, args);
+            _commandLine = new PosixParser().parse(OPTIONS, args);
 
             return true;
         }
@@ -176,66 +178,93 @@
 
     protected void execute() throws Exception
     {
-        BrokerOptions options = new BrokerOptions();
-        String configFile = commandLine.getOptionValue(OPTION_CONFIG_FILE.getOpt());
-        if(configFile != null)
+        if (_commandLine.hasOption(OPTION_HELP.getOpt()))
         {
-            options.setConfigFile(configFile);
+            final HelpFormatter formatter = new HelpFormatter();
+            formatter.printHelp("Qpid", OPTIONS, true);
         }
-
-        String logWatchConfig = commandLine.getOptionValue(OPTION_LOG_WATCH.getOpt());
-        if(logWatchConfig != null)
+        else if (_commandLine.hasOption(OPTION_VERSION.getOpt()))
         {
-            options.setLogWatchFrequency(Integer.parseInt(logWatchConfig));
-        }
-
-        String logConfig = commandLine.getOptionValue(OPTION_LOG_CONFIG_FILE.getOpt());
-        if(logConfig != null)
-        {
-            options.setLogConfigFile(logConfig);
-        }
-
-        String jmxPortRegistryServer = commandLine.getOptionValue(OPTION_JMX_PORT_REGISTRY_SERVER.getOpt());
-        if(jmxPortRegistryServer != null)
-        {
-            options.setJmxPortRegistryServer(Integer.parseInt(jmxPortRegistryServer));
-        }
-
-        String jmxPortConnectorServer = commandLine.getOptionValue(OPTION_JMX_PORT_CONNECTOR_SERVER.getLongOpt());
-        if(jmxPortConnectorServer != null)
-        {
-            options.setJmxPortConnectorServer(Integer.parseInt(jmxPortConnectorServer));
-        }
-
-        String bindAddr = commandLine.getOptionValue(OPTION_BIND.getOpt());
-        if (bindAddr != null)
-        {
-            options.setBind(bindAddr);
-        }
-
-        String[] portStr = commandLine.getOptionValues(OPTION_PORT.getOpt());
-        if(portStr != null)
-        {
-            parsePortArray(options, portStr, false);
-            for(ProtocolExclusion pe : ProtocolExclusion.values())
+            final StringBuilder protocol = new StringBuilder("AMQP version(s) [major.minor]: ");
+            boolean first = true;
+            for (final ProtocolVersion pv : ProtocolVersion.getSupportedProtocolVersions())
             {
-                parsePortArray(options, commandLine.getOptionValues(pe.getExcludeName()), pe);
-            }
-        }
+                if (first)
+                {
+                    first = false;
+                }
+                else
+                {
+                    protocol.append(", ");
+                }
 
-        String[] sslPortStr = commandLine.getOptionValues(OPTION_SSLPORT.getOpt());
-        if(sslPortStr != null)
-        {
-            parsePortArray(options, sslPortStr, true);
-            for(ProtocolExclusion pe : ProtocolExclusion.values())
-            {
-                parsePortArray(options, commandLine.getOptionValues(pe.getExcludeName()), pe);
+                protocol.append(pv.getMajorVersion()).append('-').append(pv.getMinorVersion());
             }
-        }                
-        
-        setExceptionHandler();
-        
-        startBroker(options);
+            System.out.println(QpidProperties.getVersionString() + " (" + protocol + ")");
+        }
+        else
+        {
+            BrokerOptions options = new BrokerOptions();
+            String configFile = _commandLine.getOptionValue(OPTION_CONFIG_FILE.getOpt());
+            if(configFile != null)
+            {
+                options.setConfigFile(configFile);
+            }
+
+            String logWatchConfig = _commandLine.getOptionValue(OPTION_LOG_WATCH.getOpt());
+            if(logWatchConfig != null)
+            {
+                options.setLogWatchFrequency(Integer.parseInt(logWatchConfig));
+            }
+
+            String logConfig = _commandLine.getOptionValue(OPTION_LOG_CONFIG_FILE.getOpt());
+            if(logConfig != null)
+            {
+                options.setLogConfigFile(logConfig);
+            }
+
+            String jmxPortRegistryServer = _commandLine.getOptionValue(OPTION_JMX_PORT_REGISTRY_SERVER.getOpt());
+            if(jmxPortRegistryServer != null)
+            {
+                options.setJmxPortRegistryServer(Integer.parseInt(jmxPortRegistryServer));
+            }
+
+            String jmxPortConnectorServer = _commandLine.getOptionValue(OPTION_JMX_PORT_CONNECTOR_SERVER.getLongOpt());
+            if(jmxPortConnectorServer != null)
+            {
+                options.setJmxPortConnectorServer(Integer.parseInt(jmxPortConnectorServer));
+            }
+
+            String bindAddr = _commandLine.getOptionValue(OPTION_BIND.getOpt());
+            if (bindAddr != null)
+            {
+                options.setBind(bindAddr);
+            }
+
+            String[] portStr = _commandLine.getOptionValues(OPTION_PORT.getOpt());
+            if(portStr != null)
+            {
+                parsePortArray(options, portStr, false);
+                for(ProtocolExclusion pe : ProtocolExclusion.values())
+                {
+                    parsePortArray(options, _commandLine.getOptionValues(pe.getExcludeName()), pe);
+                }
+            }
+
+            String[] sslPortStr = _commandLine.getOptionValues(OPTION_SSLPORT.getOpt());
+            if(sslPortStr != null)
+            {
+                parsePortArray(options, sslPortStr, true);
+                for(ProtocolExclusion pe : ProtocolExclusion.values())
+                {
+                    parsePortArray(options, _commandLine.getOptionValues(pe.getExcludeName()), pe);
+                }
+            }
+
+            setExceptionHandler();
+
+            startBroker(options);
+        }
     }
 
     protected void setExceptionHandler()
@@ -273,6 +302,7 @@
                 {
                     public void uncaughtException(final Thread t, final Throwable e)
                     {
+                        boolean continueOnError = Boolean.getBoolean("qpid.broker.exceptionHandler.continue");
                         try
                         {
                             System.err.println("########################################################################");
@@ -282,17 +312,20 @@
                             System.err.print(" in Thread ");
                             System.err.println(t.getName());
                             System.err.println("#");
-                            System.err.println("# Exiting");
+                            System.err.println(continueOnError ? "# Forced to continue by JVM setting 'qpid.broker.exceptionHandler.continue'" : "# Exiting");
                             System.err.println("#");
                             System.err.println("########################################################################");
                             e.printStackTrace(System.err);
 
                             Logger logger = Logger.getLogger("org.apache.qpid.server.Main");
-                            logger.error("Uncaught exception, shutting down.", e);
+                            logger.error("Uncaught exception, " + (continueOnError ? "continuing." : "shutting down."), e);
                         }
                         finally
                         {
-                            Runtime.getRuntime().halt(1);
+                            if (!continueOnError)
+                            {
+                                Runtime.getRuntime().halt(1);
+                            }
                         }
 
                     }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMap.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMap.java
index f4b4932..842b36c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMap.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMap.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.server.ack;
 
-import java.util.Collection;
-import java.util.Set;
-import java.util.Map;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.queue.QueueEntry;
 
+import java.util.Collection;
+import java.util.Set;
+
 
 public interface UnacknowledgedMessageMap
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java
index 6a5d863..b8b15c8 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.server.ack;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.server.queue.QueueEntry;
+
 import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.queue.QueueEntry;
-
 public class UnacknowledgedMessageMapImpl implements UnacknowledgedMessageMap
 {
     private final Object _lock = new Object();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/Binding.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/Binding.java
index 48f85d9..8e44da0 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/Binding.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/Binding.java
@@ -94,7 +94,7 @@
             return true;
         }
         
-        if (o == null || !(o instanceof Binding))
+        if (!(o instanceof Binding))
         {
             return false;
         }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java
index 94ab43c..fe66a6d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java
@@ -20,10 +20,6 @@
  */
 package org.apache.qpid.server.binding;
 
-import java.util.Collections;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQInternalException;
 import org.apache.qpid.AMQSecurityException;
@@ -33,8 +29,6 @@
 import org.apache.qpid.server.configuration.BindingConfigType;
 import org.apache.qpid.server.configuration.ConfigStore;
 import org.apache.qpid.server.configuration.ConfiguredObject;
-import org.apache.qpid.server.configuration.QueueConfiguration;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.messages.BindingMessages;
@@ -43,6 +37,10 @@
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 public class BindingFactory
 {
     private final VirtualHost _virtualHost;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BindingConfigType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BindingConfigType.java
index 5cd064f..1ed6b38 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BindingConfigType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BindingConfigType.java
@@ -21,9 +21,11 @@
 
 package org.apache.qpid.server.configuration;
 
-import org.apache.qpid.server.exchange.ExchangeType;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 
 public final class BindingConfigType extends ConfigObjectType<BindingConfigType, BindingConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BridgeConfigType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BridgeConfigType.java
index a8d3cd9..888feef 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BridgeConfigType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BridgeConfigType.java
@@ -21,9 +21,10 @@
 
 package org.apache.qpid.server.configuration;
 
-import org.apache.qpid.server.exchange.ExchangeType;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 
 public final class BridgeConfigType extends ConfigObjectType<BridgeConfigType, BridgeConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BrokerConfigType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BrokerConfigType.java
index e1cf872..64a59c3 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BrokerConfigType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BrokerConfigType.java
@@ -21,7 +21,10 @@
 
 package org.apache.qpid.server.configuration;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 
 public final class BrokerConfigType extends ConfigObjectType<BrokerConfigType, BrokerConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigStore.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigStore.java
index 4e031f0..aff0725 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigStore.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigStore.java
@@ -21,9 +21,9 @@
 
 package org.apache.qpid.server.configuration;
 
-import java.util.UUID;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicLong;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationManager.java
index 2c492ff..06402fa 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationManager.java
@@ -20,17 +20,18 @@
  */
 package org.apache.qpid.server.configuration;
 
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+
+import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
+import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-
 public class ConfigurationManager
 {
     public List<ConfigurationPlugin> getConfigurationPlugins(String configurationElement, Configuration configuration) throws ConfigurationException
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConnectionConfigType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConnectionConfigType.java
index 9750b12..5631fda 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConnectionConfigType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConnectionConfigType.java
@@ -21,9 +21,10 @@
 
 package org.apache.qpid.server.configuration;
 
-import org.apache.qpid.server.exchange.ExchangeType;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 
 public final class ConnectionConfigType extends ConfigObjectType<ConnectionConfigType, ConnectionConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ExchangeConfigType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ExchangeConfigType.java
index 2095301..c774411 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ExchangeConfigType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ExchangeConfigType.java
@@ -21,9 +21,11 @@
 
 package org.apache.qpid.server.configuration;
 
-import org.apache.qpid.server.exchange.ExchangeType;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 
 public final class ExchangeConfigType extends ConfigObjectType<ExchangeConfigType, ExchangeConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/LinkConfig.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/LinkConfig.java
index 0b3a907..2c37a94 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/LinkConfig.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/LinkConfig.java
@@ -21,11 +21,6 @@
 
 package org.apache.qpid.server.configuration;
 
-import org.apache.qpid.server.exchange.ExchangeType;
-
-import java.util.Map;
-
-
 public interface LinkConfig extends ConfiguredObject<LinkConfigType, LinkConfig>
 {
     VirtualHostConfig getVirtualHost();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/LinkConfigType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/LinkConfigType.java
index 4dc46b7..ea4f723 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/LinkConfigType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/LinkConfigType.java
@@ -21,9 +21,10 @@
 
 package org.apache.qpid.server.configuration;
 
-import org.apache.qpid.server.exchange.ExchangeType;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 
 public final class LinkConfigType extends ConfigObjectType<LinkConfigType, LinkConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfig.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfig.java
index be34c8d..1ef5ede 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfig.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfig.java
@@ -21,10 +21,10 @@
 
 package org.apache.qpid.server.configuration;
 
-import java.util.Map;
-
 import org.apache.qpid.AMQException;
 
+import java.util.Map;
+
 
 public interface QueueConfig extends ConfiguredObject<QueueConfigType, QueueConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfigType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfigType.java
index a794ed9..f958ef5 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfigType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfigType.java
@@ -21,9 +21,11 @@
 
 package org.apache.qpid.server.configuration;
 
-import org.apache.qpid.server.exchange.ExchangeType;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 
 public final class QueueConfigType extends ConfigObjectType<QueueConfigType, QueueConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java
index 759907d..a9e45f7 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java
@@ -20,13 +20,14 @@
  */
 package org.apache.qpid.server.configuration;
 
-import java.util.List;
-
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 
+import java.util.List;
+
 public class QueueConfiguration extends ConfigurationPlugin
 {
     private String _name;
@@ -211,7 +212,7 @@
 
         public void validateConfiguration() throws ConfigurationException
         {
-            if (_configuration.isEmpty())
+            if (getConfig().isEmpty())
             {
                 throw new ConfigurationException("Queue section cannot be empty.");
             }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
index d3b8964..5d0546f 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
@@ -20,6 +20,24 @@
 
 package org.apache.qpid.server.configuration;
 
+import org.apache.commons.configuration.CompositeConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.ConfigurationFactory;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.configuration.SystemConfiguration;
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
+import org.apache.qpid.server.exchange.DefaultExchangeFactory;
+import org.apache.qpid.server.protocol.AmqpProtocolVersion;
+import org.apache.qpid.server.queue.AMQQueueFactory;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.signal.SignalHandlerTask;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+
 import static org.apache.qpid.transport.ConnectionSettings.WILDCARD_ADDRESS;
 
 import java.io.File;
@@ -31,21 +49,7 @@
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.apache.commons.configuration.CompositeConfiguration;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.ConfigurationFactory;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.configuration.SystemConfiguration;
-import org.apache.commons.configuration.XMLConfiguration;
-import org.apache.log4j.Logger;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
-import org.apache.qpid.server.exchange.DefaultExchangeFactory;
-import org.apache.qpid.server.queue.AMQQueueFactory;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.signal.SignalHandlerTask;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+import javax.net.ssl.KeyManagerFactory;
 
 public class ServerConfiguration extends ConfigurationPlugin
 {
@@ -84,10 +88,14 @@
     public static final String MGMT_JMXPORT_CONNECTORSERVER = "management.jmxport.connectorServer";
     public static final String STATUS_UPDATES = "status-updates";
     public static final String ADVANCED_LOCALE = "advanced.locale";
+    public static final String CONNECTOR_AMQP010ENABLED = "connector.amqp010enabled";
+    public static final String CONNECTOR_AMQP091ENABLED = "connector.amqp091enabled";
+    public static final String CONNECTOR_AMQP09ENABLED = "connector.amqp09enabled";
+    public static final String CONNECTOR_AMQP08ENABLED = "connector.amqp08enabled";
+    public static final String CONNECTOR_AMQP_SUPPORTED_REPLY = "connector.amqpDefaultSupportedProtocolReply";
 
     {
         envVarMap.put("QPID_PORT", "connector.port");
-        envVarMap.put("QPID_ENABLEDIRECTBUFFERS", "advanced.enableDirectBuffers");
         envVarMap.put("QPID_SSLPORT", "connector.ssl.port");
         envVarMap.put("QPID_JMXPORT_REGISTRYSERVER", MGMT_JMXPORT_REGISTRYSERVER);
         envVarMap.put("QPID_JMXPORT_CONNECTORSERVER", MGMT_JMXPORT_CONNECTORSERVER);
@@ -108,7 +116,6 @@
         envVarMap.put("QPID_SOCKETRECEIVEBUFFER", "connector.socketReceiveBuffer");
         envVarMap.put("QPID_SOCKETWRITEBUFFER", "connector.socketWriteBuffer");
         envVarMap.put("QPID_TCPNODELAY", "connector.tcpNoDelay");
-        envVarMap.put("QPID_ENABLEPOOLEDALLOCATOR", "advanced.enablePooledAllocator");
         envVarMap.put("QPID_STATUS-UPDATES", "status-updates");
     }
 
@@ -177,7 +184,7 @@
      */
     public ServerConfiguration(Configuration conf)
     {
-        _configuration = conf;        
+        setConfig(conf);
     }
 
     /**
@@ -197,8 +204,8 @@
      */
     public void initialise() throws ConfigurationException
     {	
-        setConfiguration("", _configuration);
-        setupVirtualHosts(_configuration);
+        setConfiguration("", getConfig());
+        setupVirtualHosts(getConfig());
     }
 
     public String[] getElementsProcessed()
@@ -256,6 +263,13 @@
                         + (_configFile == null ? "" : " Configuration file : " + _configFile));
             }
         }
+
+        // QPID-3739 certType was a misleading name.
+        if (contains("connector.ssl.certType"))
+        {
+            _logger.warn("Validation warning: connector/ssl/certType is deprecated and must be replaced by connector/ssl/keyManagerFactoryAlgorithm"
+                    + (_configFile == null ? "" : " Configuration file : " + _configFile));
+        }
     }
 
     /*
@@ -303,7 +317,7 @@
 
                 // save the default virtualhost name
                 String defaultVirtualHost = vhostConfiguration.getString("default");
-                _configuration.setProperty("virtualhosts.default", defaultVirtualHost);
+                getConfig().setProperty("virtualhosts.default", defaultVirtualHost);
             }
         }
 
@@ -472,7 +486,7 @@
             {
                 VirtualHost vhost = vhostRegistry.getVirtualHost(hostName);
                 Configuration vhostConfig = newVhosts.subset("virtualhost." + hostName);
-                vhost.getConfiguration().setConfiguration("virtualhosts.virtualhost", vhostConfig); // XXX
+                vhost.getConfiguration().setConfiguration("virtualhosts.virtualhost", vhostConfig);
                 vhost.getSecurityManager().configureGlobalPlugins(this);
                 vhost.getSecurityManager().configureHostPlugins(vhost.getConfiguration());
             }
@@ -608,11 +622,6 @@
         return getDoubleValue("heartbeat.timeoutFactor", 2.0);
     }
 
-    public int getDeliveryPoolSize()
-    {
-        return getIntValue("delivery.poolsize");
-    }
-
     public long getMaximumMessageAge()
     {
         return getLongValue("maximumMessageAge");
@@ -698,11 +707,6 @@
         return getBooleanValue("connector.tcpNoDelay", true);
     }
 
-    public boolean getEnableExecutorPool()
-    {
-        return getBooleanValue("advanced.filterchain[@enableExecutorPool]");
-    }
-
     public boolean getEnableSSL()
     {
         return getBooleanValue("connector.ssl.enabled");
@@ -730,9 +734,12 @@
         return getStringValue("connector.ssl.keyStorePassword", fallback);
     }
 
-    public String getConnectorCertType()
+    public String getConnectorKeyManagerFactoryAlgorithm()
     {
-        return getStringValue("connector.ssl.certType", "SunX509");
+        final String systemFallback = KeyManagerFactory.getDefaultAlgorithm();
+        // deprecated, pre-0.17 brokers supported this name.
+        final String fallback = getStringValue("connector.ssl.certType", systemFallback);
+        return getStringValue("connector.ssl.keyManagerFactoryAlgorithm", fallback);
     }
 
     public String getDefaultVirtualHost()
@@ -836,4 +843,33 @@
         return getConfig().getString("deadLetterQueueSuffix", AMQQueueFactory.DEFAULT_DLQ_NAME_SUFFIX);
     }
 
+    public boolean isAmqp010enabled()
+    {
+        return getConfig().getBoolean(CONNECTOR_AMQP010ENABLED, true);
+    }
+
+    public boolean isAmqp091enabled()
+    {
+        return getConfig().getBoolean(CONNECTOR_AMQP091ENABLED, true);
+    }
+
+    public boolean isAmqp09enabled()
+    {
+        return getConfig().getBoolean(CONNECTOR_AMQP09ENABLED, true);
+    }
+
+    public boolean isAmqp08enabled()
+    {
+        return getConfig().getBoolean(CONNECTOR_AMQP08ENABLED, true);
+    }
+
+    /**
+     * Returns the configured default reply to an unsupported AMQP protocol initiation, or null if there is none
+     */
+    public AmqpProtocolVersion getDefaultSupportedProtocolReply()
+    {
+        String reply = getConfig().getString(CONNECTOR_AMQP_SUPPORTED_REPLY, null);
+
+        return reply == null ? null : AmqpProtocolVersion.valueOf(reply);
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerNetworkTransportConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerNetworkTransportConfiguration.java
index 81dfcb4..f6fe47b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerNetworkTransportConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerNetworkTransportConfiguration.java
@@ -19,22 +19,21 @@
  */
 package org.apache.qpid.server.configuration;
 
+import java.net.InetSocketAddress;
 import org.apache.qpid.transport.NetworkTransportConfiguration;
 
 public class ServerNetworkTransportConfiguration implements NetworkTransportConfiguration
 {
     private final ServerConfiguration _serverConfig;
-    private final int _port;
-    private final String _host;
     private final String _transport;
+    private InetSocketAddress _address;
 
     public ServerNetworkTransportConfiguration(final ServerConfiguration serverConfig, 
-                                               final int port, final String host,
+                                               final InetSocketAddress address,
                                                final String transport)
     {
         _serverConfig = serverConfig;
-        _port = port;
-        _host = host;
+        _address = address;
         _transport = transport;
     }
 
@@ -55,12 +54,12 @@
 
     public Integer getPort()
     {
-        return _port;
+        return _address.getPort();
     }
 
     public String getHost()
     {
-        return _host;
+        return _address.getHostName();
     }
 
     public String getTransport()
@@ -72,4 +71,9 @@
     {
         return _serverConfig.getConnectorProcessors();
     }
+
+    public InetSocketAddress getAddress()
+    {
+        return _address;
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SessionConfigType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SessionConfigType.java
index 97cf275..1685cfa 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SessionConfigType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SessionConfigType.java
@@ -21,9 +21,10 @@
 
 package org.apache.qpid.server.configuration;
 
-import org.apache.qpid.server.exchange.ExchangeType;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 
 public final class SessionConfigType extends ConfigObjectType<SessionConfigType, SessionConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SubscriptionConfigType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SubscriptionConfigType.java
index 99d3273..7b7848d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SubscriptionConfigType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SubscriptionConfigType.java
@@ -22,7 +22,11 @@
 package org.apache.qpid.server.configuration;
 
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 
 public final class SubscriptionConfigType extends ConfigObjectType<SubscriptionConfigType, SubscriptionConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SystemConfigImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SystemConfigImpl.java
index 09ebb07..98109ce 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SystemConfigImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SystemConfigImpl.java
@@ -21,11 +21,11 @@
 
 package org.apache.qpid.server.configuration;
 
-import java.util.UUID;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
 
 public class SystemConfigImpl implements SystemConfig
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SystemConfigType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SystemConfigType.java
index f5aabd2..d7c36da 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SystemConfigType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/SystemConfigType.java
@@ -21,7 +21,11 @@
 
 package org.apache.qpid.server.configuration;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
 
 public final class SystemConfigType extends ConfigObjectType<SystemConfigType, SystemConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfig.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfig.java
index d5420d9..10e4015 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfig.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfig.java
@@ -22,13 +22,14 @@
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
+
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 
 public class TopicConfig extends ConfigurationPlugin
 {
     public TopicConfig()
     {
-        _configuration = new PropertiesConfiguration();
+        setConfig(new PropertiesConfiguration());
     }
 
     @Override
@@ -50,7 +51,7 @@
 
     public void validateConfiguration() throws ConfigurationException
     {
-        if (_configuration.isEmpty())
+        if (getConfig().isEmpty())
         {
             throw new ConfigurationException("Topic section cannot be empty.");
         }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfiguration.java
index 8716fed..feafd3d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfiguration.java
@@ -22,6 +22,7 @@
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.server.binding.Binding;
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
@@ -56,8 +57,8 @@
         }
     }
 
-    Map<String, TopicConfig> _topics = new HashMap<String, TopicConfig>();
-    Map<String,  Map<String, TopicConfig>> _subscriptions = new HashMap<String,  Map<String, TopicConfig>>();
+    private Map<String, TopicConfig> _topics = new HashMap<String, TopicConfig>();
+    private Map<String,  Map<String, TopicConfig>> _subscriptions = new HashMap<String,  Map<String, TopicConfig>>();
 
     public String[] getElementsProcessed()
     {
@@ -67,17 +68,17 @@
     @Override
     public void validateConfiguration() throws ConfigurationException
     {
-        if (_configuration.isEmpty())
+        if (getConfig().isEmpty())
         {
             throw new ConfigurationException("Topics section cannot be empty.");
         }
 
-        int topics = _configuration.getList("topic.name").size() +
-                     _configuration.getList("topic.subscriptionName").size();
+        int topics = getConfig().getList("topic.name").size() +
+                     getConfig().getList("topic.subscriptionName").size();
 
         for (int index = 0; index < topics; index++)
         {
-            Configuration topicSubset = _configuration.subset("topic(" + index + ")");
+            Configuration topicSubset = getConfig().subset("topic(" + index + ")");
 
             // This will occur when we have a subscriptionName that is bound to a
             // topic.
@@ -90,8 +91,8 @@
 
             topic.setConfiguration(VIRTUALHOSTS_VIRTUALHOST_TOPICS + ".topic", topicSubset );
 
-            String name = _configuration.getString("topic(" + index + ").name");
-            String subscriptionName = _configuration.getString("topic(" + index + ").subscriptionName");
+            String name = getConfig().getString("topic(" + index + ").name");
+            String subscriptionName = getConfig().getString("topic(" + index + ").subscriptionName");
 
             // Record config if subscriptionName is there
             if (subscriptionName != null)
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfigType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfigType.java
index 9668233..16e08e3 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfigType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfigType.java
@@ -21,7 +21,10 @@
 
 package org.apache.qpid.server.configuration;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 
 public class VirtualHostConfigType extends ConfigObjectType<VirtualHostConfigType, VirtualHostConfig>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
index c4e4f70..558311f 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
@@ -20,17 +20,11 @@
  */
 package org.apache.qpid.server.configuration;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
+
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.binding.Binding;
@@ -39,11 +33,18 @@
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.store.MemoryMessageStore;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 public class VirtualHostConfiguration extends ConfigurationPlugin
 {
-    private String _name;
-    private Map<String, QueueConfiguration> _queues = new HashMap<String, QueueConfiguration>();
-    private Map<String, ExchangeConfiguration> _exchanges = new HashMap<String, ExchangeConfiguration>();
+    private final String _name;
+    private final Map<String, QueueConfiguration> _queues = new HashMap<String, QueueConfiguration>();
+    private final Map<String, ExchangeConfiguration> _exchanges = new HashMap<String, ExchangeConfiguration>();
 
     public VirtualHostConfiguration(String name, Configuration config) throws ConfigurationException
     {
@@ -75,7 +76,7 @@
         {
             CompositeConfiguration mungedConf = new CompositeConfiguration();
             mungedConf.addConfiguration(config.subset("exchanges.exchange(" + count++ + ")"));
-            mungedConf.addConfiguration(_configuration.subset("exchanges"));
+            mungedConf.addConfiguration(getConfig().subset("exchanges"));
             String exchName = (String) i.next();
             _exchanges.put(exchName, new ExchangeConfiguration(exchName, mungedConf));
         }
@@ -91,11 +92,6 @@
         return getLongValue("housekeeping.checkPeriod", ApplicationRegistry.getInstance().getConfiguration().getHousekeepingCheckPeriod());
     }
 
-    public String getAuthenticationDatabase()
-    {
-        return getStringValue("security.authentication.name");
-    }
-
     public List getCustomExchanges()
     {
         return getListValue("custom-exchanges.class-name");
@@ -103,7 +99,7 @@
 
     public Configuration getStoreConfiguration()
     {
-        return _configuration.subset("store");
+        return getConfig().subset("store");
     }
 
     public String getMessageStoreClass()
@@ -113,7 +109,7 @@
 
     public void setMessageStoreClass(String storeClass)
     {
-        _configuration.setProperty("store.class", storeClass);
+        getConfig().setProperty("store.class", storeClass);
     }
 
     public List getExchanges()
@@ -252,16 +248,6 @@
         return queueConfig;
     }
 
-    public long getMemoryUsageMaximum()
-    {
-        return getLongValue("queues.maximumMemoryUsage");
-    }
-
-    public long getMemoryUsageMinimum()
-    {
-        return getLongValue("queues.minimumMemoryUsage");
-    }
-
     public int getMaximumMessageAge()
     {
         return getIntValue("queues.maximumMessageAge");
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java
index cc402d5..f0ca5dc 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/management/ConfigurationManagementMBean.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.server.configuration.management;
 
-import javax.management.NotCompliantMBeanException;
-
-import org.apache.commons.configuration.ConfigurationException;
 import org.apache.qpid.management.common.mbeans.ConfigurationManagement;
 import org.apache.qpid.server.management.AMQManagedObject;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 
+import javax.management.NotCompliantMBeanException;
+
 public class ConfigurationManagementMBean extends AMQManagedObject implements ConfigurationManagement
 {
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/ConfigurationPlugin.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/ConfigurationPlugin.java
index b4f8264..d08e3bc 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/ConfigurationPlugin.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/ConfigurationPlugin.java
@@ -22,6 +22,7 @@
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.ConversionException;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.server.configuration.ConfigurationManager;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.registry.IApplicationRegistry;
@@ -42,7 +43,7 @@
     private Map<String, ConfigurationPlugin>
             _pluginConfiguration = new HashMap<String, ConfigurationPlugin>();
 
-    protected Configuration _configuration;
+    private Configuration _config;
 
     /**
      * The Elements that this Plugin can process.
@@ -65,7 +66,7 @@
 
     public Configuration getConfig()
     {
-        return _configuration;
+        return _config;
     }
 
     public <C extends ConfigurationPlugin> C getConfiguration(String plugin)
@@ -81,7 +82,7 @@
      */
     public void setConfiguration(String path, Configuration configuration) throws ConfigurationException
     {
-        _configuration = configuration;
+        _config = configuration;
 
         // Extract a list of elements for processing
         Iterator<?> keys = configuration.getKeys();
@@ -215,7 +216,7 @@
 
     protected boolean hasConfiguration()
     {
-        return _configuration != null;
+        return _config != null;
     }
 
     /// Getters
@@ -227,7 +228,7 @@
 
     protected double getDoubleValue(String property, double defaultValue)
     {
-        return _configuration.getDouble(property, defaultValue);
+        return _config.getDouble(property, defaultValue);
     }
 
     protected long getLongValue(String property)
@@ -237,7 +238,7 @@
 
     protected long getLongValue(String property, long defaultValue)
     {
-        return _configuration.getLong(property, defaultValue);
+        return _config.getLong(property, defaultValue);
     }
 
     protected int getIntValue(String property)
@@ -247,7 +248,7 @@
 
     protected int getIntValue(String property, int defaultValue)
     {
-        return _configuration.getInt(property, defaultValue);
+        return _config.getInt(property, defaultValue);
     }
 
     protected String getStringValue(String property)
@@ -257,7 +258,7 @@
 
     protected String getStringValue(String property, String defaultValue)
     {
-        return _configuration.getString(property, defaultValue);
+        return _config.getString(property, defaultValue);
     }
 
     protected boolean getBooleanValue(String property)
@@ -267,7 +268,7 @@
 
     protected boolean getBooleanValue(String property, boolean defaultValue)
     {
-        return _configuration.getBoolean(property, defaultValue);
+        return _config.getBoolean(property, defaultValue);
     }
 
     protected List getListValue(String property)
@@ -277,14 +278,14 @@
 
     protected List getListValue(String property, List defaultValue)
     {
-        return _configuration.getList(property, defaultValue);
+        return _config.getList(property, defaultValue);
     }
 
     /// Validation Helpers
 
     protected boolean contains(String property)
     {
-        return _configuration.getProperty(property) != null;
+        return _config.getProperty(property) != null;
     }
 
     /**
@@ -323,7 +324,7 @@
             throw new ConfigurationException(this.getClass().getSimpleName() +
                                              ": unable to configure invalid " +
                                              property + ":" +
-                                             _configuration.getString(property),
+                                             _config.getString(property),
                                              last);
         }
     }
@@ -332,7 +333,7 @@
     {
         try
         {
-            _configuration.getLong(property);
+            _config.getLong(property);
             return true;
         }
         catch (NoSuchElementException e)
@@ -345,7 +346,7 @@
     {
         try
         {
-            long value = _configuration.getLong(property);
+            long value = _config.getLong(property);
             return value > 0;
         }
         catch (NoSuchElementException e)
@@ -359,7 +360,7 @@
     {
         try
         {
-            _configuration.getInt(property);
+            _config.getInt(property);
             return true;
         }
         catch (NoSuchElementException e)
@@ -372,7 +373,7 @@
     {
         try
         {
-            _configuration.getBoolean(property);
+            _config.getBoolean(property);
             return true;
         }
         catch (NoSuchElementException e)
@@ -453,7 +454,7 @@
 
     protected void mergeConfiguration(ConfigurationPlugin configuration)
     {
-         _configuration = configuration.getConfig();
+         _config = configuration.getConfig();
     }
 
     public String toString()
@@ -478,6 +479,10 @@
         return super.toString();
     }
 
+    protected void setConfig(Configuration config)
+    {
+        _config = config;
+    }
 }
 
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/ConfigurationPluginFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/ConfigurationPluginFactory.java
index 02560b2..fa41f3e 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/ConfigurationPluginFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/ConfigurationPluginFactory.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.server.configuration.plugins;
 
-import java.util.List;
-
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 
+import java.util.List;
+
 public interface ConfigurationPluginFactory
 {
     /**
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionConfiguration.java
index 7a2632d..a90b1d5 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionConfiguration.java
@@ -22,9 +22,6 @@
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.ConversionException;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
 
 import java.util.Arrays;
 import java.util.List;
@@ -48,7 +45,7 @@
     }
 
     //Set Default time unit to seconds
-    TimeUnit _timeUnit = TimeUnit.SECONDS;
+    private TimeUnit _timeUnit = TimeUnit.SECONDS;
 
     public String[] getElementsProcessed()
     {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionPolicyConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionPolicyConfiguration.java
index ca8dec8..a9026c6 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionPolicyConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionPolicyConfiguration.java
@@ -22,8 +22,6 @@
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
 
 import java.util.Arrays;
 import java.util.List;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionQueueConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionQueueConfiguration.java
index 6f8020f..cb3bb5a 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionQueueConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/SlowConsumerDetectionQueueConfiguration.java
@@ -22,8 +22,7 @@
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
+
 import org.apache.qpid.server.plugins.PluginManager;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.slowconsumerdetection.policies.SlowConsumerPolicyPlugin;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/connection/ConnectionRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/connection/ConnectionRegistry.java
index 1c01ce4..9159489 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/connection/ConnectionRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/connection/ConnectionRegistry.java
@@ -20,18 +20,18 @@
  */
 package org.apache.qpid.server.connection;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.common.Closeable;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.protocol.AMQConnectionModel;
-import org.apache.qpid.server.protocol.AMQProtocolEngine;
 import org.apache.qpid.transport.TransportException;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
 public class ConnectionRegistry implements IConnectionRegistry, Closeable
 {
     private List<AMQConnectionModel> _registry = new CopyOnWriteArrayList<AMQConnectionModel>();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/connection/IConnectionRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/connection/IConnectionRegistry.java
index b4f5bff..89582e5 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/connection/IConnectionRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/connection/IConnectionRegistry.java
@@ -20,12 +20,12 @@
  */
 package org.apache.qpid.server.connection;
 
-import java.util.List;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.protocol.AMQConnectionModel;
 
+import java.util.List;
+
 public interface IConnectionRegistry
 {
     public void initialise();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
index 5ff90b3..cae0704 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
@@ -41,7 +41,6 @@
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
 import javax.management.JMException;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -62,20 +61,20 @@
 
     private Exchange _alternateExchange;
 
-    protected boolean _durable;
-    protected int _ticket;
+    private boolean _durable;
+    private int _ticket;
 
     private VirtualHost _virtualHost;
 
     private final List<Exchange.Task> _closeTaskList = new CopyOnWriteArrayList<Exchange.Task>();
 
 
-    protected AbstractExchangeMBean _exchangeMbean;
+    private AbstractExchangeMBean _exchangeMbean;
 
     /**
      * Whether the exchange is automatically deleted once all queues have detached from it
      */
-    protected boolean _autoDelete;
+    private boolean _autoDelete;
 
     //The logSubject for ths exchange
     private LogSubject _logSubject;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchangeMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchangeMBean.java
index 0f1b709..034331a 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchangeMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchangeMBean.java
@@ -20,29 +20,31 @@
  */
 package org.apache.qpid.server.exchange;
 
-import java.util.Collections;
-import java.util.Map;
-
 import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQSecurityException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.management.common.mbeans.ManagedExchange;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.actors.ManagementActor;
 import org.apache.qpid.server.management.AMQManagedObject;
 import org.apache.qpid.server.management.ManagedObject;
 import org.apache.qpid.server.management.ManagedObjectRegistry;
+import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.binding.BindingFactory;
-import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.actors.ManagementActor;
-import org.apache.qpid.management.common.mbeans.ManagedExchange;
-import org.apache.qpid.framing.AMQShortString;
 
-import javax.management.openmbean.*;
+import javax.management.JMException;
 import javax.management.MBeanException;
+import javax.management.MalformedObjectNameException;
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
-import javax.management.MalformedObjectNameException;
-import javax.management.JMException;
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.TabularType;
+import java.util.Collections;
+
 
 /**
      * Abstract MBean class. This has some of the methods implemented from
@@ -52,9 +54,9 @@
 public abstract class AbstractExchangeMBean<T extends AbstractExchange> extends AMQManagedObject implements ManagedExchange
 {
     // open mbean data types for representing exchange bindings
-    protected OpenType[] _bindingItemTypes;
-    protected CompositeType _bindingDataType;
-    protected TabularType _bindinglistDataType;
+    private OpenType[] _bindingItemTypes;
+    private CompositeType _bindingDataType;
+    private TabularType _bindinglistDataType;
 
 
     private T _exchange;
@@ -105,17 +107,17 @@
 
     public Integer getTicketNo()
     {
-        return _exchange._ticket;
+        return _exchange.getTicket();
     }
 
     public boolean isDurable()
     {
-        return _exchange._durable;
+        return _exchange.isDurable();
     }
 
     public boolean isAutoDelete()
     {
-        return _exchange._autoDelete;
+        return _exchange.isAutoDelete();
     }
 
     // Added exchangetype in the object name lets maangement apps to do any customization required
@@ -140,7 +142,7 @@
             throw new JMException("Queue \"" + queueName + "\" is not registered with the virtualhost.");
         }
 
-        CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+        CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
         try
         {
             vhost.getBindingFactory().addBinding(binding,queue,getExchange(),null);
@@ -156,7 +158,7 @@
     /**
      * Removes a queue binding from the exchange.
      *
-     * @see BindingFactory#removeBinding(String, AMQQueue, Exchange, Map)
+     * @see org.apache.qpid.server.binding.BindingFactory#removeBinding(String, AMQQueue, Exchange, java.util.Map)
      */
     public void removeBinding(String queueName, String binding) throws JMException
     {
@@ -167,7 +169,7 @@
             throw new JMException("Queue \"" + queueName + "\" is not registered with the virtualhost.");
         }
 
-        CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+        CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
         try
         {
             vhost.getBindingFactory().removeBinding(binding, queue, _exchange, Collections.<String, Object>emptyMap());
@@ -179,4 +181,35 @@
         }
         CurrentActor.remove();
     }
+
+
+    protected OpenType[] getBindingItemTypes()
+    {
+        return _bindingItemTypes;
+    }
+
+    protected void setBindingItemTypes(OpenType[] bindingItemTypes)
+    {
+        _bindingItemTypes = bindingItemTypes;
+    }
+
+    protected CompositeType getBindingDataType()
+    {
+        return _bindingDataType;
+    }
+
+    protected void setBindingDataType(CompositeType bindingDataType)
+    {
+        _bindingDataType = bindingDataType;
+    }
+
+    protected TabularType getBindinglistDataType()
+    {
+        return _bindinglistDataType;
+    }
+
+    protected void setBindinglistDataType(TabularType bindinglistDataType)
+    {
+        _bindinglistDataType = bindinglistDataType;
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java
index 090c042..153419d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java
@@ -20,23 +20,22 @@
  */
 package org.apache.qpid.server.exchange;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.log4j.Logger;
-import org.apache.qpid.AMQConnectionException;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.AMQUnknownExchangeType;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.qmf.ManagementExchange;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
 public class DefaultExchangeFactory implements ExchangeFactory
 {
     private static final Logger _logger = Logger.getLogger(DefaultExchangeFactory.class);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java
index 8d2dee5..a5fa9f0 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java
@@ -20,20 +20,20 @@
  */
 package org.apache.qpid.server.exchange;
 
-import java.util.Collection;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.protocol.AMQConstant;
-import org.apache.qpid.server.queue.IncomingMessage;
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import java.util.Collection;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
 public class DefaultExchangeRegistry implements ExchangeRegistry
 {
     private static final Logger _log = Logger.getLogger(DefaultExchangeRegistry.class);
@@ -153,24 +153,4 @@
         }
     }
 
-
-    /**
-     * Routes content through exchanges, delivering it to 1 or more queues.
-     * @param payload
-     * @throws AMQException if something goes wrong delivering data
-     */
-    public void routeContent(IncomingMessage payload) throws AMQException
-    {
-        final AMQShortString exchange = payload.getExchange();
-        final Exchange exch = getExchange(exchange);
-        // there is a small window of opportunity for the exchange to be deleted in between
-        // the BasicPublish being received (where the exchange is validated) and the final
-        // content body being received (which triggers this method)
-        // TODO: check where the exchange is validated
-        if (exch == null)
-        {
-            throw new AMQException("Exchange '" + exchange + "' does not exist");
-        }
-        payload.enqueue(exch.route(payload));
-    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchangeMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchangeMBean.java
index 94fc44d..0bfaf70 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchangeMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchangeMBean.java
@@ -20,16 +20,20 @@
  */
 package org.apache.qpid.server.exchange;
 
-import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
 import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
 import org.apache.qpid.server.binding.Binding;
 
 import javax.management.JMException;
-import javax.management.openmbean.*;
-import java.util.List;
-import java.util.Map;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
      * MBean class implementing the management interfaces.
@@ -47,7 +51,7 @@
 
     public TabularData bindings() throws OpenDataException
     {
-        TabularDataSupport bindingList = new TabularDataSupport(_bindinglistDataType);
+        TabularDataSupport bindingList = new TabularDataSupport(getBindinglistDataType());
 
         Map<String, List<String>> bindingMap = new HashMap<String, List<String>>();
 
@@ -67,7 +71,7 @@
         for(Map.Entry<String, List<String>> entry : bindingMap.entrySet())
         {
             Object[] bindingItemValues = {entry.getKey(), entry.getValue().toArray(new String[0])};
-            CompositeData bindingData = new CompositeDataSupport(_bindingDataType,
+            CompositeData bindingData = new CompositeDataSupport(getBindingDataType(),
                     COMPOSITE_ITEM_NAMES.toArray(new String[COMPOSITE_ITEM_NAMES.size()]),
                     bindingItemValues);
             bindingList.put(bindingData);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java
index 29c354f..0bcfc3a 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java
@@ -25,18 +25,17 @@
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
-
+import org.apache.qpid.server.binding.Binding;
+import org.apache.qpid.server.configuration.ExchangeConfig;
+import org.apache.qpid.server.message.InboundMessage;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.BaseQueue;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.InboundMessage;
-import org.apache.qpid.server.binding.Binding;
-import org.apache.qpid.server.configuration.ExchangeConfig;
 
 import javax.management.JMException;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 public interface Exchange extends ExchangeReferrer, ExchangeConfig
 {
@@ -113,6 +112,8 @@
 
     boolean isBound(String bindingKey, AMQQueue queue);
 
+    public boolean isBound(String bindingKey, Map<String,Object> arguments, AMQQueue queue);
+
     boolean isBound(String bindingKey);
 
     void addCloseTask(Task task);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java
index 9279548..577da79 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java
@@ -20,12 +20,12 @@
  */
 package org.apache.qpid.server.exchange;
 
-import java.util.Collection;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
 
+import java.util.Collection;
+
 
 public interface ExchangeFactory
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java
index e34ef29..18eb37e 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java
@@ -26,7 +26,7 @@
 import java.util.Collection;
 
 
-public interface ExchangeRegistry extends MessageRouter
+public interface ExchangeRegistry
 {
     void registerExchange(Exchange exchange) throws AMQException;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeType.java
index 0b55caa..ce339c4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeType.java
@@ -20,8 +20,8 @@
  */
 package org.apache.qpid.server.exchange;
 
-import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeMBean.java
index 2c85b7f..61e23c8 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeMBean.java
@@ -20,12 +20,16 @@
  */
 package org.apache.qpid.server.exchange;
 
-import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
 import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
 import org.apache.qpid.server.binding.Binding;
 
 import javax.management.JMException;
-import javax.management.openmbean.*;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
 import java.util.ArrayList;
 
 /**
@@ -46,7 +50,7 @@
     public TabularData bindings() throws OpenDataException
     {
 
-        TabularDataSupport bindingList = new TabularDataSupport(_bindinglistDataType);
+        TabularDataSupport bindingList = new TabularDataSupport(getBindinglistDataType());
 
 
         ArrayList<String> queueNames = new ArrayList<String>();
@@ -58,7 +62,7 @@
         }
 
         Object[] bindingItemValues = {BINDING_KEY_SUBSTITUTE, queueNames.toArray(new String[0])};
-        CompositeData bindingData = new CompositeDataSupport(_bindingDataType,
+        CompositeData bindingData = new CompositeDataSupport(getBindingDataType(),
                 COMPOSITE_ITEM_NAMES.toArray(new String[COMPOSITE_ITEM_NAMES.size()]), 
                 bindingItemValues);
         bindingList.put(bindingData);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java
index f58a651..b6f5f97 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java
@@ -20,17 +20,18 @@
  */
 package org.apache.qpid.server.exchange;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.framing.AMQTypedValue;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.server.binding.Binding;
 import org.apache.qpid.server.message.AMQMessageHeader;
 
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * Defines binding and matching based on a set of headers.
  */
@@ -38,7 +39,7 @@
 {
     private static final Logger _logger = Logger.getLogger(HeadersBinding.class);
 
-    private final FieldTable _mappings;
+    private final Map<String,Object> _mappings;
     private final Binding _binding;
     private final Set<String> required = new HashSet<String>();
     private final Map<String,Object> matches = new HashMap<String,Object>();
@@ -57,7 +58,7 @@
         _binding = binding;
         if(_binding !=null)
         {
-            _mappings = FieldTable.convertToFieldTable(_binding.getArguments());
+            _mappings = _binding.getArguments();
             initMappings();
         }
         else
@@ -68,37 +69,23 @@
     
     private void initMappings()
     {
-        _mappings.processOverElements(new FieldTable.FieldTableElementProcessor()
+        for(Map.Entry<String, Object> entry : _mappings.entrySet())
         {
-
-            public boolean processElement(String propertyName, AMQTypedValue value)
+            String propertyName = entry.getKey();
+            Object value = entry.getValue();
+            if (isSpecial(propertyName))
             {
-                if (isSpecial(propertyName))
-                {
-                    processSpecial(propertyName, value.getValue());
-                }
-                else if (value.getValue() == null || value.getValue().equals(""))
-                {
-                    required.add(propertyName);
-                }
-                else
-                {
-                    matches.put(propertyName,value.getValue());
-                }
-
-                return true;
+                processSpecial(propertyName, value);
             }
-
-            public Object getResult()
+            else if (value == null || value.equals(""))
             {
-                return null;
+                required.add(propertyName);
             }
-        });
-    }
-
-    protected FieldTable getMappings()
-    {
-        return _mappings;
+            else
+            {
+                matches.put(propertyName,value);
+            }
+        }
     }
     
     public Binding getBinding()
@@ -206,8 +193,14 @@
     {
         if(value instanceof String)
         {
-            if("any".equalsIgnoreCase((String) value)) return true;
-            if("all".equalsIgnoreCase((String) value)) return false;
+            if("any".equalsIgnoreCase((String) value))
+            {
+                return true;
+            }
+            if("all".equalsIgnoreCase((String) value))
+            {
+                return false;
+            }
         }
         _logger.warn("Ignoring unrecognised match type: " + value);
         return false;//default to all
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
index f9cbfeb..295a719 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
@@ -21,23 +21,24 @@
 package org.apache.qpid.server.exchange;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.server.binding.Binding;
+import org.apache.qpid.server.message.AMQMessageHeader;
+import org.apache.qpid.server.message.InboundMessage;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.BaseQueue;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.message.InboundMessage;
-import org.apache.qpid.server.message.AMQMessageHeader;
-import org.apache.qpid.server.binding.Binding;
 
 import javax.management.JMException;
 import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CopyOnWriteArraySet;
 
 /**
@@ -145,6 +146,33 @@
         return new ArrayList<BaseQueue>(queues);
     }
 
+
+    public boolean isBound(String bindingKey, Map<String, Object> arguments, AMQQueue queue)
+    {
+        CopyOnWriteArraySet<Binding> bindings;
+        if(bindingKey == null)
+        {
+            bindings = new CopyOnWriteArraySet<Binding>(getBindings());
+        }
+        else
+        {
+            bindings = _bindingsByKey.get(bindingKey);
+        }
+
+        if(bindings != null)
+        {
+            for(Binding binding : bindings)
+            {
+                if(queue == null || binding.getQueue().equals(queue))
+                {
+                    return arguments == null ? binding.getArguments() == null : binding.getArguments().equals(arguments);
+                }
+            }
+        }
+
+        return false;
+    }
+
     public boolean isBound(AMQShortString routingKey, FieldTable arguments, AMQQueue queue)
     {
         //fixme isBound here should take the arguements in to consideration.
@@ -250,10 +278,11 @@
         {
             bindings.remove(binding);
         }
-        
+
+        boolean removedBinding = _bindingHeaderMatchers.remove(new HeadersBinding(binding));
         if(_logger.isDebugEnabled())
         {
-            _logger.debug("Removing Binding: " + _bindingHeaderMatchers.remove(new HeadersBinding(binding)));
+            _logger.debug("Removing Binding: " + removedBinding);
         }
     }
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeMBean.java
index caed8f4..395c6c8 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeMBean.java
@@ -22,8 +22,8 @@
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
 import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
 import org.apache.qpid.server.binding.Binding;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.actors.ManagementActor;
@@ -32,11 +32,19 @@
 
 import javax.management.JMException;
 import javax.management.MBeanException;
-import javax.management.openmbean.*;
-
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
-import java.util.ArrayList;
 import java.util.Map;
 
 /**
@@ -60,20 +68,20 @@
     protected void init() throws OpenDataException
     {
 
-        _bindingItemTypes = new OpenType[3];
-        _bindingItemTypes[0] = SimpleType.INTEGER;
-        _bindingItemTypes[1] = SimpleType.STRING;
-        _bindingItemTypes[2] = new ArrayType(1, SimpleType.STRING);
-        _bindingDataType = new CompositeType("Exchange Binding", "Queue name and header bindings",
-                HEADERS_COMPOSITE_ITEM_NAMES.toArray(new String[HEADERS_COMPOSITE_ITEM_NAMES.size()]), 
-                HEADERS_COMPOSITE_ITEM_DESC.toArray(new String[HEADERS_COMPOSITE_ITEM_DESC.size()]), _bindingItemTypes);
-        _bindinglistDataType = new TabularType("Exchange Bindings", "List of exchange bindings for " + getName(),
-                                               _bindingDataType, HEADERS_TABULAR_UNIQUE_INDEX.toArray(new String[HEADERS_TABULAR_UNIQUE_INDEX.size()]));
+        setBindingItemTypes(new OpenType[3]);
+        getBindingItemTypes()[0] = SimpleType.INTEGER;
+        getBindingItemTypes()[1] = SimpleType.STRING;
+        getBindingItemTypes()[2] = new ArrayType(1, SimpleType.STRING);
+        setBindingDataType(new CompositeType("Exchange Binding", "Queue name and header bindings",
+                HEADERS_COMPOSITE_ITEM_NAMES.toArray(new String[HEADERS_COMPOSITE_ITEM_NAMES.size()]),
+                HEADERS_COMPOSITE_ITEM_DESC.toArray(new String[HEADERS_COMPOSITE_ITEM_DESC.size()]), getBindingItemTypes()));
+        setBindinglistDataType(new TabularType("Exchange Bindings", "List of exchange bindings for " + getName(),
+                getBindingDataType(), HEADERS_TABULAR_UNIQUE_INDEX.toArray(new String[HEADERS_TABULAR_UNIQUE_INDEX.size()])));
     }
 
     public TabularData bindings() throws OpenDataException
     {
-        TabularDataSupport bindingList = new TabularDataSupport(_bindinglistDataType);
+        TabularDataSupport bindingList = new TabularDataSupport(getBindinglistDataType());
         int count = 1;
         for (Binding binding : getExchange().getBindings())
         {
@@ -95,7 +103,7 @@
 
 
             Object[] bindingItemValues = {count++, queueName, mappingList.toArray(new String[0])};
-            CompositeData bindingData = new CompositeDataSupport(_bindingDataType, 
+            CompositeData bindingData = new CompositeDataSupport(getBindingDataType(),
                     HEADERS_COMPOSITE_ITEM_NAMES.toArray(new String[HEADERS_COMPOSITE_ITEM_NAMES.size()]), bindingItemValues);
             bindingList.put(bindingData);
         }
@@ -113,7 +121,7 @@
             throw new JMException("Queue \"" + queueName + "\" is not registered with the virtualhost.");
         }
 
-        CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+        CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
 
         final Map<String,Object> arguments = new HashMap<String, Object>();
         final String[] bindings = binding.split(",");
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/MessageRouter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/MessageRouter.java
deleted file mode 100644
index 025a801..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/MessageRouter.java
+++ /dev/null
@@ -1,40 +0,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.
- *
- */
-package org.apache.qpid.server.exchange;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.queue.IncomingMessage;
-
-/**
- * Separated out from the ExchangeRegistry interface to allow components
- * that use only this part to have a dependency with a reduced footprint.
- *
- */
-public interface MessageRouter
-{
-    /**
-     * Routes content through exchanges, delivering it to 1 or more queues.
-     * @param message the message to be routed
-     *
-     * @throws org.apache.qpid.AMQException if something goes wrong delivering data
-     */
-    void routeContent(IncomingMessage message) throws AMQException;
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java
index 3a8a86e..27166e4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java
@@ -20,29 +20,39 @@
  */
 package org.apache.qpid.server.exchange;
 
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.management.JMException;
 import org.apache.log4j.Logger;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQInvalidArgumentException;
 import org.apache.qpid.common.AMQPFilterTypes;
 import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.filter.SelectorParsingException;
+import org.apache.qpid.filter.selector.ParseException;
+import org.apache.qpid.filter.selector.TokenMgrError;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.server.binding.Binding;
+import org.apache.qpid.server.exchange.topic.TopicExchangeResult;
+import org.apache.qpid.server.exchange.topic.TopicMatcherResult;
+import org.apache.qpid.server.exchange.topic.TopicNormalizer;
+import org.apache.qpid.server.exchange.topic.TopicParser;
+import org.apache.qpid.server.filter.JMSSelectorFilter;
+import org.apache.qpid.server.filter.MessageFilter;
+import org.apache.qpid.server.message.InboundMessage;
+import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.server.queue.Filterable;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.binding.Binding;
-import org.apache.qpid.server.exchange.topic.*;
-import org.apache.qpid.server.filter.JMSSelectorFilter;
-import org.apache.qpid.server.message.InboundMessage;
-
-import javax.management.JMException;
-import java.sql.Array;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-import java.lang.ref.WeakReference;
 
 public class TopicExchange extends AbstractExchange
 {
@@ -113,24 +123,26 @@
             FieldTable oldArgs = _bindings.get(binding);
             TopicExchangeResult result = _topicExchangeResults.get(routingKey);
 
-            if(argumentsContainSelector(args))
+            if(argumentsContainFilter(args))
             {
-                if(argumentsContainSelector(oldArgs))
+                if(argumentsContainFilter(oldArgs))
                 {
-                    result.replaceQueueFilter(queue,createSelectorFilter(oldArgs), createSelectorFilter(args));
+                    result.replaceQueueFilter(queue,
+                                              createMessageFilter(oldArgs, queue),
+                                              createMessageFilter(args, queue));
                 }
                 else
                 {
-                    result.addFilteredQueue(queue,createSelectorFilter(args));
+                    result.addFilteredQueue(queue, createMessageFilter(args, queue));
                     result.removeUnfilteredQueue(queue);
                 }
             }
             else
             {
-                if(argumentsContainSelector(oldArgs))
+                if(argumentsContainFilter(oldArgs))
                 {
                     result.addUnfilteredQueue(queue);
-                    result.removeFilteredQueue(queue, createSelectorFilter(oldArgs));
+                    result.removeFilteredQueue(queue, createMessageFilter(oldArgs, queue));
                 }
                 else
                 {
@@ -149,9 +161,9 @@
             if(result == null)
             {
                 result = new TopicExchangeResult();
-                if(argumentsContainSelector(args))
+                if(argumentsContainFilter(args))
                 {
-                    result.addFilteredQueue(queue, createSelectorFilter(args));
+                    result.addFilteredQueue(queue, createMessageFilter(args, queue));
                 }
                 else
                 {
@@ -162,9 +174,9 @@
             }
             else
             {
-                if(argumentsContainSelector(args))
+                if(argumentsContainFilter(args))
                 {
-                    result.addFilteredQueue(queue, createSelectorFilter(args));
+                    result.addFilteredQueue(queue, createMessageFilter(args, queue));
                 }
                 else
                 {
@@ -178,26 +190,74 @@
 
     }
 
-    private JMSSelectorFilter createSelectorFilter(final FieldTable args) throws AMQInvalidArgumentException
+    private MessageFilter createMessageFilter(final FieldTable args, AMQQueue queue) throws AMQInvalidArgumentException
     {
+        if(argumentsContainNoLocal(args))
+        {
+            MessageFilter filter = new NoLocalFilter(queue);
 
+            if(argumentsContainJMSSelector(args))
+            {
+                filter = new CompoundFilter(filter, createJMSSelectorFilter(args));
+            }
+            return filter;
+        }
+        else
+        {
+            return createJMSSelectorFilter(args);
+        }
+
+    }
+
+
+    private MessageFilter createJMSSelectorFilter(FieldTable args) throws AMQInvalidArgumentException
+    {
         final String selectorString = args.getString(AMQPFilterTypes.JMS_SELECTOR.getValue());
         WeakReference<JMSSelectorFilter> selectorRef = _selectorCache.get(selectorString);
         JMSSelectorFilter selector = null;
 
         if(selectorRef == null || (selector = selectorRef.get())==null)
         {
-            selector = new JMSSelectorFilter(selectorString);
+            try
+            {
+                selector = new JMSSelectorFilter(selectorString);
+            }
+            catch (ParseException e)
+            {
+                throw new AMQInvalidArgumentException("Cannot parse JMS selector \"" + selectorString + "\"", e);
+            }
+            catch (SelectorParsingException e)
+            {
+                throw new AMQInvalidArgumentException("Cannot parse JMS selector \"" + selectorString + "\"", e);
+            }
+            catch (TokenMgrError e)
+            {
+                throw new AMQInvalidArgumentException("Cannot parse JMS selector \"" + selectorString + "\"", e);
+            }
             _selectorCache.put(selectorString, new WeakReference<JMSSelectorFilter>(selector));
         }
         return selector;
     }
 
-    private static boolean argumentsContainSelector(final FieldTable args)
+    private static boolean argumentsContainFilter(final FieldTable args)
     {
-        return args != null && args.containsKey(AMQPFilterTypes.JMS_SELECTOR.getValue()) && args.getString(AMQPFilterTypes.JMS_SELECTOR.getValue()).trim().length() != 0;
+        return argumentsContainNoLocal(args) || argumentsContainJMSSelector(args);
     }
 
+    private static boolean argumentsContainNoLocal(final FieldTable args)
+    {
+        return args != null
+                && args.containsKey(AMQPFilterTypes.NO_LOCAL.getValue())
+                && Boolean.TRUE.equals(args.get(AMQPFilterTypes.NO_LOCAL.getValue()));
+    }
+
+    private static boolean argumentsContainJMSSelector(final FieldTable args)
+    {
+        return args != null && (args.containsKey(AMQPFilterTypes.JMS_SELECTOR.getValue())
+                       && args.getString(AMQPFilterTypes.JMS_SELECTOR.getValue()).trim().length() != 0);
+    }
+
+
     public ArrayList<BaseQueue> doRoute(InboundMessage payload)
     {
 
@@ -251,6 +311,28 @@
         }
     }
 
+    public boolean isBound(String bindingKey, Map<String, Object> arguments, AMQQueue queue)
+    {
+        Binding binding = new Binding(null, bindingKey, queue, this, arguments);
+        if (arguments == null)
+        {
+            return _bindings.containsKey(binding);
+        }
+        else
+        {
+            FieldTable o = _bindings.get(binding);
+            if (o != null)
+            {
+                return arguments.equals(FieldTable.convertToMap(o));
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+    }
+
     public boolean isBound(AMQShortString routingKey, AMQQueue queue)
     {
         return isBound(routingKey, null, queue);
@@ -297,11 +379,11 @@
             
             result.removeBinding(binding);
             
-            if(argumentsContainSelector(bindingArgs))
+            if(argumentsContainFilter(bindingArgs))
             {
                 try
                 {
-                    result.removeFilteredQueue(binding.getQueue(), createSelectorFilter(bindingArgs));
+                    result.removeFilteredQueue(binding.getQueue(), createMessageFilter(bindingArgs, binding.getQueue()));
                 }
                 catch (AMQInvalidArgumentException e)
                 {
@@ -378,4 +460,96 @@
         deregisterQueue(binding);
     }
 
+    private static final class NoLocalFilter implements MessageFilter
+    {
+        private final AMQQueue _queue;
+
+        public NoLocalFilter(AMQQueue queue)
+        {
+            _queue = queue;
+        }
+
+        public boolean matches(Filterable message)
+        {
+            InboundMessage inbound = (InboundMessage) message;
+            final AMQSessionModel exclusiveOwningSession = _queue.getExclusiveOwningSession();
+            return exclusiveOwningSession == null || !exclusiveOwningSession.onSameConnection(inbound);
+
+        }
+
+        @Override
+        public boolean equals(Object o)
+        {
+            if (this == o)
+            {
+                return true;
+            }
+
+            if (o == null || getClass() != o.getClass())
+            {
+                return false;
+            }
+
+            NoLocalFilter that = (NoLocalFilter) o;
+
+            return _queue == null ? that._queue == null : _queue.equals(that._queue);
+        }
+
+        @Override
+        public int hashCode()
+        {
+            return _queue != null ? _queue.hashCode() : 0;
+        }
+    }
+
+    private static final class CompoundFilter implements MessageFilter
+    {
+        private MessageFilter _noLocalFilter;
+        private MessageFilter _jmsSelectorFilter;
+
+        public CompoundFilter(MessageFilter filter, MessageFilter jmsSelectorFilter)
+        {
+            _noLocalFilter = filter;
+            _jmsSelectorFilter = jmsSelectorFilter;
+        }
+
+        public boolean matches(Filterable message)
+        {
+            return _noLocalFilter.matches(message) && _jmsSelectorFilter.matches(message);
+        }
+
+        @Override
+        public boolean equals(Object o)
+        {
+            if (this == o)
+            {
+                return true;
+            }
+            if (o == null || getClass() != o.getClass())
+            {
+                return false;
+            }
+
+            CompoundFilter that = (CompoundFilter) o;
+
+            if (_jmsSelectorFilter != null ? !_jmsSelectorFilter.equals(that._jmsSelectorFilter) : that._jmsSelectorFilter != null)
+            {
+                return false;
+            }
+            if (_noLocalFilter != null ? !_noLocalFilter.equals(that._noLocalFilter) : that._noLocalFilter != null)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        @Override
+        public int hashCode()
+        {
+            int result = _noLocalFilter != null ? _noLocalFilter.hashCode() : 0;
+            result = 31 * result + (_jmsSelectorFilter != null ? _jmsSelectorFilter.hashCode() : 0);
+            return result;
+        }
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchangeMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchangeMBean.java
index 620c3ce..481a377 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchangeMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchangeMBean.java
@@ -20,16 +20,20 @@
  */
 package org.apache.qpid.server.exchange;
 
-import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
 import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
 import org.apache.qpid.server.binding.Binding;
 
 import javax.management.JMException;
-import javax.management.openmbean.*;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
 
 /** TopicExchangeMBean class implements the management interface for the Topic exchanges. */
 @MBeanDescription("Management Bean for Topic Exchange")
@@ -47,7 +51,7 @@
     /** returns exchange bindings in tabular form */
     public TabularData bindings() throws OpenDataException
     {
-        TabularDataSupport bindingList = new TabularDataSupport(_bindinglistDataType);
+        TabularDataSupport bindingList = new TabularDataSupport(getBindinglistDataType());
         Map<String, List<String>> bindingData = new HashMap<String, List<String>>();
         for (Binding binding : getExchange().getBindings())
         {
@@ -65,7 +69,7 @@
         {
             Object[] bindingItemValues = {entry.getKey(), entry.getValue().toArray(new String[entry.getValue().size()]) };
             CompositeData bindingCompositeData =
-                    new CompositeDataSupport(_bindingDataType,
+                    new CompositeDataSupport(getBindingDataType(),
                             COMPOSITE_ITEM_NAMES.toArray(new String[COMPOSITE_ITEM_NAMES.size()]), 
                             bindingItemValues);
             bindingList.put(bindingCompositeData);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKey.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKey.java
deleted file mode 100644
index 8fdb91c..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKey.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.qpid.server.exchange.headers;
-
-import org.apache.qpid.framing.AMQShortString;
-
-/*
-*
-* 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.
-*
-*/
-public class HeaderKey
-{
-    public static final HeaderKey UNKNOWN = new HeaderKey(new AMQShortString("<< UNKNOWN >>"));
-    private AMQShortString _key;
-
-    public HeaderKey(final AMQShortString key)
-    {
-        _key = key;
-    }
-
-    public String toString()
-    {
-        return _key.toString();
-    }
-
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKeyDictionary.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKeyDictionary.java
deleted file mode 100644
index 7be99a8..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKeyDictionary.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.apache.qpid.server.exchange.headers;
-
-import org.apache.qpid.framing.AMQShortString;
-
-import java.util.Map;
-import java.util.HashMap;
-
-/*
-*
-* 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.
-*
-*/
-public class HeaderKeyDictionary
-{
-
-    private final Map<AMQShortString, HeaderKey> _dictionary = new HashMap<AMQShortString, HeaderKey>();
-
-
-    public HeaderKey get(final AMQShortString key)
-    {
-        HeaderKey headerKey = _dictionary.get(key);
-        return headerKey == null ? HeaderKey.UNKNOWN : headerKey;
-    }
-
-    public HeaderKey getOrCreate(final AMQShortString key)
-    {
-        HeaderKey headerKey = _dictionary.get(key);
-        if(headerKey == null)
-        {
-            headerKey = new HeaderKey(key);
-            _dictionary.put(key, headerKey);
-        }
-        return headerKey;
-    }
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderMatcherResult.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderMatcherResult.java
deleted file mode 100644
index 518064b..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderMatcherResult.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.apache.qpid.server.exchange.headers;
-
-/*
-*
-* 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.
-*
-*/
-public class HeaderMatcherResult
-{
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersMatcherDFAState.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersMatcherDFAState.java
deleted file mode 100644
index 9da93d4..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersMatcherDFAState.java
+++ /dev/null
@@ -1,339 +0,0 @@
-package org.apache.qpid.server.exchange.headers;
-
-import org.apache.qpid.framing.AMQTypedValue;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.server.exchange.topic.TopicMatcherDFAState;
-import org.apache.qpid.server.exchange.topic.TopicWord;
-import org.apache.qpid.server.exchange.topic.TopicMatcherResult;
-
-import java.util.*;
-
-/*
-*
-* 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.
-*
-*/
-public class HeadersMatcherDFAState
-{
-
-
-    private final Collection<HeaderMatcherResult> _results;
-    private final Map<HeaderKey, Map<AMQTypedValue,HeadersMatcherDFAState>> _nextStateMap;
-    private final HeaderKeyDictionary _dictionary;
-
-    public HeadersMatcherDFAState(Map<HeaderKey, Map<AMQTypedValue,HeadersMatcherDFAState>> nextStateMap,
-                                Collection<HeaderMatcherResult> results,
-                                HeaderKeyDictionary dictionary)
-    {
-        _nextStateMap = nextStateMap;
-        _results = results;
-        _dictionary = dictionary;
-    }
-
-
-    public Collection<HeaderMatcherResult> match(final FieldTable table)
-    {
-        return match(table.iterator());
-    }
-
-
-
-    public Collection<HeaderMatcherResult> match(Iterator<Map.Entry<AMQShortString,AMQTypedValue>> fieldTableIterator)
-    {
-
-        if(_nextStateMap.isEmpty())
-        {
-            return _results;
-        }
-
-        while(fieldTableIterator.hasNext())
-        {
-
-            Map.Entry<AMQShortString, AMQTypedValue> fieldTableEntry = fieldTableIterator.next();
-            HeaderKey key = _dictionary.get(fieldTableEntry.getKey());
-            if(key != HeaderKey.UNKNOWN)
-            {
-                Map<AMQTypedValue, HeadersMatcherDFAState> valueToStateMap = _nextStateMap.get(key);
-
-                if(valueToStateMap != null)
-                {
-                    HeadersMatcherDFAState nextState = valueToStateMap.get(fieldTableEntry.getValue());
-
-                    if(nextState == null)
-                    {
-                        nextState = valueToStateMap.get(null);
-                    }
-                    if(nextState != null && nextState != this)
-                    {
-                        return nextState.match(fieldTableIterator);
-                    }
-                }
-
-            }
-        }
-
-        return _results;
-
-    }
-
-
-    HeadersMatcherDFAState mergeStateMachines(HeadersMatcherDFAState otherStateMachine)
-    {
-
-        assert(otherStateMachine._dictionary == _dictionary);
-
-        Map<Set<HeadersMatcherDFAState>, HeadersMatcherDFAState> newStateMap= new HashMap<Set<HeadersMatcherDFAState>, HeadersMatcherDFAState>();
-
-        Collection<HeaderMatcherResult> results;
-
-        if(_results.isEmpty())
-        {
-            results = otherStateMachine._results;
-        }
-        else if(otherStateMachine._results.isEmpty())
-        {
-            results = _results;
-        }
-        else
-        {
-            results = new HashSet<HeaderMatcherResult>(_results);
-            results.addAll(otherStateMachine._results);
-        }
-
-
-        final Map<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> newNextStateMap = new HashMap<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>>();
-
-        HeadersMatcherDFAState newState = new HeadersMatcherDFAState(newNextStateMap, results, _dictionary);
-
-
-        Set<HeadersMatcherDFAState> oldStates = new HashSet<HeadersMatcherDFAState>();
-        oldStates.add(this);
-        oldStates.add(otherStateMachine);
-
-        newStateMap.put(oldStates, newState);
-
-        mergeStateMachines(oldStates, newNextStateMap, newStateMap);
-
-        return newState;
-
-
-    }
-
-    private void mergeStateMachines(final Set<HeadersMatcherDFAState> oldStates,
-                                    final Map<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> newNextStateMap,
-                                    final Map<Set<HeadersMatcherDFAState>, HeadersMatcherDFAState> newStateMap)
-    {
-        Map<HeaderKey, Map<AMQTypedValue, Set<HeadersMatcherDFAState>>> nfaMap = new HashMap<HeaderKey, Map<AMQTypedValue, Set<HeadersMatcherDFAState>>>();
-
-        Set<HeaderKey> distinctKeys = new HashSet<HeaderKey>();
-
-        for(HeadersMatcherDFAState state : oldStates)
-        {
-            Map<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> map = state._nextStateMap;
-
-            for(Map.Entry<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> entry : map.entrySet())
-            {
-                Map<AMQTypedValue, Set<HeadersMatcherDFAState>> valueToStatesMap = nfaMap.get(entry.getKey());
-
-                if(valueToStatesMap == null)
-                {
-                    valueToStatesMap = new HashMap<AMQTypedValue, Set<HeadersMatcherDFAState>>();
-                    nfaMap.put(entry.getKey(), valueToStatesMap);
-                }
-
-                for(Map.Entry<AMQTypedValue, HeadersMatcherDFAState> valueToStateEntry : entry.getValue().entrySet())
-                {
-                    Set<HeadersMatcherDFAState> states = valueToStatesMap.get(valueToStateEntry.getKey());
-                    if(states == null)
-                    {
-                        states = new HashSet<HeadersMatcherDFAState>();
-                        valueToStatesMap.put(valueToStateEntry.getKey(),states);
-                    }
-                    states.add(valueToStateEntry.getValue());
-                }
-
-                distinctKeys.add(entry.getKey());
-            }
-        }
-
-        Map<HeaderKey, Set<HeadersMatcherDFAState>> anyValueStates = new HashMap<HeaderKey, Set<HeadersMatcherDFAState>>();
-
-        for(HeaderKey distinctKey : distinctKeys)
-        {
-            Map<AMQTypedValue, Set<HeadersMatcherDFAState>> valueToStateMap = nfaMap.get(distinctKey);
-            if(valueToStateMap != null)
-            {
-                Set<HeadersMatcherDFAState> statesForKeyDefault = valueToStateMap.get(null);
-                if(statesForKeyDefault != null)
-                {
-                    anyValueStates.put(distinctKey,  statesForKeyDefault);
-                }
-            }
-        }
-
-        // add the defaults for "null" to all other specified values of a given header key
-
-        for( Map.Entry<HeaderKey,Map<AMQTypedValue,Set<HeadersMatcherDFAState>>> entry : nfaMap.entrySet())
-        {
-            Map<AMQTypedValue, Set<HeadersMatcherDFAState>> valueToStatesMap = entry.getValue();
-            for(Map.Entry<AMQTypedValue, Set<HeadersMatcherDFAState>> valueToStates : valueToStatesMap.entrySet())
-            {
-                if(valueToStates.getKey() != null)
-                {
-
-
-                    Set<HeadersMatcherDFAState> defaults = anyValueStates.get(entry.getKey());
-                    if(defaults != null)
-                    {
-                        valueToStates.getValue().addAll(defaults);
-                    }
-                }
-            }
-        }
-
-        // if a given header key is not mentioned in the map of a machine; then that machine would stay at the same state
-        // for that key.
-        for(HeaderKey distinctKey : distinctKeys)
-        {
-            Map<AMQTypedValue, Set<HeadersMatcherDFAState>> valueToStatesMap = nfaMap.get(distinctKey);
-            for(HeadersMatcherDFAState oldState : oldStates)
-            {
-                if(!oldState._nextStateMap.containsKey(distinctKey))
-                {
-                    for(Set<HeadersMatcherDFAState> endStates : valueToStatesMap.values())
-                    {
-                        endStates.add(oldState);
-                    }
-                }
-            }
-        }
-
-
-
-
-        for(Map.Entry<HeaderKey,Map<AMQTypedValue,Set<HeadersMatcherDFAState>>> transitionClass : nfaMap.entrySet())
-        {
-            Map<AMQTypedValue, HeadersMatcherDFAState> valueToDFAState = newNextStateMap.get(transitionClass.getKey());
-            if(valueToDFAState == null)
-            {
-                valueToDFAState = new HashMap<AMQTypedValue, HeadersMatcherDFAState>();
-                newNextStateMap.put(transitionClass.getKey(), valueToDFAState);
-            }
-
-            for(Map.Entry<AMQTypedValue,Set<HeadersMatcherDFAState>> transition : transitionClass.getValue().entrySet())
-            {
-                Set<HeadersMatcherDFAState> destinations = transition.getValue();
-
-
-                HeadersMatcherDFAState nextState = newStateMap.get(destinations);
-
-                if(nextState == null)
-                {
-
-                    if(destinations.size() == 1)
-                    {
-                        nextState = destinations.iterator().next();
-                        newStateMap.put(destinations, nextState);
-                    }
-                    else
-                    {
-                        Collection<HeaderMatcherResult> results;
-
-                        Set<Collection<HeaderMatcherResult>> resultSets = new HashSet<Collection<HeaderMatcherResult>>();
-                        for(HeadersMatcherDFAState destination : destinations)
-                        {
-                            resultSets.add(destination._results);
-                        }
-                        resultSets.remove(Collections.EMPTY_SET);
-                        if(resultSets.size() == 0)
-                        {
-                            results = Collections.EMPTY_SET;
-                        }
-                        else if(resultSets.size() == 1)
-                        {
-                            results = resultSets.iterator().next();
-                        }
-                        else
-                        {
-                            results = new HashSet<HeaderMatcherResult>();
-                            for(Collection<HeaderMatcherResult> oldResult : resultSets)
-                            {
-                                results.addAll(oldResult);
-                            }
-                        }
-
-                        final Map<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> nextStateMap = new HashMap<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>>();
-
-                        nextState = new HeadersMatcherDFAState(nextStateMap, results, _dictionary);
-                        newStateMap.put(destinations, nextState);
-
-                        mergeStateMachines(
-                                destinations,
-                                           nextStateMap,
-                                           newStateMap);
-
-
-                    }
-
-
-                }
-                valueToDFAState.put(transition.getKey(),nextState);
-            }
-        }
-
-
-
-        final ArrayList<HeaderKey> removeKeyList = new ArrayList<HeaderKey>();
-
-        for(Map.Entry<HeaderKey,Map<AMQTypedValue,HeadersMatcherDFAState>> entry : _nextStateMap.entrySet())
-        {
-            final ArrayList<AMQTypedValue> removeValueList = new ArrayList<AMQTypedValue>();
-
-            for(Map.Entry<AMQTypedValue,HeadersMatcherDFAState> valueToDFAState : entry.getValue().entrySet())
-            {
-                if(valueToDFAState.getValue() == this)
-                {
-                    HeadersMatcherDFAState defaultState = entry.getValue().get(null);
-                    if(defaultState == null || defaultState == this)
-                    {
-                        removeValueList.add(valueToDFAState.getKey());
-                    }
-                }
-            }
-
-            for(AMQTypedValue removeValue : removeValueList)
-            {
-                entry.getValue().remove(removeValue);
-            }
-
-            if(entry.getValue().isEmpty())
-            {
-                removeKeyList.add(entry.getKey());
-            }
-
-        }
-
-        for(HeaderKey removeKey : removeKeyList)
-        {
-            _nextStateMap.remove(removeKey);
-        }
-
-    }
-
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersParser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersParser.java
deleted file mode 100644
index d76b163..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersParser.java
+++ /dev/null
@@ -1,315 +0,0 @@
-package org.apache.qpid.server.exchange.headers;
-
-import org.apache.qpid.framing.*;
-
-import java.util.*;
-
-/*
-*
-* 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.
-*
-*/
-public class HeadersParser
-{
-
-    private final HeaderKeyDictionary _dictionary = new HeaderKeyDictionary();
-    private static final AMQShortString MATCHING_TYPE_KEY = new AMQShortString("x-match");
-    private static final String ANY_MATCHING = "any";
-    private static final AMQShortString RESERVED_KEY_PREFIX = new AMQShortString("x-");
-
-
-    HeadersMatcherDFAState createStateMachine(FieldTable bindingArguments, HeaderMatcherResult result)
-    {
-        String matchingType = bindingArguments.getString(MATCHING_TYPE_KEY);
-        boolean matchAny = matchingType.equalsIgnoreCase(ANY_MATCHING);
-        if(matchAny)
-        {
-            return createStateMachineForAnyMatch(bindingArguments, result);
-        }
-        else
-        {
-            return createStateMachineForAllMatch(bindingArguments, result);
-        }
-
-
-    }
-
-
-    private HeadersMatcherDFAState createStateMachineForAnyMatch(final FieldTable bindingArguments,
-                                                                 final HeaderMatcherResult result)
-    {
-
-        // DFAs for "any" matches have only two states, "not-matched" and "matched"... they start in the former
-        // and upon meeting any of the criteria they move to the latter
-
-        //noinspection unchecked
-        final HeadersMatcherDFAState successState =
-                new HeadersMatcherDFAState(Collections.EMPTY_MAP,Collections.singleton(result),_dictionary);
-
-        Map<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> nextStateMap =
-                new HashMap<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>>();
-
-        Set<AMQShortString> seenKeys = new HashSet<AMQShortString>();
-
-        Iterator<Map.Entry<AMQShortString, AMQTypedValue>> tableIterator = bindingArguments.iterator();
-
-        while(tableIterator.hasNext())
-        {
-            final Map.Entry<AMQShortString, AMQTypedValue> entry = tableIterator.next();
-            final AMQShortString key = entry.getKey();
-            final AMQTypedValue value = entry.getValue();
-
-
-            if(seenKeys.add(key) && !key.startsWith(RESERVED_KEY_PREFIX))
-            {
-                final AMQType type = value.getType();
-
-                final HeaderKey headerKey = _dictionary.getOrCreate(key);
-                final Map<AMQTypedValue, HeadersMatcherDFAState> valueMap;
-
-                if(type == AMQType.VOID ||
-                   ((type == AMQType.ASCII_STRING || type == AMQType.WIDE_STRING) && ((CharSequence)value.getValue()).length() == 0))
-                {
-                    valueMap = Collections.singletonMap(null,successState);
-
-                }
-                else
-                {
-                    valueMap = Collections.singletonMap(value,successState);
-                }
-                nextStateMap.put(headerKey,valueMap);
-
-            }
-
-        }
-
-        if(seenKeys.size() == 0)
-        {
-            return successState;
-        }
-        else
-        {
-            return new HeadersMatcherDFAState(nextStateMap,Collections.EMPTY_SET,_dictionary);
-        }
-
-
-    }
-
-
-    private HeadersMatcherDFAState createStateMachineForAllMatch(final FieldTable bindingArguments,
-                                                                 final HeaderMatcherResult result)
-    {
-        // DFAs for "all" matches have a "success" state, a "fail" state, and states for every subset of
-        // matches which are possible, starting with the empty subset.  For example if we have a binding
-        //  { x-match="all"
-        //          a=1
-        //          b=1
-        //          c=1
-        //          d=1 }
-        // Then we would have the following states
-        // (1) Seen none of a, b, c, or d
-        // (2) Seen a=1 ; none of b,c, or d
-        // (3) Seen b=1 ; none of a,c, or d
-        // (4) Seen c=1 ; none of a,b, or d
-        // (5) Seen d=1 ; none of a,b, or c
-        // (6) Seen a=1,b=1 ; none of c,d
-        // (7) Seen a=1,c=1 ; none of b,d
-        // (8) Seen a=1,d=1 ; none of b,c
-        // (9) Seen b=1,c=1 ; none of a,d
-        //(10) Seen b=1,d=1 ; none of c,d
-        //(11) Seen c=1,d=1 ; none of a,b
-        //(12) Seen a=1,b=1,c=1 ; not d
-        //(13) Seen a=1,b=1,d=1 ; not c
-        //(14) Seen a=1,c=1,d=1 ; not b
-        //(15) Seen b=1,c=1,d=1 ; not a
-        //(16) success
-        //(17) fail
-        //
-        // All states but (16) can transition to (17); additionally:
-        // (1) can transition to (2),(3),(4),(5)
-        // (2) can transition to (6),(7),(8)
-        // (3) can transition to (6),(9),(10)
-        // (4) can transition to (7),(9),(11)
-        // (5) can transition to (8),(10),(11)
-        // (6) can transition to (12),(13)
-        // (7) can transition to (12),(14)
-        // (8) can transition to (13),(14)
-        // (9) can transition to (12),(15)
-        //(10) can transition to (13),(15)
-        //(11) can transition to (14),(15)
-        //(12)-(15) can transition to (16)
-
-        Set<AMQShortString> seenKeys = new HashSet<AMQShortString>();
-        List<KeyValuePair> requiredTerms = new ArrayList<KeyValuePair>(bindingArguments.size());
-
-        Iterator<Map.Entry<AMQShortString, AMQTypedValue>> tableIterator = bindingArguments.iterator();
-
-
-
-        while(tableIterator.hasNext())
-        {
-            final Map.Entry<AMQShortString, AMQTypedValue> entry = tableIterator.next();
-            final AMQShortString key = entry.getKey();
-            final AMQTypedValue value = entry.getValue();
-
-
-            if(seenKeys.add(key) && !key.startsWith(RESERVED_KEY_PREFIX))
-            {
-                final AMQType type = value.getType();
-
-                if(type == AMQType.VOID ||
-                   ((type == AMQType.ASCII_STRING || type == AMQType.WIDE_STRING) && ((CharSequence)value.getValue()).length() == 0))
-                {
-                    requiredTerms.add(new KeyValuePair(_dictionary.getOrCreate(key),null));
-                }
-                else
-                {
-                    requiredTerms.add(new KeyValuePair(_dictionary.getOrCreate(key),value));
-                }
-            }
-
-        }
-
-        final HeadersMatcherDFAState successState =
-                        new HeadersMatcherDFAState(Collections.EMPTY_MAP,Collections.singleton(result),_dictionary);
-
-        final HeadersMatcherDFAState failState =
-                        new HeadersMatcherDFAState(Collections.EMPTY_MAP,Collections.EMPTY_SET,_dictionary);
-
-        Map<Set<KeyValuePair>, HeadersMatcherDFAState> notSeenTermsToStateMap =
-                new HashMap<Set<KeyValuePair>, HeadersMatcherDFAState>();
-
-        notSeenTermsToStateMap.put(Collections.EMPTY_SET, successState);
-
-
-        final int numberOfTerms = requiredTerms.size();
-
-        for(int numMissingTerms = 1; numMissingTerms <= numberOfTerms; numMissingTerms++)
-        {
-            int[] pos = new int[numMissingTerms];
-            for(int i = 0; i < numMissingTerms; i++)
-            {
-                pos[i] = i;
-            }
-
-            final int maxTermValue = (numberOfTerms - (numMissingTerms - 1));
-
-            while(pos[0] < maxTermValue)
-            {
-
-                Set<KeyValuePair> stateSet = new HashSet<KeyValuePair>();
-                for(int posIndex = 0; posIndex < pos.length; posIndex++)
-                {
-                    stateSet.add(requiredTerms.get(pos[posIndex]));
-                }
-
-                final Map<HeaderKey, Map<AMQTypedValue,HeadersMatcherDFAState>> nextStateMap =
-                                    new HashMap<HeaderKey, Map<AMQTypedValue,HeadersMatcherDFAState>>();
-
-
-                for(int posIndex = 0; posIndex < pos.length; posIndex++)
-                {
-                    KeyValuePair nextTerm = requiredTerms.get(pos[posIndex]);
-                    HashSet<KeyValuePair> nextStateSet =
-                            new HashSet<KeyValuePair>(stateSet);
-                    nextStateSet.remove(nextTerm);
-
-                    Map<AMQTypedValue, HeadersMatcherDFAState> valueToStateMap =
-                            new HashMap<AMQTypedValue, HeadersMatcherDFAState>();
-                    nextStateMap.put(nextTerm._key, valueToStateMap);
-
-                    valueToStateMap.put( nextTerm._value,notSeenTermsToStateMap.get(nextStateSet));
-                    if(nextTerm._value != null)
-                    {
-                        valueToStateMap.put(null, failState);
-                    }
-
-
-                }
-
-
-                HeadersMatcherDFAState newState = new HeadersMatcherDFAState(nextStateMap, Collections.EMPTY_SET, _dictionary);
-
-                notSeenTermsToStateMap.put(stateSet, newState);
-
-                int i = numMissingTerms;
-                while(i-- != 0)
-                {
-                    if(++pos[i] <= numberOfTerms -(numMissingTerms-i))
-                    {
-                        int k = pos[i];
-                        for(int j = i+1; j < numMissingTerms; j++)
-                        {
-                            pos[j] = ++k;
-                        }
-                        break;
-                    }
-                }
-            }
-
-
-
-
-        }
-
-
-        return notSeenTermsToStateMap.get(new HashSet<KeyValuePair>(requiredTerms));
-
-
-        
-    }
-
-    public final static class KeyValuePair
-    {
-        public final HeaderKey _key;
-        public final AMQTypedValue _value;
-        private final int _hashCode;
-
-        public KeyValuePair(final HeaderKey key, final AMQTypedValue value)
-        {
-            _key = key;
-            _value = value;
-            int hash = (1 + 31 * _key.hashCode());
-            if(_value != null)
-            {
-                hash+=_value.hashCode();
-            }
-            _hashCode = hash;
-        }
-
-        public int hashCode()
-        {
-            return _hashCode;
-        }
-
-        public boolean equals(Object o)
-        {
-            assert o != null;
-            assert o instanceof KeyValuePair;
-            KeyValuePair other = (KeyValuePair)o;
-            return (_key == other._key) && (_value == null ? other._value == null : _value.equals(other._value));
-        }
-
-
-        public String toString()
-        {
-            return "{" + _key + " -> " + _value + "}";
-        }
-
-    }
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicExchangeResult.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicExchangeResult.java
index d8b09a7..44d5f7f 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicExchangeResult.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicExchangeResult.java
@@ -20,10 +20,10 @@
  */
 package org.apache.qpid.server.exchange.topic;
 
-import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.binding.Binding;
 import org.apache.qpid.server.filter.MessageFilter;
 import org.apache.qpid.server.message.InboundMessage;
+import org.apache.qpid.server.queue.AMQQueue;
 
 import java.util.ArrayList;
 import java.util.Collection;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicMatcherDFAState.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicMatcherDFAState.java
index 4446536..dfe4d85 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicMatcherDFAState.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicMatcherDFAState.java
@@ -3,7 +3,17 @@
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.AMQShortStringTokenizer;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /*
@@ -246,25 +256,25 @@
             transitions.append("[ ");
             transitions.append(entry.getKey());
             transitions.append("\t ->\t ");
-            transitions.append(entry.getValue()._id);
+            transitions.append(entry.getValue().getId());
             transitions.append(" ]\n");
         }
 
 
-        return "[ State " + _id + " ]\n" + transitions + "\n";
+        return "[ State " + getId() + " ]\n" + transitions + "\n";
 
     }
 
     public String reachableStates()
     {
-        StringBuilder result = new StringBuilder("Start state: " + _id + "\n");
+        StringBuilder result = new StringBuilder("Start state: " + getId() + "\n");
 
         SortedSet<TopicMatcherDFAState> reachableStates =
                 new TreeSet<TopicMatcherDFAState>(new Comparator<TopicMatcherDFAState>()
                                                         {
                                                             public int compare(final TopicMatcherDFAState o1, final TopicMatcherDFAState o2)
                                                             {
-                                                                return o1._id - o2._id;
+                                                                return o1.getId() - o2.getId();
                                                             }
                                                         });
         reachableStates.add(this);
@@ -292,4 +302,9 @@
         return result.toString();
     }
 
+
+    int getId()
+    {
+        return _id;
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicNormalizer.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicNormalizer.java
index 7e7cb6c..aac696a 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicNormalizer.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicNormalizer.java
@@ -22,10 +22,9 @@
 
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.AMQShortStringTokenizer;
-import org.apache.qpid.server.exchange.TopicExchange;
 
-import java.util.List;
 import java.util.ArrayList;
+import java.util.List;
 
 public class TopicNormalizer
 {
@@ -37,6 +36,10 @@
     private static final AMQShortString AMQP_STAR_TOKEN = new AMQShortString("*");
     private static final AMQShortString AMQP_HASH_TOKEN = new AMQShortString("#");
 
+    private TopicNormalizer()
+    {
+    }
+
     public static AMQShortString normalize(AMQShortString routingKey)
     {
         if(routingKey == null)
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicParser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicParser.java
index 3e9facf..1cb4301 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicParser.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicParser.java
@@ -3,9 +3,15 @@
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.AMQShortStringTokenizer;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
-import java.io.IOException;
 
 /*
 *
@@ -52,14 +58,43 @@
         }
 
 
+        public TopicWord getWord()
+        {
+            return _word;
+        }
+
+        public boolean isSelfTransition()
+        {
+            return _selfTransition;
+        }
+
+        public int getPosition()
+        {
+            return _position;
+        }
+
+        public boolean isEndState()
+        {
+            return _endState;
+        }
+
+        public boolean isFollowedByAnyLoop()
+        {
+            return _followedByAnyLoop;
+        }
+
+        public void setFollowedByAnyLoop(boolean followedByAnyLoop)
+        {
+            _followedByAnyLoop = followedByAnyLoop;
+        }
     }
 
     private static final Position ERROR_POSITION = new Position(Integer.MAX_VALUE,null, true, false);
 
     private static class SimpleState
     {
-        Set<Position> _positions;
-        Map<TopicWord, SimpleState> _nextState;
+        private Set<Position> _positions;
+        private Map<TopicWord, SimpleState> _nextState;
     }
 
 
@@ -180,11 +215,11 @@
             while(followedByWildcards && n<(positionCount+1))
             {
 
-                if(positions[n]._selfTransition)
+                if(positions[n].isSelfTransition())
                 {
                     break;
                 }
-                else if(positions[n]._word!=TopicWord.ANY_WORD)
+                else if(positions[n].getWord() !=TopicWord.ANY_WORD)
                 {
                     followedByWildcards = false;
                 }
@@ -192,7 +227,7 @@
             }
 
 
-            positions[p]._followedByAnyLoop = followedByWildcards && (n!= positionCount+1);
+            positions[p].setFollowedByAnyLoop(followedByWildcards && (n!= positionCount+1));
         }
 
 
@@ -221,7 +256,7 @@
 
             for(Position p : simpleStates[i]._positions)
             {
-                if(p._endState)
+                if(p.isEndState())
                 {
                     endState = true;
                     break;
@@ -267,7 +302,7 @@
 
         for(Position pos : state._positions)
         {
-            if(pos._selfTransition)
+            if(pos.isSelfTransition())
             {
                 Set<Position> dest = transitions.get(TopicWord.ANY_WORD);
                 if(dest == null)
@@ -278,14 +313,14 @@
                 dest.add(pos);
             }
 
-            final int nextPos = pos._position + 1;
+            final int nextPos = pos.getPosition() + 1;
             Position nextPosition = nextPos == positions.length ? ERROR_POSITION : positions[nextPos];
 
-            Set<Position> dest = transitions.get(pos._word);
+            Set<Position> dest = transitions.get(pos.getWord());
             if(dest == null)
             {
                 dest = new HashSet<Position>();
-                transitions.put(pos._word,dest);
+                transitions.put(pos.getWord(),dest);
             }
             dest.add(nextPosition);
 
@@ -312,7 +347,7 @@
             Position loopingTerminal = null;
             for(Position destPos : dest.getValue())
             {
-                if(destPos._selfTransition && destPos._endState)
+                if(destPos.isSelfTransition() && destPos.isEndState())
                 {
                     loopingTerminal = destPos;
                     break;
@@ -328,9 +363,9 @@
                 Position anyLoop = null;
                 for(Position destPos : dest.getValue())
                 {
-                    if(destPos._followedByAnyLoop)
+                    if(destPos.isFollowedByAnyLoop())
                     {
-                        if(anyLoop == null || anyLoop._position<destPos._position)
+                        if(anyLoop == null || anyLoop.getPosition() < destPos.getPosition())
                         {
                             anyLoop = destPos;
                         }
@@ -341,7 +376,7 @@
                     Collection<Position> removals = new ArrayList<Position>();
                     for(Position destPos : dest.getValue())
                     {
-                        if(destPos._position < anyLoop._position)
+                        if(destPos.getPosition() < anyLoop.getPosition())
                         {
                             removals.add(destPos);
                         }
@@ -421,193 +456,4 @@
     }
 
 
-    public static void main(String[] args)
-    {
-
-        printMatches("#.b.*.*.*.*.*.h.#.j.*.*.*.*.*.*.q.#.r.*.*.*.*.*.*.*.*","a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z");
-        printMatches(new String[]{
-                        "#.a.#",
-                        "#.b.#",
-                        "#.c.#",
-                        "#.d.#",
-                        "#.e.#",
-                        "#.f.#",
-                        "#.g.#",
-                        "#.h.#",
-                        "#.i.#",
-                        "#.j.#",
-                        "#.k.#",
-                        "#.l.#",
-                        "#.m.#",
-                        "#.n.#",
-                        "#.o.#",
-                        "#.p.#",
-                        "#.q.#"
-
-        }, "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z");        
-/*
-        printMatches(new String[]{
-                "#.a.#",
-                "#.b.#",
-                "#.c.#",
-                "#.d.#",
-                "#.e.#",
-                "#.f.#",
-                "#.g.#",
-                "#.h.#",
-                "#.i.#",
-                "#.j.#",
-                "#.k.#",
-                "#.l.#",
-                "#.m.#",
-                "#.n.#",
-                "#.o.#",
-                "#.p.#",
-                "#.q.#",
-                "#.r.#",
-                "#.s.#",
-                "#.t.#",
-                "#.u.#",
-                "#.v.#",
-                "#.w.#",
-                "#.x.#",
-                "#.y.#",
-                "#.z.#"
-
-
-        },"a.b");
-
-        printMatches("#.b.*.*.*.*.*.h.#.j.*.*.*.*.*.p.#.r.*.*.*.*.*","a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z");
-        printMatches("#.b.*.*.*.*.*.h.#.j.*.*.*.*.*.p.#.r.*.*.*.*.*.*.*.*","a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z");
-        printMatches("a.#.b.#","a.b.b.b.b.b.b.b.c");
-
-*/
-
-        printMatches("","");
-        printMatches("a","a");
-        printMatches("a","");
-        printMatches("","a");
-        printMatches("a.b","a.b");
-        printMatches("a","a.b");
-        printMatches("a.b","a");
-        printMatches("*","a");
-        printMatches("*.b","a.b");
-        printMatches("*.*","a.b");
-        printMatches("a.*","a.b");
-        printMatches("a.*.#","a.b");
-        printMatches("a.#.b","a.b");
-
-        printMatches("#.b","a");
-        printMatches("#.b","a.b");
-        printMatches("#.a.b","a.b");
-
-
-        printMatches("#","");
-        printMatches("#","a");
-        printMatches("#","a.b");
-        printMatches("#.#","a.b");
-        printMatches("#.*","a.b");
-
-        printMatches("#.a.b","a.b");
-        printMatches("a.b.#","a.b");
-        printMatches("a.#","a.b");
-        printMatches("#.*.#","a.b");
-        printMatches("#.*.b.#","a.b");
-        printMatches("#.a.*.#","a.b");
-        printMatches("#.a.#.b.#","a.b");
-        printMatches("#.*.#.*.#","a.b");
-        printMatches("*.#.*.#","a.b");
-        printMatches("#.*.#.*","a.b");
-
-
-        printMatches(new String[]{"a.#.b.#","a.*.#.b.#"},"a.b.b.b.b.b.b.b.c");
-
-
-        printMatches(new String[]{"a.b", "a.c"},"a.b");
-        printMatches(new String[]{"a.#", "a.c", "#.b"},"a.b");
-        printMatches(new String[]{"a.#", "a.c", "#.b", "#", "*.*"},"a.b");
-
-        printMatches(new String[]{"a.b.c.d.e.#", "a.b.c.d.#", "a.b.c.d.*", "a.b.c.#", "#.e", "a.*.c.d.e","#.c.*.#.*.*"},"a.b.c.d.e");
-        printMatches(new String[]{"a.b.c.d.e.#", "a.b.c.d.#", "a.b.c.d.*", "a.b.c.#", "#.e", "a.*.c.d.e","#.c.*.#.*.*"},"a.b.c.d.f.g");
-
-
-
-
-    }
-
-    private static void printMatches(final String[] bindingKeys, final String routingKey)
-    {
-        TopicMatcherDFAState sm = null;
-        Map<TopicMatcherResult, String> resultMap = new HashMap<TopicMatcherResult, String>();
-
-        TopicParser parser = new TopicParser();
-
-        long start = System.currentTimeMillis();
-        for(int i = 0; i < bindingKeys.length; i++)
-        {
-            System.out.println((System.currentTimeMillis() - start) + ":\t" + bindingKeys[i]);
-            TopicMatcherResult r = new TopicMatcherResult(){};
-            resultMap.put(r, bindingKeys[i]);
-            AMQShortString bindingKeyShortString = new AMQShortString(bindingKeys[i]);
-
-            System.err.println("=====================================================");
-            System.err.println("Adding binding key: " + bindingKeyShortString);
-            System.err.println("-----------------------------------------------------");
-
-
-            if(i==0)
-            {
-                sm = parser.createStateMachine(bindingKeyShortString, r);
-            }
-            else
-            {
-                sm = sm.mergeStateMachines(parser.createStateMachine(bindingKeyShortString, r));
-            }
-            System.err.println(sm.reachableStates());
-            System.err.println("=====================================================");
-            try
-            {
-                System.in.read();
-            }
-            catch (IOException e)
-            {
-                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            }
-        }
-        AMQShortString routingKeyShortString = new AMQShortString(routingKey);
-
-        Collection<TopicMatcherResult> results = sm.parse(parser._dictionary, routingKeyShortString);
-        Collection<String> resultStrings = new ArrayList<String>();
-
-        for(TopicMatcherResult result : results)
-        {
-            resultStrings.add(resultMap.get(result));
-        }
-
-        final ArrayList<String> nonMatches = new ArrayList<String>(Arrays.asList(bindingKeys));
-        nonMatches.removeAll(resultStrings);
-        System.out.println("\""+routingKeyShortString+"\" matched with " + resultStrings + " DID NOT MATCH with " + nonMatches);
-
-
-    }
-
-    private static void printMatches(String bindingKey, String routingKey)
-    {
-        printMatches(new String[] { bindingKey }, routingKey);
-    }
-
-
-    private static boolean matches(String bindingKey, String routingKey)
-    {
-        AMQShortString bindingKeyShortString = new AMQShortString(bindingKey);
-        AMQShortString routingKeyShortString = new AMQShortString(routingKey);
-        TopicParser parser = new TopicParser();
-
-        final TopicMatcherResult result = new TopicMatcherResult(){};
-
-        TopicMatcherDFAState sm = parser.createStateMachine(bindingKeyShortString, result);
-        return !sm.parse(parser._dictionary,routingKeyShortString).isEmpty();
-
-    }
-
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicWord.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicWord.java
index f14d70f..b23b3db 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicWord.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/topic/TopicWord.java
@@ -2,10 +2,6 @@
 
 import org.apache.qpid.framing.AMQShortString;
 
-import java.util.Map;
-import java.util.HashMap;
-import java.util.concurrent.ConcurrentHashMap;
-
 /*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/Bridge.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/Bridge.java
index 4db6ee3..b58802e 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/Bridge.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/Bridge.java
@@ -45,9 +45,28 @@
 import org.apache.qpid.server.txn.AutoCommitTransaction;
 import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.transport.*;
+import org.apache.qpid.transport.DeliveryProperties;
+import org.apache.qpid.transport.MessageAcceptMode;
+import org.apache.qpid.transport.MessageAcquireMode;
+import org.apache.qpid.transport.MessageCreditUnit;
+import org.apache.qpid.transport.MessageFlowMode;
+import org.apache.qpid.transport.MessageReject;
+import org.apache.qpid.transport.MessageRejectCode;
+import org.apache.qpid.transport.MessageTransfer;
+import org.apache.qpid.transport.Option;
+import org.apache.qpid.transport.RangeSet;
+import org.apache.qpid.transport.RangeSetFactory;
+import org.apache.qpid.transport.Session;
+import org.apache.qpid.transport.SessionException;
+import org.apache.qpid.transport.SessionListener;
 
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
@@ -503,7 +522,7 @@
             _transaction.enqueue(queues,message, new ServerTransaction.Action()
                         {
 
-                            BaseQueue[] _queues = queues.toArray(new BaseQueue[queues.size()]);
+                            private BaseQueue[] _queues = queues.toArray(new BaseQueue[queues.size()]);
 
                             public void postCommit()
                             {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/BrokerLink.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/BrokerLink.java
index a8f75d2..032df8b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/BrokerLink.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/BrokerLink.java
@@ -30,8 +30,15 @@
 import org.apache.qpid.server.configuration.LinkConfigType;
 import org.apache.qpid.server.transport.ServerSession;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.transport.*;
-import org.apache.qpid.util.Strings;
+import org.apache.qpid.transport.Binary;
+import org.apache.qpid.transport.ClientDelegate;
+import org.apache.qpid.transport.Connection;
+import org.apache.qpid.transport.ConnectionException;
+import org.apache.qpid.transport.ConnectionListener;
+import org.apache.qpid.transport.ConnectionSettings;
+import org.apache.qpid.transport.Session;
+import org.apache.qpid.transport.SessionDelegate;
+import org.apache.qpid.transport.TransportException;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
@@ -42,7 +49,11 @@
 import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslException;
 import java.io.IOException;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -365,8 +376,8 @@
                             }
                         };
                         final SaslClient sc = Sasl.createSaslClient(new String[] {"PLAIN"}, null,
-                                                                    _conSettings.getSaslProtocol(),
-                                                                    _conSettings.getSaslServerName(),
+                                                                    getConnectionSettings().getSaslProtocol(),
+                                                                    getConnectionSettings().getSaslServerName(),
                                                                     saslProps, cbh);
 
                         return sc;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java
index dac5171..56f0a6e 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java
@@ -20,12 +20,17 @@
  */
 package org.apache.qpid.server.filter;
 
-import java.util.Map;
+import org.apache.log4j.Logger;
 
 import org.apache.qpid.AMQException;
+import org.apache.qpid.AMQInvalidArgumentException;
 import org.apache.qpid.common.AMQPFilterTypes;
+import org.apache.qpid.filter.SelectorParsingException;
+import org.apache.qpid.filter.selector.ParseException;
+import org.apache.qpid.filter.selector.TokenMgrError;
 import org.apache.qpid.framing.FieldTable;
-import org.apache.log4j.Logger;
+
+import java.util.Map;
 
 
 public class FilterManagerFactory
@@ -33,6 +38,10 @@
  
     private final static Logger _logger = Logger.getLogger(FilterManagerFactory.class);
 
+    private FilterManagerFactory()
+    {
+    }
+
     //fixme move to a common class so it can be refered to from client code.
 
     public static FilterManager createManager(FieldTable filters) throws AMQException
@@ -51,7 +60,22 @@
                 if (selector != null && !selector.equals(""))
                 {
                     manager = new SimpleFilterManager();
-                    manager.add(new JMSSelectorFilter(selector));
+                    try
+                    {
+                        manager.add(new JMSSelectorFilter(selector));
+                    }
+                    catch (ParseException e)
+                    {
+                        throw new AMQInvalidArgumentException("Cannot parse JMS selector \"" + selector + "\"", e);
+                    }
+                    catch (SelectorParsingException e)
+                    {
+                        throw new AMQInvalidArgumentException("Cannot parse JMS selector \"" + selector + "\"", e);
+                    }
+                    catch (TokenMgrError e)
+                    {
+                        throw new AMQInvalidArgumentException("Cannot parse JMS selector \"" + selector + "\"", e);
+                    }
                 }
 
             }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/JMSSelectorFilter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/JMSSelectorFilter.java
index 423bbc2..47cacdc 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/JMSSelectorFilter.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/JMSSelectorFilter.java
@@ -21,8 +21,13 @@
 package org.apache.qpid.server.filter;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.AMQInvalidArgumentException;
-import org.apache.qpid.server.filter.jms.selector.SelectorParser;
+
+import org.apache.qpid.filter.BooleanExpression;
+import org.apache.qpid.filter.FilterableMessage;
+import org.apache.qpid.filter.SelectorParsingException;
+import org.apache.qpid.filter.selector.ParseException;
+import org.apache.qpid.filter.selector.SelectorParser;
+import org.apache.qpid.filter.selector.TokenMgrError;
 import org.apache.qpid.server.queue.Filterable;
 
 
@@ -33,7 +38,7 @@
     private String _selector;
     private BooleanExpression _matcher;
 
-    public JMSSelectorFilter(String selector) throws AMQInvalidArgumentException
+    public JMSSelectorFilter(String selector) throws ParseException, TokenMgrError, SelectorParsingException
     {
         _selector = selector;
         _matcher = new SelectorParser().parse(selector);
@@ -41,7 +46,8 @@
 
     public boolean matches(Filterable message)
     {
-        boolean match = _matcher.matches(message);
+
+        boolean match = _matcher.matches(wrap(message));
         if(_logger.isDebugEnabled())
         {
             _logger.debug(message + " match(" + match + ") selector(" + System.identityHashCode(_selector) + "):" + _selector);
@@ -49,6 +55,62 @@
         return match;
     }
 
+    private FilterableMessage wrap(final Filterable message)
+    {
+        return new FilterableMessage()
+        {
+            public boolean isPersistent()
+            {
+                return message.isPersistent();
+            }
+
+            public boolean isRedelivered()
+            {
+                return message.isRedelivered();
+            }
+
+            public Object getHeader(String name)
+            {
+                return message.getMessageHeader().getHeader(name);
+            }
+
+            public String getReplyTo()
+            {
+                return message.getMessageHeader().getReplyTo();
+            }
+
+            public String getType()
+            {
+                return message.getMessageHeader().getType();
+            }
+
+            public byte getPriority()
+            {
+                return message.getMessageHeader().getPriority();
+            }
+
+            public String getMessageId()
+            {
+                return message.getMessageHeader().getMessageId();
+            }
+
+            public long getTimestamp()
+            {
+                return message.getMessageHeader().getTimestamp();
+            }
+
+            public String getCorrelationId()
+            {
+                return message.getMessageHeader().getCorrelationId();
+            }
+
+            public long getExpiration()
+            {
+                return message.getMessageHeader().getExpiration();
+            }
+        };
+    }
+
     public String getSelector()
     {
         return _selector;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java
index 65ddf19..d3e097d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.filter;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.queue.Filterable;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java
index 360a5d4..b2a9009 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java
@@ -20,12 +20,12 @@
  */
 package org.apache.qpid.server.filter;
 
-import java.util.concurrent.ConcurrentLinkedQueue;
-
 import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
+
 import org.apache.qpid.server.queue.Filterable;
 
+import java.util.concurrent.ConcurrentLinkedQueue;
+
 public class SimpleFilterManager implements FilterManager
 {
     private final Logger _logger = Logger.getLogger(SimpleFilterManager.class);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/XPathExpression.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/XPathExpression.java
deleted file mode 100644
index aa35cb5..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/XPathExpression.java
+++ /dev/null
@@ -1,126 +0,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.
- */
-package org.apache.qpid.server.filter;
-//
-// Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
-//
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.queue.Filterable;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Used to evaluate an XPath Expression in a JMS selector.
- */
-public final class XPathExpression implements BooleanExpression {
-
-    private static final Logger log = Logger.getLogger(XPathExpression.class);
-    private static final String EVALUATOR_SYSTEM_PROPERTY = "org.apache.qpid.server.filter.XPathEvaluatorClassName";
-    private static final String DEFAULT_EVALUATOR_CLASS_NAME=XalanXPathEvaluator.class.getName();
-
-    private static final Constructor EVALUATOR_CONSTRUCTOR;
-
-    static {
-        String cn = System.getProperty(EVALUATOR_SYSTEM_PROPERTY, DEFAULT_EVALUATOR_CLASS_NAME);
-        Constructor m = null;
-        try {
-            try {
-                m = getXPathEvaluatorConstructor(cn);
-            } catch (Throwable e) {
-                log.warn("Invalid "+XPathEvaluator.class.getName()+" implementation: "+cn+", reason: "+e,e);
-                cn = DEFAULT_EVALUATOR_CLASS_NAME;
-                try {
-                    m = getXPathEvaluatorConstructor(cn);
-                } catch (Throwable e2) {
-                    log.error("Default XPath evaluator could not be loaded",e);
-                }
-            }
-        } finally {
-            EVALUATOR_CONSTRUCTOR = m;
-        }
-    }
-
-    private static Constructor getXPathEvaluatorConstructor(String cn) throws ClassNotFoundException, SecurityException, NoSuchMethodException {
-        Class c = XPathExpression.class.getClassLoader().loadClass(cn);
-        if( !XPathEvaluator.class.isAssignableFrom(c) ) {
-            throw new ClassCastException(""+c+" is not an instance of "+XPathEvaluator.class);
-        }
-        return c.getConstructor(new Class[]{String.class});
-    }
-
-    private final String xpath;
-    private final XPathEvaluator evaluator;
-
-    static public interface XPathEvaluator {
-        public boolean evaluate(Filterable message);
-    }
-
-    XPathExpression(String xpath) {
-        this.xpath = xpath;
-        this.evaluator = createEvaluator(xpath);
-    }
-
-    private XPathEvaluator createEvaluator(String xpath2) {
-        try {
-            return (XPathEvaluator)EVALUATOR_CONSTRUCTOR.newInstance(new Object[]{xpath});
-        } catch (InvocationTargetException e) {
-            Throwable cause = e.getCause();
-            if( cause instanceof RuntimeException ) {
-                throw (RuntimeException)cause;
-            }
-            throw new RuntimeException("Invalid XPath Expression: "+xpath+" reason: "+e.getMessage(), e);
-        } catch (Throwable e) {
-            throw new RuntimeException("Invalid XPath Expression: "+xpath+" reason: "+e.getMessage(), e);
-        }
-    }
-
-    public Object evaluate(Filterable message)  {
-//        try {
-//FIXME this is flow to disk work
-//            if( message.isDropped() )
-//                return null;
-            return evaluator.evaluate(message) ? Boolean.TRUE : Boolean.FALSE;
-//        } catch (IOException e) {
-//
-//            JMSException exception = new JMSException(e.getMessage());
-//            exception.initCause(e);
-//            throw exception;
-//
-//        }
-
-    }
-
-    public String toString() {
-        return "XPATH "+ConstantExpression.encodeString(xpath);
-    }
-
-    /**
-     * @param message
-     * @return true if the expression evaluates to Boolean.TRUE.
-     * @throws AMQException
-     */
-    public boolean matches(Filterable message)
-    {
-        Object object = evaluate(message);
-        return object!=null && object==Boolean.TRUE;
-    }
-
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/XQueryExpression.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/XQueryExpression.java
deleted file mode 100644
index ae22f17..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/XQueryExpression.java
+++ /dev/null
@@ -1,57 +0,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.
- */
-package org.apache.qpid.server.filter;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.queue.Filterable;
-
-//
-// Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
-//
-
-/**
- * Used to evaluate an XQuery Expression in a JMS selector.
- */
-public final class XQueryExpression implements BooleanExpression {
-    private final String xpath;
-
-    XQueryExpression(String xpath) {
-        super();
-        this.xpath = xpath;
-    }
-
-    public Object evaluate(Filterable message) {
-        return Boolean.FALSE;
-    }
-
-    public String toString() {
-        return "XQUERY "+ConstantExpression.encodeString(xpath);
-    }
-
-    /**
-     * @param message
-     * @return true if the expression evaluates to Boolean.TRUE.
-     * @throws AMQException
-     */
-    public boolean matches(Filterable message)
-    {
-        Object object = evaluate(message);
-        return object!=null && object==Boolean.TRUE;
-    }
-
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/XalanXPathEvaluator.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/XalanXPathEvaluator.java
deleted file mode 100644
index f83eb63..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/XalanXPathEvaluator.java
+++ /dev/null
@@ -1,101 +0,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.
- */
-
-package org.apache.qpid.server.filter;
-//
-// Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
-//
-
-import java.io.ByteArrayInputStream;
-import java.io.StringReader;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.qpid.server.queue.Filterable;
-import org.apache.xpath.CachedXPathAPI;
-import org.w3c.dom.Document;
-import org.w3c.dom.traversal.NodeIterator;
-import org.xml.sax.InputSource;
-
-public class XalanXPathEvaluator implements XPathExpression.XPathEvaluator {
-
-    private final String xpath;
-
-    public XalanXPathEvaluator(String xpath) {
-        this.xpath = xpath;
-    }
-
-    public boolean evaluate(Filterable m)
-    {
-        // TODO - we would have to check the content type and then evaluate the content
-        //        here... is this really a feature we wish to implement? - RobG
-        /*
-
-        if( m instanceof TextMessage ) {
-            String text = ((TextMessage)m).getText();
-            return evaluate(text);
-        } else if ( m instanceof BytesMessage ) {
-            BytesMessage bm = (BytesMessage) m;
-            byte data[] = new byte[(int) bm.getBodyLength()];
-            bm.readBytes(data);
-            return evaluate(data);
-        }
-        */
-        return false;
-
-    }
-
-    private boolean evaluate(byte[] data) {
-        try {
-
-            InputSource inputSource = new InputSource(new ByteArrayInputStream(data));
-
-            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-            factory.setNamespaceAware(true);
-            DocumentBuilder dbuilder = factory.newDocumentBuilder();
-            Document doc = dbuilder.parse(inputSource);
-
-            CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
-            NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc,xpath);
-            return iterator.nextNode()!=null;
-
-        } catch (Throwable e) {
-            return false;
-        }
-    }
-
-    private boolean evaluate(String text) {
-        try {
-            InputSource inputSource = new InputSource(new StringReader(text));
-
-            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-            factory.setNamespaceAware(true);
-            DocumentBuilder dbuilder = factory.newDocumentBuilder();
-            Document doc = dbuilder.parse(inputSource);
-
-            // We should associated the cachedXPathAPI object with the message being evaluated
-            // since that should speedup subsequent xpath expressions.
-            CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
-            NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc,xpath);
-            return iterator.nextNode()!=null;
-        } catch (Throwable e) {
-            return false;
-        }
-    }
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/AbstractFlowCreditManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/AbstractFlowCreditManager.java
index a77ed57..124fb0d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/AbstractFlowCreditManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/AbstractFlowCreditManager.java
@@ -22,12 +22,10 @@
 
 import java.util.ArrayList;
 import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.Set;
-import java.util.HashSet;
 
 public abstract class AbstractFlowCreditManager implements FlowCreditManager
 {
-    protected final AtomicBoolean _suspended = new AtomicBoolean(false);
+    private final AtomicBoolean _suspended = new AtomicBoolean(false);
     private final ArrayList<FlowCreditManagerListener> _listeners = new ArrayList<FlowCreditManagerListener>();
 
     public final void addStateListener(FlowCreditManagerListener listener)
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/CreditCreditManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/CreditCreditManager.java
index c677117..09fe443 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/CreditCreditManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/CreditCreditManager.java
@@ -23,14 +23,8 @@
 
 public class CreditCreditManager extends AbstractFlowCreditManager implements FlowCreditManager_0_10
 {
-        private volatile long _bytesCredit;
-        private volatile long _messageCredit;
-
-
-    public CreditCreditManager()
-     {
-         this(0L, 0L);
-     }
+    private volatile long _bytesCredit;
+    private volatile long _messageCredit;
 
     public CreditCreditManager(long bytesCredit, long messageCredit)
     {
@@ -67,9 +61,6 @@
 
     public synchronized void restoreCredit(final long messageCredit, final long bytesCredit)
     {
-        /*_bytesCredit = 0l;
-        _messageCredit = 0l;
-        setSuspended(true);*/
     }
 
     
@@ -138,7 +129,6 @@
                 }
                 else
                 {
-                    //setSuspended(true);
                     return false;
                 }
             }
@@ -158,7 +148,6 @@
             }
             else
             {
-                //setSuspended(true);
                 return false;
             }
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/Pre0_10CreditManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/Pre0_10CreditManager.java
index a193f8f..fc2d4bf 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/Pre0_10CreditManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/Pre0_10CreditManager.java
@@ -155,7 +155,6 @@
                     }
                     else
                     {
-                        //setSuspended(true);
                         return false;
                     }
                 }
@@ -183,7 +182,6 @@
                 }
                 else
                 {
-                    //setSuspended(true);
                     return false;
                 }
             }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/WindowCreditManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/WindowCreditManager.java
index a0c2e9f..2215c7b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/WindowCreditManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/flow/WindowCreditManager.java
@@ -144,7 +144,6 @@
                 }
                 else
                 {
-                    //setSuspended(true);
                     return false;
                 }
             }
@@ -164,7 +163,6 @@
             }
             else
             {
-                //setSuspended(true);
                 return false;
             }
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/AccessRequestHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/AccessRequestHandler.java
index 1b0168d..e1c2782 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/AccessRequestHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/AccessRequestHandler.java
@@ -21,15 +21,17 @@
  */

 

 

-import org.apache.qpid.framing.*;

-import org.apache.qpid.framing.amqp_8_0.MethodRegistry_8_0;

-import org.apache.qpid.framing.amqp_0_9.MethodRegistry_0_9;

-import org.apache.qpid.server.AMQChannel;

-import org.apache.qpid.server.state.StateAwareMethodListener;

-import org.apache.qpid.server.state.AMQStateManager;

-import org.apache.qpid.server.protocol.AMQProtocolSession;

 import org.apache.qpid.AMQException;

+import org.apache.qpid.framing.AccessRequestBody;

+import org.apache.qpid.framing.AccessRequestOkBody;

+import org.apache.qpid.framing.MethodRegistry;

+import org.apache.qpid.framing.amqp_0_9.MethodRegistry_0_9;

+import org.apache.qpid.framing.amqp_8_0.MethodRegistry_8_0;

 import org.apache.qpid.protocol.AMQConstant;

+import org.apache.qpid.server.AMQChannel;

+import org.apache.qpid.server.protocol.AMQProtocolSession;

+import org.apache.qpid.server.state.AMQStateManager;

+import org.apache.qpid.server.state.StateAwareMethodListener;

 

 /**

  * @author Apache Software Foundation

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicAckMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicAckMethodHandler.java
index f90e7c3..398a3ff 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicAckMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicAckMethodHandler.java
@@ -21,9 +21,9 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.BasicAckBody;
-import org.apache.qpid.protocol.AMQMethodEvent;
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.state.AMQStateManager;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicCancelMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicCancelMethodHandler.java
index bc2a2dc..0741385 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicCancelMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicCancelMethodHandler.java
@@ -20,6 +20,8 @@
  */
 package org.apache.qpid.server.handler;
 
+import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.BasicCancelBody;
 import org.apache.qpid.framing.BasicCancelOkBody;
@@ -28,7 +30,6 @@
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
-import org.apache.log4j.Logger;
 
 public class BasicCancelMethodHandler implements StateAwareMethodListener<BasicCancelBody>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java
index a1cfb14..5148296 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java
@@ -21,8 +21,12 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.*;
+import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicConsumeBody;
+import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicGetMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicGetMethodHandler.java
index 2073299..1916434 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicGetMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicGetMethodHandler.java
@@ -22,28 +22,26 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.BasicGetBody;
 import org.apache.qpid.framing.BasicGetEmptyBody;
 import org.apache.qpid.framing.MethodRegistry;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.message.AMQMessage;
 import org.apache.qpid.server.flow.FlowCreditManager;
 import org.apache.qpid.server.flow.MessageOnlyCreditManager;
-import org.apache.qpid.server.subscription.SubscriptionImpl;
-import org.apache.qpid.server.subscription.ClientDeliveryMethod;
-import org.apache.qpid.server.subscription.RecordDeliveryMethod;
-import org.apache.qpid.server.subscription.Subscription;
-import org.apache.qpid.server.subscription.SubscriptionFactoryImpl;
+import org.apache.qpid.server.message.AMQMessage;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
+import org.apache.qpid.server.subscription.ClientDeliveryMethod;
+import org.apache.qpid.server.subscription.RecordDeliveryMethod;
+import org.apache.qpid.server.subscription.Subscription;
+import org.apache.qpid.server.subscription.SubscriptionFactoryImpl;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
 public class BasicGetMethodHandler implements StateAwareMethodListener<BasicGetBody>
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java
index 8f23b1c..cb8918e 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicQosHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicQosHandler.java
index 2cf043d..87a3d1c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicQosHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicQosHandler.java
@@ -21,13 +21,13 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQMethodBody;
 import org.apache.qpid.framing.BasicQosBody;
 import org.apache.qpid.framing.MethodRegistry;
-import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
-import org.apache.qpid.server.AMQChannel;
 
 public class BasicQosHandler implements StateAwareMethodListener<BasicQosBody>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRecoverMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRecoverMethodHandler.java
index 4292173..0c4c9ca 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRecoverMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRecoverMethodHandler.java
@@ -21,13 +21,12 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.BasicRecoverBody;
-import org.apache.qpid.framing.BasicRecoverOkBody;
-import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.BasicRecoverBody;
+import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.framing.amqp_8_0.MethodRegistry_8_0;
-import org.apache.qpid.protocol.AMQMethodEvent;
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.state.AMQStateManager;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRecoverSyncMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRecoverSyncMethodHandler.java
index 1e2a83b..1e0c027 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRecoverSyncMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRecoverSyncMethodHandler.java
@@ -23,18 +23,16 @@
 

 import org.apache.log4j.Logger;

 

-import org.apache.qpid.framing.BasicRecoverBody;

-import org.apache.qpid.framing.ProtocolVersion;

+import org.apache.qpid.AMQException;

 import org.apache.qpid.framing.AMQMethodBody;

 import org.apache.qpid.framing.BasicRecoverSyncBody;

-import org.apache.qpid.framing.amqp_0_91.MethodRegistry_0_91;

+import org.apache.qpid.framing.ProtocolVersion;

 import org.apache.qpid.framing.amqp_0_9.MethodRegistry_0_9;

-import org.apache.qpid.framing.amqp_8_0.MethodRegistry_8_0;

-import org.apache.qpid.server.state.StateAwareMethodListener;

-import org.apache.qpid.server.state.AMQStateManager;

-import org.apache.qpid.server.protocol.AMQProtocolSession;

+import org.apache.qpid.framing.amqp_0_91.MethodRegistry_0_91;

 import org.apache.qpid.server.AMQChannel;

-import org.apache.qpid.AMQException;

+import org.apache.qpid.server.protocol.AMQProtocolSession;

+import org.apache.qpid.server.state.AMQStateManager;

+import org.apache.qpid.server.state.StateAwareMethodListener;

 

 public class BasicRecoverSyncMethodHandler implements StateAwareMethodListener<BasicRecoverSyncBody>

 {

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRejectMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRejectMethodHandler.java
index 0ea88e4..de76050 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRejectMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicRejectMethodHandler.java
@@ -20,14 +20,15 @@
  */
 package org.apache.qpid.server.handler;
 
+import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.BasicRejectBody;
 import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
+import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
-import org.apache.log4j.Logger;
 
 public class BasicRejectMethodHandler implements StateAwareMethodListener<BasicRejectBody>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelCloseHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelCloseHandler.java
index ecffd1b..0c8ab31 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelCloseHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelCloseHandler.java
@@ -21,17 +21,16 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQFrame;
 import org.apache.qpid.framing.ChannelCloseBody;
 import org.apache.qpid.framing.ChannelCloseOkBody;
 import org.apache.qpid.framing.MethodRegistry;
-import org.apache.qpid.protocol.AMQMethodEvent;
 import org.apache.qpid.protocol.AMQConstant;
+import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
-import org.apache.qpid.server.AMQChannel;
 
 public class ChannelCloseHandler implements StateAwareMethodListener<ChannelCloseBody>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelCloseOkHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelCloseOkHandler.java
index a857490..54b3f81 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelCloseOkHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelCloseOkHandler.java
@@ -21,9 +21,9 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.ChannelCloseOkBody;
-import org.apache.qpid.protocol.AMQMethodEvent;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelFlowHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelFlowHandler.java
index 365c8bd..a736ad5 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelFlowHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelFlowHandler.java
@@ -21,9 +21,11 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.*;
-import org.apache.qpid.protocol.AMQMethodEvent;
+import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.ChannelFlowBody;
+import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.state.AMQStateManager;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelOpenHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelOpenHandler.java
index 6d874ee..81734d7 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelOpenHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ChannelOpenHandler.java
@@ -20,12 +20,8 @@
  */
 package org.apache.qpid.server.handler;
 
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.UUID;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.ChannelOpenBody;
 import org.apache.qpid.framing.ChannelOpenOkBody;
@@ -41,6 +37,11 @@
 import org.apache.qpid.server.state.StateAwareMethodListener;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.UUID;
+
 public class ChannelOpenHandler implements StateAwareMethodListener<ChannelOpenBody>
 {
     private static final Logger _logger = Logger.getLogger(ChannelOpenHandler.class);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionCloseMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionCloseMethodHandler.java
index 6eaba87..7f0c0d2 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionCloseMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionCloseMethodHandler.java
@@ -21,12 +21,11 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQFrame;
 import org.apache.qpid.framing.ConnectionCloseBody;
 import org.apache.qpid.framing.ConnectionCloseOkBody;
 import org.apache.qpid.framing.MethodRegistry;
-import org.apache.qpid.protocol.AMQMethodEvent;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionCloseOkMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionCloseOkMethodHandler.java
index bc6e5ab..bd86c2d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionCloseOkMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionCloseOkMethodHandler.java
@@ -21,9 +21,9 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.ConnectionCloseOkBody;
-import org.apache.qpid.protocol.AMQMethodEvent;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.state.AMQState;
 import org.apache.qpid.server.state.AMQStateManager;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionOpenMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionOpenMethodHandler.java
index 9a79467..79fcfb6 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionOpenMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionOpenMethodHandler.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQMethodBody;
 import org.apache.qpid.framing.AMQShortString;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionSecureOkMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionSecureOkMethodHandler.java
index 09f35da..2ccf97f 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionSecureOkMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionSecureOkMethodHandler.java
@@ -21,9 +21,8 @@
 package org.apache.qpid.server.handler;
 
 
-import javax.security.sasl.SaslException;
-import javax.security.sasl.SaslServer;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.ConnectionCloseBody;
 import org.apache.qpid.framing.ConnectionSecureBody;
@@ -40,6 +39,9 @@
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
 
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+
 public class ConnectionSecureOkMethodHandler implements StateAwareMethodListener<ConnectionSecureOkBody>
 {
     private static final Logger _logger = Logger.getLogger(ConnectionSecureOkMethodHandler.class);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
index 2dd9a63..162e4e0 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
@@ -20,10 +20,8 @@
  */
 package org.apache.qpid.server.handler;
 
-import javax.security.sasl.SaslException;
-import javax.security.sasl.SaslServer;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.ConnectionCloseBody;
 import org.apache.qpid.framing.ConnectionSecureBody;
@@ -41,6 +39,9 @@
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
 
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+
 
 public class ConnectionStartOkMethodHandler implements StateAwareMethodListener<ConnectionStartOkBody>
 {
@@ -79,10 +80,7 @@
 
             final AuthenticationResult authResult = authMgr.authenticate(ss, body.getResponse());
             //save clientProperties
-            if (session.getClientProperties() == null)
-            {
-                session.setClientProperties(body.getClientProperties());
-            }
+            session.setClientProperties(body.getClientProperties());
 
             MethodRegistry methodRegistry = session.getMethodRegistry();
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionTuneOkMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionTuneOkMethodHandler.java
index 1da2760..299aad0 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionTuneOkMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionTuneOkMethodHandler.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.ConnectionTuneOkBody;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeBoundHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeBoundHandler.java
index 53835f3..b4eb416 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeBoundHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeBoundHandler.java
@@ -21,12 +21,15 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.*;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.ExchangeBoundBody;
+import org.apache.qpid.framing.ExchangeBoundOkBody;
+import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
-import org.apache.qpid.server.queue.QueueRegistry;
 import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.QueueRegistry;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
 import org.apache.qpid.server.virtualhost.VirtualHost;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeDeclareHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeDeclareHandler.java
index 69cf0c9..6d55f31 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeDeclareHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeDeclareHandler.java
@@ -21,10 +21,14 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQConnectionException;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQUnknownExchangeType;
-import org.apache.qpid.framing.*;
+import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.ExchangeDeclareBody;
+import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.exchange.Exchange;
@@ -62,26 +66,39 @@
             throw body.getChannelNotFoundException(channelId);
         }
 
+        final AMQShortString exchangeName = body.getExchange();
         if (_logger.isDebugEnabled())
         {
-            _logger.debug("Request to declare exchange of type " + body.getType() + " with name " + body.getExchange());
+            _logger.debug("Request to declare exchange of type " + body.getType() + " with name " + exchangeName);
         }
         
         synchronized(exchangeRegistry)
         {
-            Exchange exchange = exchangeRegistry.getExchange(body.getExchange());
+            Exchange exchange = exchangeRegistry.getExchange(exchangeName);
 
             if (exchange == null)
             {
                 if(body.getPassive() && ((body.getType() == null) || body.getType().length() ==0))
                 {
-                    throw body.getChannelException(AMQConstant.NOT_FOUND, "Unknown exchange: " + body.getExchange());
+                    throw body.getChannelException(AMQConstant.NOT_FOUND, "Unknown exchange: " + exchangeName);
+                }
+                else if(exchangeName.startsWith("amq."))
+                {
+                    throw body.getConnectionException(AMQConstant.NOT_ALLOWED,
+                              "Attempt to declare exchange: " + exchangeName +
+                              " which begins with reserved prefix 'amq.'.");
+                }
+                else if(exchangeName.startsWith("qpid."))
+                {
+                    throw body.getConnectionException(AMQConstant.NOT_ALLOWED,
+                                                      "Attempt to declare exchange: " + exchangeName +
+                                                      " which begins with reserved prefix 'qpid.'.");
                 }
                 else
                 {
                     try
                     {
-                        exchange = exchangeFactory.createExchange(body.getExchange() == null ? null : body.getExchange().intern(),
+                        exchange = exchangeFactory.createExchange(exchangeName == null ? null : exchangeName.intern(),
                                                                   body.getType() == null ? null : body.getType().intern(),
                                                                   body.getDurable(),
                                                                   body.getPassive(), body.getTicket());
@@ -94,14 +111,15 @@
                     }
                     catch(AMQUnknownExchangeType e)
                     {
-                        throw body.getConnectionException(AMQConstant.COMMAND_INVALID, "Unknown exchange: " + body.getExchange(),e);
+                        throw body.getConnectionException(AMQConstant.COMMAND_INVALID, "Unknown exchange: " + exchangeName,e);
                     }
                 }
             }
-            else if (!exchange.getTypeShortString().equals(body.getType()))
+            else if (!exchange.getTypeShortString().equals(body.getType()) && !((body.getType() == null || body.getType().length() ==0) && body.getPassive()))
             {
 
-                throw new AMQConnectionException(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: " + body.getExchange() + " of type " + exchange.getTypeShortString() + " to " + body.getType() +".",body.getClazz(), body.getMethod(),body.getMajor(),body.getMinor(),null);
+                throw new AMQConnectionException(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: " +
+                                                                          exchangeName + " of type " + exchange.getTypeShortString() + " to " + body.getType() +".",body.getClazz(), body.getMethod(),body.getMajor(),body.getMinor(),null);
             }
         }
         if(!body.getNowait())
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
index 32cd1c2..f57f7eb 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
@@ -20,11 +20,8 @@
  */
 package org.apache.qpid.server.handler;
 
-import java.util.UUID;
-import java.util.Collections;
-import java.util.concurrent.atomic.AtomicInteger;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.MethodRegistry;
@@ -45,6 +42,9 @@
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import java.util.Collections;
+import java.util.UUID;
+
 public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclareBody>
 {
     private static final Logger _logger = Logger.getLogger(QueueDeclareHandler.class);
@@ -56,9 +56,7 @@
         return _instance;
     }
 
-    public boolean autoRegister = ApplicationRegistry.getInstance().getConfiguration().getQueueAutoRegister();
-
-    private final AtomicInteger _counter = new AtomicInteger();
+    private boolean autoRegister = ApplicationRegistry.getInstance().getConfiguration().getQueueAutoRegister();
 
     public void methodReceived(AMQStateManager stateManager, QueueDeclareBody body, int channelId) throws AMQException
     {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeleteHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeleteHandler.java
index 107e485..cc37259 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeleteHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeleteHandler.java
@@ -21,19 +21,19 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.framing.QueueDeleteBody;
 import org.apache.qpid.framing.QueueDeleteOkBody;
-import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.protocol.AMQConstant;
+import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.protocol.AMQSessionModel;
-import org.apache.qpid.server.queue.QueueRegistry;
 import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.QueueRegistry;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.AMQChannel;
 
 public class QueueDeleteHandler implements StateAwareMethodListener<QueueDeleteBody>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueuePurgeHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueuePurgeHandler.java
index 7d609f9..217a264 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueuePurgeHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueuePurgeHandler.java
@@ -22,18 +22,18 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.QueuePurgeBody;
-import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.MethodRegistry;
+import org.apache.qpid.framing.QueuePurgeBody;
 import org.apache.qpid.protocol.AMQConstant;
+import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.protocol.AMQSessionModel;
-import org.apache.qpid.server.queue.QueueRegistry;
 import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.QueueRegistry;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.AMQChannel;
 
 public class QueuePurgeHandler implements StateAwareMethodListener<QueuePurgeBody>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueUnbindHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueUnbindHandler.java
index 9915627..a8ae209 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueUnbindHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueUnbindHandler.java
@@ -21,6 +21,7 @@
  */
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQMethodBody;
 import org.apache.qpid.framing.AMQShortString;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl.java
index e290afc..3b6dc3f 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl.java
@@ -20,12 +20,12 @@
  */

 package org.apache.qpid.server.handler;

 

-import java.util.Map;

-import java.util.HashMap;

-

-import org.apache.qpid.server.state.AMQStateManager;

-import org.apache.qpid.framing.*;

 import org.apache.qpid.AMQException;

+import org.apache.qpid.framing.*;

+import org.apache.qpid.server.state.AMQStateManager;

+

+import java.util.HashMap;

+import java.util.Map;

 

 public class ServerMethodDispatcherImpl implements MethodDispatcher

 {

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_0_9.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_0_9.java
index 8b1dca7..7ce8664 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_0_9.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_0_9.java
@@ -21,10 +21,10 @@
 package org.apache.qpid.server.handler;

 

 

-import org.apache.qpid.framing.amqp_0_9.MethodDispatcher_0_9;

-import org.apache.qpid.framing.*;

-import org.apache.qpid.server.state.AMQStateManager;

 import org.apache.qpid.AMQException;

+import org.apache.qpid.framing.*;

+import org.apache.qpid.framing.amqp_0_9.MethodDispatcher_0_9;

+import org.apache.qpid.server.state.AMQStateManager;

 

 

 

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_0_91.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_0_91.java
index 32cd4c4..126e148 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_0_91.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_0_91.java
@@ -21,10 +21,10 @@
 package org.apache.qpid.server.handler;

 

 

+import org.apache.qpid.AMQException;

 import org.apache.qpid.framing.*;

 import org.apache.qpid.framing.amqp_0_91.MethodDispatcher_0_91;

 import org.apache.qpid.server.state.AMQStateManager;

-import org.apache.qpid.AMQException;

 

 

 public class ServerMethodDispatcherImpl_0_91

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_8_0.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_8_0.java
index d599ca3..fabd2a5 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_8_0.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ServerMethodDispatcherImpl_8_0.java
@@ -20,10 +20,19 @@
  */

 package org.apache.qpid.server.handler;

 

-import org.apache.qpid.framing.amqp_8_0.MethodDispatcher_8_0;

-import org.apache.qpid.framing.*;

-import org.apache.qpid.server.state.AMQStateManager;

 import org.apache.qpid.AMQException;

+import org.apache.qpid.framing.BasicRecoverOkBody;

+import org.apache.qpid.framing.ChannelAlertBody;

+import org.apache.qpid.framing.TestContentBody;

+import org.apache.qpid.framing.TestContentOkBody;

+import org.apache.qpid.framing.TestIntegerBody;

+import org.apache.qpid.framing.TestIntegerOkBody;

+import org.apache.qpid.framing.TestStringBody;

+import org.apache.qpid.framing.TestStringOkBody;

+import org.apache.qpid.framing.TestTableBody;

+import org.apache.qpid.framing.TestTableOkBody;

+import org.apache.qpid.framing.amqp_8_0.MethodDispatcher_8_0;

+import org.apache.qpid.server.state.AMQStateManager;

 

 public class ServerMethodDispatcherImpl_8_0

         extends ServerMethodDispatcherImpl

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxCommitHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxCommitHandler.java
index abd2bcc..6e8896a 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxCommitHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxCommitHandler.java
@@ -21,10 +21,11 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.TxCommitBody;
-import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.MethodRegistry;
+import org.apache.qpid.framing.TxCommitBody;
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.state.AMQStateManager;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxRollbackHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxRollbackHandler.java
index 20ba3af..010a07b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxRollbackHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxRollbackHandler.java
@@ -21,11 +21,9 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.TxRollbackBody;
-import org.apache.qpid.framing.TxRollbackOkBody;
-import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.framing.AMQMethodBody;
-import org.apache.qpid.protocol.AMQMethodEvent;
+import org.apache.qpid.framing.MethodRegistry;
+import org.apache.qpid.framing.TxRollbackBody;
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.state.AMQStateManager;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxSelectHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxSelectHandler.java
index 308f5b7..44b4770 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxSelectHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/TxSelectHandler.java
@@ -21,14 +21,13 @@
 package org.apache.qpid.server.handler;
 
 import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.framing.TxSelectBody;
 import org.apache.qpid.framing.TxSelectOkBody;
-import org.apache.qpid.framing.MethodRegistry;
-import org.apache.qpid.protocol.AMQMethodEvent;
+import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
-import org.apache.qpid.server.AMQChannel;
 
 public class TxSelectHandler implements StateAwareMethodListener<TxSelectBody>
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/UnexpectedMethodException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/UnexpectedMethodException.java
index 3526fdc..cfc52c5 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/UnexpectedMethodException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/UnexpectedMethodException.java
@@ -21,8 +21,8 @@
 package org.apache.qpid.server.handler;

 

 

-import org.apache.qpid.framing.AMQMethodBody;

 import org.apache.qpid.AMQException;

+import org.apache.qpid.framing.AMQMethodBody;

 

 public class UnexpectedMethodException extends AMQException

 {

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/information/management/ServerInformationMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/information/management/ServerInformationMBean.java
index 5e6a143..4d395f6 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/information/management/ServerInformationMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/information/management/ServerInformationMBean.java
@@ -20,8 +20,6 @@
  */
 package org.apache.qpid.server.information.management;
 
-import java.io.IOException;
-
 import org.apache.qpid.common.QpidProperties;
 import org.apache.qpid.management.common.mbeans.ServerInformation;
 import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
@@ -29,6 +27,7 @@
 import org.apache.qpid.server.registry.ApplicationRegistry;
 
 import javax.management.JMException;
+import java.io.IOException;
 
 /** MBean class for the ServerInformationMBean. */
 @MBeanDescription("Server Information Interface")
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/Log4jMessageLogger.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/Log4jMessageLogger.java
index a0285eb..ec506ab 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/Log4jMessageLogger.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/Log4jMessageLogger.java
@@ -22,6 +22,7 @@
 
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.server.configuration.ServerConfiguration;
 
 public class Log4jMessageLogger extends AbstractRootMessageLogger
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
index 9c7ffcc..50a7e67 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
@@ -23,9 +23,6 @@
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.logging.RootMessageLogger;
 import org.apache.qpid.server.logging.subjects.ChannelLogSubject;
-import org.apache.qpid.server.protocol.AMQProtocolSession;
-
-import java.text.MessageFormat;
 
 /**
  * An AMQPChannelActor represtents a connection through the AMQP port with an
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java
index e0bf180..e8c6c9c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java
@@ -27,9 +27,9 @@
 
 public abstract class AbstractActor implements LogActor
 {
-    public final String _msgPrefix = System.getProperty("qpid.logging.prefix","");
+    private final String _msgPrefix = System.getProperty("qpid.logging.prefix","");
 
-    protected RootMessageLogger _rootLogger;
+    private RootMessageLogger _rootLogger;
 
     public AbstractActor(RootMessageLogger rootLogger)
     {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java
index 2ebbfeb..feacf35 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java
@@ -68,6 +68,10 @@
 
     private static LogActor _defaultActor;
 
+    private CurrentActor()
+    {
+    }
+
     /**
      * Set a new {@link LogActor} to be the Current Actor
      * <p/>
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/GenericActor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/GenericActor.java
index 9afc76c..0e418a9 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/GenericActor.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/GenericActor.java
@@ -24,7 +24,6 @@
 import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.logging.LogSubject;
 import org.apache.qpid.server.logging.RootMessageLogger;
-import org.apache.qpid.server.registry.ApplicationRegistry;
 
 public class GenericActor extends AbstractActor
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java
index 286fc78..9cd3c66 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java
@@ -22,14 +22,13 @@
 
 import org.apache.qpid.server.logging.RootMessageLogger;
 
+import javax.management.remote.JMXPrincipal;
+import javax.security.auth.Subject;
 import java.security.AccessController;
 import java.security.Principal;
 import java.text.MessageFormat;
 import java.util.Set;
 
-import javax.management.remote.JMXPrincipal;
-import javax.security.auth.Subject;
-
 /**
  * NOTE: This actor is not thread safe.
  *
@@ -52,7 +51,7 @@
      */
     private static final String UNKNOWN_PRINCIPAL = "N/A";
 
-    String _lastThreadName = null;
+    private String _lastThreadName = null;
 
     /**
      * LOG FORMAT for the ManagementActor,
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java
index 3364365..4b17e8c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java
@@ -24,8 +24,6 @@
 import org.apache.qpid.server.logging.subjects.QueueLogSubject;
 import org.apache.qpid.server.queue.AMQQueue;
 
-import java.text.MessageFormat;
-
 /**
  * This Actor is used when while the queue is performing an asynchronous process
  * of its queue.
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
index a823fb7..c699dff 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
@@ -20,35 +20,22 @@
  */
 package org.apache.qpid.server.logging.management;
 
-import static org.apache.log4j.xml.QpidLog4JConfigurator.LOCK;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-import org.apache.qpid.management.common.mbeans.LoggingManagement;
-import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
-import org.apache.qpid.server.management.AMQManagedObject;
-import org.apache.qpid.util.FileUtils;
-
 import org.apache.log4j.Level;
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
 import org.apache.log4j.xml.Log4jEntityResolver;
 import org.apache.log4j.xml.QpidLog4JConfigurator;
-import org.apache.log4j.xml.QpidLog4JConfigurator.QpidLog4JSaxErrorHandler;
 import org.apache.log4j.xml.QpidLog4JConfigurator.IllegalLoggerLevelException;
+import org.apache.log4j.xml.QpidLog4JConfigurator.QpidLog4JSaxErrorHandler;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
+
+import org.apache.qpid.management.common.mbeans.LoggingManagement;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
+import org.apache.qpid.server.management.AMQManagedObject;
 
 import javax.management.JMException;
 import javax.management.openmbean.CompositeData;
@@ -69,6 +56,16 @@
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import static org.apache.log4j.xml.QpidLog4JConfigurator.LOCK;
 
 
 /** MBean class for BrokerLoggingManagerMBean. It implements all the management features exposed for managing logging. */
@@ -85,8 +82,8 @@
                                                         Level.WARN.toString(), Level.ERROR.toString(), 
                                                         Level.FATAL.toString(),Level.OFF.toString(),
                                                         INHERITED};   
-    static TabularType _loggerLevelTabularType;
-    static CompositeType _loggerLevelCompositeType;
+    private static TabularType _loggerLevelTabularType;
+    private static CompositeType _loggerLevelCompositeType;
 
     static
     {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Broker_logmessages.properties b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Broker_logmessages.properties
index 5d1e85f..1aa7815 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Broker_logmessages.properties
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Broker_logmessages.properties
@@ -26,7 +26,7 @@
 LISTENING = BRK-1002 : Starting : Listening on {0} port {1,number,#}
 # 0 - Transport
 # 1 - Port
-SHUTTING_DOWN = BRK-1003 : Shuting down : {0} port {1,number,#}
+SHUTTING_DOWN = BRK-1003 : Shutting down : {0} port {1,number,#}
 READY = BRK-1004 : Qpid Broker Ready
 STOPPED = BRK-1005 : Stopped
 # 0 - path
@@ -35,4 +35,14 @@
 LOG_CONFIG = BRK-1007 : Using logging configuration : {0}
 
 STATS_DATA = BRK-1008 : {0,choice,0#delivered|1#received} : {1,number,#.###} kB/s peak : {2,number,#} bytes total
-STATS_MSGS = BRK-1009 : {0,choice,0#delivered|1#received} : {1,number,#.###} msg/s peak : {2,number,#} msgs total
\ No newline at end of file
+STATS_MSGS = BRK-1009 : {0,choice,0#delivered|1#received} : {1,number,#.###} msg/s peak : {2,number,#} msgs total
+
+# 0 - java vendor
+# 1 - java runtime version
+# 2 - os name
+# 3 - os type
+# 4 - os architecture
+PLATFORM = BRK-1010 : Platform : JVM : {0} version: {1} OS : {2} version: {3} arch: {4}
+
+# 0 Maximum Memory
+MAX_MEMORY = BRK-1011 : Maximum Memory : {0,number} bytes
\ No newline at end of file
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Connection_logmessages.properties b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Connection_logmessages.properties
index 81ae6f3..8559862 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Connection_logmessages.properties
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Connection_logmessages.properties
@@ -20,5 +20,6 @@
 
 # 0 - Client id
 # 1 - Protocol Version
-OPEN = CON-1001 : Open[ : Client ID : {0}][ : Protocol Version : {1}]
+# 2 - Client Version
+OPEN = CON-1001 : Open[ : Client ID : {0}][ : Protocol Version : {1}][ : Client Version : {2}]
 CLOSE = CON-1002 : Close
\ No newline at end of file
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/TransactionLog_logmessages.properties b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/TransactionLog_logmessages.properties
index fadc2e2..9ef58df 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/TransactionLog_logmessages.properties
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/TransactionLog_logmessages.properties
@@ -31,3 +31,9 @@
 RECOVERED = TXN-1005 : Recovered {0,number} messages for queue {1}
 # 0 - queue name
 RECOVERY_COMPLETE = TXN-1006 : Recovery Complete[ : {0}]
+# 0 - xid
+# 1 - queue name
+XA_INCOMPLETE_QUEUE = TXN-1007 : XA transaction recover for xid {0} incomplete as it references a queue {1} which was not durably retained
+# 0 - xid format
+# 1 - message id
+XA_INCOMPLETE_MESSAGE = TXN-1008 : XA transaction recover for xid {0} incomplete as it references a message {1} which was not durably retained
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/AbstractLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/AbstractLogSubject.java
index 779db01..baccf24 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/AbstractLogSubject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/AbstractLogSubject.java
@@ -33,10 +33,7 @@
  */
 public abstract class AbstractLogSubject implements LogSubject
 {
-    /**
-     * The logString that will be returned via toLogString
-     */
-    protected String _logString;
+    private String _logString;
 
     /**
      * Set the toString logging of this LogSubject. Based on a format provided
@@ -60,4 +57,16 @@
         return _logString;
     }
 
+    /**
+     * The logString that will be returned via toLogString
+     */
+    public String getLogString()
+    {
+        return _logString;
+    }
+
+    public void setLogString(String logString)
+    {
+        _logString = logString;
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java
index 088b59a..8f0b918 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java
@@ -22,6 +22,7 @@
 
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.queue.AMQQueue;
+
 import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.BINDING_FORMAT;
 
 public class BindingLogSubject extends AbstractLogSubject
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java
index 885b039..859d7e2 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java
@@ -36,8 +36,7 @@
 
         /**
          * LOG FORMAT used by the AMQPConnectorActor follows
-         * ChannelLogSubject.CHANNEL_FORMAT :
-         * con:{0}({1}@{2}/{3})/ch:{4}
+         * ChannelLogSubject.CHANNEL_FORMAT : con:{0}({1}@{2}/{3})/ch:{4}.
          *
          * Uses a MessageFormat call to insert the required values according to
          * these indices:
@@ -60,8 +59,7 @@
     {
         /**
          * LOG FORMAT used by the AMQPConnectorActor follows
-         * ChannelLogSubject.CHANNEL_FORMAT :
-         * con:{0}({1}@{2}/{3})/ch:{4}
+         * ChannelLogSubject.CHANNEL_FORMAT : con:{0}({1}@{2}/{3})/ch:{4}.
          *
          * Uses a MessageFormat call to insert the required values according to
          * these indices:
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java
index c1c836f..3b08a17 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java
@@ -22,11 +22,11 @@
 
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 
-import java.text.MessageFormat;
-
+import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.CONNECTION_FORMAT;
 import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SOCKET_FORMAT;
 import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.USER_FORMAT;
-import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.CONNECTION_FORMAT;
+
+import java.text.MessageFormat;
 
 /** The Connection LogSubject */
 public class ConnectionLogSubject extends AbstractLogSubject
@@ -70,31 +70,31 @@
                      * 
                      * 0 - Connection ID 1 - User ID 2 - IP 3 - Virtualhost
                      */
-                    _logString = "[" + MessageFormat.format(CONNECTION_FORMAT, 
-                                                            _session.getSessionID(), 
-                                                            _session.getAuthorizedPrincipal().getName(), 
+                    setLogString("[" + MessageFormat.format(CONNECTION_FORMAT,
+                                                            _session.getSessionID(),
+                                                            _session.getAuthorizedPrincipal().getName(),
                                                             _session.getRemoteAddress(),
-                                                            _session.getVirtualHost().getName()) 
-                                 + "] ";
+                                                            _session.getVirtualHost().getName())
+                                 + "] ");
 
                     _upToDate = true;
                 } 
                 else
                 {
-                    _logString = "[" + MessageFormat.format(USER_FORMAT, 
-                                                            _session.getSessionID(), 
-                                                            _session.getAuthorizedPrincipal().getName(), 
+                    setLogString("[" + MessageFormat.format(USER_FORMAT,
+                                                            _session.getSessionID(),
+                                                            _session.getAuthorizedPrincipal().getName(),
                                                             _session.getRemoteAddress())
-                                 + "] ";
+                                 + "] ");
 
                 }
             } 
             else
             {
-                    _logString = "[" + MessageFormat.format(SOCKET_FORMAT,
+                    setLogString("[" + MessageFormat.format(SOCKET_FORMAT,
                                                             _session.getSessionID(),
-                                                            _session.getRemoteAddress()) 
-                                 + "] ";
+                                                            _session.getRemoteAddress())
+                                 + "] ");
             }
         }
     }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java
index 6ab44a9..99a54cc 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java
@@ -22,6 +22,7 @@
 
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.virtualhost.VirtualHost;
+
 import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.EXCHANGE_FORMAT;
 
 public class ExchangeLogSubject extends AbstractLogSubject
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/LogSubjectFormat.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/LogSubjectFormat.java
index ff2bb90..28c4f0d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/LogSubjectFormat.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/LogSubjectFormat.java
@@ -32,7 +32,10 @@
 
 public class LogSubjectFormat
 {
-    
+    private LogSubjectFormat()
+    {
+    }
+
     /**
      * LOG FORMAT for the Subscription Log Subject
      * 0 - Subscription ID
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubject.java
index 3fce13b..969288b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubject.java
@@ -20,8 +20,9 @@
  */
 package org.apache.qpid.server.logging.subjects;
 
-import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+
 import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.STORE_FORMAT;
 
 public class MessageStoreLogSubject extends AbstractLogSubject
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/QueueLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/QueueLogSubject.java
index bfe12f1..53a9ab7 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/QueueLogSubject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/QueueLogSubject.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.logging.subjects;
 
 import org.apache.qpid.server.queue.AMQQueue;
+
 import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.QUEUE_FORMAT;
 
 public class QueueLogSubject extends AbstractLogSubject
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java
index 8b57647..9a23b73 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java
@@ -22,10 +22,10 @@
 
 import org.apache.qpid.server.subscription.Subscription;
 
-import java.text.MessageFormat;
-
 import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SUBSCRIPTION_FORMAT;
 
+import java.text.MessageFormat;
+
 public class SubscriptionLogSubject extends AbstractLogSubject
 {
 
@@ -42,14 +42,14 @@
 
         String queueString = new QueueLogSubject(subscription.getQueue()).toLogString();
 
-        _logString = "[" + MessageFormat.format(SUBSCRIPTION_FORMAT,
+        setLogString("[" + MessageFormat.format(SUBSCRIPTION_FORMAT,
                                                 subscription.getSubscriptionID())
                      + "("
                      // queueString is [vh(/{0})/qu({1}) ] so need to trim
                      //                ^                ^^
                      + queueString.substring(1,queueString.length() - 3)
                      + ")"
-                     + "] ";
+                     + "] ");
 
     }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/AMQManagedObject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/AMQManagedObject.java
index 6c9d6e3..5c57c01 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/AMQManagedObject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/AMQManagedObject.java
@@ -20,13 +20,11 @@
  */
 package org.apache.qpid.server.management;
 
-import org.apache.qpid.server.logging.actors.ManagementActor;
-import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.LogActor;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.actors.ManagementActor;
 
 import javax.management.ListenerNotFoundException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
 import javax.management.NotCompliantMBeanException;
 import javax.management.NotificationBroadcaster;
 import javax.management.NotificationBroadcasterSupport;
@@ -42,17 +40,11 @@
 public abstract class AMQManagedObject extends DefaultManagedObject
                                        implements NotificationBroadcaster
 {
-    /**
-     * broadcaster support class
-     */
-    protected NotificationBroadcasterSupport _broadcaster = new NotificationBroadcasterSupport();
+    private NotificationBroadcasterSupport _broadcaster = new NotificationBroadcasterSupport();
 
-    /**
-     * sequence number for notifications
-     */
-    protected long _notificationSequenceNumber = 0;
+    private long _notificationSequenceNumber = 0;
 
-    protected LogActor _logActor;
+    private LogActor _logActor;
 
     protected AMQManagedObject(Class<?> managementInterface, String typeName)
         throws NotCompliantMBeanException
@@ -79,4 +71,35 @@
     }
 
 
+    /**
+     * broadcaster support class
+     */
+    protected NotificationBroadcasterSupport getBroadcaster()
+    {
+        return _broadcaster;
+    }
+
+    /**
+     * sequence number for notifications
+     */
+    protected long getNotificationSequenceNumber()
+    {
+        return _notificationSequenceNumber;
+    }
+
+    protected void setNotificationSequenceNumber(long notificationSequenceNumber)
+    {
+        _notificationSequenceNumber = notificationSequenceNumber;
+    }
+
+    protected long incrementAndGetSequenceNumber()
+    {
+        return ++_notificationSequenceNumber;
+    }
+
+    protected LogActor getLogActor()
+    {
+        return _logActor;
+    }
+
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/AbstractAMQManagedConnectionObject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/AbstractAMQManagedConnectionObject.java
index 68350a1..e7c07b6 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/AbstractAMQManagedConnectionObject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/AbstractAMQManagedConnectionObject.java
@@ -1,21 +1,21 @@
 package org.apache.qpid.server.management;
 
-import javax.management.Notification;
+import org.apache.qpid.management.common.mbeans.ManagedConnection;
 
 import javax.management.JMException;
 import javax.management.MBeanNotificationInfo;
 import javax.management.NotCompliantMBeanException;
+import javax.management.Notification;
 import javax.management.ObjectName;
 import javax.management.monitor.MonitorNotification;
 import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.OpenType;
 import javax.management.openmbean.SimpleType;
 import javax.management.openmbean.TabularType;
-import org.apache.qpid.management.common.mbeans.ManagedConnection;
 
 public abstract class AbstractAMQManagedConnectionObject extends AMQManagedObject implements ManagedConnection
 {
-    protected final String _name;
+    private final String _name;
 
     protected static final OpenType[] _channelAttributeTypes = { SimpleType.INTEGER, SimpleType.BOOLEAN, SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN };
     protected static final CompositeType _channelType;
@@ -45,7 +45,6 @@
         _name = "anonymous".equals(remoteAddress) ? (remoteAddress + hashCode()) : remoteAddress;
     }
 
-    @Override
     public String getObjectInstanceName()
     {
         return ObjectName.quote(_name);
@@ -53,9 +52,9 @@
 
     public void notifyClients(String notificationMsg)
     {
-        final Notification n = new Notification(MonitorNotification.THRESHOLD_VALUE_EXCEEDED, this, ++_notificationSequenceNumber,
+        final Notification n = new Notification(MonitorNotification.THRESHOLD_VALUE_EXCEEDED, this, incrementAndGetSequenceNumber(),
                                                 System.currentTimeMillis(), notificationMsg);
-        _broadcaster.sendNotification(n);
+        getBroadcaster().sendNotification(n);
     }
 
     @Override
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/DefaultManagedObject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/DefaultManagedObject.java
index 0c3a5fc..10d7503 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/DefaultManagedObject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/DefaultManagedObject.java
@@ -20,6 +20,10 @@
  */
 package org.apache.qpid.server.management;
 
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.server.registry.ApplicationRegistry;
+
 import javax.management.JMException;
 import javax.management.MBeanInfo;
 import javax.management.MBeanNotificationInfo;
@@ -28,9 +32,6 @@
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
 
-import org.apache.log4j.Logger;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-
 /**
  * Provides implementation of the boilerplate ManagedObject interface. Most managed objects should find it useful
  * to extend this class rather than implementing ManagedObject from scratch.
@@ -153,7 +154,9 @@
             return parentType + "." + obj.getType();
         }
         else
+        {
             return obj.getType();
+        }
     }
 
     protected String getHierarchicalName(ManagedObject obj)
@@ -167,7 +170,9 @@
             return parentName;
         }
         else
+        {
             return "";
+        }
     }
 
     private MBeanInfo buildMBeanInfo() throws NotCompliantMBeanException
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
index 8583e8d..04a5b27 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
@@ -20,6 +20,35 @@
  */
 package org.apache.qpid.server.management;
 
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.server.security.auth.rmi.RMIPasswordAuthenticator;
+import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.Notification;
+import javax.management.NotificationFilterSupport;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnectionNotification;
+import javax.management.remote.JMXConnectorServer;
+import javax.management.remote.JMXServiceURL;
+import javax.management.remote.MBeanServerForwarder;
+import javax.management.remote.rmi.RMIConnection;
+import javax.management.remote.rmi.RMIConnectorServer;
+import javax.management.remote.rmi.RMIJRMPServerImpl;
+import javax.management.remote.rmi.RMIServerImpl;
+import javax.rmi.ssl.SslRMIClientSocketFactory;
+import javax.rmi.ssl.SslRMIServerSocketFactory;
+import javax.security.auth.Subject;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -41,35 +70,6 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationFilterSupport;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnectionNotification;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.MBeanServerForwarder;
-import javax.management.remote.rmi.RMIConnection;
-import javax.management.remote.rmi.RMIConnectorServer;
-import javax.management.remote.rmi.RMIJRMPServerImpl;
-import javax.management.remote.rmi.RMIServerImpl;
-import javax.rmi.ssl.SslRMIClientSocketFactory;
-import javax.rmi.ssl.SslRMIServerSocketFactory;
-import javax.security.auth.Subject;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.registry.IApplicationRegistry;
-import org.apache.qpid.server.security.auth.rmi.RMIPasswordAuthenticator;
-import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
-
 /**
  * This class starts up an MBeanserver. If out of the box agent has been enabled then there are no 
  * security features implemented like user authentication and authorisation.
@@ -157,9 +157,7 @@
 
                 if (!ksf.exists())
                 {
-                    throw new FileNotFoundException("Cannot find JMX management SSL keystore file " + ksf + "\n"
-                                                  + "Check broker configuration, or see create-example-ssl-stores script"
-                                                  + "in the bin/ directory if you need to generate an example store.");
+                    throw new FileNotFoundException("Cannot find JMX management SSL keystore file: " + ksf);
                 }
                 if (!ksf.canRead())
                 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanIntrospector.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanIntrospector.java
index 17a6851..89b74f9 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanIntrospector.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanIntrospector.java
@@ -20,23 +20,22 @@
  */
 package org.apache.qpid.server.management;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanAttribute;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanOperation;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanOperationParameter;
 
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanConstructorInfo;
 import javax.management.MBeanOperationInfo;
 import javax.management.MBeanParameterInfo;
 import javax.management.NotCompliantMBeanException;
-
-import org.apache.qpid.management.common.mbeans.annotations.MBeanAttribute;
-import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor;
-import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
-import org.apache.qpid.management.common.mbeans.annotations.MBeanOperation;
-import org.apache.qpid.management.common.mbeans.annotations.MBeanOperationParameter;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * This class is a utility class to introspect the MBean class and the management
@@ -51,6 +50,10 @@
     private static final String _defaultConstructorDescription = "MBean constructor";
     private static final String _defaultMbeanDescription = "Management interface of the MBean";
 
+    private MBeanIntrospector()
+    {
+    }
+
     /**
      * Introspects the management interface class for MBean attributes.
      * @param interfaceClass
@@ -328,7 +331,9 @@
                 paramInfo = new MBeanParameterInfo("p " + (i + 1), type, "parameter " + (i + 1));
             }
             if (paramInfo != null)
+            {
                 paramsInfo[i] = paramInfo;
+            }
         }
 
         return paramsInfo;
@@ -346,9 +351,10 @@
         for (Constructor cons : implClass.getConstructors())
         {
             MBeanConstructorInfo constructorInfo = getMBeanConstructorInfo(cons);
-            //MBeanConstructorInfo constructorInfo = new MBeanConstructorInfo("desc", cons);
             if (constructorInfo != null)
+            {
                 constructors.add(constructorInfo);
+            }
         }
 
         return constructors.toArray(new MBeanConstructorInfo[0]);
@@ -372,9 +378,6 @@
             }
         }
 
-        //MBeanParameterInfo[] paramsInfo = getParametersInfo(cons.getParameterAnnotations(),
-        //                                                    cons.getParameterTypes());
-
         return new MBeanConstructorInfo(cons.getName(), desc, null);
     }
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
index 40a221e..651372d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.server.management;
 
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.util.Map;
-import java.util.Set;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.server.logging.actors.ManagementActor;
+import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.security.access.Operation;
 
 import javax.management.Attribute;
 import javax.management.JMException;
@@ -41,14 +41,14 @@
 import javax.management.remote.JMXPrincipal;
 import javax.management.remote.MBeanServerForwarder;
 import javax.security.auth.Subject;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.server.logging.actors.ManagementActor;
-import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.registry.IApplicationRegistry;
-import org.apache.qpid.server.security.SecurityManager;
-import org.apache.qpid.server.security.access.Operation;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * This class can be used by the JMXConnectorServer as an InvocationHandler for the mbean operations. It delegates
@@ -87,8 +87,8 @@
             return true;
         }
 
-        // Allow querying available object names
-        if (methodName.equals("queryNames"))
+        // Allow querying available object names and mbeans
+        if (methodName.equals("queryNames") || methodName.equals("queryMBeans"))
         {
             return true;
         }
@@ -108,7 +108,7 @@
 
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
     {
-        final String methodName = getMethodName(method, args);
+        String methodName = method.getName();
 
         if (methodName.equals("getMBeanServer"))
         {
@@ -173,6 +173,7 @@
                 security = _appRegistry.getVirtualHostRegistry().getVirtualHost(vhost).getSecurityManager();
             }
 
+            methodName = getMethodName(method, args);
 			if (isAccessMethod(methodName) || impact == MBeanOperationInfo.INFO)
 			{
 				// Check for read-only method invocation permission
@@ -339,7 +340,7 @@
         // Normally JMXManagedObjectRegistry provides a Map as handback data containing a map
         // between connection id and username.
         String user = null;
-        if (handback != null && handback instanceof Map)
+        if (handback instanceof Map)
         {
             final Map<String, String> connectionIdUsernameMap = (Map<String, String>) handback;
             user = connectionIdUsernameMap.get(connectionId);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/ManagedObject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/ManagedObject.java
index de14785..483b325 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/ManagedObject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/ManagedObject.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.server.management;
 
+import org.apache.qpid.AMQException;
+
+import javax.management.JMException;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
-import javax.management.JMException;
-
-import org.apache.qpid.AMQException;
 
 /**
  * This should be implemented by all Managable objects.
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/ManagedObjectRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/ManagedObjectRegistry.java
index fda80ad..b3323c5 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/ManagedObjectRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/ManagedObjectRegistry.java
@@ -20,12 +20,11 @@
  */
 package org.apache.qpid.server.management;
 
-import javax.management.JMException;
-
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.common.Closeable;
 
-import java.rmi.RemoteException;
+import javax.management.JMException;
 import java.io.IOException;
 
 /**
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/NoopManagedObjectRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/NoopManagedObjectRegistry.java
index a048e75..e77350c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/NoopManagedObjectRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/NoopManagedObjectRegistry.java
@@ -20,11 +20,9 @@
  */
 package org.apache.qpid.server.management;
 
-import javax.management.JMException;
-
 import org.apache.log4j.Logger;
 
-import java.rmi.RemoteException;
+import javax.management.JMException;
 
 /**
  * This managed object registry does not actually register MBeans. This can be used in tests when management is
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AMQMessage.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AMQMessage.java
index e36e467..29b4eac 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AMQMessage.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AMQMessage.java
@@ -21,15 +21,14 @@
 package org.apache.qpid.server.message;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.ContentHeaderBody;
 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.store.StoredMessage;
-import org.apache.qpid.server.configuration.SessionConfig;
 import org.apache.qpid.server.queue.AMQQueue;
-
+import org.apache.qpid.server.store.StoredMessage;
 
 import java.lang.ref.WeakReference;
 import java.nio.ByteBuffer;
@@ -59,7 +58,7 @@
 
     private final long _size;
 
-    private Object _sessionIdentifier;
+    private Object _connectionIdentifier;
     private static final byte IMMEDIATE_AND_DELIVERED = (byte) (IMMEDIATE | DELIVERED_TO_CONSUMER);
 
     private WeakReference<AMQChannel> _channelRef;
@@ -223,19 +222,15 @@
     }
 
 
-    public Object getPublisherIdentifier()
+    public Object getConnectionIdentifier()
     {
-        //todo store sessionIdentifier/client id with message in store
-        //Currently the _sessionIdentifier will be null if the message has been
-        // restored from a message Store
-
-        return _sessionIdentifier;
+        return _connectionIdentifier;
 
     }
 
-    public void setClientIdentifier(final Object sessionIdentifier)
+    public void setConnectionIdentifier(final Object connectionIdentifier)
     {
-        _sessionIdentifier = sessionIdentifier;
+        _connectionIdentifier = connectionIdentifier;
     }
 
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AMQMessageReference.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AMQMessageReference.java
index 940caae..62cfa84 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AMQMessageReference.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AMQMessageReference.java
@@ -20,9 +20,6 @@
  */
 package org.apache.qpid.server.message;
 
-import org.apache.qpid.server.message.AMQMessage;
-import org.apache.qpid.server.queue.MessageCleanupException;
-
 public class AMQMessageReference extends MessageReference<AMQMessage>
 {
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AbstractServerMessageImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AbstractServerMessageImpl.java
index b1d43f0..587b76a 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AbstractServerMessageImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/AbstractServerMessageImpl.java
@@ -20,12 +20,11 @@
  */
 package org.apache.qpid.server.message;
 
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-
 import org.apache.qpid.server.store.StorableMessageMetaData;
 import org.apache.qpid.server.store.StoredMessage;
 
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
+
 public abstract class AbstractServerMessageImpl<T extends StorableMessageMetaData> implements ServerMessage<T>
 {
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/ContentHeaderBodyAdapter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/ContentHeaderBodyAdapter.java
index 84a1642..e87b67d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/ContentHeaderBodyAdapter.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/ContentHeaderBodyAdapter.java
@@ -20,8 +20,8 @@
  */
 package org.apache.qpid.server.message;
 
-import org.apache.qpid.framing.ContentHeaderBody;
 import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.ContentHeaderBody;
 import org.apache.qpid.framing.FieldTable;
 
 import java.util.Set;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/InboundMessage.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/InboundMessage.java
index 79d5574..c6dbb49 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/InboundMessage.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/InboundMessage.java
@@ -21,8 +21,8 @@
 package org.apache.qpid.server.message;
 
 
-import org.apache.qpid.server.queue.Filterable;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.queue.Filterable;
 
 public interface InboundMessage extends Filterable
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageMetaData.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageMetaData.java
index 9bfa0bb..583f0c0 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageMetaData.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageMetaData.java
@@ -20,19 +20,21 @@
  */
 package org.apache.qpid.server.message;
 
-import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
-import org.apache.qpid.framing.EncodingUtils;
+import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.EncodingUtils;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
-import org.apache.qpid.server.store.StorableMessageMetaData;
 import org.apache.qpid.server.store.MessageMetaDataType;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.store.StorableMessageMetaData;
 import org.apache.qpid.server.util.ByteBufferOutputStream;
 import org.apache.qpid.util.ByteBufferInputStream;
 
-import java.io.*;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Set;
 
@@ -159,7 +161,7 @@
 
     public int getContentSize()
     {
-        return (int) _contentHeaderBody.bodySize;
+        return (int) _contentHeaderBody.getBodySize();
     }
 
     public boolean isPersistent()
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageMetaData_0_10.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageMetaData_0_10.java
index 17ebb6e..88b0f60 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageMetaData_0_10.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageMetaData_0_10.java
@@ -20,20 +20,19 @@
 */
 package org.apache.qpid.server.message;
 
-import org.apache.qpid.server.store.StorableMessageMetaData;
+import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.store.MessageMetaDataType;
-import org.apache.qpid.transport.MessageTransfer;
+import org.apache.qpid.server.store.StorableMessageMetaData;
 import org.apache.qpid.transport.DeliveryProperties;
-import org.apache.qpid.transport.MessageProperties;
 import org.apache.qpid.transport.Header;
 import org.apache.qpid.transport.MessageDeliveryMode;
+import org.apache.qpid.transport.MessageProperties;
+import org.apache.qpid.transport.MessageTransfer;
 import org.apache.qpid.transport.Struct;
-import org.apache.qpid.transport.codec.BBEncoder;
 import org.apache.qpid.transport.codec.BBDecoder;
-import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.transport.codec.BBEncoder;
 
 import java.nio.ByteBuffer;
-import java.lang.ref.SoftReference;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -51,6 +50,7 @@
     public static final MessageMetaDataType.Factory<MessageMetaData_0_10> FACTORY = new MetaDataFactory();
 
     private volatile ByteBuffer _encoded;
+    private Object _connectionReference;
 
 
     public MessageMetaData_0_10(MessageTransfer xfr)
@@ -220,6 +220,16 @@
         return _header;
     }
 
+    public void setConnectionReference(Object connectionReference)
+    {
+        _connectionReference = connectionReference;
+    }
+
+    public Object getConnectionReference()
+    {
+        return _connectionReference;
+    }
+
     private static class MetaDataFactory implements MessageMetaDataType.Factory<MessageMetaData_0_10>
     {
         public MessageMetaData_0_10 createMetaData(ByteBuffer buf)
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageTransferHeader.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageTransferHeader.java
index 2f30f26..126e7c2 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageTransferHeader.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageTransferHeader.java
@@ -21,11 +21,11 @@
 package org.apache.qpid.server.message;
 
 import org.apache.qpid.transport.DeliveryProperties;
-import org.apache.qpid.transport.MessageProperties;
 import org.apache.qpid.transport.MessageDeliveryPriority;
+import org.apache.qpid.transport.MessageProperties;
 
-import java.util.Set;
 import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
 
 class MessageTransferHeader implements AMQMessageHeader
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageTransferMessage.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageTransferMessage.java
index c4d2a19..e4de65d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageTransferMessage.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageTransferMessage.java
@@ -20,11 +20,9 @@
  */
 package org.apache.qpid.server.message;
 
-import org.apache.qpid.transport.*;
-import org.apache.qpid.server.configuration.SessionConfig;
-import org.apache.qpid.server.store.StoredMessage;
-import org.apache.qpid.server.transport.ServerSession;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.store.StoredMessage;
+import org.apache.qpid.transport.Header;
 
 import java.nio.ByteBuffer;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/ServerMessage.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/ServerMessage.java
index d354d3b..e1ad2fd 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/message/ServerMessage.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/message/ServerMessage.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.server.message;
 
-import java.nio.ByteBuffer;
-
 import org.apache.qpid.server.store.StorableMessageMetaData;
 import org.apache.qpid.server.store.StoredMessage;
 
+import java.nio.ByteBuffer;
+
 public interface ServerMessage<T extends StorableMessageMetaData> extends EnqueableMessage, MessageContentSource
 {
     String getRoutingKey();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/HeaderPropertiesConverter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/output/HeaderPropertiesConverter.java
index fa06a99..72d1445 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/HeaderPropertiesConverter.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/output/HeaderPropertiesConverter.java
@@ -20,21 +20,28 @@
 */
 package org.apache.qpid.server.output;
 
+import org.apache.qpid.AMQPInvalidClassException;
 import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.message.MessageTransferMessage;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.transport.*;
-import org.apache.qpid.AMQPInvalidClassException;
+import org.apache.qpid.transport.DeliveryProperties;
+import org.apache.qpid.transport.Header;
+import org.apache.qpid.transport.MessageDeliveryMode;
+import org.apache.qpid.transport.MessageProperties;
+import org.apache.qpid.transport.ReplyTo;
 
 import java.util.HashMap;
 import java.util.Map;
 
 public class HeaderPropertiesConverter
 {
+    private HeaderPropertiesConverter()
+    {
+    }
 
     public static BasicContentHeaderProperties convert(MessageTransferMessage messageTransferMessage, VirtualHost vhost)
     {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/ProtocolOutputConverter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/output/ProtocolOutputConverter.java
index 5300bad..04d81bf 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/ProtocolOutputConverter.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/output/ProtocolOutputConverter.java
@@ -26,14 +26,14 @@
  */

 package org.apache.qpid.server.output;

 

-import org.apache.qpid.server.queue.QueueEntry;

-import org.apache.qpid.server.protocol.AMQProtocolSession;

-import org.apache.qpid.server.message.MessageContentSource;

-import org.apache.qpid.framing.AMQShortString;

+import org.apache.qpid.AMQException;

 import org.apache.qpid.framing.AMQDataBlock;

+import org.apache.qpid.framing.AMQShortString;

 import org.apache.qpid.framing.ContentHeaderBody;

 import org.apache.qpid.framing.abstraction.MessagePublishInfo;

-import org.apache.qpid.AMQException;

+import org.apache.qpid.server.message.MessageContentSource;

+import org.apache.qpid.server.protocol.AMQProtocolSession;

+import org.apache.qpid.server.queue.QueueEntry;

 

 public interface ProtocolOutputConverter

 {

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_9_1/ProtocolOutputConverterImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/output/ProtocolOutputConverterImpl.java
similarity index 88%
rename from qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_9_1/ProtocolOutputConverterImpl.java
rename to qpid/java/broker/src/main/java/org/apache/qpid/server/output/ProtocolOutputConverterImpl.java
index 9102b6c..cfdcf7f 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_9_1/ProtocolOutputConverterImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/output/ProtocolOutputConverterImpl.java
@@ -1,4 +1,4 @@
-package org.apache.qpid.server.output.amqp0_9_1;
+package org.apache.qpid.server.output;
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,45 +20,42 @@
  *
  */
 
-import org.apache.qpid.server.output.ProtocolOutputConverter;
-import org.apache.qpid.server.output.HeaderPropertiesConverter;
-import org.apache.qpid.server.protocol.AMQProtocolSession;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQBody;
+import org.apache.qpid.framing.AMQDataBlock;
+import org.apache.qpid.framing.AMQFrame;
+import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicCancelOkBody;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.BasicGetOkBody;
+import org.apache.qpid.framing.BasicReturnBody;
+import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.MethodRegistry;
+import org.apache.qpid.framing.abstraction.MessagePublishInfo;
+import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
 import org.apache.qpid.server.message.AMQMessage;
-import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.message.MessageContentSource;
 import org.apache.qpid.server.message.MessageTransferMessage;
-import org.apache.qpid.framing.*;
-import org.apache.qpid.framing.amqp_0_91.BasicGetBodyImpl;
-import org.apache.qpid.framing.abstraction.MessagePublishInfo;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.protocol.AMQProtocolSession;
+import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.transport.DeliveryProperties;
-import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
 
 import java.io.DataOutput;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
-public class ProtocolOutputConverterImpl implements ProtocolOutputConverter
+class ProtocolOutputConverterImpl implements ProtocolOutputConverter
 {
-    private static final MethodRegistry METHOD_REGISTRY = MethodRegistry.getMethodRegistry(ProtocolVersion.v0_91);
+    private static final int BASIC_CLASS_ID = 60;
 
-    public static Factory getInstanceFactory()
-    {
-        return new Factory()
-        {
-
-            public ProtocolOutputConverter newInstance(AMQProtocolSession session)
-            {
-                return new ProtocolOutputConverterImpl(session);
-            }
-        };
-    }
-
+    private final MethodRegistry _methodRegistry;
     private final AMQProtocolSession _protocolSession;
 
-    private ProtocolOutputConverterImpl(AMQProtocolSession session)
+    ProtocolOutputConverterImpl(AMQProtocolSession session, MethodRegistry methodRegistry)
     {
         _protocolSession = session;
+        _methodRegistry = methodRegistry;
     }
 
 
@@ -86,8 +83,8 @@
         {
             final MessageTransferMessage message = (MessageTransferMessage) entry.getMessage();
             BasicContentHeaderProperties props = HeaderPropertiesConverter.convert(message, entry.getQueue().getVirtualHost());
-            ContentHeaderBody chb = new ContentHeaderBody(props, BasicGetBodyImpl.CLASS_ID);
-            chb.bodySize = message.getSize();
+            ContentHeaderBody chb = new ContentHeaderBody(props, BASIC_CLASS_ID);
+            chb.setBodySize(message.getSize());
             return chb;
         }
     }
@@ -188,15 +185,6 @@
         }
     }
 
-    private AMQDataBlock createContentHeaderBlock(final int channelId, final ContentHeaderBody contentHeaderBody)
-    {
-
-        AMQDataBlock contentHeader = ContentHeaderBody.createAMQFrame(channelId,
-                                                                      contentHeaderBody);
-        return contentHeader;
-    }
-
-
     public void writeGetOk(QueueEntry entry, int channelId, long deliveryTag, int queueSize) throws AMQException
     {
         AMQBody deliver = createEncodedGetOkBody(entry, deliveryTag, queueSize);
@@ -233,11 +221,11 @@
         final AMQBody returnBlock = new AMQBody()
         {
 
-            public AMQBody _underlyingBody;
+            private AMQBody _underlyingBody;
 
             public AMQBody createAMQBody()
             {
-                return METHOD_REGISTRY.createBasicDeliverBody(consumerTag,
+                return _methodRegistry.createBasicDeliverBody(consumerTag,
                                                               deliveryTag,
                                                               isRedelivered,
                                                               exchangeName,
@@ -305,7 +293,7 @@
         final boolean isRedelivered = entry.isRedelivered();
 
         BasicGetOkBody getOkBody =
-                METHOD_REGISTRY.createBasicGetOkBody(deliveryTag,
+                _methodRegistry.createBasicGetOkBody(deliveryTag,
                                                     isRedelivered,
                                                     exchangeName,
                                                     routingKey,
@@ -316,7 +304,7 @@
 
     public byte getProtocolMinorVersion()
     {
-        return getProtocolSession().getProtocolMinorVersion();
+        return _protocolSession.getProtocolMinorVersion();
     }
 
     public byte getProtocolMajorVersion()
@@ -330,7 +318,7 @@
     {
 
         BasicReturnBody basicReturnBody =
-                METHOD_REGISTRY.createBasicReturnBody(replyCode,
+                _methodRegistry.createBasicReturnBody(replyCode,
                                                      replyText,
                                                      messagePublishInfo.getExchange(),
                                                      messagePublishInfo.getRoutingKey());
@@ -358,7 +346,7 @@
     public void confirmConsumerAutoClose(int channelId, AMQShortString consumerTag)
     {
 
-        BasicCancelOkBody basicCancelOkBody = METHOD_REGISTRY.createBasicCancelOkBody(consumerTag);
+        BasicCancelOkBody basicCancelOkBody = _methodRegistry.createBasicCancelOkBody(consumerTag);
         writeFrame(basicCancelOkBody.generateFrame(channelId));
 
     }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/ProtocolOutputConverterRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/output/ProtocolOutputConverterRegistry.java
index dbefeb6..dcbfd89 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/ProtocolOutputConverterRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/output/ProtocolOutputConverterRegistry.java
@@ -26,12 +26,13 @@
  */

 package org.apache.qpid.server.output;

 

+import org.apache.qpid.framing.MethodRegistry;

+import org.apache.qpid.framing.ProtocolVersion;

 import org.apache.qpid.server.output.ProtocolOutputConverter.Factory;

 import org.apache.qpid.server.protocol.AMQProtocolSession;

-import org.apache.qpid.framing.ProtocolVersion;

 

-import java.util.Map;

 import java.util.HashMap;

+import java.util.Map;

 

 public class ProtocolOutputConverterRegistry

 {

@@ -42,15 +43,19 @@
 

     static

     {

-        register(ProtocolVersion.v8_0, org.apache.qpid.server.output.amqp0_8.ProtocolOutputConverterImpl.getInstanceFactory());

-        register(ProtocolVersion.v0_9, org.apache.qpid.server.output.amqp0_9.ProtocolOutputConverterImpl.getInstanceFactory());

-        register(ProtocolVersion.v0_91, org.apache.qpid.server.output.amqp0_9_1.ProtocolOutputConverterImpl.getInstanceFactory());

+        register(ProtocolVersion.v8_0);

+        register(ProtocolVersion.v0_9);

+        register(ProtocolVersion.v0_91);

     }

 

-    private static void register(ProtocolVersion version, Factory converter)

+    private ProtocolOutputConverterRegistry()

+    {

+    }

+

+    private static void register(ProtocolVersion version)

     {

 

-        _registry.put(version,converter);

+        _registry.put(version,new ConverterFactory(version));

     }

 

 

@@ -58,4 +63,28 @@
     {

         return _registry.get(session.getProtocolVersion()).newInstance(session);

     }

+

+    private static class ConverterFactory implements Factory

+    {

+        private ProtocolVersion _protocolVersion;

+        private MethodRegistry _methodRegistry;

+        private int _classId;

+

+        public ConverterFactory(ProtocolVersion pv)

+        {

+            _protocolVersion = pv;

+

+        }

+

+        public synchronized ProtocolOutputConverter newInstance(AMQProtocolSession session)

+        {

+            if(_methodRegistry == null)

+            {

+

+                _methodRegistry = MethodRegistry.getMethodRegistry(_protocolVersion);

+

+            }

+            return new ProtocolOutputConverterImpl(session, _methodRegistry);

+        }

+    }

 }

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_8/ProtocolOutputConverterImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_8/ProtocolOutputConverterImpl.java
deleted file mode 100644
index 1e62e5e..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_8/ProtocolOutputConverterImpl.java
+++ /dev/null
@@ -1,420 +0,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.
- *
- */
-
-/*
- * This file is auto-generated by Qpid Gentools v.0.1 - do not modify.
- * Supported AMQP versions:
- *   8-0
- */
-package org.apache.qpid.server.output.amqp0_8;
-
-import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
-import org.apache.qpid.server.protocol.AMQProtocolSession;
-import org.apache.qpid.server.message.AMQMessage;
-import org.apache.qpid.server.queue.QueueEntry;
-import org.apache.qpid.server.output.ProtocolOutputConverter;
-import org.apache.qpid.server.output.HeaderPropertiesConverter;
-import org.apache.qpid.server.message.MessageContentSource;
-import org.apache.qpid.server.message.MessageTransferMessage;
-import org.apache.qpid.framing.*;
-import org.apache.qpid.framing.abstraction.MessagePublishInfo;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.transport.DeliveryProperties;
-
-import java.io.DataOutput;
-import java.io.IOException;
-
-public class ProtocolOutputConverterImpl implements ProtocolOutputConverter
-{
-
-    private static final MethodRegistry METHOD_REGISTRY = MethodRegistry.getMethodRegistry(ProtocolVersion.v8_0);
-
-    public static Factory getInstanceFactory()
-    {
-        return new Factory()
-        {
-
-            public ProtocolOutputConverter newInstance(AMQProtocolSession session)
-            {
-                return new ProtocolOutputConverterImpl(session);
-            }
-        };
-    }
-
-
-    private final AMQProtocolSession _protocolSession;
-
-    private ProtocolOutputConverterImpl(AMQProtocolSession session)
-    {
-        _protocolSession = session;
-    }
-
-
-    public AMQProtocolSession getProtocolSession()
-    {
-        return _protocolSession;
-    }
-
-    public void writeDeliver(QueueEntry entry, int channelId, long deliveryTag, AMQShortString consumerTag)
-            throws AMQException
-    {
-        AMQBody deliverBody = createEncodedDeliverBody(entry, deliveryTag, consumerTag);
-        writeMessageDelivery(entry, channelId, deliverBody);
-    }
-
-
-    private ContentHeaderBody getContentHeaderBody(QueueEntry entry)
-            throws AMQException
-    {
-        if(entry.getMessage() instanceof AMQMessage)
-        {
-            return ((AMQMessage)entry.getMessage()).getContentHeaderBody();
-        }
-        else
-        {
-            final MessageTransferMessage message = (MessageTransferMessage) entry.getMessage();
-            BasicContentHeaderProperties props = HeaderPropertiesConverter.convert(message, entry.getQueue().getVirtualHost());
-            ContentHeaderBody chb = new ContentHeaderBody(props, org.apache.qpid.framing.amqp_8_0.BasicGetBodyImpl.CLASS_ID);
-            chb.bodySize = message.getSize();
-            return chb;
-        }
-    }
-
-
-    private void writeMessageDelivery(QueueEntry entry, int channelId, AMQBody deliverBody)
-            throws AMQException
-    {
-        writeMessageDelivery(entry.getMessage(), getContentHeaderBody(entry), channelId, deliverBody);
-    }
-
-    private void writeMessageDelivery(MessageContentSource message, ContentHeaderBody contentHeaderBody, int channelId, AMQBody deliverBody)
-            throws AMQException
-    {
-
-
-        int bodySize = (int) message.getSize();
-
-        if(bodySize == 0)
-        {
-            SmallCompositeAMQBodyBlock compositeBlock = new SmallCompositeAMQBodyBlock(channelId, deliverBody,
-                                                                             contentHeaderBody);
-
-            writeFrame(compositeBlock);
-        }
-        else
-        {
-            int maxBodySize = (int) getProtocolSession().getMaxFrameSize() - AMQFrame.getFrameOverhead();
-
-
-            int capacity = bodySize > maxBodySize ? maxBodySize : bodySize;
-
-            int writtenSize = capacity;
-
-            AMQBody firstContentBody = new MessageContentSourceBody(message,0,capacity);
-
-            CompositeAMQBodyBlock
-                    compositeBlock = new CompositeAMQBodyBlock(channelId, deliverBody, contentHeaderBody, firstContentBody);
-            writeFrame(compositeBlock);
-
-            while(writtenSize < bodySize)
-            {
-                capacity = bodySize - writtenSize > maxBodySize ? maxBodySize : bodySize - writtenSize;
-                MessageContentSourceBody body = new MessageContentSourceBody(message, writtenSize, capacity);
-                writtenSize += capacity;
-
-                writeFrame(new AMQFrame(channelId, body));
-            }
-        }
-    }
-
-    private class MessageContentSourceBody implements AMQBody
-    {
-        public static final byte TYPE = 3;
-        private int _length;
-        private MessageContentSource _message;
-        private int _offset;
-
-        public MessageContentSourceBody(MessageContentSource message, int offset, int length)
-        {
-            _message = message;
-            _offset = offset;
-            _length = length;
-        }
-
-        public byte getFrameType()
-        {
-            return TYPE;
-        }
-
-        public int getSize()
-        {
-            return _length;
-        }
-
-        public void writePayload(DataOutput buffer) throws IOException
-        {
-            byte[] data = new byte[_length];
-
-            _message.getContent(java.nio.ByteBuffer.wrap(data), _offset);
-
-            buffer.write(data);
-        }
-
-        public void handle(int channelId, AMQVersionAwareProtocolSession amqProtocolSession) throws AMQException
-        {
-            throw new UnsupportedOperationException();
-        }
-    }
-
-    private AMQDataBlock createContentHeaderBlock(final int channelId, final ContentHeaderBody contentHeaderBody)
-    {
-
-        AMQDataBlock contentHeader = ContentHeaderBody.createAMQFrame(channelId,
-                                                                      contentHeaderBody);
-        return contentHeader;
-    }
-
-
-    public void writeGetOk(QueueEntry entry, int channelId, long deliveryTag, int queueSize) throws AMQException
-    {
-        AMQBody deliver = createEncodedGetOkBody(entry, deliveryTag, queueSize);
-        writeMessageDelivery(entry, channelId, deliver);
-    }
-
-
-    private AMQBody createEncodedDeliverBody(QueueEntry entry,
-                                              final long deliveryTag,
-                                              final AMQShortString consumerTag)
-            throws AMQException
-    {
-
-        final AMQShortString exchangeName;
-        final AMQShortString routingKey;
-
-        if(entry.getMessage() instanceof AMQMessage)
-        {
-            final AMQMessage message = (AMQMessage) entry.getMessage();
-            final MessagePublishInfo pb = message.getMessagePublishInfo();
-            exchangeName = pb.getExchange();
-            routingKey = pb.getRoutingKey();
-        }
-        else
-        {
-            MessageTransferMessage message = (MessageTransferMessage) entry.getMessage();
-            DeliveryProperties delvProps = message.getHeader().getDeliveryProperties();
-            exchangeName = (delvProps == null || delvProps.getExchange() == null) ? null : new AMQShortString(delvProps.getExchange());
-            routingKey = (delvProps == null || delvProps.getRoutingKey() == null) ? null : new AMQShortString(delvProps.getRoutingKey());
-        }
-
-        final boolean isRedelivered = entry.isRedelivered();
-
-        final AMQBody returnBlock = new AMQBody()
-        {
-
-            public AMQBody _underlyingBody;
-
-            public AMQBody createAMQBody()
-            {
-                return METHOD_REGISTRY.createBasicDeliverBody(consumerTag,
-                                                              deliveryTag,
-                                                              isRedelivered,
-                                                              exchangeName,
-                                                              routingKey);
-
-
-
-
-
-            }
-
-            public byte getFrameType()
-            {
-                return AMQMethodBody.TYPE;
-            }
-
-            public int getSize()
-            {
-                if(_underlyingBody == null)
-                {
-                    _underlyingBody = createAMQBody();
-                }
-                return _underlyingBody.getSize();
-            }
-
-            public void writePayload(DataOutput buffer) throws IOException
-            {
-                if(_underlyingBody == null)
-                {
-                    _underlyingBody = createAMQBody();
-                }
-                _underlyingBody.writePayload(buffer);
-            }
-
-            public void handle(final int channelId, final AMQVersionAwareProtocolSession amqMinaProtocolSession)
-                throws AMQException
-            {
-                throw new AMQException("This block should never be dispatched!");
-            }
-        };
-        return returnBlock;
-    }
-
-    private AMQBody createEncodedGetOkBody(QueueEntry entry, long deliveryTag, int queueSize)
-            throws AMQException
-    {
-        final AMQShortString exchangeName;
-        final AMQShortString routingKey;
-
-        if(entry.getMessage() instanceof AMQMessage)
-        {
-            final AMQMessage message = (AMQMessage) entry.getMessage();
-            final MessagePublishInfo pb = message.getMessagePublishInfo();
-            exchangeName = pb.getExchange();
-            routingKey = pb.getRoutingKey();
-        }
-        else
-        {
-            MessageTransferMessage message = (MessageTransferMessage) entry.getMessage();
-            DeliveryProperties delvProps = message.getHeader().getDeliveryProperties();
-            exchangeName = (delvProps == null || delvProps.getExchange() == null) ? null : new AMQShortString(delvProps.getExchange());
-            routingKey = (delvProps == null || delvProps.getRoutingKey() == null) ? null : new AMQShortString(delvProps.getRoutingKey());
-        }
-
-        final boolean isRedelivered = entry.isRedelivered();
-
-        BasicGetOkBody getOkBody =
-                METHOD_REGISTRY.createBasicGetOkBody(deliveryTag,
-                                                    isRedelivered,
-                                                    exchangeName,
-                                                    routingKey,
-                                                    queueSize);
-
-        return getOkBody;
-    }
-
-    public byte getProtocolMinorVersion()
-    {
-        return getProtocolSession().getProtocolMinorVersion();
-    }
-
-    public byte getProtocolMajorVersion()
-    {
-        return getProtocolSession().getProtocolMajorVersion();
-    }
-
-    private AMQBody createEncodedReturnFrame(MessagePublishInfo messagePublishInfo,
-                                             int replyCode,
-                                             AMQShortString replyText) throws AMQException
-    {
-
-        BasicReturnBody basicReturnBody =
-                METHOD_REGISTRY.createBasicReturnBody(replyCode,
-                        replyText,
-                        messagePublishInfo.getExchange(),
-                        messagePublishInfo.getRoutingKey());
-
-
-        return basicReturnBody;
-    }
-
-    public void writeReturn(MessagePublishInfo messagePublishInfo, ContentHeaderBody header, MessageContentSource message, int channelId, int replyCode, AMQShortString replyText)
-            throws AMQException
-    {
-
-        AMQBody returnFrame = createEncodedReturnFrame(messagePublishInfo, replyCode, replyText);
-
-        writeMessageDelivery(message, header, channelId, returnFrame);
-    }
-
-
-    public void writeFrame(AMQDataBlock block)
-    {
-        getProtocolSession().writeFrame(block);
-    }
-
-
-    public void confirmConsumerAutoClose(int channelId, AMQShortString consumerTag)
-    {
-
-        BasicCancelOkBody basicCancelOkBody = METHOD_REGISTRY.createBasicCancelOkBody(consumerTag);
-        writeFrame(basicCancelOkBody.generateFrame(channelId));
-
-    }
-
-
-    public static final class CompositeAMQBodyBlock extends AMQDataBlock
-    {
-        public static final int OVERHEAD = 3 * AMQFrame.getFrameOverhead();
-
-        private final AMQBody _methodBody;
-        private final AMQBody _headerBody;
-        private final AMQBody _contentBody;
-        private final int _channel;
-
-
-        public CompositeAMQBodyBlock(int channel, AMQBody methodBody, AMQBody headerBody, AMQBody contentBody)
-        {
-            _channel = channel;
-            _methodBody = methodBody;
-            _headerBody = headerBody;
-            _contentBody = contentBody;
-
-        }
-
-        public long getSize()
-        {
-            return OVERHEAD + _methodBody.getSize() + _headerBody.getSize() + _contentBody.getSize();
-        }
-
-        public void writePayload(DataOutput buffer) throws IOException
-        {
-            AMQFrame.writeFrames(buffer, _channel, _methodBody, _headerBody, _contentBody);
-        }
-    }
-
-    public static final class SmallCompositeAMQBodyBlock extends AMQDataBlock
-    {
-        public static final int OVERHEAD = 2 * AMQFrame.getFrameOverhead();
-
-        private final AMQBody _methodBody;
-        private final AMQBody _headerBody;
-        private final int _channel;
-
-
-        public SmallCompositeAMQBodyBlock(int channel, AMQBody methodBody, AMQBody headerBody)
-        {
-            _channel = channel;
-            _methodBody = methodBody;
-            _headerBody = headerBody;
-
-        }
-
-        public long getSize()
-        {
-            return OVERHEAD + _methodBody.getSize() + _headerBody.getSize() ;
-        }
-
-        public void writePayload(DataOutput buffer) throws IOException
-        {
-            AMQFrame.writeFrames(buffer, _channel, _methodBody, _headerBody);
-        }
-    }
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_9/ProtocolOutputConverterImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_9/ProtocolOutputConverterImpl.java
deleted file mode 100644
index 78507b0..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_9/ProtocolOutputConverterImpl.java
+++ /dev/null
@@ -1,418 +0,0 @@
-package org.apache.qpid.server.output.amqp0_9;
-/*
- *
- * 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.
- *
- */
-
-import org.apache.qpid.server.output.ProtocolOutputConverter;
-import org.apache.qpid.server.output.HeaderPropertiesConverter;
-import org.apache.qpid.server.protocol.AMQProtocolSession;
-import org.apache.qpid.server.message.AMQMessage;
-import org.apache.qpid.server.queue.QueueEntry;
-import org.apache.qpid.server.message.MessageContentSource;
-import org.apache.qpid.server.message.MessageTransferMessage;
-import org.apache.qpid.framing.*;
-import org.apache.qpid.framing.amqp_0_9.BasicGetBodyImpl;
-import org.apache.qpid.framing.abstraction.MessagePublishInfo;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.transport.DeliveryProperties;
-import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
-
-import java.io.DataOutput;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-public class ProtocolOutputConverterImpl implements ProtocolOutputConverter
-{
-    private static final MethodRegistry METHOD_REGISTRY = MethodRegistry.getMethodRegistry(ProtocolVersion.v0_9);
-
-
-    public static Factory getInstanceFactory()
-    {
-        return new Factory()
-        {
-
-            public ProtocolOutputConverter newInstance(AMQProtocolSession session)
-            {
-                return new ProtocolOutputConverterImpl(session);
-            }
-        };
-    }
-
-    private final AMQProtocolSession _protocolSession;
-
-    private ProtocolOutputConverterImpl(AMQProtocolSession session)
-    {
-        _protocolSession = session;
-    }
-
-
-    public AMQProtocolSession getProtocolSession()
-    {
-        return _protocolSession;
-    }
-
-    public void writeDeliver(QueueEntry entry, int channelId, long deliveryTag, AMQShortString consumerTag)
-            throws AMQException
-    {
-        AMQBody deliverBody = createEncodedDeliverBody(entry, deliveryTag, consumerTag);
-        writeMessageDelivery(entry, channelId, deliverBody);
-    }
-
-
-    private ContentHeaderBody getContentHeaderBody(QueueEntry entry)
-            throws AMQException
-    {
-        if(entry.getMessage() instanceof AMQMessage)
-        {
-            return ((AMQMessage)entry.getMessage()).getContentHeaderBody();
-        }
-        else
-        {
-            final MessageTransferMessage message = (MessageTransferMessage) entry.getMessage();
-            BasicContentHeaderProperties props = HeaderPropertiesConverter.convert(message, entry.getQueue().getVirtualHost());
-            ContentHeaderBody chb = new ContentHeaderBody(props, BasicGetBodyImpl.CLASS_ID);
-            chb.bodySize = message.getSize();
-            return chb;
-        }
-    }
-
-
-    private void writeMessageDelivery(QueueEntry entry, int channelId, AMQBody deliverBody)
-            throws AMQException
-    {
-        writeMessageDelivery(entry.getMessage(), getContentHeaderBody(entry), channelId, deliverBody);
-    }
-
-    private void writeMessageDelivery(MessageContentSource message, ContentHeaderBody contentHeaderBody, int channelId, AMQBody deliverBody)
-            throws AMQException
-    {
-
-
-        int bodySize = (int) message.getSize();
-
-        if(bodySize == 0)
-        {
-            SmallCompositeAMQBodyBlock compositeBlock = new SmallCompositeAMQBodyBlock(channelId, deliverBody,
-                                                                             contentHeaderBody);
-
-            writeFrame(compositeBlock);
-        }
-        else
-        {
-            int maxBodySize = (int) getProtocolSession().getMaxFrameSize() - AMQFrame.getFrameOverhead();
-
-
-            int capacity = bodySize > maxBodySize ? maxBodySize : bodySize;
-
-            int writtenSize = capacity;
-
-            AMQBody firstContentBody = new MessageContentSourceBody(message,0,capacity);
-
-
-            CompositeAMQBodyBlock
-                    compositeBlock = new CompositeAMQBodyBlock(channelId, deliverBody, contentHeaderBody, firstContentBody);
-            writeFrame(compositeBlock);
-
-            while(writtenSize < bodySize)
-            {
-                capacity = bodySize - writtenSize > maxBodySize ? maxBodySize : bodySize - writtenSize;
-                MessageContentSourceBody body = new MessageContentSourceBody(message, writtenSize, capacity);
-                writtenSize += capacity;
-
-                writeFrame(new AMQFrame(channelId, body));
-            }
-        }
-    }
-
-    private class MessageContentSourceBody implements AMQBody
-    {
-        public static final byte TYPE = 3;
-        private int _length;
-        private MessageContentSource _message;
-        private int _offset;
-
-        public MessageContentSourceBody(MessageContentSource message, int offset, int length)
-        {
-            _message = message;
-            _offset = offset;
-            _length = length;
-        }
-
-        public byte getFrameType()
-        {
-            return TYPE;
-        }
-
-        public int getSize()
-        {
-            return _length;
-        }
-
-        public void writePayload(DataOutput buffer) throws IOException
-        {
-            byte[] data = new byte[_length];
-
-            _message.getContent(ByteBuffer.wrap(data), _offset);
-
-            buffer.write(data);
-        }
-
-        public void handle(int channelId, AMQVersionAwareProtocolSession amqProtocolSession) throws AMQException
-        {
-            throw new UnsupportedOperationException();
-        }
-    }
-
-
-    private AMQDataBlock createContentHeaderBlock(final int channelId, final ContentHeaderBody contentHeaderBody)
-    {
-
-        AMQDataBlock contentHeader = ContentHeaderBody.createAMQFrame(channelId,
-                                                                      contentHeaderBody);
-        return contentHeader;
-    }
-
-
-    public void writeGetOk(QueueEntry entry, int channelId, long deliveryTag, int queueSize) throws AMQException
-    {
-        AMQBody deliver = createEncodedGetOkBody(entry, deliveryTag, queueSize);
-        writeMessageDelivery(entry, channelId, deliver);
-    }
-
-
-    private AMQBody createEncodedDeliverBody(QueueEntry entry,
-                                              final long deliveryTag,
-                                              final AMQShortString consumerTag)
-            throws AMQException
-    {
-
-        final AMQShortString exchangeName;
-        final AMQShortString routingKey;
-
-        if(entry.getMessage() instanceof AMQMessage)
-        {
-            final AMQMessage message = (AMQMessage) entry.getMessage();
-            final MessagePublishInfo pb = message.getMessagePublishInfo();
-            exchangeName = pb.getExchange();
-            routingKey = pb.getRoutingKey();
-        }
-        else
-        {
-            MessageTransferMessage message = (MessageTransferMessage) entry.getMessage();
-            DeliveryProperties delvProps = message.getHeader().getDeliveryProperties();
-            exchangeName = (delvProps == null || delvProps.getExchange() == null) ? null : new AMQShortString(delvProps.getExchange());
-            routingKey = (delvProps == null || delvProps.getRoutingKey() == null) ? null : new AMQShortString(delvProps.getRoutingKey());
-        }
-
-        final boolean isRedelivered = entry.isRedelivered();
-
-        final AMQBody returnBlock = new AMQBody()
-        {
-
-            public AMQBody _underlyingBody;
-
-            public AMQBody createAMQBody()
-            {
-                return METHOD_REGISTRY.createBasicDeliverBody(consumerTag,
-                                                              deliveryTag,
-                                                              isRedelivered,
-                                                              exchangeName,
-                                                              routingKey);
-
-
-
-
-
-            }
-
-            public byte getFrameType()
-            {
-                return AMQMethodBody.TYPE;
-            }
-
-            public int getSize()
-            {
-                if(_underlyingBody == null)
-                {
-                    _underlyingBody = createAMQBody();
-                }
-                return _underlyingBody.getSize();
-            }
-
-            public void writePayload(DataOutput buffer) throws IOException
-            {
-                if(_underlyingBody == null)
-                {
-                    _underlyingBody = createAMQBody();
-                }
-                _underlyingBody.writePayload(buffer);
-            }
-
-            public void handle(final int channelId, final AMQVersionAwareProtocolSession amqMinaProtocolSession)
-                throws AMQException
-            {
-                throw new AMQException("This block should never be dispatched!");
-            }
-        };
-        return returnBlock;
-    }
-
-    private AMQBody createEncodedGetOkBody(QueueEntry entry, long deliveryTag, int queueSize)
-            throws AMQException
-    {
-        final AMQShortString exchangeName;
-        final AMQShortString routingKey;
-
-        if(entry.getMessage() instanceof AMQMessage)
-        {
-            final AMQMessage message = (AMQMessage) entry.getMessage();
-            final MessagePublishInfo pb = message.getMessagePublishInfo();
-            exchangeName = pb.getExchange();
-            routingKey = pb.getRoutingKey();
-        }
-        else
-        {
-            MessageTransferMessage message = (MessageTransferMessage) entry.getMessage();
-            DeliveryProperties delvProps = message.getHeader().getDeliveryProperties();
-            exchangeName = (delvProps == null || delvProps.getExchange() == null) ? null : new AMQShortString(delvProps.getExchange());
-            routingKey = (delvProps == null || delvProps.getRoutingKey() == null) ? null : new AMQShortString(delvProps.getRoutingKey());
-        }
-
-        final boolean isRedelivered = entry.isRedelivered();
-
-        BasicGetOkBody getOkBody =
-                METHOD_REGISTRY.createBasicGetOkBody(deliveryTag,
-                                                    isRedelivered,
-                                                    exchangeName,
-                                                    routingKey,
-                                                    queueSize);
-
-        return getOkBody;
-    }
-
-    public byte getProtocolMinorVersion()
-    {
-        return getProtocolSession().getProtocolMinorVersion();
-    }
-
-    public byte getProtocolMajorVersion()
-    {
-        return getProtocolSession().getProtocolMajorVersion();
-    }
-
-    private AMQBody createEncodedReturnFrame(MessagePublishInfo messagePublishInfo,
-                                             int replyCode,
-                                             AMQShortString replyText) throws AMQException
-    {
-
-        BasicReturnBody basicReturnBody =
-                METHOD_REGISTRY.createBasicReturnBody(replyCode,
-                                                     replyText,
-                                                     messagePublishInfo.getExchange(),
-                                                     messagePublishInfo.getRoutingKey());
-
-
-        return basicReturnBody;
-    }
-
-    public void writeReturn(MessagePublishInfo messagePublishInfo, ContentHeaderBody header, MessageContentSource message, int channelId, int replyCode, AMQShortString replyText)
-            throws AMQException
-    {
-
-        AMQBody returnFrame = createEncodedReturnFrame(messagePublishInfo, replyCode, replyText);
-
-        writeMessageDelivery(message, header, channelId, returnFrame);
-    }
-
-
-    public void writeFrame(AMQDataBlock block)
-    {
-        getProtocolSession().writeFrame(block);
-    }
-
-
-    public void confirmConsumerAutoClose(int channelId, AMQShortString consumerTag)
-    {
-
-        BasicCancelOkBody basicCancelOkBody = METHOD_REGISTRY.createBasicCancelOkBody(consumerTag);
-        writeFrame(basicCancelOkBody.generateFrame(channelId));
-
-    }
-
-
-    public static final class CompositeAMQBodyBlock extends AMQDataBlock
-    {
-        public static final int OVERHEAD = 3 * AMQFrame.getFrameOverhead();
-
-        private final AMQBody _methodBody;
-        private final AMQBody _headerBody;
-        private final AMQBody _contentBody;
-        private final int _channel;
-
-
-        public CompositeAMQBodyBlock(int channel, AMQBody methodBody, AMQBody headerBody, AMQBody contentBody)
-        {
-            _channel = channel;
-            _methodBody = methodBody;
-            _headerBody = headerBody;
-            _contentBody = contentBody;
-
-        }
-
-        public long getSize()
-        {
-            return OVERHEAD + _methodBody.getSize() + _headerBody.getSize() + _contentBody.getSize();
-        }
-
-        public void writePayload(DataOutput buffer) throws IOException
-        {
-            AMQFrame.writeFrames(buffer, _channel, _methodBody, _headerBody, _contentBody);
-        }
-    }
-
-    public static final class SmallCompositeAMQBodyBlock extends AMQDataBlock
-    {
-        public static final int OVERHEAD = 2 * AMQFrame.getFrameOverhead();
-
-        private final AMQBody _methodBody;
-        private final AMQBody _headerBody;
-        private final int _channel;
-
-
-        public SmallCompositeAMQBodyBlock(int channel, AMQBody methodBody, AMQBody headerBody)
-        {
-            _channel = channel;
-            _methodBody = methodBody;
-            _headerBody = headerBody;
-
-        }
-
-        public long getSize()
-        {
-            return OVERHEAD + _methodBody.getSize() + _headerBody.getSize() ;
-        }
-
-        public void writePayload(DataOutput buffer) throws IOException
-        {
-            AMQFrame.writeFrames(buffer, _channel, _methodBody, _headerBody);
-        }
-    }
-
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/Activator.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/Activator.java
index df72e87..12e1eee 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/Activator.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/Activator.java
@@ -19,11 +19,12 @@
 package org.apache.qpid.server.plugins;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+
 public class Activator implements BundleActivator
 {
     private static final Logger _logger = Logger.getLogger(Activator.class);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/OsgiSystemPackageUtil.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/OsgiSystemPackageUtil.java
index 644f714..d2bb3e0 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/OsgiSystemPackageUtil.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/OsgiSystemPackageUtil.java
@@ -18,11 +18,11 @@
  */
 package org.apache.qpid.server.plugins;
 
+import org.osgi.framework.Version;
+
 import java.util.Iterator;
 import java.util.Map;
 
-import org.osgi.framework.Version;
-
 /**
  * Utility class to convert a map of package name to version numbers into the string
  * with the format expected of a OSGi system package declaration:
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/Plugin.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/Plugin.java
index 804a9d5..6dcf688 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/Plugin.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/Plugin.java
@@ -19,6 +19,7 @@
 package org.apache.qpid.server.plugins;
 
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 
 public interface Plugin
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginFactory.java
index bbf3e74..7ea2b95 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginFactory.java
@@ -19,6 +19,7 @@
 package org.apache.qpid.server.plugins;
 
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 
 public interface PluginFactory<P extends Plugin>
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java
index dab6c3b..880b1cc 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java
@@ -18,16 +18,35 @@
  */
 package org.apache.qpid.server.plugins;
 
-import static org.apache.felix.framework.util.FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP;
-import static org.apache.felix.main.AutoProcessor.AUTO_DEPLOY_ACTION_PROPERY;
-import static org.apache.felix.main.AutoProcessor.AUTO_DEPLOY_DIR_PROPERY;
-import static org.apache.felix.main.AutoProcessor.AUTO_DEPLOY_INSTALL_VALUE;
-import static org.apache.felix.main.AutoProcessor.AUTO_DEPLOY_START_VALUE;
-import static org.apache.felix.main.AutoProcessor.process;
-import static org.osgi.framework.Constants.FRAMEWORK_STORAGE;
-import static org.osgi.framework.Constants.FRAMEWORK_STORAGE_CLEAN;
-import static org.osgi.framework.Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT;
-import static org.osgi.framework.Constants.FRAMEWORK_SYSTEMPACKAGES;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.felix.framework.Felix;
+import org.apache.felix.framework.util.StringMap;
+import org.apache.log4j.Logger;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
+import org.osgi.framework.launch.Framework;
+import org.osgi.util.tracker.ServiceTracker;
+
+import org.apache.qpid.common.Closeable;
+import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.server.configuration.TopicConfiguration;
+import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
+import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionConfiguration.SlowConsumerDetectionConfigurationFactory;
+import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionPolicyConfiguration.SlowConsumerDetectionPolicyConfigurationFactory;
+import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionQueueConfiguration.SlowConsumerDetectionQueueConfigurationFactory;
+import org.apache.qpid.server.exchange.ExchangeType;
+import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.security.SecurityPluginFactory;
+import org.apache.qpid.server.security.access.plugins.LegacyAccess;
+import org.apache.qpid.server.security.auth.manager.AuthenticationManagerPluginFactory;
+import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
+import org.apache.qpid.server.virtualhost.plugins.SlowConsumerDetection;
+import org.apache.qpid.server.virtualhost.plugins.VirtualHostPluginFactory;
+import org.apache.qpid.server.virtualhost.plugins.policies.TopicDeletePolicy;
+import org.apache.qpid.slowconsumerdetection.policies.SlowConsumerPolicyPluginFactory;
+import org.apache.qpid.util.FileUtils;
 
 import java.io.File;
 import java.io.IOException;
@@ -40,36 +59,16 @@
 import java.util.Map;
 import java.util.Properties;
 
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.felix.framework.Felix;
-import org.apache.felix.framework.util.StringMap;
-import org.apache.log4j.Logger;
-import org.apache.qpid.common.Closeable;
-import org.apache.qpid.common.QpidProperties;
-import org.apache.qpid.server.configuration.TopicConfiguration;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
-import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionConfiguration.SlowConsumerDetectionConfigurationFactory;
-import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionPolicyConfiguration.SlowConsumerDetectionPolicyConfigurationFactory;
-import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionQueueConfiguration.SlowConsumerDetectionQueueConfigurationFactory;
-import org.apache.qpid.server.exchange.ExchangeType;
-import org.apache.qpid.server.security.SecurityManager;
-import org.apache.qpid.server.security.SecurityPluginFactory;
-import org.apache.qpid.server.security.access.plugins.AllowAll;
-import org.apache.qpid.server.security.access.plugins.DenyAll;
-import org.apache.qpid.server.security.access.plugins.LegacyAccess;
-import org.apache.qpid.server.security.auth.manager.AuthenticationManagerPluginFactory;
-import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
-import org.apache.qpid.server.virtualhost.plugins.SlowConsumerDetection;
-import org.apache.qpid.server.virtualhost.plugins.VirtualHostPluginFactory;
-import org.apache.qpid.server.virtualhost.plugins.policies.TopicDeletePolicy;
-import org.apache.qpid.slowconsumerdetection.policies.SlowConsumerPolicyPluginFactory;
-import org.apache.qpid.util.FileUtils;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Version;
-import org.osgi.framework.launch.Framework;
-import org.osgi.util.tracker.ServiceTracker;
+import static org.apache.felix.framework.util.FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP;
+import static org.apache.felix.main.AutoProcessor.AUTO_DEPLOY_ACTION_PROPERY;
+import static org.apache.felix.main.AutoProcessor.AUTO_DEPLOY_DIR_PROPERY;
+import static org.apache.felix.main.AutoProcessor.AUTO_DEPLOY_INSTALL_VALUE;
+import static org.apache.felix.main.AutoProcessor.AUTO_DEPLOY_START_VALUE;
+import static org.apache.felix.main.AutoProcessor.process;
+import static org.osgi.framework.Constants.FRAMEWORK_STORAGE;
+import static org.osgi.framework.Constants.FRAMEWORK_STORAGE_CLEAN;
+import static org.osgi.framework.Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT;
+import static org.osgi.framework.Constants.FRAMEWORK_SYSTEMPACKAGES;
 
 /**
  * Provides access to pluggable elements, such as exchanges
@@ -146,16 +145,13 @@
     {
         // Store all non-OSGi plugins
         // A little gross that we have to add them here, but not all the plugins are OSGIfied
-        for (SecurityPluginFactory<?> pluginFactory : Arrays.asList(
-                AllowAll.FACTORY, DenyAll.FACTORY, LegacyAccess.FACTORY))
+        for (SecurityPluginFactory<?> pluginFactory : Arrays.asList(LegacyAccess.FACTORY))
         {
             _securityPlugins.put(pluginFactory.getPluginName(), pluginFactory);
         }
         for (ConfigurationPluginFactory configFactory : Arrays.asList(
                 TopicConfiguration.FACTORY,
                 SecurityManager.SecurityConfiguration.FACTORY,
-                AllowAll.AllowAllConfiguration.FACTORY,
-                DenyAll.DenyAllConfiguration.FACTORY,
                 LegacyAccess.LegacyAccessConfiguration.FACTORY,
                 new SlowConsumerDetectionConfigurationFactory(),
                 new SlowConsumerDetectionPolicyConfigurationFactory(),
@@ -254,6 +250,8 @@
             _logger.info("Using the specified external BundleContext");
         }
 
+        // TODO save trackers in a map, keyed by class name
+        
         _exchangeTracker = new ServiceTracker(bundleContext, ExchangeType.class.getName(), null);
         _exchangeTracker.open();
         _trackers.add(_exchangeTracker);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java
index bc0d4e3..5af3899 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.server.protocol;
 
-import java.util.List;
-import java.util.UUID;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.logging.LogSubject;
 import org.apache.qpid.server.stats.StatisticsGatherer;
 
+import java.util.List;
+import java.util.UUID;
+
 public interface AMQConnectionModel extends StatisticsGatherer
 {
     /**
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
index 547f244..e9ad4ea 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
@@ -20,34 +20,15 @@
  */
 package org.apache.qpid.server.protocol;
 
-import java.io.DataOutput;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.nio.ByteBuffer;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.management.JMException;
-import javax.security.auth.Subject;
-import javax.security.sasl.SaslServer;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQChannelException;
 import org.apache.qpid.AMQConnectionException;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.codec.AMQCodecFactory;
-import org.apache.qpid.common.ClientProperties;
 import org.apache.qpid.framing.*;
+import org.apache.qpid.properties.ConnectionStartProperties;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.protocol.AMQMethodEvent;
 import org.apache.qpid.protocol.AMQMethodListener;
@@ -83,13 +64,30 @@
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.TransportException;
 import org.apache.qpid.transport.network.NetworkConnection;
+import org.apache.qpid.util.BytesDataOutput;
+
+import javax.management.JMException;
+import javax.security.auth.Subject;
+import javax.security.sasl.SaslServer;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 public class AMQProtocolEngine implements ServerProtocolEngine, Managable, AMQProtocolSession, ConnectionConfig
 {
     private static final Logger _logger = Logger.getLogger(AMQProtocolEngine.class);
 
-    private static final String CLIENT_PROPERTIES_INSTANCE = ClientProperties.instance.toString();
-
     // to save boxing the channelId and looking up in a map... cache in an array the low numbered
     // channels.  This value must be of the form 2^x - 1.
     private static final int CHANNEL_CACHE_SIZE = 0xff;
@@ -97,7 +95,7 @@
 
     private AMQShortString _contextKey;
 
-    private AMQShortString _clientVersion = null;
+    private String _clientVersion = null;
 
     private VirtualHost _virtualHost;
 
@@ -119,7 +117,7 @@
 
     private Object _lastSent;
 
-    protected volatile boolean _closed;
+    private volatile boolean _closed;
 
     // maximum number of channels this session should have
     private long _maxNoOfChannels = ApplicationRegistry.getInstance().getConfiguration().getMaxChannelCount();
@@ -134,9 +132,9 @@
     private ProtocolOutputConverter _protocolOutputConverter;
     private Subject _authorizedSubject;
     private MethodDispatcher _dispatcher;
-    private ProtocolSessionIdentifier _sessionIdentifier;
 
-    private final long _sessionID;
+    private final long _connectionID;
+    private Object _reference = new Object();
 
     private AMQPConnectionActor _actor;
     private LogSubject _logSubject;
@@ -174,7 +172,7 @@
         _codecFactory = new AMQCodecFactory(true, this);
 
         setNetworkConnection(network);
-        _sessionID = connectionId;
+        _connectionID = connectionId;
 
         _actor = new AMQPConnectionActor(this, virtualHostRegistry.getApplicationRegistry().getRootMessageLogger());
 
@@ -183,7 +181,7 @@
         _configStore = virtualHostRegistry.getConfigStore();
         _id = _configStore.createId();
 
-        _actor.message(ConnectionMessages.OPEN(null, null, false, false));
+        _actor.message(ConnectionMessages.OPEN(null, null, null, false, false, false));
 
         _registry = virtualHostRegistry.getApplicationRegistry();
         initialiseStatistics();
@@ -207,7 +205,7 @@
 
     public long getSessionID()
     {
-        return _sessionID;
+        return _connectionID;
     }
 
     public LogActor getLogActor()
@@ -369,7 +367,7 @@
         try
         {
             // Log incomming protocol negotiation request
-            _actor.message(ConnectionMessages.OPEN(null, pi._protocolMajor + "-" + pi._protocolMinor, false, true));
+            _actor.message(ConnectionMessages.OPEN(null, pi.getProtocolMajor() + "-" + pi.getProtocolMinor(), null, false, true, false));
 
             ProtocolVersion pv = pi.checkVersion(); // Fails if not correct
 
@@ -721,7 +719,7 @@
         // However, due to the poor exception handling on the client. The client-user will be notified of the
         // InvalidArgument and if they then decide to close the session/connection then the there will be time
         // for that to occur i.e. a new close method be sent before the exeption handling can mark the session closed.
-        //removeChannel(channelId);
+
         _closingChannelsList.remove(channelId);
     }
 
@@ -922,31 +920,22 @@
         _saslServer = saslServer;
     }
 
-    public FieldTable getClientProperties()
-    {
-        return _clientProperties;
-    }
-
     public void setClientProperties(FieldTable clientProperties)
     {
         _clientProperties = clientProperties;
         if (_clientProperties != null)
         {
-            if (_clientProperties.getString(CLIENT_PROPERTIES_INSTANCE) != null)
+            _clientVersion = _clientProperties.getString(ConnectionStartProperties.VERSION_0_8);
+
+            if (_clientProperties.getString(ConnectionStartProperties.CLIENT_ID_0_8) != null)
             {
-                String clientID = _clientProperties.getString(CLIENT_PROPERTIES_INSTANCE);
+                String clientID = _clientProperties.getString(ConnectionStartProperties.CLIENT_ID_0_8);
                 setContextKey(new AMQShortString(clientID));
 
                 // Log the Opening of the connection for this client
-                _actor.message(ConnectionMessages.OPEN(clientID, _protocolVersion.toString(), true, true));
-            }
-
-            if (_clientProperties.getString(ClientProperties.version.toString()) != null)
-            {
-                _clientVersion = new AMQShortString(_clientProperties.getString(ClientProperties.version.toString()));
+                _actor.message(ConnectionMessages.OPEN(clientID, _protocolVersion.toString(), _clientVersion, true, true, true));
             }
         }
-        _sessionIdentifier = new ProtocolSessionIdentifier(this);
     }
 
     private void setProtocolVersion(ProtocolVersion pv)
@@ -982,11 +971,6 @@
         return getMethodRegistry();
     }
 
-    public Object getClientIdentifier()
-    {
-        return _network.getRemoteAddress();
-    }
-
     public VirtualHost getVirtualHost()
     {
         return _virtualHost;
@@ -1155,14 +1139,9 @@
         return _lastReceivedTime;
     }
 
-    public ProtocolSessionIdentifier getSessionIdentifier()
-    {
-        return _sessionIdentifier;
-    }
-
     public String getClientVersion()
     {
-        return (_clientVersion == null) ? null : _clientVersion.toString();
+        return _clientVersion;
     }
 
     public Boolean isIncoming()
@@ -1357,6 +1336,11 @@
 		                (Throwable) null));
     }
 
+    public boolean isClosed()
+    {
+        return _closed;
+    }
+
     public List<AMQSessionModel> getSessionModels()
     {
 		List<AMQSessionModel> sessions = new ArrayList<AMQSessionModel>();
@@ -1457,30 +1441,6 @@
         return getAuthorizedPrincipal().getName();
     }
 
-    private static class ByteBufferOutputStream extends OutputStream
-    {
-
-
-        private final ByteBuffer _buf;
-
-        public ByteBufferOutputStream(ByteBuffer buf)
-        {
-            _buf = buf;
-        }
-
-        @Override
-        public void write(int b) throws IOException
-        {
-            _buf.put((byte) b);
-        }
-
-        @Override
-        public void write(byte[] b, int off, int len) throws IOException
-        {
-            _buf.put(b, off, len);
-        }
-    }
-
     public final class WriteDeliverMethod
             implements ClientDeliveryMethod
     {
@@ -1501,158 +1461,8 @@
 
     }
 
-    private static class BytesDataOutput implements DataOutput
+    public Object getReference()
     {
-        int _pos = 0;
-        byte[] _buf;
-
-        public BytesDataOutput(byte[] buf)
-        {
-            _buf = buf;
-        }
-
-        public void setBuffer(byte[] buf)
-        {
-            _buf = buf;
-            _pos = 0;
-        }
-
-        public void reset()
-        {
-            _pos = 0;
-        }
-
-        public int length()
-        {
-            return _pos;
-        }
-
-        public void write(int b)
-        {
-            _buf[_pos++] = (byte) b;
-        }
-
-        public void write(byte[] b)
-        {
-            System.arraycopy(b, 0, _buf, _pos, b.length);
-            _pos+=b.length;
-        }
-
-
-        public void write(byte[] b, int off, int len)
-        {
-            System.arraycopy(b, off, _buf, _pos, len);
-            _pos+=len;
-
-        }
-
-        public void writeBoolean(boolean v)
-        {
-            _buf[_pos++] = v ? (byte) 1 : (byte) 0;
-        }
-
-        public void writeByte(int v)
-        {
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeShort(int v)
-        {
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeChar(int v)
-        {
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeInt(int v)
-        {
-            _buf[_pos++] = (byte) (v >>> 24);
-            _buf[_pos++] = (byte) (v >>> 16);
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeLong(long v)
-        {
-            _buf[_pos++] = (byte) (v >>> 56);
-            _buf[_pos++] = (byte) (v >>> 48);
-            _buf[_pos++] = (byte) (v >>> 40);
-            _buf[_pos++] = (byte) (v >>> 32);
-            _buf[_pos++] = (byte) (v >>> 24);
-            _buf[_pos++] = (byte) (v >>> 16);
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte)v;
-        }
-
-        public void writeFloat(float v)
-        {
-            writeInt(Float.floatToIntBits(v));
-        }
-
-        public void writeDouble(double v)
-        {
-            writeLong(Double.doubleToLongBits(v));
-        }
-
-        public void writeBytes(String s)
-        {
-            int len = s.length();
-            for (int i = 0 ; i < len ; i++)
-            {
-                _buf[_pos++] = ((byte)s.charAt(i));
-            }
-        }
-
-        public void writeChars(String s)
-        {
-            int len = s.length();
-            for (int i = 0 ; i < len ; i++)
-            {
-                int v = s.charAt(i);
-                _buf[_pos++] = (byte) (v >>> 8);
-                _buf[_pos++] = (byte) v;
-            }
-        }
-
-        public void writeUTF(String s)
-        {
-            int strlen = s.length();
-
-            int pos = _pos;
-            _pos+=2;
-
-
-            for (int i = 0; i < strlen; i++)
-            {
-                int c = s.charAt(i);
-                if ((c >= 0x0001) && (c <= 0x007F))
-                {
-                    c = s.charAt(i);
-                    _buf[_pos++] = (byte) c;
-
-                }
-                else if (c > 0x07FF)
-                {
-                    _buf[_pos++]  = (byte) (0xE0 | ((c >> 12) & 0x0F));
-                    _buf[_pos++]  = (byte) (0x80 | ((c >>  6) & 0x3F));
-                    _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
-                }
-                else
-                {
-                    _buf[_pos++] = (byte) (0xC0 | ((c >>  6) & 0x1F));
-                    _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
-                }
-            }
-
-            int len = _pos - (pos + 2);
-
-            _buf[pos++] = (byte) (len >>> 8);
-            _buf[pos] = (byte) len;
-        }
-
+        return _reference;
     }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
index dfba107..6cd5b21 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
@@ -20,23 +20,25 @@
  */
 package org.apache.qpid.server.protocol;
 
+import java.util.List;
+
 import javax.security.auth.Subject;
 import javax.security.sasl.SaslServer;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.common.ClientProperties;
-import org.apache.qpid.framing.*;
 import org.apache.qpid.AMQConnectionException;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.MethodDispatcher;
+import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
 import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.security.AuthorizationHolder;
 import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.output.ProtocolOutputConverter;
+import org.apache.qpid.server.security.AuthorizationHolder;
 import org.apache.qpid.server.subscription.ClientDeliveryMethod;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
-import java.util.List;
-
 
 public interface AMQProtocolSession extends AMQVersionAwareProtocolSession, AuthorizationHolder, AMQConnectionModel
 {
@@ -58,28 +60,6 @@
 
     long getLastReceivedTime();
 
-    public static final class ProtocolSessionIdentifier
-    {
-        private final Object _sessionIdentifier;
-        private final Object _sessionInstance;
-
-        ProtocolSessionIdentifier(AMQProtocolSession session)
-        {
-            _sessionIdentifier = session.getClientIdentifier();
-            _sessionInstance = session.getClientProperties() == null ? null : session.getClientProperties().getObject(ClientProperties.instance.toAMQShortString());
-        }
-
-        public Object getSessionIdentifier()
-        {
-            return _sessionIdentifier;
-        }
-
-        public Object getSessionInstance()
-        {
-            return _sessionInstance;
-        }
-    }
-
     public static interface Task
     {
         public void doTask(AMQProtocolSession session) throws AMQException;
@@ -190,12 +170,9 @@
      */
     void setSaslServer(SaslServer saslServer);
 
-
-    FieldTable getClientProperties();
-
     void setClientProperties(FieldTable clientProperties);
 
-    Object getClientIdentifier();
+    Object getReference();
 
     VirtualHost getVirtualHost();
 
@@ -215,8 +192,6 @@
 
     public MethodDispatcher getMethodDispatcher();
 
-    public ProtocolSessionIdentifier getSessionIdentifier();
-
     String getClientVersion();
 
     long getLastIoTime();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
index 8d39420..e707206 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
@@ -22,7 +22,7 @@
  *
  * Copyright (c) 2006 The Apache Software Foundation
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
  *
@@ -37,16 +37,6 @@
  */
 package org.apache.qpid.server.protocol;
 
-import java.util.Date;
-import java.util.List;
-import javax.management.JMException;
-import javax.management.MBeanException;
-import javax.management.NotCompliantMBeanException;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularDataSupport;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.ConnectionCloseBody;
@@ -60,6 +50,17 @@
 import org.apache.qpid.server.management.AbstractAMQManagedConnectionObject;
 import org.apache.qpid.server.management.ManagedObject;
 
+import javax.management.JMException;
+import javax.management.MBeanException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import java.util.Date;
+import java.util.List;
+
 /**
  * This MBean class implements the management interface. In order to make more attributes, operations and notifications
  * available over JMX simply augment the ManagedConnection interface and add the appropriate implementation here.
@@ -91,7 +92,7 @@
 
     public String getVersion()
     {
-        return (_protocolSession.getClientVersion() == null) ? null : _protocolSession.getClientVersion().toString();
+        return _protocolSession.getClientVersion();
     }
 
     public Date getLastIoTime()
@@ -132,7 +133,7 @@
      */
     public void commitTransactions(int channelId) throws JMException
     {
-        CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+        CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
         try
         {
             AMQChannel channel = _protocolSession.getChannel(channelId);
@@ -161,7 +162,7 @@
      */
     public void rollbackTransactions(int channelId) throws JMException
     {
-        CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+        CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
         try
         {
             AMQChannel channel = _protocolSession.getChannel(channelId);
@@ -240,7 +241,7 @@
         if (CurrentActor.get() == null)
         {
             removeActor = true;
-            CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+            CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
         }
 
         try
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java
index c55fe32..a69f2a7 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQSessionModel.java
@@ -20,12 +20,20 @@
  */
 package org.apache.qpid.server.protocol;
 
+import java.util.concurrent.ConcurrentSkipListSet;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.logging.LogSubject;
+import org.apache.qpid.server.message.InboundMessage;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.SimpleAMQQueue;
 
-public interface AMQSessionModel
+/**
+ * Session model interface.
+ * Extends {@link Comparable} to allow objects to be inserted into a {@link ConcurrentSkipListSet}
+ * when monitoring the blocking and blocking of queues/sessions in {@link SimpleAMQQueue}.
+ */
+public interface AMQSessionModel extends Comparable<AMQSessionModel>
 {
     public Object getID();
 
@@ -57,4 +65,7 @@
     void block(AMQQueue queue);
 
     void unblock(AMQQueue queue);
+
+
+    boolean onSameConnection(InboundMessage inbound);
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngine.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngine.java
index a71d396..ce20690 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngine.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngine.java
@@ -21,6 +21,11 @@
 package org.apache.qpid.server.protocol;
 
 
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.util.Set;
+
 import org.apache.log4j.Logger;
 import org.apache.qpid.protocol.ServerProtocolEngine;
 import org.apache.qpid.server.registry.IApplicationRegistry;
@@ -29,10 +34,6 @@
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.network.NetworkConnection;
 
-import java.net.SocketAddress;
-import java.nio.ByteBuffer;
-import java.util.Set;
-
 public class MultiVersionProtocolEngine implements ServerProtocolEngine
 {
     private static final Logger _logger = Logger.getLogger(MultiVersionProtocolEngine.class);
@@ -44,29 +45,35 @@
     private IApplicationRegistry _appRegistry;
     private NetworkConnection _network;
     private Sender<ByteBuffer> _sender;
+    private final AmqpProtocolVersion _defaultSupportedReply;
 
     private volatile ServerProtocolEngine _delegate = new SelfDelegateProtocolEngine();
 
-    public MultiVersionProtocolEngine(IApplicationRegistry appRegistry,
-                                      String fqdn,
-                                      Set<AmqpProtocolVersion> supported,
-                                      NetworkConnection network,
-                                      long id)
+    public MultiVersionProtocolEngine(final IApplicationRegistry appRegistry,
+                                      final Set<AmqpProtocolVersion> supported,
+                                      final AmqpProtocolVersion defaultSupportedReply,
+                                      final long id,
+                                      final NetworkConnection network)
     {
-        this(appRegistry,fqdn,supported,id);
+        this(appRegistry, supported, defaultSupportedReply, id);
         setNetworkConnection(network);
     }
 
-    public MultiVersionProtocolEngine(IApplicationRegistry appRegistry,
-                                      String fqdn,
-                                      Set<AmqpProtocolVersion> supported,
-                                      long id)
+    public MultiVersionProtocolEngine(final IApplicationRegistry appRegistry,
+                                      final Set<AmqpProtocolVersion> supported,
+                                      final AmqpProtocolVersion defaultSupportedReply,
+                                      final long id)
     {
+        if(defaultSupportedReply != null && !supported.contains(defaultSupportedReply))
+        {
+            throw new IllegalArgumentException("The configured default reply (" + defaultSupportedReply
+                                             + ") to an unsupported protocol version initiation is itself not supported!");
+        }
+
         _id = id;
         _appRegistry = appRegistry;
-        _fqdn = fqdn;
         _supported = supported;
-
+        _defaultSupportedReply = defaultSupportedReply;
     }
 
 
@@ -198,6 +205,15 @@
     public void setNetworkConnection(NetworkConnection network, Sender<ByteBuffer> sender)
     {
         _network = network;
+        SocketAddress address = _network.getLocalAddress();
+        if (address instanceof InetSocketAddress)
+        {
+            _fqdn = ((InetSocketAddress) address).getHostName();
+        }
+        else
+        {
+            throw new IllegalArgumentException("Unsupported socket address class: " + address);
+        }
         _sender = sender;
     }
 
@@ -445,14 +461,18 @@
 
 
                 ServerProtocolEngine newDelegate = null;
-                byte[] newestSupported = null;
+                byte[] supportedReplyBytes = null;
+                byte[] defaultSupportedReplyBytes = null;
+                AmqpProtocolVersion supportedReplyVersion = null;
 
+                //Check the supported versions for a header match, and if there is one save the
+                //delegate. Also save most recent supported version and associated reply header bytes
                 for(int i = 0; newDelegate == null && i < _creators.length; i++)
                 {
-
                     if(_supported.contains(_creators[i].getVersion()))
                     {
-                        newestSupported = _creators[i].getHeaderIdentifier();
+                        supportedReplyBytes = _creators[i].getHeaderIdentifier();
+                        supportedReplyVersion = _creators[i].getVersion();
                         byte[] compareBytes = _creators[i].getHeaderIdentifier();
                         boolean equal = true;
                         for(int j = 0; equal && j<compareBytes.length; j++)
@@ -464,12 +484,35 @@
                             newDelegate = _creators[i].getProtocolEngine();
                         }
                     }
+
+                    //If there is a configured default reply to an unsupported version initiation,
+                    //then save the associated reply header bytes when we encounter them
+                    if(_defaultSupportedReply != null && _creators[i].getVersion() == _defaultSupportedReply)
+                    {
+                        defaultSupportedReplyBytes = _creators[i].getHeaderIdentifier();
+                    }
                 }
 
-                // If no delegate is found then send back the most recent support protocol version id
+                // If no delegate is found then send back a supported protocol version id
                 if(newDelegate == null)
                 {
-                    _sender.send(ByteBuffer.wrap(newestSupported));
+                    //if a default reply was specified use its reply header instead of the most recent supported version
+                    if(_defaultSupportedReply != null && !(_defaultSupportedReply == supportedReplyVersion))
+                    {
+                        if(_logger.isDebugEnabled())
+                        {
+                            _logger.debug("Default reply to unsupported protocol version was configured, changing reply from "
+                                    + supportedReplyVersion + " to " + _defaultSupportedReply);
+                        }
+
+                        supportedReplyBytes = defaultSupportedReplyBytes;
+                        supportedReplyVersion = _defaultSupportedReply;
+                    }
+                    if(_logger.isDebugEnabled())
+                    {
+                        _logger.debug("Unsupported protocol version requested, replying with: " + supportedReplyVersion);
+                    }
+                    _sender.send(ByteBuffer.wrap(supportedReplyBytes));
                     _sender.flush();
 
                     _delegate = new ClosedDelegateProtocolEngine();
@@ -482,7 +525,6 @@
                     _delegate = newDelegate;
 
                     _header.flip();
-                    _delegate.setNetworkConnection(_network, _sender);
                     _delegate.received(_header);
                     if(msg.hasRemaining())
                     {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java
index 7e327b2..552b1c7 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java
@@ -20,38 +20,38 @@
 */
 package org.apache.qpid.server.protocol;
 
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
-
 import org.apache.qpid.protocol.ProtocolEngineFactory;
 import org.apache.qpid.protocol.ServerProtocolEngine;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.registry.IApplicationRegistry;
-import org.apache.qpid.transport.network.NetworkConnection;
+
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
 
 public class MultiVersionProtocolEngineFactory implements ProtocolEngineFactory
 {
     private static final AtomicLong ID_GENERATOR = new AtomicLong(0);
 
     private final IApplicationRegistry _appRegistry;
-    private final String _fqdn;
     private final Set<AmqpProtocolVersion> _supported;
+    private final AmqpProtocolVersion _defaultSupportedReply;
 
-    public MultiVersionProtocolEngineFactory(String fqdn, Set<AmqpProtocolVersion> supportedVersions)
+    public MultiVersionProtocolEngineFactory(final Set<AmqpProtocolVersion> supportedVersions, final AmqpProtocolVersion defaultSupportedReply)
     {
+        if(defaultSupportedReply != null && !supportedVersions.contains(defaultSupportedReply))
+        {
+            throw new IllegalArgumentException("The configured default reply (" + defaultSupportedReply
+                                             + ") to an unsupported protocol version initiation is itself not supported!");
+        }
+
         _appRegistry = ApplicationRegistry.getInstance();
-        _fqdn = fqdn;
         _supported = supportedVersions;
-    }
-
-    public ServerProtocolEngine newProtocolEngine(NetworkConnection network)
-    {
-        return new MultiVersionProtocolEngine(_appRegistry, _fqdn, _supported, network, ID_GENERATOR.getAndIncrement());
+        _defaultSupportedReply = defaultSupportedReply;
     }
 
     public ServerProtocolEngine newProtocolEngine()
     {
-        return new MultiVersionProtocolEngine(_appRegistry, _fqdn, _supported, ID_GENERATOR.getAndIncrement());
+        return new MultiVersionProtocolEngine(_appRegistry, _supported, _defaultSupportedReply, ID_GENERATOR.getAndIncrement());
     }
 
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/ProtocolEngine_0_10.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/ProtocolEngine_0_10.java
index 5d4b8c6..182ef1e 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/ProtocolEngine_0_10.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/ProtocolEngine_0_10.java
@@ -21,15 +21,19 @@
 package org.apache.qpid.server.protocol;
 
 import org.apache.qpid.protocol.ServerProtocolEngine;
-import org.apache.qpid.transport.Sender;
-import org.apache.qpid.transport.network.InputHandler;
-import org.apache.qpid.transport.network.Assembler;
-import org.apache.qpid.transport.network.Disassembler;
-import org.apache.qpid.transport.network.NetworkConnection;
-import org.apache.qpid.server.configuration.*;
-import org.apache.qpid.server.transport.ServerConnection;
+import org.apache.qpid.server.configuration.ConfigStore;
+import org.apache.qpid.server.configuration.ConfiguredObject;
+import org.apache.qpid.server.configuration.ConnectionConfig;
+import org.apache.qpid.server.configuration.ConnectionConfigType;
+import org.apache.qpid.server.configuration.VirtualHostConfig;
 import org.apache.qpid.server.logging.messages.ConnectionMessages;
 import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.server.transport.ServerConnection;
+import org.apache.qpid.transport.Sender;
+import org.apache.qpid.transport.network.Assembler;
+import org.apache.qpid.transport.network.Disassembler;
+import org.apache.qpid.transport.network.InputHandler;
+import org.apache.qpid.transport.network.NetworkConnection;
 
 import java.net.SocketAddress;
 import java.nio.ByteBuffer;
@@ -86,8 +90,8 @@
         _connection.setSender(new Disassembler(sender, MAX_FRAME_SIZE));
 
         // FIXME Two log messages to maintain compatibility with earlier protocol versions
-        _connection.getLogActor().message(ConnectionMessages.OPEN(null, null, false, false));
-        _connection.getLogActor().message(ConnectionMessages.OPEN(null, "0-10", false, true));
+        _connection.getLogActor().message(ConnectionMessages.OPEN(null, null, null, false, false, false));
+        _connection.getLogActor().message(ConnectionMessages.OPEN(null, "0-10", null, false, true, false));
     }
 
     public SocketAddress getRemoteAddress()
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java
index ed9d589..de2e1b6 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java
@@ -29,7 +29,6 @@
 import java.util.concurrent.ConcurrentHashMap;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQInternalException;
-import org.apache.qpid.AMQInvalidArgumentException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.amqp_1_0.transport.DeliveryStateHandler;
 import org.apache.qpid.amqp_1_0.transport.LinkEndpoint;
@@ -54,6 +53,7 @@
 import org.apache.qpid.amqp_1_0.type.transport.Detach;
 import org.apache.qpid.amqp_1_0.type.transport.Error;
 import org.apache.qpid.amqp_1_0.type.transport.Transfer;
+import org.apache.qpid.filter.selector.ParseException;
 import org.apache.qpid.server.exchange.DirectExchange;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.exchange.TopicExchange;
@@ -135,7 +135,7 @@
 
                             actualFilters.put(entry.getKey(), entry.getValue());
                         }
-                        catch (AMQInvalidArgumentException e)
+                        catch (ParseException e)
                         {
                             Error error = new Error();
                             error.setCondition(AmqpError.INVALID_FIELD);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java
index 2c04a62..f6bf662 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java
@@ -20,9 +20,10 @@
 */
 package org.apache.qpid.server.queue;
 
-import java.util.Map;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import java.util.Map;
+
 public class AMQPriorityQueue extends OutOfOrderQueue
 {
     protected AMQPriorityQueue(final String name,
@@ -39,6 +40,6 @@
 
     public int getPriorities()
     {
-        return ((PriorityQueueList) _entries).getPriorities();
+        return ((PriorityQueueList) getEntries()).getPriorities();
     }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
index 32d9c48..e643338 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
@@ -22,20 +22,18 @@
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
-import org.apache.qpid.server.logging.LogSubject;
-import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.binding.Binding;
 import org.apache.qpid.server.configuration.QueueConfig;
+import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.exchange.ExchangeReferrer;
+import org.apache.qpid.server.logging.LogSubject;
 import org.apache.qpid.server.management.Managable;
 import org.apache.qpid.server.management.ManagedObject;
+import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.security.AuthorizationHolder;
 import org.apache.qpid.server.store.TransactionLogResource;
 import org.apache.qpid.server.subscription.Subscription;
-import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
 import java.util.List;
@@ -142,10 +140,9 @@
     public List<QueueEntry> getMessagesRangeOnTheQueue(final long fromPosition, final long toPosition);
 
 
-    void moveMessagesToAnotherQueue(long fromMessageId, long toMessageId, String queueName,
-                                                        ServerTransaction transaction);
+    void moveMessagesToAnotherQueue(long fromMessageId, long toMessageId, String queueName);
 
-    void copyMessagesToAnotherQueue(long fromMessageId, long toMessageId, String queueName, ServerTransaction transaction);
+    void copyMessagesToAnotherQueue(long fromMessageId, long toMessageId, String queueName);
 
     void removeMessagesFromQueue(long fromMessageId, long toMessageId);
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
index 14ca147..e04ab8c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
@@ -20,8 +20,6 @@
  */
 package org.apache.qpid.server.queue;
 
-import java.util.HashMap;
-import java.util.Map;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.exchange.ExchangeDefaults;
@@ -35,6 +33,9 @@
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public class AMQQueueFactory
 {
     public static final String X_QPID_PRIORITIES = "x-qpid-priorities";
@@ -48,6 +49,10 @@
     public static final String X_QPID_MAXIMUM_DELIVERY_COUNT = "x-qpid-maximum-delivery-count";
     public static final String DEFAULT_DLQ_NAME_SUFFIX = "_DLQ";
 
+    private AMQQueueFactory()
+    {
+    }
+
     private abstract static class QueueProperty
     {
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
index 143a6ae..b0d4cb3 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
@@ -20,6 +20,7 @@
  */
 package org.apache.qpid.server.queue;
 
+import org.apache.commons.lang.time.FastDateFormat;
 import org.apache.log4j.Logger;
 
 import org.apache.qpid.AMQException;
@@ -31,12 +32,10 @@
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.management.AMQManagedObject;
 import org.apache.qpid.server.management.ManagedObject;
-import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.message.AMQMessage;
+import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.message.MessageTransferMessage;
-import org.apache.qpid.server.txn.ServerTransaction;
-import org.apache.qpid.server.txn.LocalTransaction;
+import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.transport.MessageProperties;
 
 import javax.management.JMException;
@@ -56,9 +55,10 @@
 import javax.management.openmbean.TabularData;
 import javax.management.openmbean.TabularDataSupport;
 import javax.management.openmbean.TabularType;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
 
-import java.text.SimpleDateFormat;
-import java.util.*;
 
 /**
  * AMQQueueMBean is the management bean for an {@link AMQQueue}.
@@ -72,11 +72,13 @@
 {
 
     /** Used for debugging purposes. */
-    private static final Logger _logger = Logger.getLogger(AMQQueueMBean.class);
+    private static final Logger LOGGER = Logger.getLogger(AMQQueueMBean.class);
 
     /** Date/time format used for message expiration and message timestamp formatting */
     public static final String JMSTIMESTAMP_DATETIME_FORMAT = "MM-dd-yy HH:mm:ss.SSS z";
 
+    private static final FastDateFormat FAST_DATE_FORMAT = FastDateFormat.getInstance(JMSTIMESTAMP_DATETIME_FORMAT);
+
     private final AMQQueue _queue;
     private final String _queueName;
     // OpenMBean data types for viewMessages method
@@ -347,14 +349,14 @@
     public void notifyClients(NotificationCheck notification, AMQQueue queue, String notificationMsg)
     {
         // important : add log to the log file - monitoring tools may be looking for this
-        _logger.info(notification.name() + " On Queue " + queue.getNameShortString() + " - " + notificationMsg);
+        LOGGER.info(notification.name() + " On Queue " + queue.getNameShortString() + " - " + notificationMsg);
         notificationMsg = notification.name() + " " + notificationMsg;
 
         _lastNotification =
-            new Notification(MonitorNotification.THRESHOLD_VALUE_EXCEEDED, this, ++_notificationSequenceNumber,
+            new Notification(MonitorNotification.THRESHOLD_VALUE_EXCEEDED, this, incrementAndGetSequenceNumber(),
                 System.currentTimeMillis(), notificationMsg);
 
-        _broadcaster.sendNotification(_lastNotification);
+        getBroadcaster().sendNotification(_lastNotification);
     }
 
     public Notification getLastNotification()
@@ -491,7 +493,7 @@
                     ContentHeaderBody headerBody = msg.getContentHeaderBody();
                     // Create header attributes list
                     headerAttributes = getMessageHeaderProperties(headerBody);
-                    itemValues = new Object[]{msg.getMessageId(), headerAttributes, headerBody.bodySize, queueEntry.isRedelivered(), position, queueEntry.getDeliveryCount()};
+                    itemValues = new Object[]{msg.getMessageId(), headerAttributes, headerBody.getBodySize(), queueEntry.isRedelivered(), position, queueEntry.getDeliveryCount()};
                 }
                 else if(serverMsg instanceof MessageTransferMessage)
                 {
@@ -589,18 +591,8 @@
     private void addStringifiedJMSTimestamoAndJMSExpiration(final List<String> list,
             final long expirationDate, final long timestampDate)
     {
-        final SimpleDateFormat dateFormat;
-        if (expirationDate != 0 || timestampDate != 0)
-        {
-            dateFormat = new SimpleDateFormat(JMSTIMESTAMP_DATETIME_FORMAT);
-        }
-        else
-        {
-            dateFormat = null;
-        }
-
-        final String formattedExpirationDate = (expirationDate != 0) ? dateFormat.format(new Date(expirationDate)) : null;
-        final String formattedTimestampDate = (timestampDate != 0) ? dateFormat.format(new Date(timestampDate)) : null;
+        final String formattedExpirationDate = (expirationDate != 0) ? FAST_DATE_FORMAT.format(expirationDate) : null;
+        final String formattedTimestampDate = (timestampDate != 0) ? FAST_DATE_FORMAT.format(timestampDate) : null;
         list.add("JMSExpiration = " + formattedExpirationDate);
         list.add("JMSTimestamp = " + formattedTimestampDate);
     }
@@ -619,9 +611,7 @@
             throw new OperationsException("\"From MessageId\" should be greater than 0 and less than \"To MessageId\"");
         }
 
-        ServerTransaction txn = new LocalTransaction(_queue.getVirtualHost().getMessageStore());
-        _queue.moveMessagesToAnotherQueue(fromMessageId, toMessageId, toQueueName, txn);
-        txn.commit();
+        _queue.moveMessagesToAnotherQueue(fromMessageId, toMessageId, toQueueName);
     }
 
     /**
@@ -654,13 +644,7 @@
             throw new OperationsException("\"From MessageId\" should be greater than 0 and less than \"To MessageId\"");
         }
 
-        ServerTransaction txn = new LocalTransaction(_queue.getVirtualHost().getMessageStore());
-
-        _queue.copyMessagesToAnotherQueue(fromMessageId, toMessageId, toQueueName, txn);
-
-        txn.commit();
-
-
+        _queue.copyMessagesToAnotherQueue(fromMessageId, toMessageId, toQueueName);
     }
 
     /**
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/BaseQueue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/BaseQueue.java
index 0bd40e8..35b7cac 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/BaseQueue.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/BaseQueue.java
@@ -21,10 +21,10 @@
 
 package org.apache.qpid.server.queue;
 
-import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.store.TransactionLogResource;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.store.TransactionLogResource;
 
 public interface BaseQueue extends TransactionLogResource
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java
index b5293f5..2c645cc 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java
@@ -41,7 +41,7 @@
 
     public String getConflationKey()
     {
-        return ((ConflationQueueList) _entries).getConflationKey();
+        return ((ConflationQueueList) getEntries()).getConflationKey();
     }
 
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ConflationQueueList.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ConflationQueueList.java
index ab0a567..6a2e4f1 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ConflationQueueList.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ConflationQueueList.java
@@ -21,13 +21,13 @@
 
 package org.apache.qpid.server.queue;
 
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicReference;
-
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.txn.AutoCommitTransaction;
 import org.apache.qpid.server.txn.ServerTransaction;
 
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicReference;
+
 public class ConflationQueueList extends SimpleQueueEntryList
 {
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/Filterable.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/Filterable.java
index eaa3992..50d8f41 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/Filterable.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/Filterable.java
@@ -20,8 +20,6 @@
 */
 package org.apache.qpid.server.queue;
 
-import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.AMQException;
 import org.apache.qpid.server.message.AMQMessageHeader;
 
 public interface Filterable
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/InboundMessageAdapter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/InboundMessageAdapter.java
index 31e9725..bbc33ca 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/InboundMessageAdapter.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/InboundMessageAdapter.java
@@ -21,9 +21,9 @@
 
 package org.apache.qpid.server.queue;
 
-import org.apache.qpid.server.message.InboundMessage;
-import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.message.AMQMessageHeader;
+import org.apache.qpid.server.message.InboundMessage;
 
 public class InboundMessageAdapter implements InboundMessage
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/IncomingMessage.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/IncomingMessage.java
index 19a7a15..c5a610c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/IncomingMessage.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/IncomingMessage.java
@@ -20,25 +20,26 @@
  */
 package org.apache.qpid.server.queue;
 
-import org.apache.qpid.framing.abstraction.MessagePublishInfo;
-import org.apache.qpid.framing.abstraction.ContentChunk;
-import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
-import org.apache.qpid.server.store.StoredMessage;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.message.InboundMessage;
-import org.apache.qpid.server.message.AMQMessageHeader;
-import org.apache.qpid.server.message.EnqueableMessage;
-import org.apache.qpid.server.message.MessageContentSource;
-import org.apache.qpid.server.message.MessageMetaData;
-import org.apache.qpid.AMQException;
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.abstraction.ContentChunk;
+import org.apache.qpid.framing.abstraction.MessagePublishInfo;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.message.AMQMessageHeader;
+import org.apache.qpid.server.message.EnqueableMessage;
+import org.apache.qpid.server.message.InboundMessage;
+import org.apache.qpid.server.message.MessageContentSource;
+import org.apache.qpid.server.message.MessageMetaData;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.store.StoredMessage;
+
+import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
-import java.nio.ByteBuffer;
 
 public class IncomingMessage implements Filterable, InboundMessage, EnqueableMessage, MessageContentSource
 {
@@ -69,8 +70,6 @@
 
     private Exchange _exchange;
 
-
-    private int _receivedChunkCount = 0;
     private List<ContentChunk> _contentChunks = new ArrayList<ContentChunk>();
 
     // we keep both the original meta data object and the store reference to it just in case the
@@ -79,13 +78,20 @@
     private MessageMetaData _messageMetaData;
 
     private StoredMessage<MessageMetaData> _storedMessageHandle;
+    private Object _connectionReference;
 
 
     public IncomingMessage(
             final MessagePublishInfo info
     )
     {
+        this(info, null);
+    }
+
+    public IncomingMessage(MessagePublishInfo info, Object reference)
+    {
         _messagePublishInfo = info;
+        _connectionReference = reference;
     }
 
     public void setContentHeaderBody(final ContentHeaderBody contentHeaderBody) throws AMQException
@@ -124,12 +130,6 @@
 
     }
 
-    public MessageMetaData headersReceived()
-    {
-
-        return headersReceived(System.currentTimeMillis());
-    }
-
     public MessageMetaData headersReceived(long currentTime)
     {
         _messageMetaData = new MessageMetaData(_messagePublishInfo, _contentHeaderBody, 0, currentTime);
@@ -142,21 +142,15 @@
         return _destinationQueues;
     }
 
-    public int addContentBodyFrame(final ContentChunk contentChunk)
-            throws AMQException
+    public void addContentBodyFrame(final ContentChunk contentChunk) throws AMQException
     {
-        _storedMessageHandle.addContent((int)_bodyLengthReceived, ByteBuffer.wrap(contentChunk.getData()));
         _bodyLengthReceived += contentChunk.getSize();
         _contentChunks.add(contentChunk);
-
-
-
-        return _receivedChunkCount++;
     }
 
     public boolean allContentReceived()
     {
-        return (_bodyLengthReceived == getContentHeader().bodySize);
+        return (_bodyLengthReceived == getContentHeader().getBodySize());
     }
 
     public AMQShortString getExchange()
@@ -217,7 +211,7 @@
 
     public long getSize()
     {
-        return getContentHeader().bodySize;
+        return getContentHeader().getBodySize();
     }
 
     public long getMessageNumber()
@@ -251,18 +245,12 @@
         return _expiration;
     }
 
-    public int getReceivedChunkCount()
-    {
-        return _receivedChunkCount;
-    }
-
-
     public int getBodyCount() throws AMQException
     {
         return _contentChunks.size();
     }
 
-    public ContentChunk getContentChunk(int index) throws IllegalArgumentException, AMQException
+    public ContentChunk getContentChunk(int index)
     {
         return _contentChunks.get(index);
     }
@@ -317,4 +305,14 @@
     {
         return _storedMessageHandle;
     }
+
+    public Object getConnectionReference()
+    {
+        return _connectionReference;
+    }
+
+    public MessageMetaData getMessageMetaData()
+    {
+        return _messageMetaData;
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/NotificationCheck.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/NotificationCheck.java
index d1fb0f3..c1ebbe4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/NotificationCheck.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/NotificationCheck.java
@@ -20,7 +20,6 @@
  */

 package org.apache.qpid.server.queue;

 

-import org.apache.qpid.AMQException;

 import org.apache.qpid.server.message.ServerMessage;

 

 public enum NotificationCheck

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java
index 0220a55..53121fc 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java
@@ -1,11 +1,11 @@
 package org.apache.qpid.server.queue;
 
-import java.util.Map;
-
 import org.apache.qpid.server.subscription.Subscription;
 import org.apache.qpid.server.subscription.SubscriptionList;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import java.util.Map;
+
 public abstract class OutOfOrderQueue extends SimpleAMQQueue
 {
 
@@ -20,7 +20,7 @@
     protected void checkSubscriptionsNotAheadOfDelivery(final QueueEntry entry)
     {
         // check that all subscriptions are not in advance of the entry
-        SubscriptionList.SubscriptionNodeIterator subIter = _subscriptionList.iterator();
+        SubscriptionList.SubscriptionNodeIterator subIter = getSubscriptionList().iterator();
         while(subIter.advance() && !entry.isAcquired())
         {
             final Subscription subscription = subIter.getNode().getSubscription();
@@ -29,7 +29,7 @@
                 QueueContext context = (QueueContext) subscription.getQueueContext();
                 if(context != null)
                 {
-                    QueueEntry released = context._releasedEntry;
+                    QueueEntry released = context.getReleasedEntry();
                     while(!entry.isAcquired() && (released == null || released.compareTo(entry) > 0))
                     {
                         if(QueueContext._releasedUpdater.compareAndSet(context,released,entry))
@@ -38,7 +38,7 @@
                         }
                         else
                         {
-                            released = context._releasedEntry;
+                            released = context.getReleasedEntry();
                         }
                     }
                 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java
index 79d3ab5..05141a4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/PriorityQueueList.java
@@ -74,7 +74,7 @@
         {
             final QueueEntryList<?> nodeEntryList = node.getQueueEntryList();
             int index;
-            for(index = _priorityLists.length-1; _priorityLists[index] != nodeEntryList; index--);
+            for(index = _priorityLists.length-1; _priorityLists[index] != nodeEntryList; index--) {};
 
             while(next == null && index != 0)
             {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueContext.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueContext.java
index 825a85a..c8f04c7 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueContext.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueContext.java
@@ -25,8 +25,8 @@
 
 final class QueueContext implements AMQQueue.Context
 {
-    volatile QueueEntry _lastSeenEntry;
-    volatile QueueEntry _releasedEntry;
+    private volatile QueueEntry _lastSeenEntry;
+    private volatile QueueEntry _releasedEntry;
 
     static final AtomicReferenceFieldUpdater<QueueContext, QueueEntry>
             _lastSeenUpdater =
@@ -46,4 +46,10 @@
     {
         return _lastSeenEntry;
     }
+
+
+    QueueEntry getReleasedEntry()
+    {
+        return _releasedEntry;
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueEntry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueEntry.java
index 142cfdd..c33309b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueEntry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueEntry.java
@@ -1,10 +1,8 @@
 package org.apache.qpid.server.queue;
 
-import java.util.Collection;
-
 import org.apache.qpid.AMQException;
-import org.apache.qpid.server.subscription.Subscription;
 import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.subscription.Subscription;
 
 /*
 *
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java
index 82c6a2f..4049071 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java
@@ -34,7 +34,6 @@
 import org.apache.qpid.server.message.MessageReference;
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.subscription.Subscription;
-import org.apache.qpid.server.txn.AutoCommitTransaction;
 import org.apache.qpid.server.txn.LocalTransaction;
 import org.apache.qpid.server.txn.ServerTransaction;
 
@@ -416,11 +415,19 @@
 
         if (alternateExchange != null)
         {
-            final List<? extends BaseQueue> rerouteQueues = alternateExchange.route(new InboundMessageAdapter(this));
+            InboundMessageAdapter inboundMessageAdapter = new InboundMessageAdapter(this);
+            List<? extends BaseQueue> queues = alternateExchange.route(inboundMessageAdapter);
             final ServerMessage message = getMessage();
-            if (rerouteQueues != null && rerouteQueues.size() != 0)
+            if ((queues == null || queues.size() == 0) && alternateExchange.getAlternateExchange() != null)
             {
+                queues = alternateExchange.getAlternateExchange().route(inboundMessageAdapter);
+            }
 
+
+
+            if (queues != null && queues.size() != 0)
+            {
+                final List<? extends BaseQueue> rerouteQueues = queues;
                 ServerTransaction txn = new LocalTransaction(getQueue().getVirtualHost().getMessageStore());
 
                 txn.enqueue(rerouteQueues, message, new ServerTransaction.Action()
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java
index a537e0c..80f6bd1 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.server.queue;
 
-import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRunner.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRunner.java
index 0d44fe7..22a2029 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRunner.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRunner.java
@@ -20,17 +20,16 @@
  */
 package org.apache.qpid.server.queue;
 
-import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.queue.QueueRunner;
-import org.apache.qpid.server.queue.SimpleAMQQueue;
-
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.log4j.Logger;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.transport.TransportException;
+
 /**
  * QueueRunners are Runnables used to process a queue when requiring
  * asynchronous message delivery to subscriptions, which is necessary
@@ -47,7 +46,6 @@
     private static int SCHEDULED = 1;
     private static int RUNNING = 2;
 
-
     private final AtomicInteger _scheduled = new AtomicInteger(IDLE);
 
     private final AtomicBoolean _stateChange = new AtomicBoolean();
@@ -55,8 +53,6 @@
     private final AtomicLong _lastRunAgain = new AtomicLong();
     private final AtomicLong _lastRunTime = new AtomicLong();
 
-    private long _continues;
-
     public QueueRunner(SimpleAMQQueue queue)
     {
         _queue = queue;
@@ -74,24 +70,35 @@
 
                 runAgain = _queue.processQueue(this);
             }
-            catch (AMQException e)
+            catch (final AMQException e)
             {
                 _logger.error("Exception during asynchronous delivery by " + toString(), e);
             }
+            catch (final TransportException transe)
+            {
+                final String errorMessage = "Problem during asynchronous delivery by " + toString();
+                if(_logger.isDebugEnabled())
+                {
+                    _logger.debug(errorMessage, transe);
+                }
+                else
+                {
+                    _logger.info(errorMessage + ' ' + transe.getMessage());
+                }
+            }
             finally
             {
                 CurrentActor.remove();
-            }
-            _scheduled.compareAndSet(RUNNING, IDLE);
-            long stateChangeCount = _queue.getStateChangeCount();
-            _lastRunAgain.set(runAgain);
-            _lastRunTime.set(System.nanoTime());
-            if(runAgain == 0L || runAgain != stateChangeCount || _stateChange.compareAndSet(true,false))
-            {
-                _continues++;
-                if(_scheduled.compareAndSet(IDLE, SCHEDULED))
+                _scheduled.compareAndSet(RUNNING, IDLE);
+                final long stateChangeCount = _queue.getStateChangeCount();
+                _lastRunAgain.set(runAgain);
+                _lastRunTime.set(System.nanoTime());
+                if(runAgain == 0L || runAgain != stateChangeCount || _stateChange.compareAndSet(true,false))
                 {
-                    _queue.execute(this);
+                    if(_scheduled.compareAndSet(IDLE, SCHEDULED))
+                    {
+                        _queue.execute(this);
+                    }
                 }
             }
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
index dfad915..c37d0e2 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
@@ -27,12 +27,16 @@
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 import javax.management.JMException;
+
+import javax.management.JMException;
+
 import org.apache.log4j.Logger;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQSecurityException;
@@ -99,13 +103,10 @@
 
     private Exchange _alternateExchange;
 
-    /** Used to track bindings to exchanges so that on deletion they can easily be cancelled. */
 
+    private final QueueEntryList<QueueEntry> _entries;
 
-
-    protected final QueueEntryList _entries;
-
-    protected final SubscriptionList _subscriptionList = new SubscriptionList();
+    private final SubscriptionList _subscriptionList = new SubscriptionList();
 
     private volatile Subscription _exclusiveSubscriber;
 
@@ -137,19 +138,19 @@
     private final AtomicInteger _bindingCountHigh = new AtomicInteger();
 
     /** max allowed size(KB) of a single message */
-    public long _maximumMessageSize = ApplicationRegistry.getInstance().getConfiguration().getMaximumMessageSize();
+    private long _maximumMessageSize = ApplicationRegistry.getInstance().getConfiguration().getMaximumMessageSize();
 
     /** max allowed number of messages on a queue. */
-    public long _maximumMessageCount = ApplicationRegistry.getInstance().getConfiguration().getMaximumMessageCount();
+    private long _maximumMessageCount = ApplicationRegistry.getInstance().getConfiguration().getMaximumMessageCount();
 
     /** max queue depth for the queue */
-    public long _maximumQueueDepth = ApplicationRegistry.getInstance().getConfiguration().getMaximumQueueDepth();
+    private long _maximumQueueDepth = ApplicationRegistry.getInstance().getConfiguration().getMaximumQueueDepth();
 
     /** maximum message age before alerts occur */
-    public long _maximumMessageAge = ApplicationRegistry.getInstance().getConfiguration().getMaximumMessageAge();
+    private long _maximumMessageAge = ApplicationRegistry.getInstance().getConfiguration().getMaximumMessageAge();
 
     /** the minimum interval between sending out consecutive alerts of the same type */
-    public long _minimumAlertRepeatGap = ApplicationRegistry.getInstance().getConfiguration().getMinimumAlertRepeatGap();
+    private long _minimumAlertRepeatGap = ApplicationRegistry.getInstance().getConfiguration().getMinimumAlertRepeatGap();
 
     private long _capacity = ApplicationRegistry.getInstance().getConfiguration().getCapacity();
 
@@ -167,7 +168,7 @@
     private AtomicInteger _deliveredMessages = new AtomicInteger();
     private AtomicBoolean _stopped = new AtomicBoolean(false);
 
-    private final ConcurrentMap<AMQSessionModel, Boolean> _blockedChannels = new ConcurrentHashMap<AMQSessionModel, Boolean>();
+    private final Set<AMQSessionModel> _blockedChannels = new ConcurrentSkipListSet<AMQSessionModel>();
 
     private final AtomicBoolean _deleted = new AtomicBoolean(false);
     private final List<Task> _deleteTaskList = new CopyOnWriteArrayList<Task>();
@@ -455,7 +456,10 @@
             }
         }
 
-        _activeSubscriberCount.incrementAndGet();
+        if(subscription.isActive())
+        {
+            _activeSubscriberCount.incrementAndGet();
+        }
         subscription.setStateListener(this);
         subscription.setQueueContext(new QueueContext(_entries.getHead()));
 
@@ -778,7 +782,9 @@
     private boolean mightAssign(final Subscription sub, final QueueEntry entry)
     {
         if(_messageGroupManager == null || !sub.acquires())
+        {
             return true;
+        }
         Subscription assigned = _messageGroupManager.getAssignedSubscription(entry);
         return (assigned == null) || (assigned == sub);
     }
@@ -848,7 +854,7 @@
                 QueueContext context = (QueueContext) subscription.getQueueContext();
                 if(context != null)
                 {
-                    QueueEntry subnode = context._lastSeenEntry;
+                    QueueEntry subnode = context.getLastSeenEntry();
                     if(subnode.compareTo(entry)<0)
                     {
                         return false;
@@ -872,7 +878,7 @@
     private void setLastSeenEntry(final Subscription sub, final QueueEntry entry)
     {
         QueueContext subContext = (QueueContext) sub.getQueueContext();
-        QueueEntry releasedEntry = subContext._releasedEntry;
+        QueueEntry releasedEntry = subContext.getReleasedEntry();
 
         QueueContext._lastSeenUpdater.set(subContext, entry);
         if(releasedEntry == entry)
@@ -889,7 +895,7 @@
         {
             QueueEntry oldEntry;
 
-            while((oldEntry  = subContext._releasedEntry) == null || oldEntry.compareTo(entry) > 0)
+            while((oldEntry  = subContext.getReleasedEntry()) == null || oldEntry.compareTo(entry) > 0)
             {
                 if(QueueContext._releasedUpdater.compareAndSet(subContext, oldEntry, entry))
                 {
@@ -1113,6 +1119,17 @@
         return _stateChangeCount.get();
     }
 
+    /** Used to track bindings to exchanges so that on deletion they can easily be cancelled. */
+    protected QueueEntryList getEntries()
+    {
+        return _entries;
+    }
+
+    protected SubscriptionList getSubscriptionList()
+    {
+        return _subscriptionList;
+    }
+
 
     public static interface QueueEntryFilter
     {
@@ -1226,19 +1243,10 @@
 
     public void moveMessagesToAnotherQueue(final long fromMessageId,
                                            final long toMessageId,
-                                           String queueName,
-                                           ServerTransaction txn) throws IllegalArgumentException
+                                           String destinationQueueName) throws IllegalArgumentException
     {
 
-        final AMQQueue toQueue = getVirtualHost().getQueueRegistry().getQueue(new AMQShortString(queueName));
-        if (toQueue == null)
-        {
-            throw new IllegalArgumentException("Queue '" + queueName + "' is not registered with the virtualhost.");
-        }
-        else if (toQueue == this)
-        {
-            throw new IllegalArgumentException("The destination queue cant be the same as the source queue");
-        }
+        final AMQQueue toQueue = getValidatedDestinationQueue(destinationQueueName);
 
         List<QueueEntry> entries = getMessagesOnTheQueue(new QueueEntryFilter()
         {
@@ -1258,65 +1266,68 @@
         });
 
 
-
-        // Move the messages in on the message store.
-        for (final QueueEntry entry : entries)
+        final ServerTransaction txn = new LocalTransaction(getVirtualHost().getMessageStore());
+        boolean shouldRollback = true;
+        try
         {
-            final ServerMessage message = entry.getMessage();
-            txn.enqueue(toQueue, message,
-                        new ServerTransaction.Action()
-                        {
-
-                            public void postCommit()
+            // Move the messages in on the message store.
+            for (final QueueEntry entry : entries)
+            {
+                final ServerMessage message = entry.getMessage();
+                txn.enqueue(toQueue, message,
+                            new ServerTransaction.Action()
                             {
-                                try
+
+                                public void postCommit()
                                 {
-                                    toQueue.enqueue(message);
+                                    try
+                                    {
+                                        toQueue.enqueue(message);
+                                    }
+                                    catch (AMQException e)
+                                    {
+                                        throw new RuntimeException(e);
+                                    }
                                 }
-                                catch (AMQException e)
+
+                                public void onRollback()
                                 {
-                                    throw new RuntimeException(e);
+                                    entry.release();
                                 }
-                            }
-
-                            public void onRollback()
-                            {
-                                entry.release();
-                            }
-                        });
-            txn.dequeue(this, message,
-                        new ServerTransaction.Action()
-                        {
-
-                            public void postCommit()
-                            {
-                                entry.discard();
-                            }
-
-                            public void onRollback()
+                            });
+                txn.dequeue(this, message,
+                            new ServerTransaction.Action()
                             {
 
-                            }
-                        });
+                                public void postCommit()
+                                {
+                                    entry.discard();
+                                }
 
+                                public void onRollback()
+                                {
+
+                                }
+                            });
+            }
+            txn.commit();
+            shouldRollback = false;
+        }
+        finally
+        {
+            if (shouldRollback)
+            {
+                txn.rollback();
+            }
         }
 
     }
 
     public void copyMessagesToAnotherQueue(final long fromMessageId,
                                            final long toMessageId,
-                                           String queueName,
-                                           final ServerTransaction txn) throws IllegalArgumentException
+                                           String destinationQueueName) throws IllegalArgumentException
     {
-        final AMQQueue toQueue = getVirtualHost().getQueueRegistry().getQueue(new AMQShortString(queueName));
-        if (toQueue == null)
-        {
-            throw new IllegalArgumentException("Queue '" + queueName + "' is not registered with the virtualhost.");
-        }
-        else if (toQueue == this)
-        {
-            throw new IllegalArgumentException("The destination queue cant be the same as the source queue");
-        }
+        final AMQQueue toQueue = getValidatedDestinationQueue(destinationQueueName);
 
         List<QueueEntry> entries = getMessagesOnTheQueue(new QueueEntryFilter()
         {
@@ -1334,36 +1345,63 @@
             }
         });
 
-
-        // Move the messages in on the message store.
-        for (QueueEntry entry : entries)
+        final ServerTransaction txn = new LocalTransaction(_virtualHost.getMessageStore());
+        boolean shouldRollback = true;
+        try
         {
-            final ServerMessage message = entry.getMessage();
-
-            txn.enqueue(toQueue, message, new ServerTransaction.Action()
+            // Copy the messages in on the message store.
+            for (QueueEntry entry : entries)
             {
-                public void postCommit()
+                final ServerMessage message = entry.getMessage();
+
+                txn.enqueue(toQueue, message, new ServerTransaction.Action()
                 {
-                    try
+                    public void postCommit()
                     {
-                        toQueue.enqueue(message);
+                        try
+                        {
+                            toQueue.enqueue(message);
+                        }
+                        catch (AMQException e)
+                        {
+                            throw new RuntimeException(e);
+                        }
                     }
-                    catch (AMQException e)
+
+                    public void onRollback()
                     {
-                        throw new RuntimeException(e);
                     }
-                }
+                });
 
-                public void onRollback()
-                {
+            }
 
-                }
-            });
-
+            txn.commit();
+            shouldRollback = false;
+        }
+        finally
+        {
+            if (shouldRollback)
+            {
+                txn.rollback();
+            }
         }
 
     }
 
+    private AMQQueue getValidatedDestinationQueue(String queueName)
+    {
+        final AMQQueue toQueue = getVirtualHost().getQueueRegistry().getQueue(new AMQShortString(queueName));
+        if (toQueue == null)
+        {
+            throw new IllegalArgumentException("Queue '" + queueName + "' is not registered with the virtualhost.");
+        }
+        else if (toQueue == this)
+        {
+            throw new IllegalArgumentException("The destination queue can't be the same as the source queue");
+        }
+        return toQueue;
+    }
+
     public void removeMessagesFromQueue(long fromMessageId, long toMessageId)
     {
 
@@ -1543,10 +1581,16 @@
                 for(final QueueEntry entry : entries)
                 {
                     adapter.setEntry(entry);
-                    final List<? extends BaseQueue> rerouteQueues = _alternateExchange.route(adapter);
-                    final ServerMessage message = entry.getMessage();
-                    if(rerouteQueues != null && rerouteQueues.size() != 0)
+                    List<? extends BaseQueue> queues = _alternateExchange.route(adapter);
+                    if((queues == null || queues.size() == 0) && _alternateExchange.getAlternateExchange() != null)
                     {
+                        queues = _alternateExchange.getAlternateExchange().route(adapter);
+                    }
+
+                    final ServerMessage message = entry.getMessage();
+                    if(queues != null && queues.size() != 0)
+                    {
+                        final List<? extends BaseQueue> rerouteQueues = queues;
                         txn.enqueue(rerouteQueues, entry.getMessage(),
                                     new ServerTransaction.Action()
                                     {
@@ -1659,7 +1703,7 @@
                 //Overfull log message
                 _logActor.message(_logSubject, QueueMessages.OVERFULL(_atomicQueueSize.get(), _capacity));
 
-                _blockedChannels.putIfAbsent(channel, Boolean.TRUE);
+                _blockedChannels.add(channel);
 
                 channel.block(this);
 
@@ -1692,11 +1736,10 @@
                     _logActor.message(_logSubject, QueueMessages.UNDERFULL(_atomicQueueSize.get(), _flowResumeCapacity));
                 }
 
-
-                for(AMQSessionModel c : _blockedChannels.keySet())
+                for(final AMQSessionModel blockedChannel : _blockedChannels)
                 {
-                    c.unblock(this);
-                    _blockedChannels.remove(c);
+                    blockedChannel.unblock(this);
+                    _blockedChannels.remove(blockedChannel);
                 }
             }
         }
@@ -1714,7 +1757,6 @@
 
     public void deliverAsync(Subscription sub)
     {
-        //_stateChangeCount.incrementAndGet();
         if(_exclusiveSubscriber == null)
         {
             deliverAsync();
@@ -1890,8 +1932,8 @@
         QueueContext context = (QueueContext) sub.getQueueContext();
         if(context != null)
         {
-            QueueEntry lastSeen = context._lastSeenEntry;
-            QueueEntry releasedNode = context._releasedEntry;
+            QueueEntry lastSeen = context.getLastSeenEntry();
+            QueueEntry releasedNode = context.getReleasedEntry();
 
             QueueEntry node = (releasedNode != null && lastSeen.compareTo(releasedNode)>=0) ? releasedNode : _entries.next(lastSeen);
 
@@ -1913,8 +1955,8 @@
                     QueueContext._releasedUpdater.compareAndSet(context, releasedNode, null);
                 }
 
-                lastSeen = context._lastSeenEntry;
-                releasedNode = context._releasedEntry;
+                lastSeen = context.getLastSeenEntry();
+                releasedNode = context.getReleasedEntry();
                 node = (releasedNode != null && lastSeen.compareTo(releasedNode)>0) ? releasedNode : _entries.next(lastSeen);
             }
             return node;
@@ -1930,8 +1972,8 @@
         QueueContext context = (QueueContext) sub.getQueueContext();
         if(context != null)
         {
-            QueueEntry releasedNode = context._releasedEntry;
-            return releasedNode == null || releasedNode.compareTo(entry) < 0;
+            QueueEntry releasedNode = context.getReleasedEntry();
+            return releasedNode != null && releasedNode.compareTo(entry) < 0;
         }
         else
         {
@@ -2255,8 +2297,7 @@
 
         public boolean equals(Object o)
         {
-            return o != null
-                    && o instanceof SimpleAMQQueue.QueueEntryListener
+            return o instanceof SimpleAMQQueue.QueueEntryListener
                     && _sub == ((QueueEntryListener) o)._sub;
         }
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryImpl.java
index 0707dc0..4a10d31 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryImpl.java
@@ -22,9 +22,16 @@
 
 import org.apache.qpid.server.message.ServerMessage;
 
+import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
+
 public class SimpleQueueEntryImpl extends QueueEntryImpl
 {
-    volatile SimpleQueueEntryImpl _next;
+    static final AtomicReferenceFieldUpdater<SimpleQueueEntryImpl, SimpleQueueEntryImpl>
+                _nextUpdater =
+            AtomicReferenceFieldUpdater.newUpdater
+            (SimpleQueueEntryImpl.class, SimpleQueueEntryImpl.class, "_next");
+
+    private volatile SimpleQueueEntryImpl _next;
 
     public SimpleQueueEntryImpl(SimpleQueueEntryList queueEntryList)
     {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java
index b40e5a2..c82d1b9 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleQueueEntryList.java
@@ -20,10 +20,12 @@
 */
 package org.apache.qpid.server.queue;
 
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 import org.apache.qpid.server.message.ServerMessage;
 
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
+
 public class SimpleQueueEntryList implements QueueEntryList<SimpleQueueEntryImpl>
 {
 
@@ -40,12 +42,11 @@
     private final AMQQueue _queue;
 
     static final AtomicReferenceFieldUpdater<SimpleQueueEntryImpl, SimpleQueueEntryImpl>
-                _nextUpdater =
-            AtomicReferenceFieldUpdater.newUpdater
-            (SimpleQueueEntryImpl.class, SimpleQueueEntryImpl.class, "_next");
+                _nextUpdater = SimpleQueueEntryImpl._nextUpdater;
 
     private AtomicLong _scavenges = new AtomicLong(0L);
     private final long _scavengeCount = Integer.getInteger("qpid.queue.scavenge_count", 50);
+    private final AtomicReference<SimpleQueueEntryImpl> _unscavengedHWM = new AtomicReference<SimpleQueueEntryImpl>();
 
 
     public SimpleQueueEntryList(AMQQueue queue)
@@ -55,28 +56,17 @@
         _tail = _head;
     }
 
-    void advanceHead()
-    {
-        SimpleQueueEntryImpl next = _head.getNextNode();
-        SimpleQueueEntryImpl newNext = _head.getNextValidEntry();
-
-        if (next == newNext)
-        {
-            if (_scavenges.incrementAndGet() > _scavengeCount)
-            {
-                _scavenges.set(0L);
-                scavenge();
-            }
-        }
-    }
-
     void scavenge()
     {
+        SimpleQueueEntryImpl hwm = _unscavengedHWM.getAndSet(null);
         SimpleQueueEntryImpl next = _head.getNextValidEntry();
 
-        while (next != null)
+        if(hwm != null)
         {
-            next = next.getNextValidEntry();
+            while (next != null && hwm.compareTo(next)>0)
+            {
+                next = next.getNextValidEntry();
+            }
         }
     }
 
@@ -126,7 +116,6 @@
 
     public static class QueueEntryIteratorImpl implements QueueEntryIterator<SimpleQueueEntryImpl>
     {
-
         private SimpleQueueEntryImpl _lastNode;
 
         QueueEntryIteratorImpl(SimpleQueueEntryImpl startNode)
@@ -134,10 +123,9 @@
             _lastNode = startNode;
         }
 
-
         public boolean atTail()
         {
-            return _lastNode.getNextNode() == null;
+            return _lastNode.getNextValidEntry() == null;
         }
 
         public SimpleQueueEntryImpl getNode()
@@ -147,28 +135,17 @@
 
         public boolean advance()
         {
+            SimpleQueueEntryImpl nextValidNode = _lastNode.getNextValidEntry();
 
-            if(!atTail())
+            if(nextValidNode != null)
             {
-                SimpleQueueEntryImpl nextNode = _lastNode.getNextNode();
-                while(nextNode.isDispensed() && nextNode.getNextNode() != null)
-                {
-                    nextNode = nextNode.getNextNode();
-                }
-                _lastNode = nextNode;
-                return true;
-
-            }
-            else
-            {
-                return false;
+                _lastNode = nextValidNode;
             }
 
+            return nextValidNode != null;
         }
-
     }
 
-
     public QueueEntryIteratorImpl iterator()
     {
         return new QueueEntryIteratorImpl(_head);
@@ -182,7 +159,32 @@
 
     public void entryDeleted(SimpleQueueEntryImpl queueEntry)
     {
-        advanceHead();
+        SimpleQueueEntryImpl next = _head.getNextNode();
+        SimpleQueueEntryImpl newNext = _head.getNextValidEntry();
+
+        // the head of the queue has not been deleted, hence the deletion must have been mid queue.
+        if (next == newNext)
+        {
+            SimpleQueueEntryImpl unscavengedHWM = _unscavengedHWM.get();
+            while(unscavengedHWM == null || unscavengedHWM.compareTo(queueEntry)<0)
+            {
+                _unscavengedHWM.compareAndSet(unscavengedHWM, queueEntry);
+                unscavengedHWM = _unscavengedHWM.get();
+            }
+            if (_scavenges.incrementAndGet() > _scavengeCount)
+            {
+                _scavenges.set(0L);
+                scavenge();
+            }
+        }
+        else
+        {
+            SimpleQueueEntryImpl unscavengedHWM = _unscavengedHWM.get();
+            if(unscavengedHWM != null && (next == null || unscavengedHWM.compareTo(next) < 0))
+            {
+                _unscavengedHWM.compareAndSet(unscavengedHWM, null);
+            }
+        }
     }
 
     public int getPriorities()
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SortedQueue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SortedQueue.java
index 865b3d1..446f57b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SortedQueue.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SortedQueue.java
@@ -19,11 +19,12 @@
  */
 package org.apache.qpid.server.queue;
 
-import java.util.Map;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import java.util.Map;
+
 public class SortedQueue extends OutOfOrderQueue
 {
     //Lock object to synchronize enqueue. Used instead of the object
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SortedQueueEntryList.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SortedQueueEntryList.java
index 414a123..7f742d4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SortedQueueEntryList.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SortedQueueEntryList.java
@@ -21,12 +21,7 @@
 package org.apache.qpid.server.queue;
 
 import org.apache.qpid.server.message.ServerMessage;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
 import org.apache.qpid.server.queue.SortedQueueEntryImpl.Colour;
-import org.apache.qpid.server.store.StoreContext;
 
 /**
  * A sorted implementation of QueueEntryList.
@@ -367,7 +362,7 @@
 
             if(chosenChild != null)
             {
-                // we have one child (x), we can move it up to replace x;
+                // we have one child (x), we can move it up to replace x
                 chosenChild.setParent(entry.getParent());
                 if(chosenChild.getParent() == null)
                 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java
index 48f2efb..8f3b7ae 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java
@@ -21,14 +21,16 @@
  */
 
 
-import java.util.concurrent.Executor;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.subscription.Subscription;
+import org.apache.qpid.transport.TransportException;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 
 
 class SubFlushRunner implements Runnable
@@ -67,18 +69,30 @@
             }
             catch (AMQException e)
             {
-                _logger.error(e);
+                _logger.error("Exception during asynchronous delivery by " + toString(), e);
+            }
+            catch (final TransportException transe)
+            {
+                final String errorMessage = "Problem during asynchronous delivery by " + toString();
+                if(_logger.isDebugEnabled())
+                {
+                    _logger.debug(errorMessage, transe);
+                }
+                else
+                {
+                    _logger.info(errorMessage + ' ' + transe.getMessage());
+                }
             }
             finally
             {
                 CurrentActor.remove();
-            }
-            _scheduled.compareAndSet(RUNNING, IDLE);
-            if ((!complete || _stateChange.compareAndSet(true,false))&& !_sub.isSuspended())
-            {
-                if(_scheduled.compareAndSet(IDLE,SCHEDULED))
+                _scheduled.compareAndSet(RUNNING, IDLE);
+                if ((!complete || _stateChange.compareAndSet(true,false))&& !_sub.isSuspended())
                 {
-                    getQueue().execute(this);
+                    if(_scheduled.compareAndSet(IDLE,SCHEDULED))
+                    {
+                        getQueue().execute(this);
+                    }
                 }
             }
         }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
index 6753cf4..9951f7d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
@@ -20,18 +20,10 @@
  */
 package org.apache.qpid.server.registry;
 
-import java.net.InetSocketAddress;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicReference;
-
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.log4j.Logger;
+import org.osgi.framework.BundleContext;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.common.Closeable;
 import org.apache.qpid.common.QpidProperties;
@@ -45,6 +37,7 @@
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
 import org.apache.qpid.server.logging.CompositeStartupMessageLogger;
 import org.apache.qpid.server.logging.Log4jMessageLogger;
+import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.logging.RootMessageLogger;
 import org.apache.qpid.server.logging.SystemOutMessageLogger;
 import org.apache.qpid.server.logging.actors.AbstractActor;
@@ -65,7 +58,16 @@
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.virtualhost.VirtualHostImpl;
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
-import org.osgi.framework.BundleContext;
+
+import java.net.InetSocketAddress;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
 
 
 /**
@@ -76,33 +78,33 @@
  */
 public abstract class ApplicationRegistry implements IApplicationRegistry
 {
-    protected static final Logger _logger = Logger.getLogger(ApplicationRegistry.class);
+    private static final Logger _logger = Logger.getLogger(ApplicationRegistry.class);
 
     private static AtomicReference<IApplicationRegistry> _instance = new AtomicReference<IApplicationRegistry>(null);
 
-    protected final ServerConfiguration _configuration;
+    private final ServerConfiguration _configuration;
 
-    protected final Map<InetSocketAddress, QpidAcceptor> _acceptors = new HashMap<InetSocketAddress, QpidAcceptor>();
+    private final Map<InetSocketAddress, QpidAcceptor> _acceptors = new HashMap<InetSocketAddress, QpidAcceptor>();
 
-    protected ManagedObjectRegistry _managedObjectRegistry;
+    private ManagedObjectRegistry _managedObjectRegistry;
 
-    protected AuthenticationManager _authenticationManager;
+    private AuthenticationManager _authenticationManager;
 
-    protected VirtualHostRegistry _virtualHostRegistry;
+    private VirtualHostRegistry _virtualHostRegistry;
 
-    protected SecurityManager _securityManager;
+    private SecurityManager _securityManager;
 
-    protected PluginManager _pluginManager;
+    private PluginManager _pluginManager;
 
-    protected ConfigurationManager _configurationManager;
+    private ConfigurationManager _configurationManager;
 
-    protected RootMessageLogger _rootMessageLogger;
+    private RootMessageLogger _rootMessageLogger;
 
-    protected CompositeStartupMessageLogger _startupMessageLogger;
+    private CompositeStartupMessageLogger _startupMessageLogger;
 
-    protected UUID _brokerId = UUID.randomUUID();
+    private UUID _brokerId = UUID.randomUUID();
 
-    protected QMFService _qmfService;
+    private QMFService _qmfService;
 
     private BrokerConfig _broker;
 
@@ -114,17 +116,74 @@
 
     private BundleContext _bundleContext;
 
-    static
+    protected static Logger get_logger()
     {
-        Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownService()));
+        return _logger;
     }
 
-    private static class ShutdownService implements Runnable
+    protected Map<InetSocketAddress, QpidAcceptor> getAcceptors()
     {
-        public void run()
-        {
-            remove();
-        }
+        return _acceptors;
+    }
+
+    protected void setManagedObjectRegistry(ManagedObjectRegistry managedObjectRegistry)
+    {
+        _managedObjectRegistry = managedObjectRegistry;
+    }
+
+    protected void setAuthenticationManager(AuthenticationManager authenticationManager)
+    {
+        _authenticationManager = authenticationManager;
+    }
+
+    protected void setVirtualHostRegistry(VirtualHostRegistry virtualHostRegistry)
+    {
+        _virtualHostRegistry = virtualHostRegistry;
+    }
+
+    protected void setSecurityManager(SecurityManager securityManager)
+    {
+        _securityManager = securityManager;
+    }
+
+    protected void setPluginManager(PluginManager pluginManager)
+    {
+        _pluginManager = pluginManager;
+    }
+
+    protected void setConfigurationManager(ConfigurationManager configurationManager)
+    {
+        _configurationManager = configurationManager;
+    }
+
+    protected void setRootMessageLogger(RootMessageLogger rootMessageLogger)
+    {
+        _rootMessageLogger = rootMessageLogger;
+    }
+
+    protected CompositeStartupMessageLogger getStartupMessageLogger()
+    {
+        return _startupMessageLogger;
+    }
+
+    protected void setStartupMessageLogger(CompositeStartupMessageLogger startupMessageLogger)
+    {
+        _startupMessageLogger = startupMessageLogger;
+    }
+
+    protected void setBrokerId(UUID brokerId)
+    {
+        _brokerId = brokerId;
+    }
+
+    protected QMFService getQmfService()
+    {
+        return _qmfService;
+    }
+
+    protected void setQmfService(QMFService qmfService)
+    {
+        _qmfService = qmfService;
     }
 
     public static void initialise(IApplicationRegistry instance) throws Exception
@@ -201,7 +260,6 @@
                     _logger.info("Shutting down ApplicationRegistry(" + instance + ")");
                 }
                 instance.close();
-                instance.getBroker().getSystem().removeBroker(instance.getBroker());
             }
         }
         catch (Exception e)
@@ -256,7 +314,7 @@
 
             _qmfService = new QMFService(getConfigStore(), this);
 
-            CurrentActor.get().message(BrokerMessages.STARTUP(QpidProperties.getReleaseVersion(), QpidProperties.getBuildVersion()));
+            logStartupMessages(CurrentActor.get());
 
             _virtualHostRegistry = new VirtualHostRegistry(this);
 
@@ -285,6 +343,7 @@
         }
     }
 
+
     /**
      * Iterates across all discovered authentication manager factories, offering the security configuration to each.
      * Expects <b>exactly</b> one authentication manager to configure and initialise itself.
@@ -358,57 +417,71 @@
         {
             _reportingTimer = new Timer("Statistics-Reporting", true);
             
-            class StatisticsReportingTask extends TimerTask
-            {
-                private final int DELIVERED = 0;
-                private final int RECEIVED = 1;
-                
-                public void run()
-                {
-                    CurrentActor.set(new AbstractActor(ApplicationRegistry.getInstance().getRootMessageLogger()) {
-                        public String getLogMessage()
-                        {
-                            return "[" + Thread.currentThread().getName() + "] ";
-                        }
-                    });
-                    
-                    if (broker)
-                    {
-                        CurrentActor.get().message(BrokerMessages.STATS_DATA(DELIVERED, _dataDelivered.getPeak() / 1024.0, _dataDelivered.getTotal()));
-                        CurrentActor.get().message(BrokerMessages.STATS_MSGS(DELIVERED, _messagesDelivered.getPeak(), _messagesDelivered.getTotal()));
-                        CurrentActor.get().message(BrokerMessages.STATS_DATA(RECEIVED, _dataReceived.getPeak() / 1024.0, _dataReceived.getTotal()));
-                        CurrentActor.get().message(BrokerMessages.STATS_MSGS(RECEIVED, _messagesReceived.getPeak(), _messagesReceived.getTotal()));
-                    }
-                    
-                    if (virtualhost)
-                    {
-                        for (VirtualHost vhost : getVirtualHostRegistry().getVirtualHosts())
-                        {
-                            String name = vhost.getName();
-                            StatisticsCounter dataDelivered = vhost.getDataDeliveryStatistics();
-                            StatisticsCounter messagesDelivered = vhost.getMessageDeliveryStatistics();
-                            StatisticsCounter dataReceived = vhost.getDataReceiptStatistics();
-                            StatisticsCounter messagesReceived = vhost.getMessageReceiptStatistics();
-                            
-                            CurrentActor.get().message(VirtualHostMessages.STATS_DATA(name, DELIVERED, dataDelivered.getPeak() / 1024.0, dataDelivered.getTotal()));
-                            CurrentActor.get().message(VirtualHostMessages.STATS_MSGS(name, DELIVERED, messagesDelivered.getPeak(), messagesDelivered.getTotal()));
-                            CurrentActor.get().message(VirtualHostMessages.STATS_DATA(name, RECEIVED, dataReceived.getPeak() / 1024.0, dataReceived.getTotal()));
-                            CurrentActor.get().message(VirtualHostMessages.STATS_MSGS(name, RECEIVED, messagesReceived.getPeak(), messagesReceived.getTotal()));
-                        }
-                    }
-                    
-                    if (reset)
-                    {
-                        resetStatistics();
-                    }
 
-                    CurrentActor.remove();
+
+            _reportingTimer.scheduleAtFixedRate(new StatisticsReportingTask(broker, virtualhost, reset),
+                                                report / 2,
+                                                report);
+        }
+    }
+
+    private class StatisticsReportingTask extends TimerTask
+    {
+        private final int DELIVERED = 0;
+        private final int RECEIVED = 1;
+
+        private boolean _broker;
+        private boolean _virtualhost;
+        private boolean _reset;
+
+
+        public StatisticsReportingTask(boolean broker, boolean virtualhost, boolean reset)
+        {
+            _broker = broker;
+            _virtualhost = virtualhost;
+            _reset = reset;
+        }
+
+        public void run()
+        {
+            CurrentActor.set(new AbstractActor(ApplicationRegistry.getInstance().getRootMessageLogger()) {
+                public String getLogMessage()
+                {
+                    return "[" + Thread.currentThread().getName() + "] ";
+                }
+            });
+
+            if (_broker)
+            {
+                CurrentActor.get().message(BrokerMessages.STATS_DATA(DELIVERED, _dataDelivered.getPeak() / 1024.0, _dataDelivered.getTotal()));
+                CurrentActor.get().message(BrokerMessages.STATS_MSGS(DELIVERED, _messagesDelivered.getPeak(), _messagesDelivered.getTotal()));
+                CurrentActor.get().message(BrokerMessages.STATS_DATA(RECEIVED, _dataReceived.getPeak() / 1024.0, _dataReceived.getTotal()));
+                CurrentActor.get().message(BrokerMessages.STATS_MSGS(RECEIVED, _messagesReceived.getPeak(), _messagesReceived.getTotal()));
+            }
+
+            if (_virtualhost)
+            {
+                for (VirtualHost vhost : getVirtualHostRegistry().getVirtualHosts())
+                {
+                    String name = vhost.getName();
+                    StatisticsCounter dataDelivered = vhost.getDataDeliveryStatistics();
+                    StatisticsCounter messagesDelivered = vhost.getMessageDeliveryStatistics();
+                    StatisticsCounter dataReceived = vhost.getDataReceiptStatistics();
+                    StatisticsCounter messagesReceived = vhost.getMessageReceiptStatistics();
+
+                    CurrentActor.get().message(VirtualHostMessages.STATS_DATA(name, DELIVERED, dataDelivered.getPeak() / 1024.0, dataDelivered.getTotal()));
+                    CurrentActor.get().message(VirtualHostMessages.STATS_MSGS(name, DELIVERED, messagesDelivered.getPeak(), messagesDelivered.getTotal()));
+                    CurrentActor.get().message(VirtualHostMessages.STATS_DATA(name, RECEIVED, dataReceived.getPeak() / 1024.0, dataReceived.getTotal()));
+                    CurrentActor.get().message(VirtualHostMessages.STATS_MSGS(name, RECEIVED, messagesReceived.getPeak(), messagesReceived.getTotal()));
                 }
             }
 
-            _reportingTimer.scheduleAtFixedRate(new StatisticsReportingTask(),
-                                                report / 2,
-                                                report);
+            if (_reset)
+            {
+                resetStatistics();
+            }
+
+            CurrentActor.remove();
         }
     }
 
@@ -449,35 +522,49 @@
         }
     }
 
-
     public void close()
     {
         if (_logger.isInfoEnabled())
         {
             _logger.info("Shutting down ApplicationRegistry:" + this);
         }
-        
-        //Stop Statistics Reporting
-        if (_reportingTimer != null)
+
+        //Set the Actor for Broker Shutdown
+        CurrentActor.set(new BrokerActor(getRootMessageLogger()));
+        try
         {
-            _reportingTimer.cancel();
+            //Stop Statistics Reporting
+            if (_reportingTimer != null)
+            {
+                _reportingTimer.cancel();
+            }
+
+            //Stop incoming connections
+            unbind();
+
+            //Shutdown virtualhosts
+            close(_virtualHostRegistry);
+
+            close(_authenticationManager);
+
+            close(_qmfService);
+
+            close(_pluginManager);
+
+            close(_managedObjectRegistry);
+
+            BrokerConfig broker = getBroker();
+            if(broker != null)
+            {
+                broker.getSystem().removeBroker(broker);
+            }
+
+            CurrentActor.get().message(BrokerMessages.STOPPED());
         }
-
-        //Stop incoming connections
-        unbind();
-
-        //Shutdown virtualhosts
-        close(_virtualHostRegistry);
-
-        close(_authenticationManager);
-
-        close(_qmfService);
-
-        close(_pluginManager);
-
-        close(_managedObjectRegistry);
-
-        CurrentActor.get().message(BrokerMessages.STOPPED());
+        finally
+        {
+            CurrentActor.remove();
+        }
     }
 
     private void unbind()
@@ -654,4 +741,18 @@
     {
         _statisticsEnabled = enabled;
     }
+
+    private void logStartupMessages(LogActor logActor)
+    {
+        logActor.message(BrokerMessages.STARTUP(QpidProperties.getReleaseVersion(), QpidProperties.getBuildVersion()));
+
+        logActor.message(BrokerMessages.PLATFORM(System.getProperty("java.vendor"),
+                                                 System.getProperty("java.runtime.version", System.getProperty("java.version")),
+                                                 System.getProperty("os.name"),
+                                                 System.getProperty("os.version"),
+                                                 System.getProperty("os.arch")));
+
+        logActor.message(BrokerMessages.MAX_MEMORY(Runtime.getRuntime().maxMemory()));
+    }
+
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/BrokerConfigAdapter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/BrokerConfigAdapter.java
index f77b8d2..58fdc99 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/BrokerConfigAdapter.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/BrokerConfigAdapter.java
@@ -20,16 +20,21 @@
  */
 package org.apache.qpid.server.registry;
 
-import org.apache.qpid.server.configuration.*;
-import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.common.QpidProperties;
 import org.apache.qpid.common.ServerPropertyNames;
+import org.apache.qpid.server.configuration.BrokerConfig;
+import org.apache.qpid.server.configuration.BrokerConfigType;
+import org.apache.qpid.server.configuration.ConfigStore;
+import org.apache.qpid.server.configuration.ConfiguredObject;
+import org.apache.qpid.server.configuration.SystemConfig;
+import org.apache.qpid.server.configuration.VirtualHostConfig;
+import org.apache.qpid.server.virtualhost.VirtualHost;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.UUID;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
 public class BrokerConfigAdapter implements BrokerConfig
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java
index 9121f8f..b28e3d6 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java
@@ -20,16 +20,15 @@
  */
 package org.apache.qpid.server.registry;
 
-import java.io.File;
-
 import org.apache.commons.configuration.ConfigurationException;
+import org.osgi.framework.BundleContext;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.logging.actors.BrokerActor;
-import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.management.JMXManagedObjectRegistry;
 import org.apache.qpid.server.management.NoopManagedObjectRegistry;
-import org.osgi.framework.BundleContext;
+
+import java.io.File;
 
 public class ConfigurationFileApplicationRegistry extends ApplicationRegistry
 {
@@ -44,31 +43,15 @@
     }
 
     @Override
-    public void close()
-    {
-        //Set the Actor for Broker Shutdown
-        CurrentActor.set(new BrokerActor(_rootMessageLogger));
-        try
-        {
-            super.close();
-        }
-        finally
-        {
-            CurrentActor.remove();
-        }
-    }
-
-
-    @Override
     protected void initialiseManagedObjectRegistry() throws AMQException
     {
-        if (_configuration.getManagementEnabled())
+        if (getConfiguration().getManagementEnabled())
         {
-            _managedObjectRegistry = new JMXManagedObjectRegistry();
+            setManagedObjectRegistry(new JMXManagedObjectRegistry());
         }
         else
         {
-            _managedObjectRegistry = new NoopManagedObjectRegistry();
+            setManagedObjectRegistry(new NoopManagedObjectRegistry());
         }
     }
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
index c27e0d1..59bf250 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
@@ -20,15 +20,12 @@
  */
 package org.apache.qpid.server.registry;
 
-import java.net.InetSocketAddress;
-import java.util.UUID;
-
 import org.apache.qpid.qmf.QMFService;
 import org.apache.qpid.server.configuration.BrokerConfig;
 import org.apache.qpid.server.configuration.ConfigStore;
+import org.apache.qpid.server.configuration.ConfigurationManager;
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
-import org.apache.qpid.server.configuration.ConfigurationManager;
 import org.apache.qpid.server.logging.RootMessageLogger;
 import org.apache.qpid.server.management.ManagedObjectRegistry;
 import org.apache.qpid.server.plugins.PluginManager;
@@ -39,6 +36,9 @@
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
 
+import java.net.InetSocketAddress;
+import java.util.UUID;
+
 public interface IApplicationRegistry extends StatisticsGatherer
 {
     /**
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AbstractPlugin.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AbstractPlugin.java
index ff80499..704e50d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AbstractPlugin.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AbstractPlugin.java
@@ -20,8 +20,8 @@
  */
 package org.apache.qpid.server.security;
 
-import org.apache.commons.configuration.ConfigurationException;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.security.access.ObjectProperties;
 import org.apache.qpid.server.security.access.ObjectType;
@@ -32,9 +32,9 @@
  */
 public abstract class AbstractPlugin implements SecurityPlugin
 {
-	protected final Logger _logger = Logger.getLogger(getClass());
+	private final Logger _logger = Logger.getLogger(getClass());
     
-    protected ConfigurationPlugin _config;
+    private ConfigurationPlugin _config;
 	
 	public Result getDefault()
 	{
@@ -50,4 +50,8 @@
         _config = config;
     }
 
+    public ConfigurationPlugin getConfig()
+    {
+        return _config;
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AbstractProxyPlugin.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AbstractProxyPlugin.java
index ec11e2d..236931e 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AbstractProxyPlugin.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AbstractProxyPlugin.java
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.server.security;
 
-import org.apache.commons.configuration.Configuration;
 import org.apache.qpid.server.security.access.ObjectProperties;
 import org.apache.qpid.server.security.access.ObjectType;
 import org.apache.qpid.server.security.access.Operation;
@@ -28,8 +27,6 @@
 /**
  * This {@link SecurityPlugin} proxies the authorise calls to a serries of methods, one per {@link Operation}.
  * 
- * Plugins that extend this class should override the relevant authorise method and implement their own
- * {@link #setConfiguration(Configuration)} method.
  */
 public abstract class AbstractProxyPlugin extends AbstractPlugin
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AuthorizationHolder.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AuthorizationHolder.java
index 3d8c77a..8f3bdf7 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AuthorizationHolder.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AuthorizationHolder.java
@@ -20,12 +20,8 @@
  */
 package org.apache.qpid.server.security;
 
-import java.security.Principal;
-
 import javax.security.auth.Subject;
-
-import org.apache.qpid.server.security.auth.sasl.GroupPrincipal;
-import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
+import java.security.Principal;
 
 /**
  * Represents the authorization of the logged on user. 
@@ -35,8 +31,8 @@
 {
     /** 
      * Returns the {@link Subject} of the authorized user.  This is guaranteed to
-     * contain at least one {@link UsernamePrincipal}, representing the the identity
-     * used when the user logged on to the application, and zero or more {@link GroupPrincipal}
+     * contain at least one {@link org.apache.qpid.server.security.auth.sasl.UsernamePrincipal}, representing the the identity
+     * used when the user logged on to the application, and zero or more {@link org.apache.qpid.server.security.auth.sasl.GroupPrincipal}
      * representing the group(s) to which the user belongs.
      *
      * @return the Subject
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityManager.java
index 2a1ae8a..436660c 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityManager.java
@@ -18,6 +18,19 @@
  */
 package org.apache.qpid.server.security;
 
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
+import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.plugins.PluginManager;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.security.access.ObjectProperties;
+import org.apache.qpid.server.security.access.Operation;
+
 import static org.apache.qpid.server.security.access.ObjectType.EXCHANGE;
 import static org.apache.qpid.server.security.access.ObjectType.METHOD;
 import static org.apache.qpid.server.security.access.ObjectType.QUEUE;
@@ -30,26 +43,17 @@
 import static org.apache.qpid.server.security.access.Operation.PURGE;
 import static org.apache.qpid.server.security.access.Operation.UNBIND;
 
+import javax.security.auth.Subject;
 import java.net.SocketAddress;
-import java.security.Principal;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
 
-import javax.security.auth.Subject;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.log4j.Logger;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
-import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.plugins.PluginManager;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.security.access.ObjectProperties;
-import org.apache.qpid.server.security.access.Operation;
-
 /**
  * The security manager contains references to all loaded {@link SecurityPlugin}s and delegates security decisions to them based
  * on virtual host name. The plugins can be external <em>OSGi</em> .jar files that export the required classes or just internal
@@ -61,7 +65,7 @@
 {
     private static final Logger _logger = Logger.getLogger(SecurityManager.class);
     
-    /** Container for the {@link Principal} that is using to this thread. */
+    /** Container for the {@link java.security.Principal} that is using to this thread. */
     private static final ThreadLocal<Subject> _subject = new ThreadLocal<Subject>();
     private static final ThreadLocal<Boolean> _accessChecksDisabled = new ThreadLocal<Boolean>()
     {
@@ -101,7 +105,7 @@
 
         public void validateConfiguration() throws ConfigurationException
         {
-            if (_configuration.isEmpty())
+            if (getConfig().isEmpty())
             {
                 throw new ConfigurationException("security section is incomplete, no elements found.");
             }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityPluginActivator.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityPluginActivator.java
index 5ee7833..21c2d1c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityPluginActivator.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityPluginActivator.java
@@ -21,10 +21,11 @@
 package org.apache.qpid.server.security;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
+import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
+
 /**
  * An OSGi {@link BundleActivator} that loads a {@link SecurityPluginFactory}.
  */
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java
index 8a52d31..a9ec4d1 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java
@@ -18,13 +18,17 @@
  */
 package org.apache.qpid.server.security.access;
 
-import java.util.*;
-
 import org.apache.commons.lang.StringUtils;
+
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.queue.AMQQueue;
 
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * An set of properties for an access control v2 rule {@link ObjectType}.
  * 
@@ -315,19 +319,28 @@
                 || ruleValue.equals(STAR)
                 || (ruleValue.endsWith(STAR) 
                         && thisValue != null
-                        && thisValue.length() > ruleValue.length()
-                        && thisValue.startsWith(ruleValue.substring(0, ruleValue.length() - 2)));
+                        && thisValue.length() >= ruleValue.length() - 1
+                        && thisValue.startsWith(ruleValue.substring(0, ruleValue.length() - 1)));
     }
 
     @Override
     public boolean equals(Object o)
     {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+        if (this == o)
+        {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass())
+        {
+            return false;
+        }
 
         ObjectProperties that = (ObjectProperties) o;
 
-        if (_properties != null ? !_properties.equals(that._properties) : that._properties != null) return false;
+        if (_properties != null ? !_properties.equals(that._properties) : that._properties != null)
+        {
+            return false;
+        }
 
         return true;
     }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/ObjectType.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/ObjectType.java
index 69c7ff1..90ecd1d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/ObjectType.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/ObjectType.java
@@ -18,7 +18,15 @@
  */
 package org.apache.qpid.server.security.access;
 
-import static org.apache.qpid.server.security.access.Operation.*;
+import static org.apache.qpid.server.security.access.Operation.ACCESS;
+import static org.apache.qpid.server.security.access.Operation.BIND;
+import static org.apache.qpid.server.security.access.Operation.CONSUME;
+import static org.apache.qpid.server.security.access.Operation.CREATE;
+import static org.apache.qpid.server.security.access.Operation.DELETE;
+import static org.apache.qpid.server.security.access.Operation.PUBLISH;
+import static org.apache.qpid.server.security.access.Operation.PURGE;
+import static org.apache.qpid.server.security.access.Operation.UNBIND;
+import static org.apache.qpid.server.security.access.Operation.UPDATE;
 
 import java.util.EnumSet;
 import java.util.Set;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/AllowAll.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/AllowAll.java
deleted file mode 100644
index db18a89..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/AllowAll.java
+++ /dev/null
@@ -1,99 +0,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.
- */
-package org.apache.qpid.server.security.access.plugins;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
-import org.apache.qpid.server.security.Result;
-import org.apache.qpid.server.security.SecurityPluginFactory;
-
-/** Always allow. */
-public class AllowAll extends BasicPlugin
-{
-    public static class AllowAllConfiguration extends ConfigurationPlugin {
-        public static final ConfigurationPluginFactory FACTORY = new ConfigurationPluginFactory()
-        {
-            public List<String> getParentPaths()
-            {
-                return Arrays.asList("security.allow-all", "virtualhosts.virtualhost.security.allow-all");
-            }
-
-            public ConfigurationPlugin newInstance(String path, Configuration config) throws ConfigurationException
-            {
-                ConfigurationPlugin instance = new AllowAllConfiguration();
-                instance.setConfiguration(path, config);
-                return instance;
-            }
-        };
-        
-        public String[] getElementsProcessed()
-        {
-            return new String[] { "" };
-        }
-
-        public void validateConfiguration() throws ConfigurationException
-        {
-//            if (!_configuration.isEmpty())
-//            {
-//                throw new ConfigurationException("allow-all section takes no elements.");
-//            }
-        }
-
-    }
-    
-    public static final SecurityPluginFactory<AllowAll> FACTORY = new SecurityPluginFactory<AllowAll>()
-    {
-        public AllowAll newInstance(ConfigurationPlugin config) throws ConfigurationException                    
-        {
-            AllowAllConfiguration configuration = config.getConfiguration(AllowAllConfiguration.class.getName());
-
-            // If there is no configuration for this plugin then don't load it.
-            if (configuration == null)
-            {
-                return null;
-            }
-
-            AllowAll plugin = new AllowAll();
-            plugin.configure(configuration);
-            return plugin;
-        }
-
-        public String getPluginName()
-        {
-            return AllowAll.class.getName();
-        }
-
-        public Class<AllowAll> getPluginClass()
-        {
-            return AllowAll.class;
-        }
-    };
-	
-    @Override
-	public Result getDefault()
-	{
-		return Result.ALLOWED;
-    }
-
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/BasicPlugin.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/BasicPlugin.java
index f316155..4df135a 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/BasicPlugin.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/BasicPlugin.java
@@ -20,16 +20,14 @@
  */
 package org.apache.qpid.server.security.access.plugins;
 
-import org.apache.commons.configuration.ConfigurationException;
 import org.apache.qpid.server.security.AbstractPlugin;
 import org.apache.qpid.server.security.Result;
-import org.apache.qpid.server.security.SecurityPlugin;
 import org.apache.qpid.server.security.access.ObjectProperties;
 import org.apache.qpid.server.security.access.ObjectType;
 import org.apache.qpid.server.security.access.Operation;
 
 /**
- * This {@link SecurityPlugin} simply abstains from all authorisation requests and ignores configuration.
+ * This {@link org.apache.qpid.server.security.SecurityPlugin} simply abstains from all authorisation requests and ignores configuration.
  */
 public abstract class BasicPlugin extends AbstractPlugin
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/DenyAll.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/DenyAll.java
deleted file mode 100644
index 6c0fb1e..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/DenyAll.java
+++ /dev/null
@@ -1,99 +0,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.
- */
-package org.apache.qpid.server.security.access.plugins;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
-import org.apache.qpid.server.security.Result;
-import org.apache.qpid.server.security.SecurityPluginFactory;
-
-/** Always Deny. */
-public class DenyAll extends BasicPlugin
-{
-    public static class DenyAllConfiguration extends ConfigurationPlugin {
-        public static final ConfigurationPluginFactory FACTORY = new ConfigurationPluginFactory()
-        {
-            public List<String> getParentPaths()
-            {
-                return Arrays.asList("security.deny-all", "virtualhosts.virtualhost.security.deny-all");
-            }
-
-            public ConfigurationPlugin newInstance(String path, Configuration config) throws ConfigurationException
-            {
-                ConfigurationPlugin instance = new DenyAllConfiguration();
-                instance.setConfiguration(path, config);
-                return instance;
-            }
-        };
-        
-        public String[] getElementsProcessed()
-        {
-            return new String[] { "" };
-        }
-
-        public void validateConfiguration() throws ConfigurationException
-        {
-            if (!_configuration.isEmpty())
-            {
-                throw new ConfigurationException("deny-all section takes no elements.");
-            }
-        }
-
-    }
-    
-    public static final SecurityPluginFactory<DenyAll> FACTORY = new SecurityPluginFactory<DenyAll>()
-    {
-        public DenyAll newInstance(ConfigurationPlugin config) throws ConfigurationException
-        {
-            DenyAllConfiguration configuration = config.getConfiguration(DenyAllConfiguration.class.getName());
-
-            // If there is no configuration for this plugin then don't load it.
-            if (configuration == null)
-            {
-                return null;
-            }
-
-            DenyAll plugin = new DenyAll();
-            plugin.configure(configuration);
-            return plugin;
-        }
-
-        public String getPluginName()
-        {
-            return DenyAll.class.getName();
-        }
-
-        public Class<DenyAll> getPluginClass()
-        {
-            return DenyAll.class;
-        }
-    };
-	
-    @Override
-	public Result getDefault()
-	{
-		return Result.DENIED;
-    }
-
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/LegacyAccess.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/LegacyAccess.java
index bd99cdd..4b7a2fb 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/LegacyAccess.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/plugins/LegacyAccess.java
@@ -18,18 +18,19 @@
  */
 package org.apache.qpid.server.security.access.plugins;
 
-import java.util.Arrays;
-import java.util.List;
-
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
-import org.apache.qpid.server.configuration.VirtualHostConfiguration;
-import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
 import org.apache.qpid.server.security.SecurityPluginFactory;
 
-/** Always Abstain. */
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * The <code>LegacyAccess</code> plugin is used internally and  simply ignores legacy elements of the configuration file.
+ */
 public class LegacyAccess extends BasicPlugin
 {
     public static class LegacyAccessConfiguration extends ConfigurationPlugin {
@@ -37,9 +38,7 @@
         {
             public List<String> getParentPaths()
             {
-                return Arrays.asList("security.jmx", "virtualhosts.virtualhost.security.jmx",
-                                     "security.msg-auth", "virtualhosts.virtualhost.security.msg-auth",
-                                     "security.principal-databases", "virtualhosts.virtualhost.security.principal-databases");
+                return Arrays.asList("security.msg-auth", "virtualhosts.virtualhost.security.msg-auth");
             }
 
             public ConfigurationPlugin newInstance(String path, Configuration config) throws ConfigurationException
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/AuthenticationResult.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/AuthenticationResult.java
index 8c2d60a..949c0f2 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/AuthenticationResult.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/AuthenticationResult.java
@@ -53,8 +53,8 @@
         ERROR
     }
 
-    public final AuthenticationStatus _status;
-    public final byte[] _challenge;
+    private final AuthenticationStatus _status;
+    private final byte[] _challenge;
     private final Exception _cause;
     private final Subject _subject;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/AbstractPasswordFilePrincipalDatabase.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/AbstractPasswordFilePrincipalDatabase.java
new file mode 100644
index 0000000..7088fae
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/AbstractPasswordFilePrincipalDatabase.java
@@ -0,0 +1,484 @@
+/*
+ *
+ * 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.server.security.auth.database;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.server.security.auth.sasl.AuthenticationProviderInitialiser;
+import org.apache.qpid.server.security.auth.sasl.UsernamePasswordInitialiser;
+import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
+
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.login.AccountNotFoundException;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.regex.Pattern;
+
+public abstract class AbstractPasswordFilePrincipalDatabase<U extends PasswordPrincipal> implements PrincipalDatabase
+{
+    private final Pattern _regexp = Pattern.compile(":");
+
+    private final Map<String, AuthenticationProviderInitialiser> _saslServers =
+            new HashMap<String, AuthenticationProviderInitialiser>();
+
+    protected static final String DEFAULT_ENCODING = "utf-8";
+    private final Map<String, U> _userMap = new HashMap<String, U>();
+    private final ReentrantLock _userUpdate = new ReentrantLock();
+    private final Random _random = new Random();
+    private File _passwordFile;
+
+
+    protected AbstractPasswordFilePrincipalDatabase(UsernamePasswordInitialiser... initialisers)
+    {
+        for(UsernamePasswordInitialiser initialiser : initialisers)
+        {
+            initialiser.initialise(this);
+            _saslServers.put(initialiser.getMechanismName(), initialiser);
+        }
+    }
+
+    public final void setPasswordFile(String passwordFile) throws IOException
+    {
+        File f = new File(passwordFile);
+        getLogger().info("PasswordFile using file " + f.getAbsolutePath());
+        _passwordFile = f;
+        if (!f.exists())
+        {
+            throw new FileNotFoundException("Cannot find password file " + f);
+        }
+        if (!f.canRead())
+        {
+            throw new FileNotFoundException("Cannot read password file " + f +
+                                            ". Check permissions.");
+        }
+
+        loadPasswordFile();
+    }
+
+    /**
+     * SASL Callback Mechanism - sets the Password in the PasswordCallback based on the value in the PasswordFile
+     * If you want to change the password for a user, use updatePassword instead.
+     *
+     * @param principal The Principal to set the password for
+     * @param callback  The PasswordCallback to call setPassword on
+     *
+     * @throws javax.security.auth.login.AccountNotFoundException If the Principal cannot be found in this Database
+     */
+    public final void setPassword(Principal principal, PasswordCallback callback) throws AccountNotFoundException
+    {
+        if (_passwordFile == null)
+        {
+            throw new AccountNotFoundException("Unable to locate principal since no password file was specified during initialisation");
+        }
+        if (principal == null)
+        {
+            throw new IllegalArgumentException("principal must not be null");
+        }
+        char[] pwd = lookupPassword(principal.getName());
+
+        if (pwd != null)
+        {
+            callback.setPassword(pwd);
+        }
+        else
+        {
+            throw new AccountNotFoundException("No account found for principal " + principal);
+        }
+    }
+
+
+    /**
+     * Looks up the password for a specified user in the password file. Note this code is <b>not</b> secure since it
+     * creates strings of passwords. It should be modified to create only char arrays which get nulled out.
+     *
+     * @param name The principal name to lookup
+     *
+     * @return a char[] for use in SASL.
+     */
+    protected final char[] lookupPassword(String name)
+    {
+        U user = _userMap.get(name);
+        if (user == null)
+        {
+            return null;
+        }
+        else
+        {
+            return user.getPassword();
+        }
+    }
+
+    protected boolean compareCharArray(char[] a, char[] b)
+    {
+        boolean equal = false;
+        if (a.length == b.length)
+        {
+            equal = true;
+            int index = 0;
+            while (equal && index < a.length)
+            {
+                equal = a[index] == b[index];
+                index++;
+            }
+        }
+        return equal;
+    }
+
+    /**
+     * Changes the password for the specified user
+     *
+     * @param principal to change the password for
+     * @param password plaintext password to set the password too
+     */
+    public boolean updatePassword(Principal principal, char[] password) throws AccountNotFoundException
+    {
+        U user = _userMap.get(principal.getName());
+
+        if (user == null)
+        {
+            throw new AccountNotFoundException(principal.getName());
+        }
+
+        char[] orig = user.getPassword();
+        _userUpdate.lock();
+        try
+        {
+            user.setPassword(password);
+
+            savePasswordFile();
+
+            return true;
+        }
+        catch (IOException e)
+        {
+            getLogger().error("Unable to save password file due to '" + e.getMessage()
+                              + "', password change for user '" + principal + "' discarded");
+            //revert the password change
+            user.restorePassword(orig);
+
+            return false;
+        }
+        finally
+        {
+            _userUpdate.unlock();
+        }
+    }
+
+
+    private void loadPasswordFile() throws IOException
+    {
+        try
+        {
+            _userUpdate.lock();
+            _userMap.clear();
+
+            BufferedReader reader = null;
+            try
+            {
+                reader = new BufferedReader(new FileReader(_passwordFile));
+                String line;
+
+                while ((line = reader.readLine()) != null)
+                {
+                    String[] result = _regexp.split(line);
+                    if (result == null || result.length < 2 || result[0].startsWith("#"))
+                    {
+                        continue;
+                    }
+
+                    U user = createUserFromFileData(result);
+                    getLogger().info("Created user:" + user);
+                    _userMap.put(user.getName(), user);
+                }
+            }
+            finally
+            {
+                if (reader != null)
+                {
+                    reader.close();
+                }
+            }
+        }
+        finally
+        {
+            _userUpdate.unlock();
+        }
+    }
+
+    protected abstract U createUserFromFileData(String[] result);
+
+
+    protected abstract Logger getLogger();
+
+    protected File createTempFileOnSameFilesystem()
+    {
+        File liveFile = _passwordFile;
+        File tmp;
+
+        do
+        {
+            tmp = new File(liveFile.getPath() + _random.nextInt() + ".tmp");
+        }
+        while(tmp.exists());
+
+        tmp.deleteOnExit();
+        return tmp;
+    }
+
+    protected void swapTempFileToLive(final File temp) throws IOException
+    {
+        File live = _passwordFile;
+        // Remove any existing ".old" file
+        final File old = new File(live.getAbsoluteFile() + ".old");
+        if (old.exists())
+        {
+            old.delete();
+        }
+
+        // Create an new ".old" file
+        if(!live.renameTo(old))
+        {
+            //unable to rename the existing file to the backup name
+            getLogger().error("Could not backup the existing password file");
+            throw new IOException("Could not backup the existing password file");
+        }
+
+        // Move temp file to be the new "live" file
+        if(!temp.renameTo(live))
+        {
+            //failed to rename the new file to the required filename
+            if(!old.renameTo(live))
+            {
+                //unable to return the backup to required filename
+                getLogger().error(
+                        "Could not rename the new password file into place, and unable to restore original file");
+                throw new IOException("Could not rename the new password file into place, and unable to restore original file");
+            }
+
+            getLogger().error("Could not rename the new password file into place");
+            throw new IOException("Could not rename the new password file into place");
+        }
+    }
+
+    protected void savePasswordFile() throws IOException
+    {
+        try
+        {
+            _userUpdate.lock();
+
+            BufferedReader reader = null;
+            PrintStream writer = null;
+
+            File tmp = createTempFileOnSameFilesystem();
+
+            try
+            {
+                writer = new PrintStream(tmp);
+                reader = new BufferedReader(new FileReader(_passwordFile));
+                String line;
+
+                while ((line = reader.readLine()) != null)
+                {
+                    String[] result = _regexp.split(line);
+                    if (result == null || result.length < 2 || result[0].startsWith("#"))
+                    {
+                        writer.write(line.getBytes(DEFAULT_ENCODING));
+                        writer.println();
+                        continue;
+                    }
+
+                    U user = _userMap.get(result[0]);
+
+                    if (user == null)
+                    {
+                        writer.write(line.getBytes(DEFAULT_ENCODING));
+                        writer.println();
+                    }
+                    else if (!user.isDeleted())
+                    {
+                        if (!user.isModified())
+                        {
+                            writer.write(line.getBytes(DEFAULT_ENCODING));
+                            writer.println();
+                        }
+                        else
+                        {
+                            byte[] encodedPassword = user.getEncodedPassword();
+
+                            writer.write((user.getName() + ":").getBytes(DEFAULT_ENCODING));
+                            writer.write(encodedPassword);
+                            writer.println();
+
+                            user.saved();
+                        }
+                    }
+                }
+
+                for (U user : _userMap.values())
+                {
+                    if (user.isModified())
+                    {
+                        byte[] encodedPassword;
+                        encodedPassword = user.getEncodedPassword();
+                        writer.write((user.getName() + ":").getBytes(DEFAULT_ENCODING));
+                        writer.write(encodedPassword);
+                        writer.println();
+                        user.saved();
+                    }
+                }
+            }
+            catch(IOException e)
+            {
+                getLogger().error("Unable to create the new password file: " + e);
+                throw new IOException("Unable to create the new password file",e);
+            }
+            finally
+            {
+
+                try
+                {
+                    if (reader != null)
+                    {
+                        reader.close();
+                    }
+                }
+                finally
+                {
+                    if (writer != null)
+                    {
+                        writer.close();
+                    }
+                }
+
+            }
+
+            swapTempFileToLive(tmp);
+        }
+        finally
+        {
+            _userUpdate.unlock();
+        }
+    }
+
+    protected abstract U createUserFromPassword(Principal principal, char[] passwd);
+
+
+    public void reload() throws IOException
+    {
+        loadPasswordFile();
+    }
+
+    public Map<String, AuthenticationProviderInitialiser> getMechanisms()
+    {
+        return _saslServers;
+    }
+
+    public List<Principal> getUsers()
+    {
+        return new LinkedList<Principal>(_userMap.values());
+    }
+
+    public Principal getUser(String username)
+    {
+        if (_userMap.containsKey(username))
+        {
+            return new UsernamePrincipal(username);
+        }
+        return null;
+    }
+
+    public boolean deletePrincipal(Principal principal) throws AccountNotFoundException
+    {
+        U user = _userMap.get(principal.getName());
+
+        if (user == null)
+        {
+            throw new AccountNotFoundException(principal.getName());
+        }
+
+        try
+        {
+            _userUpdate.lock();
+            user.delete();
+
+            try
+            {
+                savePasswordFile();
+            }
+            catch (IOException e)
+            {
+                getLogger().error("Unable to remove user '" + user.getName() + "' from password file.");
+                return false;
+            }
+
+            _userMap.remove(user.getName());
+        }
+        finally
+        {
+            _userUpdate.unlock();
+        }
+
+        return true;
+    }
+
+    public boolean createPrincipal(Principal principal, char[] password)
+    {
+        if (_userMap.get(principal.getName()) != null)
+        {
+            return false;
+        }
+
+        U user = createUserFromPassword(principal, password);
+
+
+        try
+        {
+            _userUpdate.lock();
+            _userMap.put(user.getName(), user);
+
+            try
+            {
+                savePasswordFile();
+                return true;
+            }
+            catch (IOException e)
+            {
+                //remove the use on failure.
+                _userMap.remove(user.getName());
+                return false;
+            }
+        }
+        finally
+        {
+            _userUpdate.unlock();
+        }
+    }
+}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabase.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabase.java
index 5a92b33..63eb768 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabase.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabase.java
@@ -21,29 +21,12 @@
 package org.apache.qpid.server.security.auth.database;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.server.security.auth.management.AMQUserManagementMBean;
-import org.apache.qpid.server.security.auth.sasl.AuthenticationProviderInitialiser;
-import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
-import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HexInitialiser;
-import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HashedInitialiser;
-import org.apache.qpid.util.FileUtils;
 
-import javax.security.auth.callback.PasswordCallback;
+import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HashedInitialiser;
+import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HexInitialiser;
+
 import javax.security.auth.login.AccountNotFoundException;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintStream;
 import java.security.Principal;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.regex.Pattern;
 
 /**
  * Represents a user database where the account information is stored in a simple flat file.
@@ -52,100 +35,19 @@
  *
  * where a carriage return separates each username/password pair. Passwords are assumed to be in plain text.
  */
-public class Base64MD5PasswordFilePrincipalDatabase implements PrincipalDatabase
+public class Base64MD5PasswordFilePrincipalDatabase extends AbstractPasswordFilePrincipalDatabase<HashedUser>
 {
-    private static final Logger _logger = Logger.getLogger(Base64MD5PasswordFilePrincipalDatabase.class);
-
-    private File _passwordFile;
-
-    private Pattern _regexp = Pattern.compile(":");
-
-    private Map<String, AuthenticationProviderInitialiser> _saslServers;
-
-    AMQUserManagementMBean _mbean;
-    public static final String DEFAULT_ENCODING = "utf-8";
-    private Map<String, HashedUser> _users = new HashMap<String, HashedUser>();
-    private ReentrantLock _userUpdate = new ReentrantLock();
+    private final Logger _logger = Logger.getLogger(Base64MD5PasswordFilePrincipalDatabase.class);
 
     public Base64MD5PasswordFilePrincipalDatabase()
     {
-        _saslServers = new HashMap<String, AuthenticationProviderInitialiser>();
-
         /**
          *  Create Authenticators for MD5 Password file.
          */
+        super(new CRAMMD5HashedInitialiser(), new CRAMMD5HexInitialiser());
 
-        // Accept Plain incomming and hash it for comparison to the file.
-        CRAMMD5HashedInitialiser cram = new CRAMMD5HashedInitialiser();
-        cram.initialise(this);
-        _saslServers.put(cram.getMechanismName(), cram);
-
-        //Add the Hex initialiser
-        CRAMMD5HexInitialiser cramHex = new CRAMMD5HexInitialiser();
-        cramHex.initialise(this);
-        _saslServers.put(cramHex.getMechanismName(), cramHex);
-
-        //fixme The PDs should setup a PD Mangement MBean
-//        try
-//        {
-//            _mbean = new AMQUserManagementMBean();
-//            _mbean.setPrincipalDatabase(this);
-//        }
-//        catch (JMException e)
-//        {
-//            _logger.warn("User management disabled as unable to create MBean:" + e);
-//        }
     }
 
-    public void setPasswordFile(String passwordFile) throws IOException
-    {
-        File f = new File(passwordFile);
-        _logger.info("PasswordFilePrincipalDatabase using file " + f.getAbsolutePath());
-        _passwordFile = f;
-        if (!f.exists())
-        {
-            throw new FileNotFoundException("Cannot find password file " + f);
-        }
-        if (!f.canRead())
-        {
-            throw new FileNotFoundException("Cannot read password file " + f +
-                                            ". Check permissions.");
-        }
-
-        loadPasswordFile();
-    }
-
-    /**
-     * SASL Callback Mechanism - sets the Password in the PasswordCallback based on the value in the PasswordFile
-     * If you want to change the password for a user, use updatePassword instead.
-     *
-     * @param principal The Principal to set the password for
-     * @param callback  The PasswordCallback to call setPassword on
-     *
-     * @throws AccountNotFoundException If the Principal cannont be found in this Database
-     */
-    public void setPassword(Principal principal, PasswordCallback callback) throws AccountNotFoundException
-    {
-        if (_passwordFile == null)
-        {
-            throw new AccountNotFoundException("Unable to locate principal since no password file was specified during initialisation");
-        }
-        if (principal == null)
-        {
-            throw new IllegalArgumentException("principal must not be null");
-        }
-
-        char[] pwd = lookupPassword(principal.getName());
-
-        if (pwd != null)
-        {
-            callback.setPassword(pwd);
-        }
-        else
-        {
-            throw new AccountNotFoundException("No account found for principal " + principal);
-        }
-    }
 
     /**
      * Used to verify that the presented Password is correct. Currently only used by Management Console
@@ -180,7 +82,7 @@
         }
         catch (Exception e1)
         {
-            _logger.warn("Unable to hash password for user '" + principal + "' for comparison");
+            getLogger().warn("Unable to hash password for user '" + principal + "' for comparison");
             return false;
         }
         
@@ -194,374 +96,21 @@
 
         return compareCharArray(pwd, hashedPassword);
     }
-    
-    private boolean compareCharArray(char[] a, char[] b)
+
+    protected HashedUser createUserFromPassword(Principal principal, char[] passwd)
     {
-        boolean equal = false;
-        if (a.length == b.length)
-        {
-            equal = true;
-            int index = 0;
-            while (equal && index < a.length)
-            {
-                equal = a[index] == b[index];
-                index++;
-            }
-        }
-        return equal;
+        return new HashedUser(principal.getName(), passwd);
     }
 
-    /**
-     * Changes the password for the specified user
-     * 
-     * @param principal to change the password for
-     * @param password plaintext password to set the password too
-     */
-    public boolean updatePassword(Principal principal, char[] password) throws AccountNotFoundException
+
+    protected HashedUser createUserFromFileData(String[] result)
     {
-        HashedUser user = _users.get(principal.getName());
-
-        if (user == null)
-        {
-            throw new AccountNotFoundException(principal.getName());
-        }
-
-        try
-        {
-            try
-            {
-                _userUpdate.lock();
-                char[] orig = user.getPassword();
-                user.setPassword(password,false);
-
-                try
-                {
-                    savePasswordFile();
-                }
-                catch (IOException e)
-                {
-                    _logger.error("Unable to save password file, password change for user'"
-                                  + principal + "' will revert at restart");
-                    //revert the password change
-                    user.setPassword(orig,true);
-                    return false;
-                }
-                return true;
-            }
-            finally
-            {
-                _userUpdate.unlock();
-            }
-        }
-        catch (Exception e)
-        {
-            return false;
-        }
+        return new HashedUser(result);
     }
 
-    public boolean createPrincipal(Principal principal, char[] password)
+    protected Logger getLogger()
     {
-        if (_users.get(principal.getName()) != null)
-        {
-            return false;
-        }
-
-        HashedUser user;
-        try
-        {
-            user = new HashedUser(principal.getName(), password);
-        }
-        catch (Exception e1)
-        {
-            _logger.warn("Unable to create new user '" + principal.getName() + "'");
-            return false;
-        }
-
-
-        try
-        {
-            _userUpdate.lock();
-            _users.put(user.getName(), user);
-
-            try
-            {
-                savePasswordFile();
-                return true;
-            }
-            catch (IOException e)
-            {
-                //remove the use on failure.
-                _users.remove(user.getName());
-                return false;
-            }
-        }
-        finally
-        {
-            _userUpdate.unlock();
-        }
-    }
-
-    public boolean deletePrincipal(Principal principal) throws AccountNotFoundException
-    {
-        HashedUser user = _users.get(principal.getName());
-
-        if (user == null)
-        {
-            throw new AccountNotFoundException(principal.getName());
-        }
-
-        try
-        {
-            _userUpdate.lock();
-            user.delete();
-
-            try
-            {
-                savePasswordFile();
-            }
-            catch (IOException e)
-            {
-                _logger.warn("Unable to remove user '" + user.getName() + "' from password file.");
-                return false;
-            }
-
-            _users.remove(user.getName());
-        }
-        finally
-        {
-            _userUpdate.unlock();
-        }
-
-        return true;
-    }
-
-    public Map<String, AuthenticationProviderInitialiser> getMechanisms()
-    {
-        return _saslServers;
-    }
-
-    public List<Principal> getUsers()
-    {
-        return new LinkedList<Principal>(_users.values());
-    }
-
-    public Principal getUser(String username)
-    {
-        if (_users.containsKey(username))
-        {
-            return new UsernamePrincipal(username);
-        }
-        return null;
-    }
-
-    /**
-     * Looks up the password for a specified user in the password file. Note this code is <b>not</b> secure since it
-     * creates strings of passwords. It should be modified to create only char arrays which get nulled out.
-     *
-     * @param name The principal name to lookup
-     *
-     * @return a char[] for use in SASL.
-     */
-    private char[] lookupPassword(String name)
-    {
-        HashedUser user = _users.get(name);
-        if (user == null)
-        {
-            return null;
-        }
-        else
-        {
-            return user.getPassword();
-        }
-    }
-
-    private void loadPasswordFile() throws IOException
-    {
-        try
-        {
-            _userUpdate.lock();
-            _users.clear();
-
-            BufferedReader reader = null;
-            try
-            {
-                reader = new BufferedReader(new FileReader(_passwordFile));
-                String line;
-
-                while ((line = reader.readLine()) != null)
-                {
-                    String[] result = _regexp.split(line);
-                    if (result == null || result.length < 2 || result[0].startsWith("#"))
-                    {
-                        continue;
-                    }
-
-                    HashedUser user = new HashedUser(result);
-                    _logger.info("Created user:" + user);
-                    _users.put(user.getName(), user);
-                }
-            }
-            finally
-            {
-                if (reader != null)
-                {
-                    reader.close();
-                }
-            }
-        }
-        finally
-        {
-            _userUpdate.unlock();
-        }
-    }
-
-    private void savePasswordFile() throws IOException
-    {
-        try
-        {
-            _userUpdate.lock();
-
-            BufferedReader reader = null;
-            PrintStream writer = null;
-            
-            Random r = new Random();
-            File tmp;
-            do
-            {
-                tmp = new File(_passwordFile.getPath() + r.nextInt() + ".tmp");
-            }
-            while(tmp.exists());
-            
-            tmp.deleteOnExit();
-
-            try
-            {
-                writer = new PrintStream(tmp);
-                reader = new BufferedReader(new FileReader(_passwordFile));
-                String line;
-
-                while ((line = reader.readLine()) != null)
-                {
-                    String[] result = _regexp.split(line);
-                    if (result == null || result.length < 2 || result[0].startsWith("#"))
-                    {
-                        writer.write(line.getBytes(DEFAULT_ENCODING));
-                        writer.println();
-                        continue;
-                    }
-
-                    HashedUser user = _users.get(result[0]);
-
-                    if (user == null)
-                    {
-                        writer.write(line.getBytes(DEFAULT_ENCODING));
-                        writer.println();
-                    }
-                    else if (!user.isDeleted())
-                    {
-                        if (!user.isModified())
-                        {
-                            writer.write(line.getBytes(DEFAULT_ENCODING));
-                            writer.println();
-                        }
-                        else
-                        {
-                            try
-                            {
-                                byte[] encodedPassword = user.getEncodedPassword();
-
-                                writer.write((user.getName() + ":").getBytes(DEFAULT_ENCODING));
-                                writer.write(encodedPassword);
-                                writer.println();
-
-                                user.saved();
-                            }
-                            catch (Exception e)
-                            {
-                                _logger.warn("Unable to encode new password reverting to old password.");
-                                writer.write(line.getBytes(DEFAULT_ENCODING));
-                                writer.println();
-                            }
-                        }
-                    }
-                }
-
-                for (HashedUser user : _users.values())
-                {
-                    if (user.isModified())
-                    {
-                        byte[] encodedPassword;
-                        try
-                        {
-                            encodedPassword = user.getEncodedPassword();
-                            writer.write((user.getName() + ":").getBytes(DEFAULT_ENCODING));
-                            writer.write(encodedPassword);
-                            writer.println();
-                            user.saved();
-                        }
-                        catch (Exception e)
-                        {
-                            _logger.warn("Unable to get Encoded password for user'" + user.getName() + "' password not saved");
-                        }
-                    }
-                }
-            }
-            catch(IOException e)
-            {
-                _logger.error("Unable to create the new password file: " + e);
-                throw new IOException("Unable to create the new password file" + e);
-            }
-            finally
-            {
-                if (reader != null)
-                {
-                    reader.close();
-                }
-
-                if (writer != null)
-                {
-                    writer.close();
-                }
-            }
-            
-            // Swap temp file to main password file.
-            File old = new File(_passwordFile.getAbsoluteFile() + ".old");
-            if (old.exists())
-            {
-                old.delete();
-            }
-            
-            if(!_passwordFile.renameTo(old))
-            {
-                //unable to rename the existing file to the backup name 
-                _logger.error("Could not backup the existing password file");
-                throw new IOException("Could not backup the existing password file");
-            }
-
-            if(!tmp.renameTo(_passwordFile))
-            {
-                //failed to rename the new file to the required filename
-                
-                if(!old.renameTo(_passwordFile))
-                {
-                    //unable to return the backup to required filename
-                    _logger.error("Could not rename the new password file into place, and unable to restore original file");
-                    throw new IOException("Could not rename the new password file into place, and unable to restore original file");
-                }
-                
-                _logger.error("Could not rename the new password file into place");
-                throw new IOException("Could not rename the new password file into place");
-            }
-        }
-        finally
-        {
-            _userUpdate.unlock();
-        }
-    }
-
-    public void reload() throws IOException
-    {
-        loadPasswordFile();
+        return _logger;
     }
 
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/HashedUser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/HashedUser.java
index 3690e7f..b9de158 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/HashedUser.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/HashedUser.java
@@ -20,26 +20,25 @@
  */
 package org.apache.qpid.server.security.auth.database;
 
-import org.apache.commons.codec.EncoderException;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
 
 import java.io.UnsupportedEncodingException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
-import java.security.Principal;
 
-public class HashedUser implements Principal
+
+public class HashedUser implements PasswordPrincipal
 {
     private static final Logger _logger = Logger.getLogger(HashedUser.class);
 
-    String _name;
-    char[] _password;
-    byte[] _encodedPassword = null;
+    private String _name;
+    private char[] _password;
+    private byte[] _encodedPassword = null;
     private boolean _modified = false;
     private boolean _deleted = false;
 
-    HashedUser(String[] data) throws UnsupportedEncodingException
+    HashedUser(String[] data)
     {
         if (data.length != 2)
         {
@@ -48,7 +47,15 @@
 
         _name = data[0];
 
-        byte[] encoded_password = data[1].getBytes(Base64MD5PasswordFilePrincipalDatabase.DEFAULT_ENCODING);
+        byte[] encoded_password;
+        try
+        {
+            encoded_password = data[1].getBytes(Base64MD5PasswordFilePrincipalDatabase.DEFAULT_ENCODING);
+        }
+        catch (UnsupportedEncodingException e)
+        {
+            throw new RuntimeException("MD5 encoding not supported, even though the Java standard requires it",e);
+        }
 
         Base64 b64 = new Base64();
         byte[] decoded = b64.decode(encoded_password);
@@ -64,15 +71,23 @@
         }
     }
 
-    public HashedUser(String name, char[] password) throws UnsupportedEncodingException, NoSuchAlgorithmException
+    public HashedUser(String name, char[] password)
     {
         _name = name;
         setPassword(password,false);
     }
 
-    public static byte[] getMD5(byte[] data) throws NoSuchAlgorithmException, UnsupportedEncodingException
+    public static byte[] getMD5(byte[] data)
     {
-        MessageDigest md = MessageDigest.getInstance("MD5");
+        MessageDigest md = null;
+        try
+        {
+            md = MessageDigest.getInstance("MD5");
+        }
+        catch (NoSuchAlgorithmException e)
+        {
+            throw new RuntimeException("MD5 not supported although Java compliance requires it");
+        }
 
         for (byte b : data)
         {
@@ -92,12 +107,22 @@
         return _name;
     }
 
-    char[] getPassword()
+    public char[] getPassword()
     {
         return _password;
     }
 
-    void setPassword(char[] password, boolean alreadyHashed) throws UnsupportedEncodingException,  NoSuchAlgorithmException
+    public void setPassword(char[] password)
+    {
+        setPassword(password, false);
+    }
+
+    public void restorePassword(char[] password)
+    {
+        setPassword(password, true);
+    }
+
+    void setPassword(char[] password, boolean alreadyHashed)
     {
         if(alreadyHashed){
             _password = password;
@@ -126,7 +151,7 @@
         _encodedPassword = null;
     }
 
-    byte[] getEncodedPassword() throws EncoderException, UnsupportedEncodingException, NoSuchAlgorithmException
+    public byte[] getEncodedPassword()
     {
         if (_encodedPassword == null)
         {
@@ -135,7 +160,7 @@
         return _encodedPassword;
     }
 
-    private void encodePassword() throws EncoderException, UnsupportedEncodingException, NoSuchAlgorithmException
+    private void encodePassword()
     {
         byte[] byteArray = new byte[_password.length];
         int index = 0;
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PasswordPrincipal.java
similarity index 68%
copy from qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
copy to qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PasswordPrincipal.java
index 68fbb5e..8e12d5f 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PasswordPrincipal.java
@@ -18,17 +18,23 @@
  * under the License.
  *
  */
+package org.apache.qpid.server.security.auth.database;
 
-package org.apache.qpid.transport;
+import java.security.Principal;
 
-import java.io.IOException;
-
-public class OpenException extends IOException
+interface PasswordPrincipal extends Principal
 {
+    char[] getPassword();
+    byte[] getEncodedPassword();
 
-    public OpenException(String string, Throwable lastException)
-    {
-        super(string, lastException);
-    }
+    void setPassword(char[] password);
+    void restorePassword(char[] password);
 
+    boolean isDeleted();
+
+    boolean isModified();
+
+    void saved();
+
+    void delete();
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabase.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabase.java
index 7cb34da..bfd04ad 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabase.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabase.java
@@ -21,29 +21,13 @@
 package org.apache.qpid.server.security.auth.database;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.server.security.auth.sasl.AuthenticationProviderInitialiser;
-import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
+
 import org.apache.qpid.server.security.auth.sasl.amqplain.AmqPlainInitialiser;
-import org.apache.qpid.server.security.auth.sasl.anonymous.AnonymousInitialiser;
 import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5Initialiser;
 import org.apache.qpid.server.security.auth.sasl.plain.PlainInitialiser;
 
-import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.login.AccountNotFoundException;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintStream;
 import java.security.Principal;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.regex.Pattern;
 
 /**
  * Represents a user database where the account information is stored in a simple flat file.
@@ -52,102 +36,19 @@
  *
  * where a carriage return separates each username/password pair. Passwords are assumed to be in plain text.
  */
-public class PlainPasswordFilePrincipalDatabase implements PrincipalDatabase
+public class PlainPasswordFilePrincipalDatabase extends AbstractPasswordFilePrincipalDatabase<PlainUser>
 {
-    public static final String DEFAULT_ENCODING = "utf-8";
-    
-    private static final Logger _logger = Logger.getLogger(PlainPasswordFilePrincipalDatabase.class);
 
-    private File _passwordFile;
-
-    private Pattern _regexp = Pattern.compile(":");
-
-    private Map<String, AuthenticationProviderInitialiser> _saslServers;    
-    
-    private Map<String, PlainUser> _users = new HashMap<String, PlainUser>();
-    private ReentrantLock _userUpdate = new ReentrantLock();
+    private final Logger _logger = Logger.getLogger(PlainPasswordFilePrincipalDatabase.class);
 
     public PlainPasswordFilePrincipalDatabase()
     {
-        _saslServers = new HashMap<String, AuthenticationProviderInitialiser>();
-
         /**
          *  Create Authenticators for Plain Password file.
          */
-
-        // Accept AMQPlain incomming and compare it to the file.
-        AmqPlainInitialiser amqplain = new AmqPlainInitialiser();
-        amqplain.initialise(this);
-
-
-
-        // Accept AMQPlain incomming and compare it to the file.
-        AnonymousInitialiser anonymous = new AnonymousInitialiser();
-        anonymous.initialise(this);
-
-
-        // Accept Plain incomming and compare it to the file.
-        PlainInitialiser plain = new PlainInitialiser();
-        plain.initialise(this);
-
-        //  Accept MD5 incomming and Hash file value for comparison
-        CRAMMD5Initialiser cram = new CRAMMD5Initialiser();
-        cram.initialise(this);
-
-        _saslServers.put(amqplain.getMechanismName(), amqplain);
-        _saslServers.put(plain.getMechanismName(), plain);
-        _saslServers.put(cram.getMechanismName(), cram);
-        _saslServers.put(anonymous.getMechanismName(), anonymous);
+        super(new AmqPlainInitialiser(), new PlainInitialiser(), new CRAMMD5Initialiser());
     }
 
-    public void setPasswordFile(String passwordFile) throws IOException
-    {
-        File f = new File(passwordFile);
-        _logger.info("PlainPasswordFile using file " + f.getAbsolutePath());
-        _passwordFile = f;
-        if (!f.exists())
-        {
-            throw new FileNotFoundException("Cannot find password file " + f);
-        }
-        if (!f.canRead())
-        {
-            throw new FileNotFoundException("Cannot read password file " + f +
-                                            ". Check permissions.");
-        }
-        
-        loadPasswordFile();
-    }
-
-    /**
-     * SASL Callback Mechanism - sets the Password in the PasswordCallback based on the value in the PasswordFile
-     * If you want to change the password for a user, use updatePassword instead.
-     *
-     * @param principal The Principal to set the password for
-     * @param callback  The PasswordCallback to call setPassword on
-     *
-     * @throws AccountNotFoundException If the Principal cannot be found in this Database
-     */
-    public void setPassword(Principal principal, PasswordCallback callback) throws AccountNotFoundException
-    {
-        if (_passwordFile == null)
-        {
-            throw new AccountNotFoundException("Unable to locate principal since no password file was specified during initialisation");
-        }
-        if (principal == null)
-        {
-            throw new IllegalArgumentException("principal must not be null");
-        }
-        char[] pwd = lookupPassword(principal.getName());
-        
-        if (pwd != null)
-        {
-            callback.setPassword(pwd);
-        }
-        else
-        {
-            throw new AccountNotFoundException("No account found for principal " + principal);
-        }
-    }
 
     /**
      * Used to verify that the presented Password is correct. Currently only used by Management Console
@@ -173,352 +74,21 @@
 
     }
 
-    /**
-     * Changes the password for the specified user
-     * 
-     * @param principal to change the password for
-     * @param password plaintext password to set the password too
-     */
-    public boolean updatePassword(Principal principal, char[] password) throws AccountNotFoundException
+    protected PlainUser createUserFromPassword(Principal principal, char[] passwd)
     {
-        PlainUser user = _users.get(principal.getName());
-
-        if (user == null)
-        {
-            throw new AccountNotFoundException(principal.getName());
-        }
-
-        char[] orig = user.getPassword();
-        _userUpdate.lock();
-        try
-        {
-            user.setPassword(password);
-
-            savePasswordFile();
-
-            return true;
-        }
-        catch (IOException e)
-        {
-            _logger.error("Unable to save password file due to '"+e.getMessage()
-                          +"', password change for user '" + principal + "' discarded");
-            //revert the password change
-            user.setPassword(orig);
-            return false;
-        }
-        finally
-        {                                   
-            _userUpdate.unlock();
-        }
-    }
-
-    public boolean createPrincipal(Principal principal, char[] password)
-    {
-        if (_users.get(principal.getName()) != null)
-        {
-            return false;
-        }
-
-        PlainUser user = new PlainUser(principal.getName(), password);
-
-        try
-        {
-            _userUpdate.lock();
-            _users.put(user.getName(), user);
-
-            try
-            {
-                savePasswordFile();
-                return true;
-            }
-            catch (IOException e)
-            {
-                //remove the use on failure.
-                _users.remove(user.getName());
-                _logger.warn("Unable to create user '" + user.getName());
-                return false;
-            }
-        }
-        finally
-        {
-            _userUpdate.unlock();
-        }
-    }
-
-    public boolean deletePrincipal(Principal principal) throws AccountNotFoundException
-    {
-        PlainUser user = _users.get(principal.getName());
-
-        if (user == null)
-        {
-            throw new AccountNotFoundException(principal.getName());
-        }
-
-        try
-        {
-            _userUpdate.lock();
-            user.delete();
-
-            try
-            {
-                savePasswordFile();
-            }
-            catch (IOException e)
-            {
-                _logger.error("Unable to remove user '" + user.getName() + "' from password file.");
-                return false;
-            }
-
-            _users.remove(user.getName());
-        }
-        finally
-        {
-            _userUpdate.unlock();
-        }
-
-        return true;
-    }
-
-    public Map<String, AuthenticationProviderInitialiser> getMechanisms()
-    {
-        return _saslServers;
-    }
-
-    public List<Principal> getUsers()
-    {
-        return new LinkedList<Principal>(_users.values());
-    }
-
-    public Principal getUser(String username)
-    {
-        if (_users.containsKey(username))
-        {
-            return new UsernamePrincipal(username);
-        }
-        return null;
-    }
-
-    private boolean compareCharArray(char[] a, char[] b)
-    {
-        boolean equal = false;
-        if (a.length == b.length)
-        {
-            equal = true;
-            int index = 0;
-            while (equal && index < a.length)
-            {
-                equal = a[index] == b[index];
-                index++;
-            }
-        }
-        return equal;
+        return new PlainUser(principal.getName(), passwd);
     }
 
 
-    /**
-     * Looks up the password for a specified user in the password file. Note this code is <b>not</b> secure since it
-     * creates strings of passwords. It should be modified to create only char arrays which get nulled out.
-     *
-     * @param name The principal name to lookup
-     *
-     * @return a char[] for use in SASL.
-     */
-    private char[] lookupPassword(String name)
+    @Override
+    protected PlainUser createUserFromFileData(String[] result)
     {
-        PlainUser user = _users.get(name);
-        if (user == null)
-        {
-            return null;
-        }
-        else
-        {
-            return user.getPassword();
-        }
+        return new PlainUser(result);
     }
 
-    private void loadPasswordFile() throws IOException
+
+    protected Logger getLogger()
     {
-        try
-        {
-            _userUpdate.lock();
-            _users.clear();
-
-            BufferedReader reader = null;
-            try
-            {
-                reader = new BufferedReader(new FileReader(_passwordFile));
-                String line;
-
-                while ((line = reader.readLine()) != null)
-                {
-                    String[] result = _regexp.split(line);
-                    if (result == null || result.length < 2 || result[0].startsWith("#"))
-                    {
-                        continue;
-                    }
-
-                    PlainUser user = new PlainUser(result);
-                    _logger.info("Created user:" + user);
-                    _users.put(user.getName(), user);
-                }
-            }
-            finally
-            {
-                if (reader != null)
-                {
-                    reader.close();
-                }
-            }
-        }
-        finally
-        {
-            _userUpdate.unlock();
-        }
-    }
-
-    private void savePasswordFile() throws IOException
-    {
-        try
-        {
-            _userUpdate.lock();
-
-            BufferedReader reader = null;
-            PrintStream writer = null;
-
-            final File tmp = createTempFileOnSameFilesystem(_passwordFile);
-
-            try
-            {
-                writer = new PrintStream(tmp);
-                reader = new BufferedReader(new FileReader(_passwordFile));
-                String line;
-
-                while ((line = reader.readLine()) != null)
-                {
-                    String[] result = _regexp.split(line);
-                    if (result == null || result.length < 2 || result[0].startsWith("#"))
-                    {
-                        writer.write(line.getBytes(DEFAULT_ENCODING));
-                        writer.println();
-                        continue;
-                    }
-
-                    PlainUser user = _users.get(result[0]);
-
-                    if (user == null)
-                    {
-                        writer.write(line.getBytes(DEFAULT_ENCODING));
-                        writer.println();
-                    }
-                    else if (!user.isDeleted())
-                    {
-                        if (!user.isModified())
-                        {
-                            writer.write(line.getBytes(DEFAULT_ENCODING));
-                            writer.println();
-                        }
-                        else
-                        {
-                            byte[] password = user.getPasswordBytes();
-
-                            writer.write((user.getName() + ":").getBytes(DEFAULT_ENCODING));
-                            writer.write(password);
-                            writer.println();
-
-                            user.saved();
-                        }
-                    }
-                }
-
-                for (PlainUser user : _users.values())
-                {
-                    if (user.isModified())
-                    {
-                        byte[] password;
-                        password = user.getPasswordBytes();
-                        writer.write((user.getName() + ":").getBytes(DEFAULT_ENCODING));
-                        writer.write(password);
-                        writer.println();
-                        user.saved();
-                    }
-                }
-            }
-            catch(IOException e)
-            {
-                _logger.error("Unable to create the new password file: " + e);
-                throw new IOException("Unable to create the new password file" + e);
-            }
-            finally
-            {
-                if (writer != null)
-                {
-                    writer.close();
-                }
-                if (reader != null)
-                {
-                    reader.close();
-                }
-            }
-
-            swapTempFileToLive(_passwordFile, tmp);
-
-        }
-        finally
-        {
-            _userUpdate.unlock();
-        }
-    }
-
-    private void swapTempFileToLive(final File live, final File temp) throws IOException
-    {
-        // Remove any existing ".old" file
-        final File old = new File(live.getAbsoluteFile() + ".old");
-        if (old.exists())
-        {
-            old.delete();
-        }
-
-        // Create an new ".old" file
-        if(!live.renameTo(old))
-        {
-            //unable to rename the existing file to the backup name
-            _logger.error("Could not backup the existing password file");
-            throw new IOException("Could not backup the existing password file");
-        }
-
-        // Move temp file to be the new "live" file
-        if(!temp.renameTo(live))
-        {
-            //failed to rename the new file to the required filename
-            if(!old.renameTo(live))
-            {
-                //unable to return the backup to required filename
-                _logger.error("Could not rename the new password file into place, and unable to restore original file");
-                throw new IOException("Could not rename the new password file into place, and unable to restore original file");
-            }
-
-            _logger.error("Could not rename the new password file into place");
-            throw new IOException("Could not rename the new password file into place");
-        }
-    }
-
-    private File createTempFileOnSameFilesystem(final File liveFile)
-    {
-        File tmp;
-        final Random r = new Random();
-
-        do
-        {
-            tmp = new File(liveFile.getPath() + r.nextInt() + ".tmp");
-        }
-        while(tmp.exists());
-
-        tmp.deleteOnExit();
-        return tmp;
-    }
-    
-    public void reload() throws IOException
-    {
-        loadPasswordFile();
+        return _logger;
     }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainUser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainUser.java
index 46a78a5..bf9bfc6 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainUser.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainUser.java
@@ -20,11 +20,7 @@
  */
 package org.apache.qpid.server.security.auth.database;
 
-import org.apache.log4j.Logger;
-
-import java.security.Principal;
-
-public class PlainUser implements Principal
+public class PlainUser implements PasswordPrincipal
 {
     private String _name;
     private char[] _password;
@@ -61,12 +57,12 @@
         return _name;
     }
 
-    char[] getPassword()
+    public char[] getPassword()
     {
         return _password;
     }
     
-    byte[] getPasswordBytes()
+    public byte[] getEncodedPassword()
     {
         byte[] byteArray = new byte[_password.length];
         int index = 0;
@@ -77,7 +73,14 @@
         return byteArray;
     }
 
-    void setPassword(char[] password)
+
+
+    public void restorePassword(char[] password)
+    {
+        setPassword(password);
+    }
+
+    public void setPassword(char[] password)
     {
         _password = password;
         _modified = true;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PrincipalDatabase.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PrincipalDatabase.java
index ef37e04..67f4b73 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PrincipalDatabase.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PrincipalDatabase.java
@@ -22,14 +22,12 @@
 
 import org.apache.qpid.server.security.auth.sasl.AuthenticationProviderInitialiser;
 
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.security.Principal;
-import java.util.Map;
-import java.util.List;
-
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.login.AccountNotFoundException;
+import java.io.IOException;
+import java.security.Principal;
+import java.util.List;
+import java.util.Map;
 
 /** Represents a "user database" which is really a way of storing principals (i.e. usernames) and passwords. */
 public interface PrincipalDatabase
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PropertiesPrincipalDatabase.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PropertiesPrincipalDatabase.java
index ff88513..4203cb0 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PropertiesPrincipalDatabase.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PropertiesPrincipalDatabase.java
@@ -27,14 +27,14 @@
 
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.login.AccountNotFoundException;
-import java.util.Properties;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.List;
-import java.util.LinkedList;
-import java.security.Principal;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
 public class PropertiesPrincipalDatabase implements PrincipalDatabase
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/management/AMQUserManagementMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/management/AMQUserManagementMBean.java
index 2081303..1314a5d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/management/AMQUserManagementMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/management/AMQUserManagementMBean.java
@@ -20,9 +20,14 @@
  */
 package org.apache.qpid.server.security.auth.management;
 
-import java.io.IOException;
-import java.security.Principal;
-import java.util.List;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.management.common.mbeans.UserManagement;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
+import org.apache.qpid.management.common.mbeans.annotations.MBeanOperation;
+import org.apache.qpid.server.management.AMQManagedObject;
+import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
+import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
 
 import javax.management.JMException;
 import javax.management.openmbean.CompositeData;
@@ -35,14 +40,9 @@
 import javax.management.openmbean.TabularDataSupport;
 import javax.management.openmbean.TabularType;
 import javax.security.auth.login.AccountNotFoundException;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.management.common.mbeans.UserManagement;
-import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
-import org.apache.qpid.management.common.mbeans.annotations.MBeanOperation;
-import org.apache.qpid.server.management.AMQManagedObject;
-import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
-import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
+import java.io.IOException;
+import java.security.Principal;
+import java.util.List;
 
 /** MBean class for AMQUserManagementMBean. It implements all the management features exposed for managing users. */
 @MBeanDescription("User Management Interface")
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/manager/AuthenticationManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/manager/AuthenticationManager.java
index 82eb7d3..03cc12d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/manager/AuthenticationManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/manager/AuthenticationManager.java
@@ -20,21 +20,20 @@
  */
 package org.apache.qpid.server.security.auth.manager;
 
-import javax.security.auth.Subject;
-import javax.security.sasl.SaslException;
-import javax.security.sasl.SaslServer;
-
 import org.apache.qpid.amqp_1_0.transport.CallbackHanderSource;
 import org.apache.qpid.common.Closeable;
 import org.apache.qpid.server.plugins.Plugin;
 import org.apache.qpid.server.security.auth.AuthenticationResult;
 
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+
 /**
  * Implementations of the AuthenticationManager are responsible for determining
  * the authenticity of a user's credentials.
  * 
  * If the authentication is successful, the manager is responsible for producing a populated
- * {@link Subject} containing the user's identity and zero or more principals representing
+ * {@link javax.security.auth.Subject} containing the user's identity and zero or more principals representing
  * groups to which the user belongs.
  * <p>
  * The {@link #initialise()} method is responsible for registering SASL mechanisms required by
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java
index 978ad2b..b5d70d9 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java
@@ -20,29 +20,10 @@
  */
 package org.apache.qpid.server.security.auth.manager;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.security.Security;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.AccountNotFoundException;
-import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslException;
-import javax.security.sasl.SaslServer;
-import javax.security.sasl.SaslServerFactory;
-
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.configuration.PropertyException;
 import org.apache.qpid.configuration.PropertyUtils;
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
@@ -55,6 +36,25 @@
 import org.apache.qpid.server.security.auth.sasl.JCAProvider;
 import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
 
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.AccountNotFoundException;
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+import javax.security.sasl.SaslServerFactory;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.Security;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+
 
 /**
  * Concrete implementation of the AuthenticationManager that determines if supplied
@@ -95,9 +95,9 @@
      */
     private final Map<String, Map<String, ?>> _serverCreationProperties = new HashMap<String, Map<String, ?>>();
 
-    protected PrincipalDatabase _principalDatabase = null;
+    private PrincipalDatabase _principalDatabase = null;
 
-    protected AMQUserManagementMBean _mbean = null;
+    private AMQUserManagementMBean _mbean = null;
 
     public static final AuthenticationManagerPluginFactory<PrincipalDatabaseAuthenticationManager> FACTORY = new AuthenticationManagerPluginFactory<PrincipalDatabaseAuthenticationManager>()
     {
@@ -160,13 +160,13 @@
   
         public String getPrincipalDatabaseClass()
         {
-            return _configuration.getString("principal-database.class");
+            return getConfig().getString("principal-database.class");
         }
   
         public Map<String,String> getPdClassAttributeMap() throws ConfigurationException
         {
-            final List<String> argumentNames = _configuration.getList("principal-database.attributes.attribute.name");
-            final List<String> argumentValues = _configuration.getList("principal-database.attributes.attribute.value");
+            final List<String> argumentNames = getConfig().getList("principal-database.attributes.attribute.name");
+            final List<String> argumentValues = getConfig().getList("principal-database.attributes.attribute.value");
             final Map<String,String> attributes = new HashMap<String,String>(argumentNames.size());
 
             for (int i = 0; i < argumentNames.size(); i++)
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticator.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticator.java
index b7985ad..e27fd99 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticator.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticator.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.server.security.auth.rmi;
 
-import javax.management.remote.JMXAuthenticator;
-import javax.management.remote.JMXPrincipal;
-import javax.security.auth.Subject;
-
 import org.apache.qpid.server.security.auth.AuthenticationResult;
 import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus;
 import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
 
+import javax.management.remote.JMXAuthenticator;
+import javax.management.remote.JMXPrincipal;
+import javax.security.auth.Subject;
+
 public class RMIPasswordAuthenticator implements JMXAuthenticator
 {
     static final String UNABLE_TO_LOOKUP = "The broker was unable to lookup the user details";
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/AuthenticationProviderInitialiser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/AuthenticationProviderInitialiser.java
index bc5d8a4..c227aa1 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/AuthenticationProviderInitialiser.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/AuthenticationProviderInitialiser.java
@@ -20,10 +20,9 @@
  */
 package org.apache.qpid.server.security.auth.sasl;
 
-import java.util.Map;
-
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.sasl.SaslServerFactory;
+import java.util.Map;
 
 public interface AuthenticationProviderInitialiser
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/JCAProvider.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/JCAProvider.java
index d6f6c71..8711e1b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/JCAProvider.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/JCAProvider.java
@@ -20,11 +20,10 @@
  */
 package org.apache.qpid.server.security.auth.sasl;
 
+import javax.security.sasl.SaslServerFactory;
 import java.security.Provider;
 import java.util.Map;
 
-import javax.security.sasl.SaslServerFactory;
-
 public class JCAProvider extends Provider
 {
     public JCAProvider(String name, Map<String, Class<? extends SaslServerFactory>> providerMap)
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/UsernamePasswordInitialiser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/UsernamePasswordInitialiser.java
index 5c13e03..f4e8f80 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/UsernamePasswordInitialiser.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/UsernamePasswordInitialiser.java
@@ -20,9 +20,10 @@
  */
 package org.apache.qpid.server.security.auth.sasl;
 
-import java.io.IOException;
-import java.security.Principal;
-import java.util.Map;
+import org.apache.commons.configuration.Configuration;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
@@ -31,14 +32,9 @@
 import javax.security.auth.callback.UnsupportedCallbackException;
 import javax.security.auth.login.AccountNotFoundException;
 import javax.security.sasl.AuthorizeCallback;
-
-import org.apache.commons.configuration.Configuration;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
-import org.apache.qpid.server.security.auth.sasl.AuthenticationProviderInitialiser;
-import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
+import java.io.IOException;
+import java.security.Principal;
+import java.util.Map;
 
 public abstract class UsernamePasswordInitialiser implements AuthenticationProviderInitialiser
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/UsernamePrincipal.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/UsernamePrincipal.java
index b4ee13f..9e7db94 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/UsernamePrincipal.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/UsernamePrincipal.java
@@ -20,11 +20,10 @@
  */
 package org.apache.qpid.server.security.auth.sasl;
 
+import javax.security.auth.Subject;
 import java.security.Principal;
 import java.util.Set;
 
-import javax.security.auth.Subject;
-
 /** A principal that is just a wrapper for a simple username. */
 public class UsernamePrincipal implements Principal
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainInitialiser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainInitialiser.java
index 7acc632..8603072 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainInitialiser.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainInitialiser.java
@@ -20,10 +20,10 @@
  */
 package org.apache.qpid.server.security.auth.sasl.amqplain;
 
-import javax.security.sasl.SaslServerFactory;
-
 import org.apache.qpid.server.security.auth.sasl.UsernamePasswordInitialiser;
 
+import javax.security.sasl.SaslServerFactory;
+
 public class AmqPlainInitialiser extends UsernamePasswordInitialiser
 {
     public String getMechanismName()
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainSaslServer.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainSaslServer.java
index dee40e7..eecc704 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainSaslServer.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainSaslServer.java
@@ -20,9 +20,9 @@
  */
 package org.apache.qpid.server.security.auth.sasl.amqplain;
 
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
+import org.apache.qpid.framing.AMQFrameDecodingException;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.FieldTableFactory;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
@@ -32,10 +32,9 @@
 import javax.security.sasl.AuthorizeCallback;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
-
-import org.apache.qpid.framing.AMQFrameDecodingException;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.framing.FieldTableFactory;
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
 
 public class AmqPlainSaslServer implements SaslServer
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainSaslServerFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainSaslServerFactory.java
index 17d123e..3a73f57 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainSaslServerFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/amqplain/AmqPlainSaslServerFactory.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.server.security.auth.sasl.amqplain;
 
-import java.util.Map;
-
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
 import javax.security.sasl.SaslServerFactory;
+import java.util.Map;
 
 public class AmqPlainSaslServerFactory implements SaslServerFactory
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/anonymous/AnonymousInitialiser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/anonymous/AnonymousInitialiser.java
index e35e999..83369a8 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/anonymous/AnonymousInitialiser.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/anonymous/AnonymousInitialiser.java
@@ -20,53 +20,17 @@
  */
 package org.apache.qpid.server.security.auth.sasl.anonymous;
 
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.sasl.SaslServerFactory;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
-import org.apache.qpid.server.security.auth.sasl.AuthenticationProviderInitialiser;
 import org.apache.qpid.server.security.auth.sasl.UsernamePasswordInitialiser;
 
-import java.io.IOException;
-import java.util.Map;
+import javax.security.sasl.SaslServerFactory;
 
-public class AnonymousInitialiser implements AuthenticationProviderInitialiser
+public class AnonymousInitialiser extends UsernamePasswordInitialiser
 {
     public String getMechanismName()
     {
         return "ANONYMOUS";
     }
 
-    public void initialise(String baseConfigPath, Configuration configuration, Map<String, PrincipalDatabase> principalDatabases) throws Exception
-    {
-    }
-
-    public void initialise(PrincipalDatabase db)
-    {
-    }
-
-    public CallbackHandler getCallbackHandler()
-    {
-        return new CallbackHandler()
-        {
-
-            public Callback[] _callbacks;
-
-            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
-            {
-                _callbacks =callbacks;
-            }
-        };
-    }
-
-    public Map<String, ?> getProperties()
-    {
-        return null;
-    }
-
     public Class<? extends SaslServerFactory> getServerFactoryClassForJCARegistration()
     {
         return AnonymousSaslServerFactory.class;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/anonymous/AnonymousSaslServerFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/anonymous/AnonymousSaslServerFactory.java
index de69503..4650234 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/anonymous/AnonymousSaslServerFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/anonymous/AnonymousSaslServerFactory.java
@@ -20,15 +20,12 @@
  */
 package org.apache.qpid.server.security.auth.sasl.anonymous;
 
-import org.apache.qpid.server.security.auth.sasl.amqplain.AmqPlainSaslServer;
-
-import java.util.Map;
-
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
 import javax.security.sasl.SaslServerFactory;
+import java.util.Map;
 
 public class AnonymousSaslServerFactory implements SaslServerFactory
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedInitialiser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedInitialiser.java
index 97f9a4e..842215c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedInitialiser.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedInitialiser.java
@@ -20,8 +20,8 @@
  */
 package org.apache.qpid.server.security.auth.sasl.crammd5;
 
-import org.apache.qpid.server.security.auth.sasl.UsernamePasswordInitialiser;
 import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
+import org.apache.qpid.server.security.auth.sasl.UsernamePasswordInitialiser;
 
 import javax.security.sasl.SaslServerFactory;
 import java.util.Map;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java
index f6cab08..a2d9fa5 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedSaslServer.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.server.security.auth.sasl.crammd5;
 
-import javax.security.sasl.SaslServer;
-import javax.security.sasl.SaslException;
-import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslServerFactory;
 import javax.security.auth.callback.CallbackHandler;
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+import javax.security.sasl.SaslServerFactory;
 import java.util.Enumeration;
 import java.util.Map;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedServerFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedServerFactory.java
index 5298b5c..4e82940 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedServerFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HashedServerFactory.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.server.security.auth.sasl.crammd5;
 
-import java.util.Map;
-
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
 import javax.security.sasl.SaslServerFactory;
+import java.util.Map;
 
 public class CRAMMD5HashedServerFactory implements SaslServerFactory
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexInitialiser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexInitialiser.java
index 1398187..478f195 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexInitialiser.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexInitialiser.java
@@ -21,16 +21,16 @@
 package org.apache.qpid.server.security.auth.sasl.crammd5;
 
 import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
-import org.apache.qpid.server.security.auth.sasl.UsernamePasswordInitialiser;
 import org.apache.qpid.server.security.auth.sasl.AuthenticationProviderInitialiser;
+import org.apache.qpid.server.security.auth.sasl.UsernamePasswordInitialiser;
 
-import javax.security.sasl.SaslServerFactory;
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.login.AccountNotFoundException;
-import java.util.Map;
-import java.util.List;
-import java.security.Principal;
+import javax.security.sasl.SaslServerFactory;
 import java.io.IOException;
+import java.security.Principal;
+import java.util.List;
+import java.util.Map;
 
 public class CRAMMD5HexInitialiser extends UsernamePasswordInitialiser
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java
index 192ff74..e19baaa 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexSaslServer.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.server.security.auth.sasl.crammd5;
 
-import javax.security.sasl.SaslServer;
-import javax.security.sasl.SaslException;
-import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslServerFactory;
 import javax.security.auth.callback.CallbackHandler;
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+import javax.security.sasl.SaslServerFactory;
 import java.util.Enumeration;
 import java.util.Map;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexServerFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexServerFactory.java
index ce0e19a..06c9108 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexServerFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5HexServerFactory.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.server.security.auth.sasl.crammd5;
 
-import java.util.Map;
-
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
 import javax.security.sasl.SaslServerFactory;
+import java.util.Map;
 
 public class CRAMMD5HexServerFactory implements SaslServerFactory
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5Initialiser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5Initialiser.java
index 2648328..83e33d5 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5Initialiser.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/crammd5/CRAMMD5Initialiser.java
@@ -20,8 +20,8 @@
  */
 package org.apache.qpid.server.security.auth.sasl.crammd5;
 
-import org.apache.qpid.server.security.auth.sasl.UsernamePasswordInitialiser;
 import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
+import org.apache.qpid.server.security.auth.sasl.UsernamePasswordInitialiser;
 
 import javax.security.sasl.SaslServerFactory;
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainInitialiser.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainInitialiser.java
index 1d16cd8..67676d3 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainInitialiser.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainInitialiser.java
@@ -20,10 +20,10 @@
  */
 package org.apache.qpid.server.security.auth.sasl.plain;
 
-import javax.security.sasl.SaslServerFactory;
-
 import org.apache.qpid.server.security.auth.sasl.UsernamePasswordInitialiser;
 
+import javax.security.sasl.SaslServerFactory;
+
 public class PlainInitialiser extends UsernamePasswordInitialiser
 {
     public String getMechanismName()
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainPasswordCallback.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainPasswordCallback.java
index 7230e8e..0ea2f3c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainPasswordCallback.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainPasswordCallback.java
@@ -20,9 +20,8 @@
  */
 package org.apache.qpid.server.security.auth.sasl.plain;
 
-import java.util.Arrays;
-
 import javax.security.auth.callback.PasswordCallback;
+import java.util.Arrays;
 
 /**
  * Custom PasswordCallback for use during the PLAIN authentication process.
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainSaslServer.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainSaslServer.java
index 847a3a3..a811806 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainSaslServer.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainSaslServer.java
@@ -20,16 +20,14 @@
  */
 package org.apache.qpid.server.security.auth.sasl.plain;
 
-import java.io.IOException;
-
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.callback.UnsupportedCallbackException;
 import javax.security.sasl.AuthorizeCallback;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
+import java.io.IOException;
 
 public class PlainSaslServer implements SaslServer
 {
@@ -53,57 +51,65 @@
 
     public byte[] evaluateResponse(byte[] response) throws SaslException
     {
+        int authzidNullPosition = findNullPosition(response, 0);
+        if (authzidNullPosition < 0)
+        {
+            throw new SaslException("Invalid PLAIN encoding, authzid null terminator not found");
+        }
+        int authcidNullPosition = findNullPosition(response, authzidNullPosition + 1);
+        if (authcidNullPosition < 0)
+        {
+            throw new SaslException("Invalid PLAIN encoding, authcid null terminator not found");
+        }
+
+        PlainPasswordCallback passwordCb;
+        AuthorizeCallback authzCb;
+
         try
         {
-            int authzidNullPosition = findNullPosition(response, 0);
-            if (authzidNullPosition < 0)
-            {
-                throw new SaslException("Invalid PLAIN encoding, authzid null terminator not found");
-            }
-            int authcidNullPosition = findNullPosition(response, authzidNullPosition + 1);
-            if (authcidNullPosition < 0)
-            {
-                throw new SaslException("Invalid PLAIN encoding, authcid null terminator not found");
-            }
-
             // we do not currently support authcid in any meaningful way
-            // String authcid = new String(response, 0, authzidNullPosition, "utf8");
             String authzid = new String(response, authzidNullPosition + 1, authcidNullPosition - authzidNullPosition - 1, "utf8");
 
             // TODO: should not get pwd as a String but as a char array...
             int passwordLen = response.length - authcidNullPosition - 1;
             String pwd = new String(response, authcidNullPosition + 1, passwordLen, "utf8");
-            
+
             // we do not care about the prompt but it throws if null
             NameCallback nameCb = new NameCallback("prompt", authzid);
-            PlainPasswordCallback passwordCb = new PlainPasswordCallback("prompt", false, pwd);
-            AuthorizeCallback authzCb = new AuthorizeCallback(authzid, authzid);
+            passwordCb = new PlainPasswordCallback("prompt", false, pwd);
+            authzCb = new AuthorizeCallback(authzid, authzid);
 
             Callback[] callbacks = new Callback[]{nameCb, passwordCb, authzCb};
             _cbh.handle(callbacks);
 
-            if (passwordCb.isAuthenticated())
-            {
-                _complete = true;
-            }
-            if (authzCb.isAuthorized() && _complete)
-            {
-                _authorizationId = authzCb.getAuthenticationID();
-                return null;
-            }
-            else
-            {
-                throw new SaslException("Authentication failed");
-            }
         }
         catch (IOException e)
         {
+            if(e instanceof SaslException)
+            {
+                throw (SaslException) e;
+            }
             throw new SaslException("Error processing data: " + e, e);
         }
         catch (UnsupportedCallbackException e)
         {
             throw new SaslException("Unable to obtain data from callback handler: " + e, e);
         }
+
+        if (passwordCb.isAuthenticated())
+        {
+            _complete = true;
+        }
+
+        if (authzCb.isAuthorized() && _complete)
+        {
+            _authorizationId = authzCb.getAuthenticationID();
+            return null;
+        }
+        else
+        {
+            throw new SaslException("Authentication failed");
+        }
     }
 
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainSaslServerFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainSaslServerFactory.java
index 3144bfb..445e5ef 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainSaslServerFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/sasl/plain/PlainSaslServerFactory.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.server.security.auth.sasl.plain;
 
-import java.util.Map;
-
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
 import javax.security.sasl.SaslServerFactory;
+import java.util.Map;
 
 public class PlainSaslServerFactory implements SaslServerFactory
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/signal/SignalHandlerTask.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/signal/SignalHandlerTask.java
index 4e3fae1..bdcfd86 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/signal/SignalHandlerTask.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/signal/SignalHandlerTask.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.server.signal;
 
+import org.apache.log4j.Logger;
+
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 
-import org.apache.log4j.Logger;
-
 public abstract class SignalHandlerTask
 {
     private static final Logger LOGGER = Logger.getLogger(SignalHandlerTask.class);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/state/AMQStateManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/state/AMQStateManager.java
index 33aebff..f97b77a 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/state/AMQStateManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/state/AMQStateManager.java
@@ -20,51 +20,23 @@
  */
 package org.apache.qpid.server.state;
 
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArraySet;
-
 import org.apache.log4j.Logger;
 
 import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQConnectionException;
-import org.apache.qpid.framing.*;
+import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.ChannelCloseBody;
+import org.apache.qpid.framing.ChannelCloseOkBody;
+import org.apache.qpid.framing.ChannelOpenBody;
+import org.apache.qpid.framing.MethodDispatcher;
+import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.protocol.AMQMethodEvent;
 import org.apache.qpid.protocol.AMQMethodListener;
-import org.apache.qpid.protocol.AMQConstant;
-import org.apache.qpid.server.handler.BasicAckMethodHandler;
-import org.apache.qpid.server.handler.BasicCancelMethodHandler;
-import org.apache.qpid.server.handler.BasicConsumeMethodHandler;
-import org.apache.qpid.server.handler.BasicGetMethodHandler;
-import org.apache.qpid.server.handler.BasicPublishMethodHandler;
-import org.apache.qpid.server.handler.BasicQosHandler;
-import org.apache.qpid.server.handler.BasicRecoverMethodHandler;
-import org.apache.qpid.server.handler.BasicRejectMethodHandler;
-import org.apache.qpid.server.handler.ChannelCloseHandler;
-import org.apache.qpid.server.handler.ChannelCloseOkHandler;
-import org.apache.qpid.server.handler.ChannelFlowHandler;
-import org.apache.qpid.server.handler.ChannelOpenHandler;
-import org.apache.qpid.server.handler.ConnectionCloseMethodHandler;
-import org.apache.qpid.server.handler.ConnectionCloseOkMethodHandler;
-import org.apache.qpid.server.handler.ConnectionOpenMethodHandler;
-import org.apache.qpid.server.handler.ConnectionSecureOkMethodHandler;
-import org.apache.qpid.server.handler.ConnectionStartOkMethodHandler;
-import org.apache.qpid.server.handler.ConnectionTuneOkMethodHandler;
-import org.apache.qpid.server.handler.ExchangeBoundHandler;
-import org.apache.qpid.server.handler.ExchangeDeclareHandler;
-import org.apache.qpid.server.handler.ExchangeDeleteHandler;
-import org.apache.qpid.server.handler.QueueBindHandler;
-import org.apache.qpid.server.handler.QueueDeclareHandler;
-import org.apache.qpid.server.handler.QueueDeleteHandler;
-import org.apache.qpid.server.handler.QueuePurgeHandler;
-import org.apache.qpid.server.handler.TxCommitHandler;
-import org.apache.qpid.server.handler.TxRollbackHandler;
-import org.apache.qpid.server.handler.TxSelectHandler;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
 
+import java.util.concurrent.CopyOnWriteArraySet;
+
 /**
  * The state manager is responsible for managing the state of the protocol session. <p/> For each AMQProtocolHandler
  * there is a separate state manager.
@@ -78,16 +50,6 @@
     /** The current state */
     private AMQState _currentState;
 
-    /**
-     * Maps from an AMQState instance to a Map from Class to StateTransitionHandler. The class must be a subclass of
-     * AMQFrame.
-     */
-/*    private final EnumMap<AMQState, Map<Class<? extends AMQMethodBody>, StateAwareMethodListener<? extends AMQMethodBody>>> _state2HandlersMap =
-        new EnumMap<AMQState, Map<Class<? extends AMQMethodBody>, StateAwareMethodListener<? extends AMQMethodBody>>>(
-            AMQState.class);
-  */
-
-
     private CopyOnWriteArraySet<StateListener> _stateListeners = new CopyOnWriteArraySet<StateListener>();
 
     public AMQStateManager(VirtualHostRegistry virtualHostRegistry, AMQProtocolSession protocolSession)
@@ -99,64 +61,6 @@
 
     }
 
-    /*
-    protected void registerListeners()
-    {
-        Map<Class<? extends AMQMethodBody>, StateAwareMethodListener<? extends AMQMethodBody>> frame2handlerMap;
-
-        frame2handlerMap = new HashMap<Class<? extends AMQMethodBody>, StateAwareMethodListener<? extends AMQMethodBody>>();
-        _state2HandlersMap.put(AMQState.CONNECTION_NOT_STARTED, frame2handlerMap);
-
-        frame2handlerMap = new HashMap<Class<? extends AMQMethodBody>, StateAwareMethodListener<? extends AMQMethodBody>>();
-        _state2HandlersMap.put(AMQState.CONNECTION_NOT_AUTH, frame2handlerMap);
-
-        frame2handlerMap = new HashMap<Class<? extends AMQMethodBody>, StateAwareMethodListener<? extends AMQMethodBody>>();
-        _state2HandlersMap.put(AMQState.CONNECTION_NOT_TUNED, frame2handlerMap);
-
-        frame2handlerMap = new HashMap<Class<? extends AMQMethodBody>, StateAwareMethodListener<? extends AMQMethodBody>>();
-        frame2handlerMap.put(ConnectionOpenBody.class, ConnectionOpenMethodHandler.getInstance());
-        _state2HandlersMap.put(AMQState.CONNECTION_NOT_OPENED, frame2handlerMap);
-
-        //
-        // ConnectionOpen handlers
-        //
-        frame2handlerMap = new HashMap<Class<? extends AMQMethodBody>, StateAwareMethodListener<? extends AMQMethodBody>>();
-        ChannelOpenHandler.getInstance();
-        ChannelCloseHandler.getInstance();
-        ChannelCloseOkHandler.getInstance();
-        ConnectionCloseMethodHandler.getInstance();
-        ConnectionCloseOkMethodHandler.getInstance();
-        ConnectionTuneOkMethodHandler.getInstance();
-        ConnectionSecureOkMethodHandler.getInstance();
-        ConnectionStartOkMethodHandler.getInstance();
-        ExchangeDeclareHandler.getInstance();
-        ExchangeDeleteHandler.getInstance();
-        ExchangeBoundHandler.getInstance();
-        BasicAckMethodHandler.getInstance();
-        BasicRecoverMethodHandler.getInstance();
-        BasicConsumeMethodHandler.getInstance();
-        BasicGetMethodHandler.getInstance();
-        BasicCancelMethodHandler.getInstance();
-        BasicPublishMethodHandler.getInstance();
-        BasicQosHandler.getInstance();
-        QueueBindHandler.getInstance();
-        QueueDeclareHandler.getInstance();
-        QueueDeleteHandler.getInstance();
-        QueuePurgeHandler.getInstance();
-        ChannelFlowHandler.getInstance();
-        TxSelectHandler.getInstance();
-        TxCommitHandler.getInstance();
-        TxRollbackHandler.getInstance();
-        BasicRejectMethodHandler.getInstance();
-
-        _state2HandlersMap.put(AMQState.CONNECTION_OPEN, frame2handlerMap);
-
-        frame2handlerMap = new HashMap<Class<? extends AMQMethodBody>, StateAwareMethodListener<? extends AMQMethodBody>>();
-
-        _state2HandlersMap.put(AMQState.CONNECTION_CLOSING, frame2handlerMap);
-
-    } */
-
     public AMQState getCurrentState()
     {
         return _currentState;
@@ -217,30 +121,6 @@
         }
     }
 
-/*
-    protected <B extends AMQMethodBody> StateAwareMethodListener<B> findStateTransitionHandler(AMQState currentState,
-        B frame)
-    // throws IllegalStateTransitionException
-    {
-        final Map<Class<? extends AMQMethodBody>, StateAwareMethodListener<? extends AMQMethodBody>> classToHandlerMap =
-            _state2HandlersMap.get(currentState);
-
-        final StateAwareMethodListener<B> handler =
-            (classToHandlerMap == null) ? null : (StateAwareMethodListener<B>) classToHandlerMap.get(frame.getClass());
-
-        if (handler == null)
-        {
-            _logger.debug("No state transition handler defined for receiving frame " + frame);
-
-            return null;
-        }
-        else
-        {
-            return handler;
-        }
-    }
-*/
-
     public void addStateListener(StateListener listener)
     {
         _logger.debug("Adding state listener");
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/state/StateAwareMethodListener.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/state/StateAwareMethodListener.java
index 3c11bb8..b543728 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/state/StateAwareMethodListener.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/state/StateAwareMethodListener.java
@@ -22,7 +22,6 @@
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQMethodBody;
-import org.apache.qpid.protocol.AMQMethodEvent;
 
 /**
  * A frame listener that is informed of the protocol state when invoked and has
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java
index b732121..2bd17cf 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java
@@ -18,12 +18,12 @@
  */
 package org.apache.qpid.server.stats;
 
-import java.util.Date;
-import java.util.concurrent.atomic.AtomicLong;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicLong;
+
 /**
  * This class collects statistics and counts the total, rate per second and
  * peak rate per second values for the events that are registered with it. 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/AbstractMessageStore.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/AbstractMessageStore.java
index b9adaea..fc5d2a4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/AbstractMessageStore.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/AbstractMessageStore.java
@@ -20,15 +20,15 @@
  */
 package org.apache.qpid.server.store;
 
-import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.logging.LogSubject;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.messages.MessageStoreMessages;
 import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject;
-import org.apache.qpid.server.logging.LogSubject;
+import org.apache.qpid.server.virtualhost.VirtualHost;
 
 public abstract class AbstractMessageStore implements MessageStore
 {
-    protected LogSubject _logSubject;
+    private LogSubject _logSubject;
 
     public void configure(VirtualHost virtualHost) throws Exception
     {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/ConfigurationRecoveryHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/ConfigurationRecoveryHandler.java
index 09e7fe0..fb67500 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/ConfigurationRecoveryHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/ConfigurationRecoveryHandler.java
@@ -20,12 +20,12 @@
 */
 package org.apache.qpid.server.store;
 
+import org.apache.qpid.framing.FieldTable;
+
 import java.nio.ByteBuffer;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.framing.FieldTable;
-
 public interface ConfigurationRecoveryHandler
 {
     QueueRecoveryHandler begin(MessageStore store);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
index 45083c1..4d63136 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
@@ -20,6 +20,24 @@
 */
 package org.apache.qpid.server.store;
 
+import org.apache.commons.configuration.Configuration;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.federation.Bridge;
+import org.apache.qpid.server.federation.BrokerLink;
+import org.apache.qpid.server.logging.LogSubject;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
+import org.apache.qpid.server.logging.messages.MessageStoreMessages;
+import org.apache.qpid.server.logging.messages.TransactionLogMessages;
+import org.apache.qpid.server.message.EnqueableMessage;
+import org.apache.qpid.server.queue.AMQQueue;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
@@ -45,23 +63,6 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.commons.configuration.Configuration;
-import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQStoreException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.federation.Bridge;
-import org.apache.qpid.server.federation.BrokerLink;
-import org.apache.qpid.server.logging.LogSubject;
-import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
-import org.apache.qpid.server.logging.messages.MessageStoreMessages;
-import org.apache.qpid.server.logging.messages.TransactionLogMessages;
-import org.apache.qpid.server.message.EnqueableMessage;
-import org.apache.qpid.server.queue.AMQQueue;
-
 /**
  * An implementation of a {@link MessageStore} that uses Apache Derby as the persistance
  * mechanism.
@@ -91,7 +92,9 @@
     private static final String LINKS_TABLE_NAME = "QPID_LINKS";
     private static final String BRIDGES_TABLE_NAME = "QPID_BRIDGES";
 
-
+    private static final String XID_TABLE_NAME = "QPID_XIDS";
+    private static final String XID_ACTIONS_TABLE_NAME = "QPID_XID_ACTIONS";
+    
     private static final int DB_VERSION = 3;
 
 
@@ -189,6 +192,31 @@
                                                     + "arguments )"
                                                     + " values (?, ?, ?, ?, ?, ?)";
 
+    private static final String CREATE_XIDS_TABLE =
+            "CREATE TABLE "+XID_TABLE_NAME+" ( format bigint not null,"
+            + " global_id varchar(64) for bit data, branch_id varchar(64) for bit data,  PRIMARY KEY ( format, " +
+            "global_id, branch_id ))";
+    private static final String INSERT_INTO_XIDS = 
+            "INSERT INTO "+XID_TABLE_NAME+" ( format, global_id, branch_id ) values (?, ?, ?)";
+    private static final String DELETE_FROM_XIDS = "DELETE FROM " + XID_TABLE_NAME
+                                                      + " WHERE format = ? and global_id = ? and branch_id = ?";
+    private static final String SELECT_ALL_FROM_XIDS = "SELECT format, global_id, branch_id FROM " + XID_TABLE_NAME;
+
+
+    private static final String CREATE_XID_ACTIONS_TABLE =
+            "CREATE TABLE "+XID_ACTIONS_TABLE_NAME+" ( format bigint not null,"
+            + " global_id varchar(64) for bit data not null, branch_id varchar(64) for bit data not null, " +
+            "action_type char not null, queue_name varchar(255) not null, message_id bigint not null" +
+            ",  PRIMARY KEY ( " +
+            "format, global_id, branch_id, action_type, queue_name, message_id))";
+    private static final String INSERT_INTO_XID_ACTIONS =
+            "INSERT INTO "+XID_ACTIONS_TABLE_NAME+" ( format, global_id, branch_id, action_type, " +
+            "queue_name, message_id ) values (?,?,?,?,?,?) ";
+    private static final String DELETE_FROM_XID_ACTIONS = "DELETE FROM " + XID_ACTIONS_TABLE_NAME
+                                                   + " WHERE format = ? and global_id = ? and branch_id = ?";
+    private static final String SELECT_ALL_FROM_XID_ACTIONS = 
+            "SELECT action_type, queue_name, message_id FROM " + XID_ACTIONS_TABLE_NAME + 
+            " WHERE format = ? and global_id = ? and branch_id = ?";
 
     private static final String DERBY_SINGLE_DB_SHUTDOWN_CODE = "08006";
 
@@ -294,7 +322,8 @@
             _configured = true;
         }
 
-        recoverQueueEntries(recoveryHandler);
+        TransactionLogRecoveryHandler.DtxRecordRecoveryHandler dtxrh = recoverQueueEntries(recoveryHandler);
+        recoverXids(dtxrh);
 
     }
 
@@ -349,7 +378,8 @@
         createMessageContentTable(conn);
         createLinkTable(conn);
         createBridgeTable(conn);
-
+        createXidTable(conn);
+        createXidActionTable(conn);
         conn.close();
     }
 
@@ -518,8 +548,38 @@
         }
     }
 
+    private void createXidTable(final Connection conn) throws SQLException
+    {
+        if(!tableExists(XID_TABLE_NAME, conn))
+        {
+            Statement stmt = conn.createStatement();
+            try
+            {
+                stmt.execute(CREATE_XIDS_TABLE);
+            }
+            finally
+            {
+                stmt.close();
+            }
+        }
+    }
 
 
+    private void createXidActionTable(final Connection conn) throws SQLException
+    {
+        if(!tableExists(XID_ACTIONS_TABLE_NAME, conn))
+        {
+            Statement stmt = conn.createStatement();
+            try
+            {
+                stmt.execute(CREATE_XID_ACTIONS_TABLE);
+            }
+            finally
+            {
+                stmt.close();
+            }
+        }
+    }
 
     private boolean tableExists(final String tableName, final Connection conn) throws SQLException
     {
@@ -650,12 +710,12 @@
             conn = newAutoCommitConnection();
 
             PreparedStatement stmt = conn.prepareStatement(SELECT_ALL_FROM_BRIDGES);
-            stmt.setLong(1, linkId.getLeastSignificantBits());
-            stmt.setLong(2, linkId.getMostSignificantBits());
-
 
             try
             {
+                stmt.setLong(1, linkId.getLeastSignificantBits());
+                stmt.setLong(2, linkId.getMostSignificantBits());
+
                 ResultSet rs = stmt.executeQuery();
 
                 try
@@ -1110,11 +1170,7 @@
                                     insertStmt.setString(3, routingKey == null ? null : routingKey.toString());
                                     if(args != null)
                                     {
-                                        /* This would be the Java 6 way of setting a Blob
-                                        Blob blobArgs = conn.createBlob();
-                                        blobArgs.setBytes(0, args.getDataAsBytes());
-                                        stmt.setBlob(4, blobArgs);
-                                        */
+                                        // TODO - In Java 6 we could use create/set Blob
                                         byte[] bytes = args.getDataAsBytes();
                                         ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
                                         insertStmt.setBinaryStream(4, bis, bytes.length);
@@ -1712,7 +1768,7 @@
 
                 if (_logger.isDebugEnabled())
                 {
-                    _logger.debug("Dequeuing message " + messageId + " on queue " + name );//+ "[Connection" + conn + "]");
+                    _logger.debug("Dequeuing message " + messageId + " on queue " + name );
                 }
             }
             finally
@@ -1729,6 +1785,126 @@
 
     }
 
+
+    private void removeXid(ConnectionWrapper connWrapper, long format, byte[] globalId, byte[] branchId)
+            throws AMQStoreException
+    {
+        Connection conn = connWrapper.getConnection();
+
+
+        try
+        {
+            PreparedStatement stmt = conn.prepareStatement(DELETE_FROM_XIDS);
+            try
+            {
+                stmt.setLong(1,format);
+                stmt.setBytes(2,globalId);
+                stmt.setBytes(3,branchId);
+                int results = stmt.executeUpdate();
+
+
+
+                if(results != 1)
+                {
+                    throw new AMQStoreException("Unable to find message with xid");
+                }
+            }
+            finally
+            {
+                stmt.close();
+            }
+
+            stmt = conn.prepareStatement(DELETE_FROM_XID_ACTIONS);
+            try
+            {
+                stmt.setLong(1,format);
+                stmt.setBytes(2,globalId);
+                stmt.setBytes(3,branchId);
+                int results = stmt.executeUpdate();
+
+            }
+            finally
+            {
+                stmt.close();
+            }
+
+        }
+        catch (SQLException e)
+        {
+            _logger.error("Failed to dequeue: " + e.getMessage(), e);
+            throw new AMQStoreException("Error deleting enqueued message with xid", e);
+        }
+
+    }
+
+
+    private void recordXid(ConnectionWrapper connWrapper, long format, byte[] globalId, byte[] branchId,
+                           Transaction.Record[] enqueues, Transaction.Record[] dequeues) throws AMQStoreException
+    {
+        Connection conn = connWrapper.getConnection();
+
+
+        try
+        {
+
+            PreparedStatement stmt = conn.prepareStatement(INSERT_INTO_XIDS);
+            try
+            {
+                stmt.setLong(1,format);
+                stmt.setBytes(2, globalId);
+                stmt.setBytes(3, branchId);
+                stmt.executeUpdate();
+            }
+            finally
+            {
+                stmt.close();
+            }
+            
+            stmt = conn.prepareStatement(INSERT_INTO_XID_ACTIONS);
+
+            try
+            {
+                stmt.setLong(1,format);
+                stmt.setBytes(2, globalId);
+                stmt.setBytes(3, branchId);
+
+                if(enqueues != null)
+                {
+                    stmt.setString(4, "E");
+                    for(Transaction.Record record : enqueues)
+                    {
+                        stmt.setString(5, record.getQueue().getResourceName());
+                        stmt.setLong(6, record.getMessage().getMessageNumber());
+                        stmt.executeUpdate();
+                    }
+                }
+
+                if(dequeues != null)
+                {
+                    stmt.setString(4, "D");
+                    for(Transaction.Record record : dequeues)
+                    {
+                        stmt.setString(5, record.getQueue().getResourceName());
+                        stmt.setLong(6, record.getMessage().getMessageNumber());
+                        stmt.executeUpdate();
+                    }
+                }
+
+            }
+            finally
+            {
+                stmt.close();
+            }
+
+        }
+        catch (SQLException e)
+        {
+            _logger.error("Failed to enqueue: " + e.getMessage(), e);
+            throw new AMQStoreException("Error writing xid ", e);
+        }
+
+    }
+    
     private static final class ConnectionWrapper
     {
         private final Connection _connection;
@@ -1922,7 +2098,7 @@
 
 
 
-    private void recoverQueueEntries(TransactionLogRecoveryHandler recoveryHandler) throws SQLException
+    private TransactionLogRecoveryHandler.DtxRecordRecoveryHandler recoverQueueEntries(TransactionLogRecoveryHandler recoveryHandler) throws SQLException
     {
         Connection conn = newAutoCommitConnection();
         try
@@ -1953,7 +2129,7 @@
                 stmt.close();
             }
 
-            queueEntryHandler.completeQueueEntryRecovery();
+            return queueEntryHandler.completeQueueEntryRecovery();
         }
         finally
         {
@@ -1961,6 +2137,166 @@
         }
     }
 
+    private static final class Xid
+    {
+
+        private final long _format;
+        private final byte[] _globalId;
+        private final byte[] _branchId;
+
+        public Xid(long format, byte[] globalId, byte[] branchId)
+        {
+            _format = format;
+            _globalId = globalId;
+            _branchId = branchId;
+        }
+
+        public long getFormat()
+        {
+            return _format;
+        }
+
+        public byte[] getGlobalId()
+        {
+            return _globalId;
+        }
+
+        public byte[] getBranchId()
+        {
+            return _branchId;
+        }
+    }
+
+    private static class RecordImpl implements MessageStore.Transaction.Record, TransactionLogResource, EnqueableMessage
+    {
+
+        private final String _queueName;
+        private long _messageNumber;
+
+        public RecordImpl(String queueName, long messageNumber)
+        {
+            _queueName = queueName;
+            _messageNumber = messageNumber;
+        }
+
+        public TransactionLogResource getQueue()
+        {
+            return this;
+        }
+
+        public EnqueableMessage getMessage()
+        {
+            return this;
+        }
+
+        public long getMessageNumber()
+        {
+            return _messageNumber;
+        }
+
+        public boolean isPersistent()
+        {
+            return true;
+        }
+
+        public StoredMessage getStoredMessage()
+        {
+            throw new UnsupportedOperationException();
+        }
+
+        public String getResourceName()
+        {
+            return _queueName;
+        }
+    }
+
+    private void recoverXids(TransactionLogRecoveryHandler.DtxRecordRecoveryHandler dtxrh) throws SQLException
+    {
+        Connection conn = newAutoCommitConnection();
+        try
+        {
+            List<Xid> xids = new ArrayList<Xid>();
+            
+            Statement stmt = conn.createStatement();
+            try
+            {
+                ResultSet rs = stmt.executeQuery(SELECT_ALL_FROM_XIDS);
+                try
+                {
+                    while(rs.next())
+                    {
+
+                        long format = rs.getLong(1);
+                        byte[] globalId = rs.getBytes(2);
+                        byte[] branchId = rs.getBytes(3);
+                        xids.add(new Xid(format, globalId, branchId));
+                    }
+                }
+                finally
+                {
+                    rs.close();
+                }
+            }
+            finally
+            {
+                stmt.close();
+            }
+
+            
+            
+            for(Xid xid : xids)
+            {
+                List<RecordImpl> enqueues = new ArrayList<RecordImpl>();
+                List<RecordImpl> dequeues = new ArrayList<RecordImpl>();
+                
+                PreparedStatement pstmt = conn.prepareStatement(SELECT_ALL_FROM_XID_ACTIONS);
+            
+                try
+                {
+                    pstmt.setLong(1, xid.getFormat());
+                    pstmt.setBytes(2, xid.getGlobalId());
+                    pstmt.setBytes(3, xid.getBranchId());
+
+                    ResultSet rs = pstmt.executeQuery();
+                    try
+                    {
+                        while(rs.next())
+                        {
+
+                            String actionType = rs.getString(1);
+                            String queueName = rs.getString(2);
+                            long messageId = rs.getLong(3);
+
+                            RecordImpl record = new RecordImpl(queueName, messageId);
+                            List<RecordImpl> records = "E".equals(actionType) ? enqueues : dequeues;
+                            records.add(record);
+                        }
+                    }
+                    finally
+                    {
+                        rs.close();
+                    }
+                }
+                finally
+                {
+                    pstmt.close();
+                }
+                
+                dtxrh.dtxRecord(xid.getFormat(), xid.getGlobalId(), xid.getBranchId(), 
+                                enqueues.toArray(new RecordImpl[enqueues.size()]), 
+                                dequeues.toArray(new RecordImpl[dequeues.size()]));
+            }
+            
+            
+            dtxrh.completeDtxRecordRecovery();
+        }
+        finally
+        {
+            conn.close();
+        }
+
+    }
+    
     StorableMessageMetaData getMetaData(long messageId) throws SQLException
     {
 
@@ -2031,11 +2367,8 @@
             stmt.setInt(3, offset+chunkData.length);
 
 
-            /* this would be the Java 6 way of doing things
-            Blob dataAsBlob = conn.createBlob();
-            dataAsBlob.setBytes(1L, chunkData);
-            stmt.setBlob(3, dataAsBlob);
-            */
+            // TODO in Java 6 we could just use blobs
+
             ByteArrayInputStream bis = new ByteArrayInputStream(chunkData);
             stmt.setBinaryStream(4, bis, chunkData.length);
             stmt.executeUpdate();
@@ -2181,8 +2514,21 @@
         {
             DerbyMessageStore.this.abortTran(_connWrapper);
         }
+
+        public void removeXid(long format, byte[] globalId, byte[] branchId) throws AMQStoreException
+        {
+            DerbyMessageStore.this.removeXid(_connWrapper, format, globalId, branchId);
+        }
+
+        public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
+                throws AMQStoreException
+        {
+            DerbyMessageStore.this.recordXid(_connWrapper, format, globalId, branchId, enqueues, dequeues);
+        }
     }
 
+
+
     private class StoredDerbyMessage implements StoredMessage
     {
 
@@ -2366,4 +2712,4 @@
         }
     }
 
-}
+}
\ No newline at end of file
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java
index 9cd2567..123ecd8 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.store;
 
 import org.apache.commons.configuration.Configuration;
+
 import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java
index c5393f7..b01e5aa 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java
@@ -20,12 +20,9 @@
  */
 package org.apache.qpid.server.store;
 
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
-
 import org.apache.commons.configuration.Configuration;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.framing.AMQShortString;
@@ -38,9 +35,12 @@
 import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
 import org.apache.qpid.server.logging.messages.MessageStoreMessages;
 import org.apache.qpid.server.message.EnqueableMessage;
-import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.queue.AMQQueue;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+
 /** A simple message store that stores the messages in a threadsafe structure in memory. */
 public class MemoryMessageStore implements MessageStore, DurableConfigurationStore
 {
@@ -78,6 +78,14 @@
         {
         }
 
+        public void removeXid(long format, byte[] globalId, byte[] branchId)
+        {
+        }
+
+        public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
+        {
+        }
+
     };
 
     public void configureConfigStore(String name, ConfigurationRecoveryHandler handler, Configuration configuration, LogSubject logSubject) throws Exception
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStore.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStore.java
index 88c95ad..00bb044 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStore.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStore.java
@@ -20,9 +20,9 @@
  */
 package org.apache.qpid.server.store;
 
+import org.apache.commons.configuration.Configuration;
 import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.server.logging.LogSubject;
-import org.apache.commons.configuration.Configuration;
 import org.apache.qpid.server.message.EnqueableMessage;
 
 /**
@@ -125,7 +125,16 @@
         void abortTran() throws AMQStoreException;
 
 
+        public static interface Record
+        {
+            TransactionLogResource getQueue();
+            EnqueableMessage getMessage();
+        }
 
+        void removeXid(long format, byte[] globalId, byte[] branchId) throws AMQStoreException;
+
+        void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
+                throws AMQStoreException;
     }
 
     public void configureTransactionLog(String name,
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStoreClosedException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStoreClosedException.java
index 3d1538c..b0a736c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStoreClosedException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStoreClosedException.java
@@ -1,6 +1,4 @@
-package org.apache.qpid.server.store;
-
-import org.apache.qpid.AMQException;/*
+/*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -21,6 +19,10 @@
  *
  */
 
+package org.apache.qpid.server.store;
+
+import org.apache.qpid.AMQException;
+
 /**
  * NOTE: this class currently extends AMQException but
  * we should be using AMQExceptions internally in the code base for Protocol errors hence
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/TransactionLogRecoveryHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/TransactionLogRecoveryHandler.java
index 802596e..48ca727 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/TransactionLogRecoveryHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/TransactionLogRecoveryHandler.java
@@ -28,6 +28,13 @@
     {
         void queueEntry(String queuename, long messageId);
 
-        void completeQueueEntryRecovery();
+        DtxRecordRecoveryHandler completeQueueEntryRecovery();
+    }
+
+    public static interface DtxRecordRecoveryHandler
+    {
+        void dtxRecord(long format, byte[] globalId, byte[] branchId, MessageStore.Transaction.Record[] enqueues, MessageStore.Transaction.Record[] dequeues);
+
+        void completeDtxRecordRecovery();
     }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/AssignedSubscriptionMessageGroupManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/AssignedSubscriptionMessageGroupManager.java
index f511cc0..6b2dff7 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/AssignedSubscriptionMessageGroupManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/AssignedSubscriptionMessageGroupManager.java
@@ -20,11 +20,12 @@
  */
 package org.apache.qpid.server.subscription;
 
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.QueueEntry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.QueueEntry;
+
 import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -47,7 +48,10 @@
     private static int pow2(final int i)
     {
         int val = 1;
-        while(val < i) val<<=1;
+        while(val < i)
+        {
+            val<<=1;
+        }
         return val;
     }
 
@@ -111,11 +115,15 @@
         public boolean visit(final QueueEntry entry)
         {
             if(!entry.isAvailable())
+            {
                 return false;
+            }
 
             Object groupId = entry.getMessage().getMessageHeader().getHeader(_groupId);
             if(groupId == null)
+            {
                 return false;
+            }
 
             Integer group = groupId.hashCode() & _groupMask;
             Subscription assignedSub = _groupMap.get(group);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ClientDeliveryMethod.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ClientDeliveryMethod.java
index fbc8b3a..632b59d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ClientDeliveryMethod.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ClientDeliveryMethod.java
@@ -20,8 +20,8 @@
 */
 package org.apache.qpid.server.subscription;
 
-import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.AMQException;
+import org.apache.qpid.server.queue.QueueEntry;
 
 public interface ClientDeliveryMethod
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/DefinedGroupMessageGroupManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/DefinedGroupMessageGroupManager.java
index 689e48b..62e94f6 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/DefinedGroupMessageGroupManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/DefinedGroupMessageGroupManager.java
@@ -20,12 +20,13 @@
  */
 package org.apache.qpid.server.subscription;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.QueueEntry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -188,7 +189,9 @@
         public boolean visit(final QueueEntry entry)
         {
             if(!entry.isAvailable())
+            {
                 return false;
+            }
 
             Object groupId = getKey(entry);
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ExplicitAcceptDispositionChangeListener.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ExplicitAcceptDispositionChangeListener.java
index 80c5e28..cf27548 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ExplicitAcceptDispositionChangeListener.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ExplicitAcceptDispositionChangeListener.java
@@ -20,10 +20,11 @@
  */
 package org.apache.qpid.server.subscription;
 
-import org.apache.qpid.server.transport.ServerSession;
-import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.server.queue.QueueEntry;
+import org.apache.qpid.server.transport.ServerSession;
+
 
 class ExplicitAcceptDispositionChangeListener implements ServerSession.MessageDispositionChangeListener
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ImplicitAcceptDispositionChangeListener.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ImplicitAcceptDispositionChangeListener.java
index a61b0b4..1e37675 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ImplicitAcceptDispositionChangeListener.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/ImplicitAcceptDispositionChangeListener.java
@@ -20,10 +20,11 @@
  */
 package org.apache.qpid.server.subscription;
 
-import org.apache.qpid.server.transport.ServerSession;
-import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.server.queue.QueueEntry;
+import org.apache.qpid.server.transport.ServerSession;
+
 class ImplicitAcceptDispositionChangeListener implements ServerSession.MessageDispositionChangeListener
 {
     private static final Logger _logger = Logger.getLogger(ImplicitAcceptDispositionChangeListener.class);
@@ -71,8 +72,6 @@
     public boolean acquire()
     {
         boolean acquired = _entry.acquire(getSubscription());
-        //TODO - why acknowledge here??? seems bizarre...
-      //  getSubscription().getSession().acknowledge(getSubscription(), _entry);
         return acquired;
 
     }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription.java
index bc1be90..66825ca 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription.java
@@ -22,7 +22,6 @@
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.QueueEntry;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionFactory.java
index 0fd7fdf..3659243 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionFactory.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionFactory.java
@@ -20,22 +20,21 @@
  */
 package org.apache.qpid.server.subscription;
 
-import java.util.Map;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.server.protocol.AMQProtocolSession;
+import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.filter.FilterManager;
 import org.apache.qpid.server.flow.FlowCreditManager;
 import org.apache.qpid.server.flow.FlowCreditManager_0_10;
-import org.apache.qpid.server.subscription.Subscription;
+import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.transport.ServerSession;
-import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.transport.MessageAcceptMode;
 import org.apache.qpid.transport.MessageAcquireMode;
 import org.apache.qpid.transport.MessageFlowMode;
 
+import java.util.Map;
+
 /**
  * Allows the customisation of the creation of a subscription. This is typically done within an AMQQueue. This factory
  * primarily assists testing although in future more sophisticated subscribers may need a different subscription
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionFactoryImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionFactoryImpl.java
index 1622d63..a2e30b6 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionFactoryImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionFactoryImpl.java
@@ -20,9 +20,6 @@
  */
 package org.apache.qpid.server.subscription;
 
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.common.AMQPFilterTypes;
 import org.apache.qpid.framing.AMQShortString;
@@ -38,6 +35,9 @@
 import org.apache.qpid.transport.MessageAcquireMode;
 import org.apache.qpid.transport.MessageFlowMode;
 
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+
 public class SubscriptionFactoryImpl implements SubscriptionFactory
 {
     private static final AtomicLong SUB_ID_GENERATOR = new AtomicLong(0);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
index 23ae14e..1f25c21 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
@@ -24,7 +24,6 @@
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.common.AMQPFilterTypes;
-import org.apache.qpid.common.ClientProperties;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.server.AMQChannel;
@@ -320,9 +319,6 @@
 
     private final Boolean _autoClose;
 
-
-    private static final String CLIENT_PROPERTIES_INSTANCE = ClientProperties.instance.toString();
-
     private AMQQueue _queue;
     private final AtomicBoolean _deleted = new AtomicBoolean(false);
 
@@ -479,10 +475,6 @@
 
     public boolean hasInterest(QueueEntry entry)
     {
-
-
-
-
         //check that the message hasn't been rejected
         if (entry.isRejectedBy(getSubscriptionID()))
         {
@@ -490,27 +482,21 @@
             {
                 _logger.debug("Subscription:" + this + " rejected message:" + entry);
             }
-//            return false;
         }
 
         if (_noLocal)
         {
-
             AMQMessage message = (AMQMessage) entry.getMessage();
 
-            //todo - client id should be recorded so we don't have to handle
-            // the case where this is null.
-            final Object publisher = message.getPublisherIdentifier();
+            final Object publisherReference = message.getConnectionIdentifier();
 
             // We don't want local messages so check to see if message is one we sent
-            Object localInstance = getProtocolSession();
+            Object localReference = getProtocolSession().getReference();
 
-            if(publisher.equals(localInstance))
+            if(publisherReference != null && publisherReference.equals(localReference))
             {
                 return false;
             }
-
-
         }
 
 
@@ -585,7 +571,7 @@
 
     public boolean wouldSuspend(QueueEntry msg)
     {
-        return !_creditManager.useCreditForMessage(msg.getMessage().getSize());//_channel.wouldSuspend(msg.getMessage());
+        return !_creditManager.useCreditForMessage(msg.getMessage().getSize());
     }
 
     public boolean trySendLock()
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionList.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionList.java
index 3e6299c..bf5ce31 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionList.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionList.java
@@ -20,11 +20,9 @@
 */
 package org.apache.qpid.server.subscription;
 
-import org.apache.qpid.server.subscription.Subscription;
-
-import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
 
 public class SubscriptionList
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription_0_10.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription_0_10.java
index bde756d..76d975a 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription_0_10.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription_0_10.java
@@ -20,46 +20,58 @@
  */
 package org.apache.qpid.server.subscription;
 
-import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SUBSCRIPTION_FORMAT;
-import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.QUEUE_FORMAT;
-
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.BaseQueue;
-import org.apache.qpid.server.queue.InboundMessageAdapter;
-import org.apache.qpid.server.queue.QueueEntry;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.server.configuration.ConfigStore;
 import org.apache.qpid.server.configuration.ConfiguredObject;
 import org.apache.qpid.server.configuration.SessionConfig;
 import org.apache.qpid.server.configuration.SubscriptionConfig;
 import org.apache.qpid.server.configuration.SubscriptionConfigType;
 import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.flow.FlowCreditManager;
-import org.apache.qpid.server.flow.CreditCreditManager;
-import org.apache.qpid.server.flow.WindowCreditManager;
-import org.apache.qpid.server.flow.FlowCreditManager_0_10;
 import org.apache.qpid.server.filter.FilterManager;
+import org.apache.qpid.server.flow.CreditCreditManager;
+import org.apache.qpid.server.flow.FlowCreditManager;
+import org.apache.qpid.server.flow.FlowCreditManager_0_10;
+import org.apache.qpid.server.flow.WindowCreditManager;
+import org.apache.qpid.server.logging.LogActor;
+import org.apache.qpid.server.logging.LogSubject;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.actors.GenericActor;
 import org.apache.qpid.server.logging.messages.ChannelMessages;
 import org.apache.qpid.server.logging.messages.SubscriptionMessages;
-import org.apache.qpid.server.logging.LogActor;
-import org.apache.qpid.server.logging.LogSubject;
-import org.apache.qpid.server.message.InboundMessage;
-import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.message.MessageTransferMessage;
 import org.apache.qpid.server.message.AMQMessage;
+import org.apache.qpid.server.message.InboundMessage;
+import org.apache.qpid.server.message.MessageTransferMessage;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.server.queue.InboundMessageAdapter;
+import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.transport.ServerSession;
-import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.txn.AutoCommitTransaction;
-import org.apache.qpid.transport.*;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.transport.util.Logger;
+import org.apache.qpid.server.txn.ServerTransaction;
+import org.apache.qpid.transport.DeliveryProperties;
+import org.apache.qpid.transport.Header;
+import org.apache.qpid.transport.MessageAcceptMode;
+import org.apache.qpid.transport.MessageAcquireMode;
+import org.apache.qpid.transport.MessageCreditUnit;
+import org.apache.qpid.transport.MessageDeliveryPriority;
+import org.apache.qpid.transport.MessageFlowMode;
+import org.apache.qpid.transport.MessageProperties;
+import org.apache.qpid.transport.MessageTransfer;
+import org.apache.qpid.transport.Method;
+import org.apache.qpid.transport.Option;
+import org.apache.qpid.transport.ReplyTo;
+import org.apache.qpid.transport.Struct;
 import org.apache.qpid.url.AMQBindingURL;
 
+import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.QUEUE_FORMAT;
+import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SUBSCRIPTION_FORMAT;
+
 import java.net.URISyntaxException;
+import java.nio.ByteBuffer;
 import java.text.MessageFormat;
 import java.util.Arrays;
 import java.util.Collections;
@@ -67,13 +79,12 @@
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.ConcurrentHashMap;
-import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
 
 public class Subscription_0_10 implements Subscription, FlowCreditManager.FlowCreditManagerListener, SubscriptionConfig, LogSubject
 {
@@ -387,6 +398,10 @@
                 {
                     deliveryProps.setTimestamp(origDeliveryProps.getTimestamp());
                 }
+                if(origDeliveryProps.hasTtl())
+                {
+                    deliveryProps.setTtl(origDeliveryProps.getTtl());
+                }
 
 
             }
@@ -537,36 +552,8 @@
                 messageProps.setCorrelationId(serverMsg.getMessageHeader().getCorrelationId().getBytes());
             }
 
-
             // TODO - ReplyTo
 
-
-            final Map<String, Object> appHeaders = new HashMap<String, Object>();
-
-            /*properties.getHeaders().processOverElements(
-                    new FieldTable.FieldTableElementProcessor()
-                    {
-
-                        public boolean processElement(String propertyName, AMQTypedValue value)
-                        {
-                            Object val = value.getValue();
-                            if(val instanceof AMQShortString)
-                            {
-                                val = val.toString();
-                            }
-                            appHeaders.put(propertyName, val);
-                            return true;
-                        }
-
-                        public Object getResult()
-                        {
-                            return appHeaders;
-                        }
-                    });
-
-
-            messageProps.setApplicationHeaders(appHeaders);
-*/
             Header header = new Header(deliveryProps, messageProps, null);
             xfr = batch ? new MessageTransfer(_destination,_acceptMode,_acquireMode,header, body, BATCHED)
                         : new MessageTransfer(_destination,_acceptMode,_acquireMode,header, body);
@@ -690,7 +677,10 @@
     {
         entry.setRedelivered();
         entry.routeToAlternate();
-
+        if(entry.isAcquiredBy(this))
+        {
+            entry.discard();
+        }
     }
 
     void release(final QueueEntry entry, final boolean setRedelivered)
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java
index abbc5a3..637ea7d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java
@@ -24,8 +24,8 @@
 
 public class QpidAcceptor
 {
-    NetworkTransport _transport;
-    String _protocol;
+    private NetworkTransport _transport;
+    private String _protocol;
     public QpidAcceptor(NetworkTransport transport, String protocol)
     {
         _transport = transport;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java
index 04cdbf2..c38f3d0 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java
@@ -20,27 +20,6 @@
  */
 package org.apache.qpid.server.transport;
 
-import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.CONNECTION_FORMAT;
-import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SOCKET_FORMAT;
-import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.USER_FORMAT;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.management.JMException;
-
-import org.apache.qpid.server.management.ManagedObject;
-
-import org.apache.qpid.server.management.Managable;
-
-import java.security.Principal;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.security.auth.Subject;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.configuration.ConnectionConfig;
@@ -49,6 +28,8 @@
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.actors.GenericActor;
 import org.apache.qpid.server.logging.messages.ConnectionMessages;
+import org.apache.qpid.server.management.Managable;
+import org.apache.qpid.server.management.ManagedObject;
 import org.apache.qpid.server.protocol.AMQConnectionModel;
 import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.security.AuthorizationHolder;
@@ -62,8 +43,20 @@
 import org.apache.qpid.transport.Method;
 import org.apache.qpid.transport.ProtocolEvent;
 import org.apache.qpid.transport.Session;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.CONNECTION_FORMAT;
+import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SOCKET_FORMAT;
+import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.USER_FORMAT;
+
+import javax.management.JMException;
+import javax.security.auth.Subject;
+import java.security.Principal;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
 
 public class ServerConnection extends Connection implements Managable, AMQConnectionModel, LogSubject, AuthorizationHolder
 {
@@ -114,7 +107,7 @@
             {
                 _onOpenTask.run();    
             }
-            _actor.message(ConnectionMessages.OPEN(getClientId(), "0-10", true, true));
+            _actor.message(ConnectionMessages.OPEN(getClientId(), "0-10", getClientVersion(), true, true, true));
 
             getVirtualHost().getConnectionRegistry().registerConnection(this);
         }
@@ -495,4 +488,14 @@
             _mBean = null;
         }
     }
+
+    public String getClientId()
+    {
+        return getConnectionDelegate().getClientId();
+    }
+
+    public String getClientVersion()
+    {
+        return getConnectionDelegate().getClientVersion();
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
index 66ed6f1..28d8cb2 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
@@ -20,17 +20,10 @@
  */
 package org.apache.qpid.server.transport;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import javax.security.sasl.SaslException;
-import javax.security.sasl.SaslServer;
+import static org.apache.qpid.transport.Connection.State.CLOSE_RCVD;
+
 import org.apache.qpid.common.ServerPropertyNames;
+import org.apache.qpid.properties.ConnectionStartProperties;
 import org.apache.qpid.protocol.ProtocolEngine;
 import org.apache.qpid.server.configuration.BrokerConfig;
 import org.apache.qpid.server.protocol.AMQConnectionModel;
@@ -41,24 +34,25 @@
 import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus;
 import org.apache.qpid.server.subscription.Subscription_0_10;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.transport.Binary;
-import org.apache.qpid.transport.Connection;
-import org.apache.qpid.transport.ConnectionClose;
-import org.apache.qpid.transport.ConnectionCloseCode;
-import org.apache.qpid.transport.ConnectionOpen;
-import org.apache.qpid.transport.ConnectionOpenOk;
-import org.apache.qpid.transport.ConnectionStartOk;
-import org.apache.qpid.transport.ConnectionTuneOk;
-import org.apache.qpid.transport.ServerDelegate;
-import org.apache.qpid.transport.Session;
-import org.apache.qpid.transport.SessionAttach;
-import org.apache.qpid.transport.SessionDelegate;
-import org.apache.qpid.transport.SessionDetach;
-import org.apache.qpid.transport.SessionDetachCode;
-import org.apache.qpid.transport.SessionDetached;
+import org.apache.qpid.transport.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
 
 public class ServerConnectionDelegate extends ServerDelegate
 {
+    private static final Logger LOGGER = LoggerFactory.getLogger(ServerConnectionDelegate.class);
+
     private final String _localFQDN;
     private final IApplicationRegistry _appRegistry;
     private int _maxNoOfChannels;
@@ -140,17 +134,20 @@
         }
     }
 
+    @Override
     public void connectionClose(Connection conn, ConnectionClose close)
     {
+        final ServerConnection sconn = (ServerConnection) conn;
         try
         {
-            ((ServerConnection) conn).logClosed();
+            sconn.logClosed();
         }
         finally
         {
-            super.connectionClose(conn, close);
+            sconn.closeCode(close);
+            sconn.setState(CLOSE_RCVD);
+            sendConnectionCloseOkAndCloseSender(conn);
         }
-        
     }
 
     public void connectionOpen(Connection conn, ConnectionOpen open)
@@ -177,19 +174,19 @@
 
             if (!vhost.getSecurityManager().accessVirtualhost(vhostName, ((ProtocolEngine) sconn.getConfig()).getRemoteAddress()))
             {
-                sconn.invoke(new ConnectionClose(ConnectionCloseCode.CONNECTION_FORCED, "Permission denied '"+vhostName+"'"));
                 sconn.setState(Connection.State.CLOSING);
+                sconn.invoke(new ConnectionClose(ConnectionCloseCode.CONNECTION_FORCED, "Permission denied '"+vhostName+"'"));
             }
             else
             {
-	            sconn.invoke(new ConnectionOpenOk(Collections.emptyList()));
-	            sconn.setState(Connection.State.OPEN);
+                sconn.setState(Connection.State.OPEN);
+                sconn.invoke(new ConnectionOpenOk(Collections.emptyList()));
             }
         }
         else
         {
-            sconn.invoke(new ConnectionClose(ConnectionCloseCode.INVALID_PATH, "Unknown virtualhost '"+vhostName+"'"));
             sconn.setState(Connection.State.CLOSING);
+            sconn.invoke(new ConnectionClose(ConnectionCloseCode.INVALID_PATH, "Unknown virtualhost '"+vhostName+"'"));
         }
         
     }
@@ -202,9 +199,9 @@
 
         if (okChannelMax > getChannelMax())
         {
-            _logger.error("Connection '" + sconn.getConnectionId() + "' being severed, " +
+            LOGGER.error("Connection '" + sconn.getConnectionId() + "' being severed, " +
                     "client connectionTuneOk returned a channelMax (" + okChannelMax +
-                    ") above the servers offered limit (" + getChannelMax() +")");
+                    ") above the server's offered limit (" + getChannelMax() +")");
 
             //Due to the error we must forcefully close the connection without negotiation
             sconn.getSender().close();
@@ -234,23 +231,26 @@
 
     @Override public void sessionDetach(Connection conn, SessionDetach dtc)
     {
-        // To ensure a clean detach, we unregister any remaining subscriptions. Unregister ensures
-        // that any in-progress delivery (SubFlushRunner/QueueRunner) is completed before the unregister
+        // To ensure a clean detach, we stop any remaining subscriptions. Stop ensures
+        // that any in-progress delivery (SubFlushRunner/QueueRunner) is completed before the stop
         // completes.
-        unregisterAllSubscriptions(conn, dtc);
+        stopAllSubscriptions(conn, dtc);
+        Session ssn = conn.getSession(dtc.getChannel());
+        ((ServerSession)ssn).setClose(true);
         super.sessionDetach(conn, dtc);
     }
 
-    private void unregisterAllSubscriptions(Connection conn, SessionDetach dtc)
+    private void stopAllSubscriptions(Connection conn, SessionDetach dtc)
     {
         final ServerSession ssn = (ServerSession) conn.getSession(dtc.getChannel());
         final Collection<Subscription_0_10> subs = ssn.getSubscriptions();
         for (Subscription_0_10 subscription_0_10 : subs)
         {
-            ssn.unregister(subscription_0_10);
+            subscription_0_10.stop();
         }
     }
 
+
     @Override
     public void sessionAttach(final Connection conn, final SessionAttach atc)
     {
@@ -258,8 +258,7 @@
 
         if(isSessionNameUnique(atc.getName(), conn))
         {
-            ssn = sessionAttachImpl(conn, atc);
-            conn.registerSession(ssn);
+            super.sessionAttach(conn, atc);
             ((ServerConnection)conn).checkForNotification();
         }
         else
@@ -299,4 +298,14 @@
     {
         return _clientProperties;
     }
+
+    public String getClientId()
+    {
+        return _clientProperties == null ? null : (String) _clientProperties.get(ConnectionStartProperties.CLIENT_ID_0_10);
+    }
+
+    public String getClientVersion()
+    {
+        return _clientProperties == null ? null : (String) _clientProperties.get(ConnectionStartProperties.VERSION_0_10);
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java
index 17c7bed..bb54516 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java
@@ -20,17 +20,6 @@
  */
 package org.apache.qpid.server.transport;
 
-import java.io.IOException;
-import java.util.Date;
-import java.util.List;
-import javax.management.JMException;
-import javax.management.NotCompliantMBeanException;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularDataSupport;
-
-import org.apache.qpid.common.ClientProperties;
 import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor;
 import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
 import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -39,6 +28,16 @@
 import org.apache.qpid.server.management.ManagedObject;
 import org.apache.qpid.server.protocol.AMQSessionModel;
 
+import javax.management.JMException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
+
 /**
  * This MBean class implements the management interface. In order to make more attributes, operations and notifications
  * available over JMX simply augment the ManagedConnection interface and add the appropriate implementation here.
@@ -76,7 +75,7 @@
     @Override
     public String getVersion()
     {
-        return String.valueOf(_serverConnection.getConnectionDelegate().getClientProperties().get(ClientProperties.version.toString()));
+        return String.valueOf(_serverConnection.getClientVersion());
     }
 
     @Override
@@ -132,7 +131,7 @@
         }
         else if (session.isTransactional())
         {
-            CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+            CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
             try
             {
                 session.commit();
@@ -154,7 +153,7 @@
         }
         else if (session.isTransactional())
         {
-            CurrentActor.set(new ManagementActor(_logActor.getRootMessageLogger()));
+            CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
             try
             {
                 session.rollback();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
index 62a1e2b..d63934e 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
@@ -21,6 +21,11 @@
 package org.apache.qpid.server.transport;
 
 import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.CHANNEL_FORMAT;
+import org.apache.qpid.server.message.InboundMessage;
+import org.apache.qpid.server.message.MessageMetaData_0_10;
+import org.apache.qpid.server.message.MessageTransferMessage;
+import org.apache.qpid.server.txn.RollbackOnlyDtxException;
+import org.apache.qpid.server.txn.TimeoutDtxException;
 import static org.apache.qpid.util.Serial.gt;
 
 import java.security.Principal;
@@ -30,17 +35,21 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.SortedMap;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
+
 import javax.security.auth.Subject;
+
 import org.apache.qpid.AMQException;
+import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.protocol.ProtocolEngine;
 import org.apache.qpid.server.configuration.ConfigStore;
@@ -64,24 +73,19 @@
 import org.apache.qpid.server.security.AuthorizationHolder;
 import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.subscription.Subscription_0_10;
+import org.apache.qpid.server.txn.AlreadyKnownDtxException;
 import org.apache.qpid.server.txn.AsyncAutoCommitTransaction;
+import org.apache.qpid.server.txn.DistributedTransaction;
+import org.apache.qpid.server.txn.DtxNotSelectedException;
+import org.apache.qpid.server.txn.IncorrectDtxStateException;
+import org.apache.qpid.server.txn.JoinAndResumeDtxException;
 import org.apache.qpid.server.txn.LocalTransaction;
+import org.apache.qpid.server.txn.NotAssociatedDtxException;
 import org.apache.qpid.server.txn.ServerTransaction;
+import org.apache.qpid.server.txn.SuspendAndFailDtxException;
+import org.apache.qpid.server.txn.UnknownDtxBranchException;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.transport.Binary;
-import org.apache.qpid.transport.Connection;
-import org.apache.qpid.transport.MessageCreditUnit;
-import org.apache.qpid.transport.MessageFlow;
-import org.apache.qpid.transport.MessageFlowMode;
-import org.apache.qpid.transport.MessageSetFlowMode;
-import org.apache.qpid.transport.MessageStop;
-import org.apache.qpid.transport.MessageTransfer;
-import org.apache.qpid.transport.Method;
-import org.apache.qpid.transport.Range;
-import org.apache.qpid.transport.RangeSet;
-import org.apache.qpid.transport.RangeSetFactory;
-import org.apache.qpid.transport.Session;
-import org.apache.qpid.transport.SessionDelegate;
+import org.apache.qpid.transport.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -100,13 +104,12 @@
     private long _createTime = System.currentTimeMillis();
     private LogActor _actor = GenericActor.getInstance(this);
 
-    private final ConcurrentMap<AMQQueue, Boolean> _blockingQueues = new ConcurrentHashMap<AMQQueue, Boolean>();
+    private final Set<AMQQueue> _blockingQueues = new ConcurrentSkipListSet<AMQQueue>();
 
     private final AtomicBoolean _blocking = new AtomicBoolean(false);
     private ChannelLogSubject _logSubject;
     private final AtomicInteger _outstandingCredit = new AtomicInteger(UNLIMITED_CREDIT);
 
-
     public static interface MessageDispositionChangeListener
     {
         public void onAccept();
@@ -356,7 +359,15 @@
 
     public void onClose()
     {
-        _transaction.rollback();
+        if(_transaction instanceof LocalTransaction)
+        {
+            _transaction.rollback();
+        }
+        else if(_transaction instanceof DistributedTransaction)
+        {
+            getVirtualHost().getDtxRegistry().endAssociations(this);
+        }
+
         for(MessageDispositionChangeListener listener : _messageDispositionListenerMap.values())
         {
             listener.onRelease(true);
@@ -392,6 +403,9 @@
 
                                  public void onRollback()
                                  {
+                                     // The client has acknowledge the message and therefore have seen it.
+                                     // In the event of rollback, the message must be marked as redelivered.
+                                     entry.setRedelivered();
                                      entry.release();
                                  }
                              });
@@ -452,6 +466,95 @@
         _txnStarts.incrementAndGet();
     }
 
+    public void selectDtx()
+    {
+        _transaction = new DistributedTransaction(this, getMessageStore(), getVirtualHost());
+
+    }
+
+
+    public void startDtx(Xid xid, boolean join, boolean resume)
+            throws JoinAndResumeDtxException,
+                   UnknownDtxBranchException,
+                   AlreadyKnownDtxException,
+                   DtxNotSelectedException
+    {
+        DistributedTransaction distributedTransaction = assertDtxTransaction();
+        distributedTransaction.start(xid, join, resume);
+    }
+
+
+    public void endDtx(Xid xid, boolean fail, boolean suspend)
+            throws NotAssociatedDtxException,
+            UnknownDtxBranchException,
+            DtxNotSelectedException,
+            SuspendAndFailDtxException, TimeoutDtxException
+    {
+        DistributedTransaction distributedTransaction = assertDtxTransaction();
+        distributedTransaction.end(xid, fail, suspend);
+    }
+
+
+    public long getTimeoutDtx(Xid xid)
+            throws UnknownDtxBranchException
+    {
+        return getVirtualHost().getDtxRegistry().getTimeout(xid);
+    }
+
+
+    public void setTimeoutDtx(Xid xid, long timeout)
+            throws UnknownDtxBranchException
+    {
+        getVirtualHost().getDtxRegistry().setTimeout(xid, timeout);
+    }
+
+
+    public void prepareDtx(Xid xid)
+            throws UnknownDtxBranchException,
+            IncorrectDtxStateException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException
+    {
+        getVirtualHost().getDtxRegistry().prepare(xid);
+    }
+
+    public void commitDtx(Xid xid, boolean onePhase)
+            throws UnknownDtxBranchException,
+            IncorrectDtxStateException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException
+    {
+        getVirtualHost().getDtxRegistry().commit(xid, onePhase);
+    }
+
+
+    public void rollbackDtx(Xid xid)
+            throws UnknownDtxBranchException,
+            IncorrectDtxStateException, AMQStoreException, TimeoutDtxException
+    {
+        getVirtualHost().getDtxRegistry().rollback(xid);
+    }
+
+
+    public void forgetDtx(Xid xid) throws UnknownDtxBranchException, IncorrectDtxStateException
+    {
+        getVirtualHost().getDtxRegistry().forget(xid);
+    }
+
+    public List<Xid> recoverDtx()
+    {
+        return getVirtualHost().getDtxRegistry().recover();
+    }
+
+    private DistributedTransaction assertDtxTransaction() throws DtxNotSelectedException
+    {
+        if(_transaction instanceof DistributedTransaction)
+        {
+            return (DistributedTransaction) _transaction;
+        }
+        else
+        {
+            throw new DtxNotSelectedException();
+        }
+    }
+
+
     public void commit()
     {
         _transaction.commit();
@@ -524,12 +627,12 @@
 
     public Principal getAuthorizedPrincipal()
     {
-        return ((ServerConnection) getConnection()).getAuthorizedPrincipal();
+        return getConnection().getAuthorizedPrincipal();
     }
     
     public Subject getAuthorizedSubject()
     {
-        return ((ServerConnection) getConnection()).getAuthorizedSubject();
+        return getConnection().getAuthorizedSubject();
     }
 
     public void addSessionCloseTask(Task task)
@@ -544,7 +647,7 @@
 
     public Object getReference()
     {
-        return ((ServerConnection) getConnection()).getReference();
+        return getConnection().getReference();
     }
 
     public MessageStore getMessageStore()
@@ -624,7 +727,7 @@
 
     public AMQConnectionModel getConnectionModel()
     {
-        return (ServerConnection) getConnection();
+        return getConnection();
     }
 
     public String getClientID()
@@ -632,6 +735,12 @@
         return getConnection().getClientId();
     }
 
+    @Override
+    public ServerConnection getConnection()
+    {
+        return (ServerConnection) super.getConnection();
+    }
+
     public LogActor getLogActor()
     {
         return _actor;
@@ -676,7 +785,8 @@
 
     public void block(AMQQueue queue)
     {
-        if(_blockingQueues.putIfAbsent(queue, Boolean.TRUE) == null)
+
+        if(_blockingQueues.add(queue))
         {
 
             if(_blocking.compareAndSet(false,true))
@@ -694,7 +804,7 @@
     {
         if(_blockingQueues.remove(queue) && _blockingQueues.isEmpty())
         {
-            if(_blocking.compareAndSet(true,false))
+            if(_blocking.compareAndSet(true,false) && !isClosing())
             {
 
                 _actor.message(_logSubject, ChannelMessages.FLOW_REMOVED());
@@ -710,11 +820,19 @@
         }
     }
 
+    public boolean onSameConnection(InboundMessage inbound)
+    {
+        return ((inbound instanceof MessageTransferMessage)
+                && ((MessageTransferMessage)inbound).getConnectionReference() == getConnection().getReference())
+                || ((inbound instanceof MessageMetaData_0_10)
+                    && (((MessageMetaData_0_10)inbound).getConnectionReference())== getConnection().getReference());
+    }
+
 
     public String toLogString()
     {
-        long connectionId = getConnection() instanceof ServerConnection
-                            ? ((ServerConnection) getConnection()).getConnectionId()
+        long connectionId = super.getConnection() instanceof ServerConnection
+                            ? getConnection().getConnectionId()
                             : -1;
 
         String remoteAddress = _connectionConfig instanceof ProtocolEngine
@@ -749,6 +867,16 @@
         }
     }
 
+    void stopSubscriptions()
+    {
+        final Collection<Subscription_0_10> subscriptions = getSubscriptions();
+        for (Subscription_0_10 subscription_0_10 : subscriptions)
+        {
+            subscription_0_10.stop();
+        }
+    }
+
+
     public void receivedComplete()
     {
         final Collection<Subscription_0_10> subscriptions = getSubscriptions();
@@ -889,4 +1017,14 @@
             return _future.isComplete();
         }
     }
+
+    protected void setClose(boolean close)
+    {
+        super.setClose(close);
+    }
+
+    public int compareTo(AMQSessionModel session)
+    {
+        return getId().toString().compareTo(session.getID().toString());
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java
index 2eab65c..c94a476 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java
@@ -20,13 +20,10 @@
  */
 package org.apache.qpid.server.transport;
 
-import java.nio.ByteBuffer;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
+import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.AMQUnknownExchangeType;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
@@ -54,10 +51,24 @@
 import org.apache.qpid.server.store.StoredMessage;
 import org.apache.qpid.server.subscription.SubscriptionFactoryImpl;
 import org.apache.qpid.server.subscription.Subscription_0_10;
+import org.apache.qpid.server.txn.AlreadyKnownDtxException;
+import org.apache.qpid.server.txn.DtxNotSelectedException;
+import org.apache.qpid.server.txn.IncorrectDtxStateException;
+import org.apache.qpid.server.txn.JoinAndResumeDtxException;
+import org.apache.qpid.server.txn.NotAssociatedDtxException;
+import org.apache.qpid.server.txn.RollbackOnlyDtxException;
 import org.apache.qpid.server.txn.ServerTransaction;
+import org.apache.qpid.server.txn.SuspendAndFailDtxException;
+import org.apache.qpid.server.txn.TimeoutDtxException;
+import org.apache.qpid.server.txn.UnknownDtxBranchException;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.transport.*;
 
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
 public class ServerSessionDelegate extends SessionDelegate
 {
     private static final Logger LOGGER = Logger.getLogger(ServerSessionDelegate.class);
@@ -154,7 +165,12 @@
     @Override
     public void messageSubscribe(Session session, MessageSubscribe method)
     {
-        //TODO - work around broken Python tests
+        /*
+          TODO - work around broken Python tests
+          Correct code should read like
+          if not hasAcceptMode() exception ILLEGAL_ARGUMENT "Accept-mode not supplied"
+          else if not method.hasAcquireMode() exception ExecutionErrorCode.ILLEGAL_ARGUMENT, "Acquire-mode not supplied"
+        */
         if(!method.hasAcceptMode())
         {
             method.setAcceptMode(MessageAcceptMode.EXPLICIT);
@@ -165,15 +181,7 @@
 
         }
 
-       /* if(!method.hasAcceptMode())
-        {
-            exception(session,method,ExecutionErrorCode.ILLEGAL_ARGUMENT, "Accept-mode not supplied");
-        }
-        else if(!method.hasAcquireMode())
-        {
-            exception(session,method,ExecutionErrorCode.ILLEGAL_ARGUMENT, "Acquire-mode not supplied");
-        }
-        else */if(!method.hasQueue())
+        if(!method.hasQueue())
         {
             exception(session,method,ExecutionErrorCode.ILLEGAL_ARGUMENT, "queue not supplied");
         }
@@ -201,6 +209,10 @@
                 {
                     exception(session,method,ExecutionErrorCode.RESOURCE_LOCKED, "Exclusive Queue: " + queueName + " owned exclusively by another session");
                 }
+                else if(queue.isExclusive() && queue.getExclusiveOwningSession() != null && queue.getExclusiveOwningSession() != session)
+                {
+                    exception(session,method,ExecutionErrorCode.RESOURCE_LOCKED, "Exclusive Queue: " + queueName + " owned exclusively by another session");
+                }
                 else
                 {
                     if(queue.isExclusive())
@@ -223,7 +235,6 @@
                                 }
                             });
                         }
-
                     }
 
                     FlowCreditManager_0_10 creditManager = new WindowCreditManager(0L,0L);
@@ -283,6 +294,7 @@
         }
 
         final MessageMetaData_0_10 messageMetaData = new MessageMetaData_0_10(xfr);
+        messageMetaData.setConnectionReference(((ServerSession)ssn).getReference());
         
         if (!getVirtualHost(ssn).getSecurityManager().authorisePublish(messageMetaData.isImmediate(), messageMetaData.getRoutingKey(), exchange.getName()))
         {
@@ -428,6 +440,235 @@
         ((ServerSession)session).rollback();
     }
 
+    @Override
+    public void dtxSelect(Session session, DtxSelect method)
+    {
+        // TODO - check current tx mode
+        ((ServerSession)session).selectDtx();
+    }
+
+    @Override
+    public void dtxStart(Session session, DtxStart method)
+    {
+        XaResult result = new XaResult();
+        result.setStatus(DtxXaStatus.XA_OK);
+        try
+        {
+            ((ServerSession)session).startDtx(method.getXid(), method.getJoin(), method.getResume());
+            session.executionResult(method.getId(), result);
+        }
+        catch(JoinAndResumeDtxException e)
+        {
+            exception(session, method, ExecutionErrorCode.COMMAND_INVALID, e.getMessage());
+        }
+        catch(UnknownDtxBranchException e)
+        {
+            exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Unknown xid " + method.getXid());
+        }
+        catch(AlreadyKnownDtxException e)
+        {
+            exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Xid already started an neither join nor " +
+                                                                       "resume set" + method.getXid());
+        }
+        catch(DtxNotSelectedException e)
+        {
+            exception(session, method, ExecutionErrorCode.COMMAND_INVALID, e.getMessage());
+        }
+
+    }
+
+    @Override
+    public void dtxEnd(Session session, DtxEnd method)
+    {
+        XaResult result = new XaResult();
+        result.setStatus(DtxXaStatus.XA_OK);
+        try
+        {
+            try
+            {
+                ((ServerSession)session).endDtx(method.getXid(), method.getFail(), method.getSuspend());
+            }
+            catch (TimeoutDtxException e)
+            {
+                result.setStatus(DtxXaStatus.XA_RBTIMEOUT);
+            }
+            session.executionResult(method.getId(), result);
+        }
+        catch(UnknownDtxBranchException e)
+        {
+            exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
+        }
+        catch(NotAssociatedDtxException e)
+        {
+            exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
+        }
+        catch(DtxNotSelectedException e)
+        {
+            exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
+        }
+        catch(SuspendAndFailDtxException e)
+        {
+            exception(session, method, ExecutionErrorCode.COMMAND_INVALID, e.getMessage());
+        }
+
+    }
+
+    @Override
+    public void dtxCommit(Session session, DtxCommit method)
+    {
+        XaResult result = new XaResult();
+        result.setStatus(DtxXaStatus.XA_OK);
+        try
+        {
+            try
+            {
+                ((ServerSession)session).commitDtx(method.getXid(), method.getOnePhase());
+            }
+            catch (RollbackOnlyDtxException e)
+            {
+                result.setStatus(DtxXaStatus.XA_RBROLLBACK);
+            }
+            catch (TimeoutDtxException e)
+            {
+                result.setStatus(DtxXaStatus.XA_RBTIMEOUT);
+            }
+            session.executionResult(method.getId(), result);
+        }
+        catch(UnknownDtxBranchException e)
+        {
+            exception(session, method, ExecutionErrorCode.NOT_FOUND, e.getMessage());
+        }
+        catch(IncorrectDtxStateException e)
+        {
+            exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
+        }
+        catch(AMQStoreException e)
+        {
+            exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, e.getMessage());
+        }
+    }
+
+    @Override
+    public void dtxForget(Session session, DtxForget method)
+    {
+        try
+        {
+            ((ServerSession)session).forgetDtx(method.getXid());
+        }
+        catch(UnknownDtxBranchException e)
+        {
+            exception(session, method, ExecutionErrorCode.NOT_FOUND, e.getMessage());
+        }
+        catch(IncorrectDtxStateException e)
+        {
+            exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
+        }
+
+    }
+
+    @Override
+    public void dtxGetTimeout(Session session, DtxGetTimeout method)
+    {
+        GetTimeoutResult result = new GetTimeoutResult();
+        try
+        {
+            result.setTimeout(((ServerSession) session).getTimeoutDtx(method.getXid()));
+            session.executionResult(method.getId(), result);
+        }
+        catch(UnknownDtxBranchException e)
+        {
+            exception(session, method, ExecutionErrorCode.NOT_FOUND, e.getMessage());
+        }
+    }
+
+    @Override
+    public void dtxPrepare(Session session, DtxPrepare method)
+    {
+        XaResult result = new XaResult();
+        result.setStatus(DtxXaStatus.XA_OK);
+        try
+        {
+            try
+            {
+                ((ServerSession)session).prepareDtx(method.getXid());
+            }
+            catch (RollbackOnlyDtxException e)
+            {
+                result.setStatus(DtxXaStatus.XA_RBROLLBACK);
+            }
+            catch (TimeoutDtxException e)
+            {
+                result.setStatus(DtxXaStatus.XA_RBTIMEOUT);
+            }
+            session.executionResult((int) method.getId(), result);
+        }
+        catch(UnknownDtxBranchException e)
+        {
+            exception(session, method, ExecutionErrorCode.NOT_FOUND, e.getMessage());
+        }
+        catch(IncorrectDtxStateException e)
+        {
+            exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
+        }
+        catch(AMQStoreException e)
+        {
+            exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, e.getMessage());
+        }
+    }
+
+    @Override
+    public void dtxRecover(Session session, DtxRecover method)
+    {
+        RecoverResult result = new RecoverResult();
+        List inDoubt = ((ServerSession)session).recoverDtx();
+        result.setInDoubt(inDoubt);
+        session.executionResult(method.getId(), result);
+    }
+
+    @Override
+    public void dtxRollback(Session session, DtxRollback method)
+    {
+
+        XaResult result = new XaResult();
+        result.setStatus(DtxXaStatus.XA_OK);
+        try
+        {
+            try
+            {
+                ((ServerSession)session).rollbackDtx(method.getXid());
+            }
+            catch (TimeoutDtxException e)
+            {
+                result.setStatus(DtxXaStatus.XA_RBTIMEOUT);
+            }
+            session.executionResult(method.getId(), result);
+        }
+        catch(UnknownDtxBranchException e)
+        {
+            exception(session, method, ExecutionErrorCode.NOT_FOUND, e.getMessage());
+        }
+        catch(IncorrectDtxStateException e)
+        {
+            exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
+        }
+        catch(AMQStoreException e)
+        {
+            exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, e.getMessage());
+        }
+    }
+
+    @Override
+    public void dtxSetTimeout(Session session, DtxSetTimeout method)
+    {
+        try
+        {
+            ((ServerSession)session).setTimeoutDtx(method.getXid(), method.getTimeout());
+        }
+        catch(UnknownDtxBranchException e)
+        {
+            exception(session, method, ExecutionErrorCode.NOT_FOUND, e.getMessage());
+        }
+    }
 
     @Override
     public void executionSync(final Session ssn, final ExecutionSync sync)
@@ -465,9 +706,9 @@
             }
             else
             {
-                if(!exchange.getTypeShortString().toString().equals(method.getType()))
+                if(!exchange.getTypeShortString().toString().equals(method.getType()) && (method.getType() != null && method.getType().length() > 0))
                 {
-                    exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Cannot redeclare with a different exchange type");
+                    exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to redeclare exchange: " + exchangeName + " of type " + exchange.getTypeShortString() + " to " + method.getType() +".");
                 }
             }
 
@@ -476,48 +717,96 @@
         {
             if (exchange == null)
             {
-                ExchangeRegistry exchangeRegistry = getExchangeRegistry(session);
-                ExchangeFactory exchangeFactory = virtualHost.getExchangeFactory();
-
-
-
-                try
+                if(exchangeName.startsWith("amq."))
                 {
-
-                    exchange = exchangeFactory.createExchange(method.getExchange(),
-                                                              method.getType(),
-                                                              method.getDurable(),
-                                                              method.getAutoDelete());
-
-                    String alternateExchangeName = method.getAlternateExchange();
-                    if(alternateExchangeName != null && alternateExchangeName.length() != 0)
-                    {
-                        Exchange alternate = getExchange(session, alternateExchangeName);
-                        exchange.setAlternateExchange(alternate);
-                    }
-
-                    if (exchange.isDurable())
-                    {
-                        DurableConfigurationStore store = virtualHost.getDurableConfigurationStore();
-                        store.createExchange(exchange);
-                    }
-
-                    exchangeRegistry.registerExchange(exchange);
+                    exception(session, method, ExecutionErrorCode.NOT_ALLOWED,
+                              "Attempt to declare exchange: " + exchangeName +
+                              " which begins with reserved prefix 'amq.'.");
                 }
-                catch(AMQUnknownExchangeType e)
+                else if(exchangeName.startsWith("qpid."))
                 {
-                    exception(session, method, ExecutionErrorCode.NOT_FOUND, "Unknown Exchange Type: " + method.getType());
+                    exception(session, method, ExecutionErrorCode.NOT_ALLOWED,
+                              "Attempt to declare exchange: " + exchangeName +
+                              " which begins with reserved prefix 'qpid.'.");
                 }
-                catch (AMQException e)
+                else
                 {
-                    exception(session, method, e, "Cannot declare exchange '" + exchangeName);
+                    ExchangeRegistry exchangeRegistry = getExchangeRegistry(session);
+                    ExchangeFactory exchangeFactory = virtualHost.getExchangeFactory();
+
+
+
+                    try
+                    {
+
+                        exchange = exchangeFactory.createExchange(method.getExchange(),
+                                                                  method.getType(),
+                                                                  method.getDurable(),
+                                                                  method.getAutoDelete());
+
+                        String alternateExchangeName = method.getAlternateExchange();
+                        boolean validAlternate;
+                        if(alternateExchangeName != null && alternateExchangeName.length() != 0)
+                        {
+                            Exchange alternate = getExchange(session, alternateExchangeName);
+                            if(alternate == null)
+                            {
+                                validAlternate = false;
+                            }
+                            else
+                            {
+                                exchange.setAlternateExchange(alternate);
+                                validAlternate = true;
+                            }
+                        }
+                        else
+                        {
+                            validAlternate = true;
+                        }
+
+                        if(validAlternate)
+                        {
+                            if (exchange.isDurable())
+                            {
+                                DurableConfigurationStore store = virtualHost.getDurableConfigurationStore();
+                                store.createExchange(exchange);
+                            }
+
+                            exchangeRegistry.registerExchange(exchange);
+                        }
+                        else
+                        {
+                            exception(session, method, ExecutionErrorCode.NOT_FOUND,
+                                        "Unknown alternate exchange " + alternateExchangeName);
+                        }
+                    }
+                    catch(AMQUnknownExchangeType e)
+                    {
+                        exception(session, method, ExecutionErrorCode.NOT_FOUND, "Unknown Exchange Type: " + method.getType());
+                    }
+                    catch (AMQException e)
+                    {
+                        exception(session, method, e, "Cannot declare exchange '" + exchangeName);
+                    }
                 }
             }
             else
             {
                 if(!exchange.getTypeShortString().toString().equals(method.getType()))
                 {
-                    exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Cannot redeclare with a different exchange type");
+                    exception(session, method, ExecutionErrorCode.NOT_ALLOWED,
+                            "Attempt to redeclare exchange: " + exchangeName
+                                    + " of type " + exchange.getTypeShortString()
+                                    + " to " + method.getType() +".");
+                }
+                else if(method.hasAlternateExchange()
+                          && (exchange.getAlternateExchange() == null ||
+                              !method.getAlternateExchange().equals(exchange.getAlternateExchange().getName())))
+                {
+                    exception(session, method, ExecutionErrorCode.NOT_ALLOWED,
+                            "Attempt to change alternate exchange of: " + exchangeName
+                                    + " from " + exchange.getAlternateExchange()
+                                    + " to " + method.getAlternateExchange() +".");
                 }
             }
 
@@ -710,15 +999,10 @@
         {
             exception(session, method, ExecutionErrorCode.INVALID_ARGUMENT, "Bind not allowed for default exchange");
         }
-/*
-        else if (!method.hasBindingKey())
-        {
-            exception(session, method, ExecutionErrorCode.ILLEGAL_ARGUMENT, "binding-key not set");
-        }
-*/
         else
         {
             //TODO - here because of non-compiant python tests
+            // should raise exception ILLEGAL_ARGUMENT "binding-key not set"
             if (!method.hasBindingKey())
             {
                 method.setBindingKey(method.getQueue());
@@ -739,10 +1023,7 @@
             }
             else
             {
-                AMQShortString routingKey = new AMQShortString(method.getBindingKey());
-                FieldTable fieldTable = FieldTable.convertToFieldTable(method.getArguments());
-
-                if (!exchange.isBound(routingKey, fieldTable, queue))
+                if (!exchange.isBound(method.getBindingKey(), method.getArguments(), queue))
                 {
                     try
                     {
@@ -854,12 +1135,6 @@
                 if(method.hasBindingKey())
                 {
 
-                    if(method.hasArguments())
-                    {
-                        FieldTable args = FieldTable.convertToFieldTable(method.getArguments());
-                        
-                        result.setArgsNotMatched(!exchange.isBound(new AMQShortString(method.getBindingKey()), args, queue));
-                    }
                     if(queueMatched)
                     {
                         result.setKeyNotMatched(!exchange.isBound(method.getBindingKey(), queue));
@@ -868,23 +1143,28 @@
                     {
                         result.setKeyNotMatched(!exchange.isBound(method.getBindingKey()));
                     }
+
+                    if(method.hasArguments())
+                    {
+                        result.setArgsNotMatched(!exchange.isBound(result.getKeyNotMatched() ? null : method.getBindingKey(), method.getArguments(), queueMatched ? queue : null));
+                    }
+
                 }
                 else if (method.hasArguments())
                 {
-                    // TODO
-
+                    result.setArgsNotMatched(!exchange.isBound(null, method.getArguments(), queueMatched ? queue : null));
                 }
 
-                result.setQueueNotMatched(!exchange.isBound(queue));
-
             }
             else if(exchange != null && method.hasBindingKey())
             {
+                result.setKeyNotMatched(!exchange.isBound(method.getBindingKey()));
+
                 if(method.hasArguments())
                 {
-                    // TODO
+                    result.setArgsNotMatched(!exchange.isBound(result.getKeyNotMatched() ? null : method.getBindingKey(), method.getArguments(), queue));
                 }
-                result.setKeyNotMatched(!exchange.isBound(method.getBindingKey()));
+
 
             }
 
@@ -893,11 +1173,15 @@
         {
             if(method.hasArguments())
             {
-                // TODO
+                result.setArgsNotMatched(!exchange.isBound(method.getBindingKey(), method.getArguments(), null));
             }
             result.setKeyNotMatched(!exchange.isBound(method.getBindingKey()));
 
         }
+        else if(exchange != null && method.hasArguments())
+        {
+            result.setArgsNotMatched(!exchange.isBound(null, method.getArguments(), null));
+        }
 
 
         session.executionResult((int) method.getId(), result);
@@ -1141,6 +1425,10 @@
                 {
                     exception(session,method,ExecutionErrorCode.RESOURCE_LOCKED, "Exclusive Queue: " + queueName + " owned exclusively by another session");
                 }
+                else if(queue.isExclusive() && queue.getExclusiveOwningSession()  != null && queue.getExclusiveOwningSession() != session)
+                {
+                    exception(session,method,ExecutionErrorCode.RESOURCE_LOCKED, "Exclusive Queue: " + queueName + " owned exclusively by another session");
+                }
                 else if (method.getIfEmpty() && !queue.isEmpty())
                 {
                     exception(session, method, ExecutionErrorCode.PRECONDITION_FAILED, "Queue " + queueName + " not empty");
@@ -1287,8 +1575,9 @@
 
         ServerSession serverSession = (ServerSession)session;
 
-        serverSession.unregisterSubscriptions();
+        serverSession.stopSubscriptions();
         serverSession.onClose();
+        serverSession.unregisterSubscriptions();
     }
 
     @Override
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/AlreadyKnownDtxException.java
similarity index 76%
copy from qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
copy to qpid/java/broker/src/main/java/org/apache/qpid/server/txn/AlreadyKnownDtxException.java
index 68fbb5e..faa4ec5 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/AlreadyKnownDtxException.java
@@ -19,16 +19,14 @@
  *
  */
 
-package org.apache.qpid.transport;
+package org.apache.qpid.server.txn;
 
-import java.io.IOException;
+import org.apache.qpid.transport.Xid;
 
-public class OpenException extends IOException
+public class AlreadyKnownDtxException extends DtxException
 {
-
-    public OpenException(String string, Throwable lastException)
+    public AlreadyKnownDtxException(Xid id)
     {
-        super(string, lastException);
+        super("Xid " + id + " cannot be started as it is already known");
     }
-
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java
index 7e238ae..a062c67 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/AsyncAutoCommitTransaction.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.txn;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.server.message.EnqueableMessage;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java
index ad2a299..597797b 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/AutoCommitTransaction.java
@@ -20,11 +20,8 @@
  */
 package org.apache.qpid.server.txn;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.server.message.EnqueableMessage;
@@ -33,6 +30,9 @@
 import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.store.MessageStore;
 
+import java.util.Collection;
+import java.util.List;
+
 /**
  * An implementation of ServerTransaction where each enqueue/dequeue
  * operation takes place within it own transaction.
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DistributedTransaction.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DistributedTransaction.java
new file mode 100644
index 0000000..36f5f7b
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DistributedTransaction.java
@@ -0,0 +1,246 @@
+/*
+ *
+ * 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.server.txn;
+
+import org.apache.qpid.server.message.EnqueableMessage;
+import org.apache.qpid.server.protocol.AMQSessionModel;
+import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.server.queue.QueueEntry;
+import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.transport.Xid;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+public class DistributedTransaction implements ServerTransaction
+{
+
+    private final AutoCommitTransaction _autoCommitTransaction;
+
+    private volatile MessageStore.Transaction _transaction;
+
+    private long _txnStartTime = 0L;
+
+    private DtxBranch _branch;
+    private AMQSessionModel _session;
+    private VirtualHost _vhost;
+
+
+    public DistributedTransaction(AMQSessionModel session, MessageStore store, VirtualHost vhost)
+    {
+        _session = session;
+        _vhost = vhost;
+        _autoCommitTransaction = new AutoCommitTransaction(vhost.getMessageStore());
+    }
+
+    public long getTransactionStartTime()
+    {
+        return _txnStartTime;
+    }
+
+    public void addPostTransactionAction(Action postTransactionAction)
+    {
+        if(_branch != null)
+        {
+            _branch.addPostTransactionAcion(postTransactionAction);
+        }
+        else
+        {
+            _autoCommitTransaction.addPostTransactionAction(postTransactionAction);
+        }
+    }
+
+    public void dequeue(BaseQueue queue, EnqueableMessage message, Action postTransactionAction)
+    {
+        if(_branch != null)
+        {
+            _branch.dequeue(queue, message);
+            _branch.addPostTransactionAcion(postTransactionAction);
+        }
+        else
+        {
+            _autoCommitTransaction.dequeue(queue, message, postTransactionAction);
+        }
+    }
+
+    public void dequeue(Collection<QueueEntry> messages, Action postTransactionAction)
+    {
+        if(_branch != null)
+        {
+            for(QueueEntry entry : messages)
+            {
+                _branch.dequeue(entry.getQueue(), entry.getMessage());
+            }
+            _branch.addPostTransactionAcion(postTransactionAction);
+        }
+        else
+        {
+            _autoCommitTransaction.dequeue(messages, postTransactionAction);
+        }
+    }
+
+    public void enqueue(BaseQueue queue, EnqueableMessage message, Action postTransactionAction)
+    {
+        if(_branch != null)
+        {
+            _branch.enqueue(queue, message);
+            _branch.addPostTransactionAcion(postTransactionAction);
+            enqueue(Collections.singletonList(queue), message, postTransactionAction, System.currentTimeMillis());
+        }
+        else
+        {
+            _autoCommitTransaction.enqueue(queue, message, postTransactionAction);
+        }
+    }
+
+    public void enqueue(List<? extends BaseQueue> queues, EnqueableMessage message,
+                        Action postTransactionAction, long currentTime)
+    {
+        if(_branch != null)
+        {
+            for(BaseQueue queue : queues)
+            {
+                _branch.enqueue(queue, message);
+            }
+            _branch.addPostTransactionAcion(postTransactionAction);
+        }
+        else
+        {
+            _autoCommitTransaction.enqueue(queues, message, postTransactionAction, currentTime);
+        }
+    }
+
+    public void commit()
+    {
+        throw new IllegalStateException("Cannot call tx.commit() on a distributed transaction");
+    }
+
+    public void commit(Runnable immediatePostTransactionAction)
+    {
+        throw new IllegalStateException("Cannot call tx.commit() on a distributed transaction");
+    }
+
+    public void rollback()
+    {
+        throw new IllegalStateException("Cannot call tx.rollback() on a distributed transaction");
+    }
+
+    public boolean isTransactional()
+    {
+        return _branch != null;
+    }
+    
+    public void start(Xid id, boolean join, boolean resume)
+            throws UnknownDtxBranchException, AlreadyKnownDtxException, JoinAndResumeDtxException
+    {
+        if(join && resume)
+        {
+            throw new JoinAndResumeDtxException(id);
+        }
+
+        DtxBranch branch = _vhost.getDtxRegistry().getBranch(id);
+
+        if(branch == null)
+        {
+            if(join || resume)
+            {
+                throw new UnknownDtxBranchException(id);
+            }
+            branch = new DtxBranch(id,_vhost.getMessageStore(), _vhost);
+            if(_vhost.getDtxRegistry().registerBranch(branch))
+            {
+                _branch = branch;
+                branch.associateSession(_session);
+            }
+            else
+            {
+                throw new AlreadyKnownDtxException(id);
+            }
+        }
+        else
+        {
+            if(join)
+            {
+                branch.associateSession(_session);
+            }
+            else if(resume)
+            {
+                branch.resumeSession(_session);
+            }
+            else
+            {
+                throw new AlreadyKnownDtxException(id);
+            }
+            _branch = branch;
+        }
+    }
+    
+    public void end(Xid id, boolean fail, boolean suspend)
+            throws UnknownDtxBranchException, NotAssociatedDtxException, SuspendAndFailDtxException, TimeoutDtxException
+    {
+        DtxBranch branch = _vhost.getDtxRegistry().getBranch(id);
+
+        if(suspend && fail)
+        {
+            branch.disassociateSession(_session);
+            _branch = null;
+            throw new SuspendAndFailDtxException(id);
+        }
+
+
+        if(branch == null)
+        {
+            throw new UnknownDtxBranchException(id);
+        }
+        else
+        {
+            if(!branch.isAssociated(_session))
+            {
+                throw new NotAssociatedDtxException(id);
+            }
+            if(branch.expired() || branch.getState() == DtxBranch.State.TIMEDOUT)
+            {
+                branch.disassociateSession(_session);
+                throw new TimeoutDtxException(id);
+            }
+
+            if(suspend)
+            {
+                branch.suspendSession(_session);
+            }
+            else
+            {
+                if(fail)
+                {
+                    branch.setState(DtxBranch.State.ROLLBACK_ONLY);
+                }
+                branch.disassociateSession(_session);
+            }
+
+            _branch = null;
+
+        }
+    }
+
+}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxBranch.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxBranch.java
new file mode 100644
index 0000000..99bb639
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxBranch.java
@@ -0,0 +1,348 @@
+/*
+ *
+ * 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.server.txn;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ScheduledFuture;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.message.EnqueableMessage;
+import org.apache.qpid.server.protocol.AMQSessionModel;
+import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.transport.Xid;
+
+public class DtxBranch
+{
+    private static final Logger _logger = Logger.getLogger(DtxBranch.class);
+
+    private final Xid _xid;
+    private final List<ServerTransaction.Action> _postTransactionActions = new ArrayList<ServerTransaction.Action>();
+    private       State                          _state = State.ACTIVE;
+    private long _timeout;
+    private Map<AMQSessionModel, State> _associatedSessions = new HashMap<AMQSessionModel, State>();
+    private final List<Record> _enqueueRecords = new ArrayList<Record>();
+    private final List<Record> _dequeueRecords = new ArrayList<Record>();
+
+    private MessageStore.Transaction _transaction;
+    private long _expiration;
+    private VirtualHost _vhost;
+    private ScheduledFuture<?> _timeoutFuture;
+    private MessageStore _store;
+
+
+    public enum State
+    {
+        ACTIVE,
+        PREPARED,
+        TIMEDOUT,
+        SUSPENDED,
+        FORGOTTEN,
+        HEUR_COM,
+        HEUR_RB,
+        ROLLBACK_ONLY
+    }
+
+
+    public DtxBranch(Xid xid, MessageStore store, VirtualHost vhost)
+    {
+        _xid = xid;
+        _store = store;
+        _vhost = vhost;
+    }
+
+    public Xid getXid()
+    {
+        return _xid;
+    }
+
+    public State getState()
+    {
+        return _state;
+    }
+
+    public void setState(State state)
+    {
+        _state = state;
+    }
+
+    public long getTimeout()
+    {
+        return _timeout;
+    }
+
+    public void setTimeout(long timeout)
+    {
+        if(_timeoutFuture != null)
+        {
+            _timeoutFuture.cancel(false);
+        }
+        _timeout = timeout;
+        _expiration = timeout == 0 ? 0 : System.currentTimeMillis() + timeout;
+
+        if(_timeout == 0)
+        {
+            _timeoutFuture = null;
+        }
+        else
+        {
+            _timeoutFuture = _vhost.scheduleTask(_timeout, new Runnable()
+            {
+                public void run()
+                {
+                    setState(State.TIMEDOUT);
+                    try
+                    {
+                        rollback();
+                    }
+                    catch (AMQStoreException e)
+                    {
+                        _logger.error("Unexpected error when attempting to rollback XA transaction ("+
+                                      _xid + ") due to  timeout", e);
+                        throw new RuntimeException(e);
+                    }
+                }
+            });
+        }
+    }
+
+    public boolean expired()
+    {
+        return _timeout != 0 && _expiration < System.currentTimeMillis();
+    }
+
+    public synchronized boolean isAssociated(AMQSessionModel session)
+    {
+        return _associatedSessions.containsKey(session);
+    }
+
+    public synchronized boolean hasAssociatedSessions()
+    {
+        return !_associatedSessions.isEmpty();
+    }
+
+
+    public synchronized boolean hasAssociatedActiveSessions()
+    {
+        if(hasAssociatedSessions())
+        {
+            for(State state : _associatedSessions.values())
+            {
+                if(state != State.SUSPENDED)
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    public synchronized void clearAssociations()
+    {
+        _associatedSessions.clear();
+    }
+
+    synchronized boolean associateSession(AMQSessionModel associatedSession)
+    {
+        return _associatedSessions.put(associatedSession, State.ACTIVE) != null;
+    }
+
+    synchronized boolean disassociateSession(AMQSessionModel associatedSession)
+    {
+        return _associatedSessions.remove(associatedSession) != null;
+    }
+
+    public synchronized boolean resumeSession(AMQSessionModel session)
+    {
+        if(_associatedSessions.containsKey(session) && _associatedSessions.get(session) == State.SUSPENDED)
+        {
+            _associatedSessions.put(session, State.ACTIVE);
+            return true;
+        }
+        return false;
+    }
+
+    public synchronized boolean suspendSession(AMQSessionModel session)
+    {
+        if(_associatedSessions.containsKey(session) && _associatedSessions.get(session) == State.ACTIVE)
+        {
+            _associatedSessions.put(session, State.SUSPENDED);
+            return true;
+        }
+        return false;
+    }
+
+    public void prepare() throws AMQStoreException
+    {
+
+        MessageStore.Transaction txn = _store.newTransaction();
+        txn.recordXid(_xid.getFormat(),
+                      _xid.getGlobalId(),
+                      _xid.getBranchId(),
+                      _enqueueRecords.toArray(new Record[_enqueueRecords.size()]),
+                      _dequeueRecords.toArray(new Record[_dequeueRecords.size()]));
+        txn.commitTran();
+
+        prePrepareTransaction();
+    }
+
+    public synchronized void rollback() throws AMQStoreException
+    {
+        if(_timeoutFuture != null)
+        {
+            _timeoutFuture.cancel(false);
+            _timeoutFuture = null;
+        }
+
+
+        if(_transaction != null)
+        {
+            // prepare has previously been called
+
+            MessageStore.Transaction txn = _store.newTransaction();
+            txn.removeXid(_xid.getFormat(), _xid.getGlobalId(), _xid.getBranchId());
+            txn.commitTran();
+
+            _transaction.abortTran();
+        }
+
+        for(ServerTransaction.Action action : _postTransactionActions)
+        {
+            action.onRollback();
+        }
+        _postTransactionActions.clear();
+    }
+
+    public void commit() throws AMQStoreException
+    {
+        if(_timeoutFuture != null)
+        {
+            _timeoutFuture.cancel(false);
+            _timeoutFuture = null;
+        }
+
+        if(_transaction == null)
+        {
+            prePrepareTransaction();
+        }
+        else
+        {
+            _transaction.removeXid(_xid.getFormat(), _xid.getGlobalId(), _xid.getBranchId());
+        }
+        _transaction.commitTran();
+
+        for(ServerTransaction.Action action : _postTransactionActions)
+        {
+            action.postCommit();
+        }
+        _postTransactionActions.clear();
+    }
+
+    public void prePrepareTransaction() throws AMQStoreException
+    {
+        _transaction = _store.newTransaction();
+
+        for(Record enqueue : _enqueueRecords)
+        {
+            if(enqueue.isDurable())
+            {
+                _transaction.enqueueMessage(enqueue.getQueue(), enqueue.getMessage());
+            }
+        }
+
+
+        for(Record enqueue : _dequeueRecords)
+        {
+            if(enqueue.isDurable())
+            {
+                _transaction.dequeueMessage(enqueue.getQueue(), enqueue.getMessage());
+            }
+        }
+    }
+
+
+    public void addPostTransactionAcion(ServerTransaction.Action postTransactionAction)
+    {
+        _postTransactionActions.add(postTransactionAction);
+    }
+
+
+    public void dequeue(BaseQueue queue, EnqueableMessage message)
+    {
+        _dequeueRecords.add(new Record(queue, message));
+    }
+
+
+    public void enqueue(BaseQueue queue, EnqueableMessage message)
+    {
+        _enqueueRecords.add(new Record(queue, message));
+    }
+
+    private static final class Record implements MessageStore.Transaction.Record
+    {
+        private final BaseQueue _queue;
+        private final EnqueableMessage _message;
+
+        public Record(BaseQueue queue, EnqueableMessage message)
+        {
+            _queue = queue;
+            _message = message;
+        }
+
+        public BaseQueue getQueue()
+        {
+            return _queue;
+        }
+
+        public EnqueableMessage getMessage()
+        {
+            return _message;
+        }
+
+        public boolean isDurable()
+        {
+            return _message.isPersistent() && _queue.isDurable();
+        }
+    }
+
+
+    public void close()
+    {
+        if(_transaction != null)
+        {
+            try
+            {
+                _state = null;
+                _transaction.abortTran();
+            }
+            catch(AMQStoreException e)
+            {
+                _logger.error("Error while closing XA branch", e);
+            }
+        }
+    }
+}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxException.java
similarity index 69%
copy from qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
copy to qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxException.java
index 68fbb5e..d18d0cb 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxException.java
@@ -19,16 +19,26 @@
  *
  */
 
-package org.apache.qpid.transport;
+package org.apache.qpid.server.txn;
 
-import java.io.IOException;
-
-public class OpenException extends IOException
+public class DtxException extends Exception
 {
-
-    public OpenException(String string, Throwable lastException)
+    public DtxException()
     {
-        super(string, lastException);
     }
 
+    public DtxException(String message)
+    {
+        super(message);
+    }
+
+    public DtxException(String message, Throwable cause)
+    {
+        super(message, cause);
+    }
+
+    public DtxException(Throwable cause)
+    {
+        super(cause);
+    }
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxNotSelectedException.java
similarity index 78%
rename from qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
rename to qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxNotSelectedException.java
index 68fbb5e..c1289b1 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxNotSelectedException.java
@@ -19,16 +19,12 @@
  *
  */
 
-package org.apache.qpid.transport;
+package org.apache.qpid.server.txn;
 
-import java.io.IOException;
-
-public class OpenException extends IOException
+public class DtxNotSelectedException extends DtxException
 {
-
-    public OpenException(String string, Throwable lastException)
+    public DtxNotSelectedException()
     {
-        super(string, lastException);
+        super("Distribution transactions have not been selected on this session");
     }
-
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java
new file mode 100644
index 0000000..5c54c11
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/DtxRegistry.java
@@ -0,0 +1,333 @@
+/*
+ *
+ * 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.server.txn;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.protocol.AMQSessionModel;
+import org.apache.qpid.transport.Xid;
+
+public class DtxRegistry
+{
+    private final Map<ComparableXid, DtxBranch> _branches = new HashMap<ComparableXid, DtxBranch>();
+
+
+    private static final class ComparableXid
+    {
+        private final Xid _xid;
+        
+        private ComparableXid(Xid xid)
+        {
+            _xid = xid;
+        }
+
+        @Override
+        public boolean equals(Object o)
+        {
+            if(this == o)
+            {
+                return true;
+            }
+            if(o == null || getClass() != o.getClass())
+            {
+                return false;
+            }
+
+            ComparableXid that = (ComparableXid) o;
+
+            return compareBytes(_xid.getBranchId(), that._xid.getBranchId())
+                    && compareBytes(_xid.getGlobalId(), that._xid.getGlobalId()); 
+        }
+
+        private static boolean compareBytes(byte[] a, byte[] b)
+        {
+            if(a.length != b.length)
+            {
+                return false;
+            }
+            for(int i = 0; i < a.length; i++)
+            {
+                if(a[i] != b[i])
+                {
+                    return false;
+                }
+            }
+            return true;
+        }
+
+
+        @Override
+        public int hashCode()
+        {
+            int result = 0;
+            for(int i = 0; i < _xid.getGlobalId().length; i++)
+            {
+                result = 31 * result + (int) _xid.getGlobalId()[i];
+            }
+            for(int i = 0; i < _xid.getBranchId().length; i++)
+            {
+                result = 31 * result + (int) _xid.getBranchId()[i];
+            }
+
+            return result;
+        }
+    }
+    
+    public synchronized DtxBranch getBranch(Xid xid)
+    {
+        return _branches.get(new ComparableXid(xid));
+    }
+
+    public synchronized boolean registerBranch(DtxBranch branch)
+    {
+        ComparableXid xid = new ComparableXid(branch.getXid());
+        if(!_branches.containsKey(xid))
+        {
+            _branches.put(xid, branch);
+            return true;
+        }
+        return false;
+    }
+
+    synchronized boolean unregisterBranch(DtxBranch branch)
+    {
+        return (_branches.remove(new ComparableXid(branch.getXid())) != null);
+    }
+
+    public void commit(Xid id, boolean onePhase)
+            throws IncorrectDtxStateException, UnknownDtxBranchException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException
+    {
+        DtxBranch branch = getBranch(id);
+        if(branch != null)
+        {
+            synchronized (branch)
+            {
+                if(!branch.hasAssociatedActiveSessions())
+                {
+                    branch.clearAssociations();
+
+                    if(branch.expired() || branch.getState() == DtxBranch.State.TIMEDOUT)
+                    {
+                        unregisterBranch(branch);
+                        throw new TimeoutDtxException(id);
+                    }
+                    else if(branch.getState() == DtxBranch.State.ROLLBACK_ONLY)
+                    {
+                        throw new RollbackOnlyDtxException(id);
+                    }
+                    else if(onePhase && branch.getState() == DtxBranch.State.PREPARED)
+                    {
+                        throw new IncorrectDtxStateException("Cannot call one-phase commit on a prepared branch", id);
+                    }
+                    else if(!onePhase && branch.getState() != DtxBranch.State.PREPARED)
+                    {
+                        throw new IncorrectDtxStateException("Cannot call two-phase commit on a non-prepared branch",
+                                                             id);
+                    }
+                    branch.commit();
+                    branch.setState(DtxBranch.State.FORGOTTEN);
+                    unregisterBranch(branch);
+                }
+                else
+                {
+                    throw new IncorrectDtxStateException("Branch was still associated with a session", id);
+                }
+            }
+        }
+        else
+        {
+            throw new UnknownDtxBranchException(id);
+        }
+    }
+
+    public synchronized void prepare(Xid id)
+            throws UnknownDtxBranchException,
+            IncorrectDtxStateException, AMQStoreException, RollbackOnlyDtxException, TimeoutDtxException
+    {
+        DtxBranch branch = getBranch(id);
+        if(branch != null)
+        {
+            synchronized (branch)
+            {
+                if(!branch.hasAssociatedActiveSessions())
+                {
+                    branch.clearAssociations();
+
+                    if(branch.expired() || branch.getState() == DtxBranch.State.TIMEDOUT)
+                    {
+                        unregisterBranch(branch);
+                        throw new TimeoutDtxException(id);
+                    }
+                    else if(branch.getState() != DtxBranch.State.ACTIVE
+                            && branch.getState() != DtxBranch.State.ROLLBACK_ONLY)
+                    {
+                        throw new IncorrectDtxStateException("Cannot prepare a transaction in state "
+                                                             + branch.getState(), id);
+                    }
+                    else
+                    {
+                        branch.prepare();
+                        branch.setState(DtxBranch.State.PREPARED);
+                    }
+                }
+                else
+                {
+                    throw new IncorrectDtxStateException("Branch still has associated sessions", id);
+                }
+            }
+        }
+        else
+        {
+            throw new UnknownDtxBranchException(id);
+        }
+    }
+
+    public void rollback(Xid id)
+            throws IncorrectDtxStateException,
+            UnknownDtxBranchException,
+            AMQStoreException, TimeoutDtxException
+    {
+
+        DtxBranch branch = getBranch(id);
+        if(branch != null)
+        {
+            synchronized (branch)
+            {
+                if(branch.expired() || branch.getState() == DtxBranch.State.TIMEDOUT)
+                {
+                    unregisterBranch(branch);
+                    throw new TimeoutDtxException(id);
+                }
+                if(!branch.hasAssociatedActiveSessions())
+                {
+                    branch.clearAssociations();
+                    branch.rollback();
+                    branch.setState(DtxBranch.State.FORGOTTEN);
+                    unregisterBranch(branch);
+                }
+                else
+                {
+                    throw new IncorrectDtxStateException("Branch was still associated with a session", id);
+                }
+            }
+        }
+        else
+        {
+            throw new UnknownDtxBranchException(id);
+        }
+    }
+
+
+    public void forget(Xid id) throws UnknownDtxBranchException, IncorrectDtxStateException
+    {
+        DtxBranch branch = getBranch(id);
+        if(branch != null)
+        {
+            synchronized (branch)
+            {
+                if(!branch.hasAssociatedSessions())
+                {
+                    if(branch.getState() != DtxBranch.State.HEUR_COM && branch.getState() != DtxBranch.State.HEUR_RB)
+                    {
+                        throw new IncorrectDtxStateException("Branch should not be forgotten - "
+                                                             + "it is not heuristically complete", id);
+                    }
+                    branch.setState(DtxBranch.State.FORGOTTEN);
+                    unregisterBranch(branch);
+                }
+                else
+                {
+                    throw new IncorrectDtxStateException("Branch was still associated with a session", id);
+                }
+            }
+        }
+        else
+        {
+            throw new UnknownDtxBranchException(id);
+        }
+    }
+
+    public long getTimeout(Xid id) throws UnknownDtxBranchException
+    {
+        DtxBranch branch = getBranch(id);
+        if(branch != null)
+        {
+            return branch.getTimeout();
+        }
+        else
+        {
+            throw new UnknownDtxBranchException(id);
+        }
+    }
+
+    public void setTimeout(Xid id, long timeout) throws UnknownDtxBranchException
+    {
+        DtxBranch branch = getBranch(id);
+        if(branch != null)
+        {
+            branch.setTimeout(timeout);
+        }
+        else
+        {
+            throw new UnknownDtxBranchException(id);
+        }
+    }
+
+    public synchronized List<Xid> recover()
+    {
+        List<Xid> inDoubt = new ArrayList<Xid>();
+        for(DtxBranch branch : _branches.values())
+        {
+            if(branch.getState() == DtxBranch.State.PREPARED)
+            {
+                inDoubt.add(branch.getXid());
+            }
+        }
+        return inDoubt;
+    }
+
+    public synchronized void endAssociations(AMQSessionModel session)
+    {
+        for(DtxBranch branch : _branches.values())
+        {
+            if(branch.isAssociated(session))
+            {
+                branch.setState(DtxBranch.State.ROLLBACK_ONLY);
+                branch.disassociateSession(session);
+            }
+        }
+    }
+
+
+    public synchronized void close()
+    {
+        for(DtxBranch branch : _branches.values())
+        {
+            branch.close();
+        }
+        _branches.clear();
+    }
+
+}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/IncorrectDtxStateException.java
similarity index 76%
copy from qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
copy to qpid/java/broker/src/main/java/org/apache/qpid/server/txn/IncorrectDtxStateException.java
index 68fbb5e..45f094e 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/IncorrectDtxStateException.java
@@ -19,16 +19,14 @@
  *
  */
 
-package org.apache.qpid.transport;
+package org.apache.qpid.server.txn;
 
-import java.io.IOException;
+import org.apache.qpid.transport.Xid;
 
-public class OpenException extends IOException
+public class IncorrectDtxStateException extends DtxException
 {
-
-    public OpenException(String string, Throwable lastException)
+    public IncorrectDtxStateException(String message, Xid id)
     {
-        super(string, lastException);
+        super(message + " (xid: " + id + ")");
     }
-
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/JoinAndResumeDtxException.java
similarity index 76%
copy from qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
copy to qpid/java/broker/src/main/java/org/apache/qpid/server/txn/JoinAndResumeDtxException.java
index 68fbb5e..a25e5a4 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/JoinAndResumeDtxException.java
@@ -19,16 +19,14 @@
  *
  */
 
-package org.apache.qpid.transport;
+package org.apache.qpid.server.txn;
 
-import java.io.IOException;
+import org.apache.qpid.transport.Xid;
 
-public class OpenException extends IOException
+public class JoinAndResumeDtxException extends DtxException
 {
-
-    public OpenException(String string, Throwable lastException)
+    public JoinAndResumeDtxException(Xid id)
     {
-        super(string, lastException);
+        super("Cannot start a branch with both join and resume set " + id);
     }
-
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java
index 34bac04..9b61f754 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/LocalTransaction.java
@@ -20,9 +20,8 @@
  * 
  */
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.message.EnqueableMessage;
@@ -31,8 +30,9 @@
 import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.store.MessageStore;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 
 /**
  * A concrete implementation of ServerTransaction where enqueue/dequeue
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/NotAssociatedDtxException.java
similarity index 76%
copy from qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
copy to qpid/java/broker/src/main/java/org/apache/qpid/server/txn/NotAssociatedDtxException.java
index 68fbb5e..de07054 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/NotAssociatedDtxException.java
@@ -19,16 +19,14 @@
  *
  */
 
-package org.apache.qpid.transport;
+package org.apache.qpid.server.txn;
 
-import java.io.IOException;
+import org.apache.qpid.transport.Xid;
 
-public class OpenException extends IOException
+public class NotAssociatedDtxException extends DtxException
 {
-
-    public OpenException(String string, Throwable lastException)
+    public NotAssociatedDtxException(Xid id)
     {
-        super(string, lastException);
+        super("Xid " + id + " not associated with the current session");
     }
-
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/RollbackOnlyDtxException.java
similarity index 77%
copy from qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
copy to qpid/java/broker/src/main/java/org/apache/qpid/server/txn/RollbackOnlyDtxException.java
index 68fbb5e..6cf12d8 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/RollbackOnlyDtxException.java
@@ -19,16 +19,14 @@
  *
  */
 
-package org.apache.qpid.transport;
+package org.apache.qpid.server.txn;
 
-import java.io.IOException;
+import org.apache.qpid.transport.Xid;
 
-public class OpenException extends IOException
+public class RollbackOnlyDtxException extends DtxException
 {
-
-    public OpenException(String string, Throwable lastException)
+    public RollbackOnlyDtxException(Xid id)
     {
-        super(string, lastException);
+        super("Transaction " + id + " may only be rolled back");
     }
-
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/SuspendAndFailDtxException.java
similarity index 76%
copy from qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
copy to qpid/java/broker/src/main/java/org/apache/qpid/server/txn/SuspendAndFailDtxException.java
index 68fbb5e..228844f 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/SuspendAndFailDtxException.java
@@ -19,16 +19,14 @@
  *
  */
 
-package org.apache.qpid.transport;
+package org.apache.qpid.server.txn;
 
-import java.io.IOException;
+import org.apache.qpid.transport.Xid;
 
-public class OpenException extends IOException
+public class SuspendAndFailDtxException extends DtxException
 {
-
-    public OpenException(String string, Throwable lastException)
-    {
-        super(string, lastException);
-    }
-
+public SuspendAndFailDtxException(Xid id)
+{
+    super("Cannot end a branch with both suspend and fail set " + id);
+}
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/TimeoutDtxException.java
similarity index 76%
copy from qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
copy to qpid/java/broker/src/main/java/org/apache/qpid/server/txn/TimeoutDtxException.java
index 68fbb5e..50f7708 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/TimeoutDtxException.java
@@ -19,16 +19,14 @@
  *
  */
 
-package org.apache.qpid.transport;
+package org.apache.qpid.server.txn;
 
-import java.io.IOException;
+import org.apache.qpid.transport.Xid;
 
-public class OpenException extends IOException
+public class TimeoutDtxException extends DtxException
 {
-
-    public OpenException(String string, Throwable lastException)
+    public TimeoutDtxException(Xid id)
     {
-        super(string, lastException);
+        super("Transaction " + id + " has timed-out and may only be rolled back");
     }
-
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/UnknownDtxBranchException.java
similarity index 78%
copy from qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
copy to qpid/java/broker/src/main/java/org/apache/qpid/server/txn/UnknownDtxBranchException.java
index 68fbb5e..c23e518 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/OpenException.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/UnknownDtxBranchException.java
@@ -19,16 +19,14 @@
  *
  */
 
-package org.apache.qpid.transport;
+package org.apache.qpid.server.txn;
 
-import java.io.IOException;
+import org.apache.qpid.transport.Xid;
 
-public class OpenException extends IOException
+public class UnknownDtxBranchException extends DtxException
 {
-
-    public OpenException(String string, Throwable lastException)
+    public UnknownDtxBranchException(Xid id)
     {
-        super(string, lastException);
+        super("Unknown xid " + id);
     }
-
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/util/CircularBuffer.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/util/CircularBuffer.java
deleted file mode 100644
index e730e2f..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/util/CircularBuffer.java
+++ /dev/null
@@ -1,131 +0,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.
- *
- */
-package org.apache.qpid.server.util;
-
-import java.util.Iterator;
-
-import org.apache.log4j.Logger;
-
-public class CircularBuffer implements Iterable
-{
-
-    private static final Logger _logger = Logger.getLogger(CircularBuffer.class);
-
-    private final Object[] _log;
-    private int _size;
-    private int _index;
-
-    public CircularBuffer(int size)
-    {
-        _log = new Object[size];
-    }
-
-    public void add(Object o)
-    {
-        _log[_index++] = o;
-        _size = Math.min(_size+1, _log.length);
-        if(_index >= _log.length)
-        {
-            _index = 0;
-        }
-    }
-
-    public Object get(int i)
-    {
-        if(i >= _log.length)
-        {
-            throw new ArrayIndexOutOfBoundsException(i);
-        }
-        return _log[index(i)];
-    }
-
-    public int size() {
-        return _size;
-    }
-
-    public Iterator iterator()
-    {
-        return new Iterator()
-        {
-            private int i = 0;
-
-            public boolean hasNext()
-            {
-                return i < _size;
-            }
-
-            public Object next()
-            {
-                return get(i++);
-            }
-
-            public void remove()
-            {
-                throw new UnsupportedOperationException();
-            }
-        };
-    }
-
-    public String toString()
-    {
-        StringBuilder s = new StringBuilder();
-        boolean first = true;
-        for(Object o : this)
-        {
-            if(!first)
-            {
-                s.append(", ");
-            }
-            else
-            {
-                first = false;
-            }
-            s.append(o);
-        }
-        return s.toString();
-    }
-
-    public void dump()
-    {
-        for(Object o : this)
-        {
-         _logger.info(o);
-        }
-    }
-
-    int index(int i)
-    {
-        return _size == _log.length ? (_index + i) % _log.length : i;
-    }
-
-    public static void main(String[] artgv)
-    {
-        String[] items = new String[]{
-                "A","B","C","D","E","F","G","H","I","J","K"
-        };
-        CircularBuffer buffer = new CircularBuffer(5);
-        for(String s : items)
-        {
-            buffer.add(s);
-            _logger.info(buffer);
-        }
-    }
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/util/LoggingProxy.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/util/LoggingProxy.java
deleted file mode 100644
index eda97e0..0000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/util/LoggingProxy.java
+++ /dev/null
@@ -1,105 +0,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.
- *
- */
-package org.apache.qpid.server.util;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Arrays;
-
-/**
- * Dynamic proxy that records invocations in a fixed size circular buffer,
- * dumping details on hitting an exception.
- * <p>
- * Useful in debugging.
- * <p>
- */
-public class LoggingProxy implements InvocationHandler
-{
-    private final Object _target;
-    private final CircularBuffer _log;
-
-    public LoggingProxy(Object target, int size)
-    {
-        _target = target;
-        _log = new CircularBuffer(size);
-    }
-
-    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
-    {
-        try
-        {
-            entered(method, args);
-            Object result = method.invoke(_target, args);
-            returned(method, result);
-            return result;
-        }
-        catch(InvocationTargetException e)
-        {
-            dump();
-            throw e.getTargetException();
-        }
-    }
-
-    void dump()
-    {
-        _log.dump();
-    }
-
-    CircularBuffer getBuffer()
-    {
-        return _log;
-    }
-
-    private synchronized void entered(Method method, Object[] args)
-    {
-        if (args == null)
-        {
-            _log.add(Thread.currentThread() + ": " + method.getName() + "() entered");
-        }
-        else
-        {
-            _log.add(Thread.currentThread() + ": " + method.getName() + "(" + Arrays.toString(args) + ") entered");
-        }
-    }
-
-    private synchronized void returned(Method method, Object result)
-    {
-        if (method.getReturnType() == Void.TYPE)
-        {
-            _log.add(Thread.currentThread() + ": " + method.getName() + "() returned");
-        }
-        else
-        {
-            _log.add(Thread.currentThread() + ": " + method.getName() + "() returned " + result);
-        }
-    }
-
-    public Object getProxy(Class... c)
-    {
-        return Proxy.newProxyInstance(_target.getClass().getClassLoader(), c, this);
-    }
-
-    public int getBufferSize() {
-        return _log.size();
-    }
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java
index ebace95..523bafb 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java
@@ -21,13 +21,14 @@
 package org.apache.qpid.server.virtualhost;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.server.logging.RootMessageLogger;
 import org.apache.qpid.server.logging.actors.AbstractActor;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 
 public abstract class HouseKeepingTask implements Runnable
 {
-    Logger _logger = Logger.getLogger(this.getClass());
+    private Logger _logger = Logger.getLogger(this.getClass());
 
     private VirtualHost _virtualHost;
 
@@ -59,7 +60,7 @@
         {
             execute();
         }
-        catch (Throwable e)
+        catch (Exception e)
         {
             _logger.warn(this.getClass().getSimpleName() + " throw exception: " + e, e);
         }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/ManagedVirtualHost.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/ManagedVirtualHost.java
index 767474d..cb7f213 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/ManagedVirtualHost.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/ManagedVirtualHost.java
@@ -20,10 +20,10 @@
  */

 package org.apache.qpid.server.virtualhost;

 

-import java.io.IOException;

-

 import org.apache.qpid.management.common.mbeans.annotations.MBeanAttribute;

 

+import java.io.IOException;

+

 /**

  * The management interface exposed to allow management of a virtualHost

  */

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
index 41a5471..4b586db 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
@@ -22,7 +22,7 @@
 
 import java.util.Map;
 import java.util.UUID;
-
+import java.util.concurrent.ScheduledFuture;
 import org.apache.qpid.common.Closeable;
 import org.apache.qpid.server.binding.BindingFactory;
 import org.apache.qpid.server.configuration.ConfigStore;
@@ -37,10 +37,10 @@
 import org.apache.qpid.server.queue.QueueRegistry;
 import org.apache.qpid.server.registry.IApplicationRegistry;
 import org.apache.qpid.server.security.SecurityManager;
-import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
 import org.apache.qpid.server.stats.StatisticsGatherer;
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.txn.DtxRegistry;
 
 public interface VirtualHost extends DurableConfigurationStore.Source, VirtualHostConfig, Closeable, StatisticsGatherer
 {
@@ -60,8 +60,6 @@
 
     DurableConfigurationStore getDurableConfigurationStore();
 
-    AuthenticationManager getAuthenticationManager();
-
     SecurityManager getSecurityManager();
 
     void close();
@@ -97,7 +95,11 @@
 
     ConfigStore getConfigStore();
 
+    DtxRegistry getDtxRegistry();
+
     void removeBrokerConnection(BrokerLink brokerLink);
 
     LinkRegistry getLinkRegistry(String remoteContainerId);
+
+    ScheduledFuture<?> scheduleTask(long delay, Runnable timeoutTask);
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java
index 51892d9..0e96547 100755
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostConfigRecoveryHandler.java
@@ -20,43 +20,47 @@
 */
 package org.apache.qpid.server.virtualhost;
 
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.UUID;
+import org.apache.log4j.Logger;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.server.binding.BindingFactory;
+import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.federation.BrokerLink;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.messages.TransactionLogMessages;
+import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject;
+import org.apache.qpid.server.message.AMQMessage;
+import org.apache.qpid.server.message.AbstractServerMessageImpl;
 import org.apache.qpid.server.message.EnqueableMessage;
+import org.apache.qpid.server.message.MessageTransferMessage;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.AMQQueueFactory;
+import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.store.ConfigurationRecoveryHandler;
 import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.store.MessageStoreRecoveryHandler;
 import org.apache.qpid.server.store.StoredMessage;
 import org.apache.qpid.server.store.TransactionLogRecoveryHandler;
 import org.apache.qpid.server.store.TransactionLogResource;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.AMQQueueFactory;
-import org.apache.qpid.server.queue.QueueRegistry;
-import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject;
-import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.messages.TransactionLogMessages;
-import org.apache.qpid.server.message.AMQMessage;
-import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.message.MessageTransferMessage;
-import org.apache.qpid.server.binding.BindingFactory;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.AMQException;
-
-import org.apache.log4j.Logger;
+import org.apache.qpid.server.txn.DtxBranch;
+import org.apache.qpid.server.txn.DtxRegistry;
+import org.apache.qpid.server.txn.ServerTransaction;
+import org.apache.qpid.transport.Xid;
+import org.apache.qpid.transport.util.Functions;
 import org.apache.qpid.util.ByteBufferInputStream;
 
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.TreeMap;
-import java.util.UUID;
-
 public class VirtualHostConfigRecoveryHandler implements ConfigurationRecoveryHandler,
                                                         ConfigurationRecoveryHandler.QueueRecoveryHandler,
                                                         ConfigurationRecoveryHandler.ExchangeRecoveryHandler,
@@ -65,7 +69,8 @@
                                                         MessageStoreRecoveryHandler,
                                                         MessageStoreRecoveryHandler.StoredMessageRecoveryHandler,
                                                         TransactionLogRecoveryHandler,
-                                                        TransactionLogRecoveryHandler.QueueEntryRecoveryHandler
+                                                        TransactionLogRecoveryHandler.QueueEntryRecoveryHandler,
+                                                        TransactionLogRecoveryHandler.DtxRecordRecoveryHandler
 {
     private static final Logger _logger = Logger.getLogger(VirtualHostConfigRecoveryHandler.class);
 
@@ -78,7 +83,7 @@
     private MessageStore _store;
 
     private final Map<String, Integer> _queueRecoveries = new TreeMap<String, Integer>();
-    private Map<Long, ServerMessage> _recoveredMessages = new HashMap<Long, ServerMessage>();
+    private Map<Long, AbstractServerMessageImpl> _recoveredMessages = new HashMap<Long, AbstractServerMessageImpl>();
     private Map<Long, StoredMessage> _unusedMessages = new HashMap<Long, StoredMessage>();
 
 
@@ -160,7 +165,7 @@
 
     public void message(StoredMessage message)
     {
-        ServerMessage serverMessage;
+        AbstractServerMessageImpl serverMessage;
         switch(message.getMetaData().getType())
         {
             case META_DATA_0_8:
@@ -173,9 +178,6 @@
                 throw new RuntimeException("Unknown message type retrieved from store " + message.getMetaData().getClass());
         }
 
-        //_logger.debug("Recovered message with id " + serverMessage);
-        
-
         _recoveredMessages.put(message.getMessageNumber(), serverMessage);
         _unusedMessages.put(message.getMessageNumber(), message);
     }
@@ -198,6 +200,164 @@
     {
     }
 
+    public void dtxRecord(long format, byte[] globalId, byte[] branchId,
+                          MessageStore.Transaction.Record[] enqueues,
+                          MessageStore.Transaction.Record[] dequeues)
+    {
+        Xid id = new Xid(format, globalId, branchId);
+        DtxRegistry dtxRegistry = _virtualHost.getDtxRegistry();
+        DtxBranch branch = dtxRegistry.getBranch(id);
+        if(branch == null)
+        {
+            branch = new DtxBranch(id, _store, _virtualHost);
+            dtxRegistry.registerBranch(branch);
+        }
+        for(MessageStore.Transaction.Record record : enqueues)
+        {
+            final AMQQueue queue = _virtualHost.getQueueRegistry().getQueue(record.getQueue().getResourceName());
+            if(queue != null)
+            {
+                final long messageId = record.getMessage().getMessageNumber();
+                final AbstractServerMessageImpl message = _recoveredMessages.get(messageId);
+                _unusedMessages.remove(messageId);
+
+                if(message != null)
+                {
+                    message.incrementReference();
+
+                    branch.enqueue(queue,message);
+
+                    branch.addPostTransactionAcion(new ServerTransaction.Action()
+                    {
+
+                        public void postCommit()
+                        {
+                            try
+                            {
+
+                                queue.enqueue(message, true, null);
+                                message.decrementReference();
+                            }
+                            catch (AMQException e)
+                            {
+                                _logger.error("Unable to enqueue message " + message.getMessageNumber() + " into " +
+                                              "queue " + queue.getName() + " (from XA transaction)", e);
+                                throw new RuntimeException(e);
+                            }
+                        }
+
+                        public void onRollback()
+                        {
+                            message.decrementReference();
+                        }
+                    });
+                }
+                else
+                {
+                    StringBuilder xidString = xidAsString(id);
+                    String messageNumberString = String.valueOf(message.getMessageNumber());
+                    CurrentActor.get().message(_logSubject,
+                                               TransactionLogMessages.XA_INCOMPLETE_MESSAGE(xidString.toString(),
+                                                                                            messageNumberString));
+                    
+                }
+
+            }
+            else
+            {
+                StringBuilder xidString = xidAsString(id);
+                CurrentActor.get().message(_logSubject,
+                                           TransactionLogMessages.XA_INCOMPLETE_QUEUE(xidString.toString(),
+                                                                                      record.getQueue().getResourceName()));
+
+            }
+        }
+        for(MessageStore.Transaction.Record record : dequeues)
+        {
+            final AMQQueue queue = _virtualHost.getQueueRegistry().getQueue(record.getQueue().getResourceName());
+            if(queue != null)
+            {
+                final long messageId = record.getMessage().getMessageNumber();
+                final AbstractServerMessageImpl message = _recoveredMessages.get(messageId);
+                _unusedMessages.remove(messageId);
+
+                if(message != null)
+                {
+                    final QueueEntry entry = queue.getMessageOnTheQueue(messageId);
+                    
+                    entry.acquire();
+                    
+                    branch.dequeue(queue, message);
+
+                    branch.addPostTransactionAcion(new ServerTransaction.Action()
+                    {
+
+                        public void postCommit()
+                        {
+                            entry.discard();
+                        }
+
+                        public void onRollback()
+                        {
+                            entry.release();
+                        }
+                    });
+                }
+                else
+                {
+                    StringBuilder xidString = xidAsString(id);
+                    String messageNumberString = String.valueOf(message.getMessageNumber());
+                    CurrentActor.get().message(_logSubject,
+                                               TransactionLogMessages.XA_INCOMPLETE_MESSAGE(xidString.toString(),
+                                                                                            messageNumberString));
+
+                }
+
+            }
+            else
+            {
+                StringBuilder xidString = xidAsString(id);
+                CurrentActor.get().message(_logSubject,
+                                           TransactionLogMessages.XA_INCOMPLETE_QUEUE(xidString.toString(),
+                                                                                      queue.getName()));
+            }
+
+        }
+
+        try
+        {
+            branch.setState(DtxBranch.State.PREPARED);
+            branch.prePrepareTransaction();
+        }
+        catch (AMQStoreException e)
+        {
+            _logger.error("Unexpected database exception when attempting to prepare a recovered XA transaction " +
+                          xidAsString(id), e);
+            throw new RuntimeException(e);
+        }
+    }
+
+    private static StringBuilder xidAsString(Xid id)
+    {
+        return new StringBuilder("(")
+                    .append(id.getFormat())
+                    .append(',')
+                    .append(Functions.str(id.getGlobalId()))
+                    .append(',')
+                    .append(Functions.str(id.getBranchId()))
+                    .append(')');
+    }
+
+    public void completeDtxRecordRecovery()
+    {
+        for(StoredMessage m : _unusedMessages.values())
+        {
+            _logger.warn("Message id " + m.getMessageNumber() + " in store, but not in any queue - removing....");
+            m.remove();
+        }
+        CurrentActor.get().message(_logSubject, TransactionLogMessages.RECOVERY_COMPLETE(null, false));
+    }
+
     private static final class ProcessAction
     {
         private final AMQQueue _queue;
@@ -354,15 +514,9 @@
 
     }
 
-    public void completeQueueEntryRecovery()
+    public DtxRecordRecoveryHandler completeQueueEntryRecovery()
     {
 
-        for(StoredMessage m : _unusedMessages.values())
-        {
-            _logger.warn("Message id " + m.getMessageNumber() + " in store, but not in any queue - removing....");
-            m.remove();
-        }
-
         for(Map.Entry<String,Integer> entry : _queueRecoveries.entrySet())
         {
             CurrentActor.get().message(_logSubject, TransactionLogMessages.RECOVERED(entry.getValue(), entry.getKey()));
@@ -370,7 +524,9 @@
             CurrentActor.get().message(_logSubject, TransactionLogMessages.RECOVERY_COMPLETE(entry.getKey(), true));
         }
 
-        CurrentActor.get().message(_logSubject, TransactionLogMessages.RECOVERY_COMPLETE(null, false));
+
+
+        return this;
     }
 
     private static class DummyMessage implements EnqueableMessage
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
index a4a3633..9a0606f 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
@@ -20,21 +20,11 @@
  */
 package org.apache.qpid.server.virtualhost;
 
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-
+import java.util.concurrent.ScheduledFuture;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.framing.AMQShortString;
@@ -73,14 +63,25 @@
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.registry.IApplicationRegistry;
 import org.apache.qpid.server.security.SecurityManager;
-import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
 import org.apache.qpid.server.stats.StatisticsCounter;
 import org.apache.qpid.server.store.ConfigurationRecoveryHandler;
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.txn.DtxRegistry;
 import org.apache.qpid.server.virtualhost.plugins.VirtualHostPlugin;
 import org.apache.qpid.server.virtualhost.plugins.VirtualHostPluginFactory;
 
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
 public class VirtualHostImpl implements VirtualHost
 {
     private static final Logger _logger = Logger.getLogger(VirtualHostImpl.class);
@@ -97,12 +98,12 @@
 
     private MessageStore _messageStore;
 
-    protected VirtualHostMBean _virtualHostMBean;
+    private DtxRegistry _dtxRegistry;
+
+    private VirtualHostMBean _virtualHostMBean;
 
     private AMQBrokerManagerMBean _brokerMBean;
 
-    private final AuthenticationManager _authenticationManager;
-
     private SecurityManager _securityManager;
 
     private final ScheduledThreadPoolExecutor _houseKeepingTasks;
@@ -121,6 +122,7 @@
     private static final int HOUSEKEEPING_SHUTDOWN_TIMEOUT = 5;
     private final Map<String, LinkRegistry> _linkRegistry = new HashMap<String, LinkRegistry>();
 
+
     public IConnectionRegistry getConnectionRegistry()
     {
         return _connectionRegistry;
@@ -191,6 +193,7 @@
         _broker = _appRegistry.getBroker();
         _configuration = hostConfig;
         _name = _configuration.getName();
+        _dtxRegistry = new DtxRegistry();
 
         _id = _appRegistry.getConfigStore().createId();
 
@@ -241,7 +244,6 @@
 			initialiseMessageStore(hostConfig);
         }
 		
-        _authenticationManager = ApplicationRegistry.getInstance().getAuthenticationManager();
 
         _brokerMBean = new AMQBrokerManagerMBean(_virtualHostMBean);
         _brokerMBean.register();
@@ -260,54 +262,9 @@
     {
         if (period != 0L)
         {
-            class VirtualHostHouseKeepingTask extends HouseKeepingTask
-            {
-                public VirtualHostHouseKeepingTask(VirtualHost vhost)
-                {
-                    super(vhost);
-                }
 
-                public void execute()
-                {
-                    for (AMQQueue q : _queueRegistry.getQueues())
-                    {
-                        _logger.debug("Checking message status for queue: "
-                                      + q.getName());
-                        try
-                        {
-                            q.checkMessageStatus();
-                        }
-                        catch (Exception e)
-                        {
-                            _logger.error("Exception in housekeeping for queue: "
-                                          + q.getNameShortString().toString(), e);
-                            //Don't throw exceptions as this will stop the
-                            // house keeping task from running.
-                        }
-                    }
-                    for (AMQConnectionModel connection : getConnectionRegistry().getConnections())
-                    {
-                        _logger.debug("Checking for long running open transactions on connection " + connection);
-                        for (AMQSessionModel session : connection.getSessionModels())
-                        {
-	                        _logger.debug("Checking for long running open transactions on session " + session);
-                            try
-                            {
-                                session.checkTransactionStatus(_configuration.getTransactionTimeoutOpenWarn(),
-	                                                           _configuration.getTransactionTimeoutOpenClose(),
-	                                                           _configuration.getTransactionTimeoutIdleWarn(),
-	                                                           _configuration.getTransactionTimeoutIdleClose());
-                            }
-                            catch (Exception e)
-                            {
-                                _logger.error("Exception in housekeeping for connection: " + connection.toString(), e);
-                            }
-                        }
-                    }
-                }
-            }
 
-            scheduleHouseKeepingTask(period, new VirtualHostHouseKeepingTask(this));
+            scheduleHouseKeepingTask(period, new VirtualHostHouseKeepingTask());
 
             Map<String, VirtualHostPluginFactory> plugins =
                 ApplicationRegistry.getInstance().getPluginManager().getVirtualHostPlugins();
@@ -340,6 +297,53 @@
         }
     }
 
+    private class VirtualHostHouseKeepingTask extends HouseKeepingTask
+    {
+        public VirtualHostHouseKeepingTask()
+        {
+            super(VirtualHostImpl.this);
+        }
+
+        public void execute()
+        {
+            for (AMQQueue q : _queueRegistry.getQueues())
+            {
+                _logger.debug("Checking message status for queue: "
+                              + q.getName());
+                try
+                {
+                    q.checkMessageStatus();
+                }
+                catch (Exception e)
+                {
+                    _logger.error("Exception in housekeeping for queue: "
+                                  + q.getNameShortString().toString(), e);
+                    //Don't throw exceptions as this will stop the
+                    // house keeping task from running.
+                }
+            }
+            for (AMQConnectionModel connection : getConnectionRegistry().getConnections())
+            {
+                _logger.debug("Checking for long running open transactions on connection " + connection);
+                for (AMQSessionModel session : connection.getSessionModels())
+                {
+                    _logger.debug("Checking for long running open transactions on session " + session);
+                    try
+                    {
+                        session.checkTransactionStatus(_configuration.getTransactionTimeoutOpenWarn(),
+                                                       _configuration.getTransactionTimeoutOpenClose(),
+                                                       _configuration.getTransactionTimeoutIdleWarn(),
+                                                       _configuration.getTransactionTimeoutIdleClose());
+                    }
+                    catch (Exception e)
+                    {
+                        _logger.error("Exception in housekeeping for connection: " + connection.toString(), e);
+                    }
+                }
+            }
+        }
+    }
+
     /**
      * Allow other broker components to register a HouseKeepingTask
      *
@@ -352,6 +356,11 @@
                                                TimeUnit.MILLISECONDS);
     }
 
+    public ScheduledFuture<?> scheduleTask(long delay, Runnable task)
+    {
+        return _houseKeepingTasks.schedule(task, delay, TimeUnit.MILLISECONDS);
+    }
+
     public long getHouseKeepingTaskCount()
     {
         return _houseKeepingTasks.getTaskCount();
@@ -575,11 +584,6 @@
         return _durableConfigurationStore;
     }
 
-    public AuthenticationManager getAuthenticationManager()
-    {
-        return _authenticationManager;
-    }
-
     public SecurityManager getSecurityManager()
     {
         return _securityManager;
@@ -618,6 +622,11 @@
             }
         }
 
+        if(_dtxRegistry != null)
+        {
+            _dtxRegistry.close();
+        }
+
         //Close MessageStore
         if (_messageStore != null)
         {
@@ -796,6 +805,11 @@
         return getApplicationRegistry().getConfigStore();
     }
 
+    public DtxRegistry getDtxRegistry()
+    {
+        return _dtxRegistry;
+    }
+
     /**
      * Temporary Startup RT class to record the creation of persistent queues / exchanges.
      *
@@ -805,11 +819,11 @@
      */
     private static class StartupRoutingTable implements DurableConfigurationStore
     {
-        public List<Exchange> exchange = new LinkedList<Exchange>();
-        public List<CreateQueueTuple> queue = new LinkedList<CreateQueueTuple>();
-        public List<CreateBindingTuple> bindings = new LinkedList<CreateBindingTuple>();
-        public List<BrokerLink> links = new LinkedList<BrokerLink>();
-        public List<Bridge> bridges = new LinkedList<Bridge>();
+        private List<Exchange> exchange = new LinkedList<Exchange>();
+        private List<CreateQueueTuple> queue = new LinkedList<CreateQueueTuple>();
+        private List<CreateBindingTuple> bindings = new LinkedList<CreateBindingTuple>();
+        private List<BrokerLink> links = new LinkedList<BrokerLink>();
+        private List<Bridge> bridges = new LinkedList<Bridge>();
         
         public void configure(VirtualHost virtualHost, String base, VirtualHostConfiguration config) throws Exception
         {
@@ -876,8 +890,8 @@
 
         private static class CreateQueueTuple
         {
-            public AMQQueue queue;
-            public FieldTable arguments;
+            private AMQQueue queue;
+            private FieldTable arguments;
 
             public CreateQueueTuple(AMQQueue queue, FieldTable arguments)
             {
@@ -888,10 +902,10 @@
 
         private static class CreateBindingTuple
         {
-            public AMQQueue queue;
-            public FieldTable arguments;
-            public Exchange exchange;
-            public AMQShortString routingKey;
+            private AMQQueue queue;
+            private FieldTable arguments;
+            private Exchange exchange;
+            private AMQShortString routingKey;
 
             public CreateBindingTuple(Exchange exchange, AMQShortString routingKey, AMQQueue queue, FieldTable args)
             {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostRegistry.java
index 32d0c4c..ef621a1 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostRegistry.java
@@ -21,8 +21,8 @@
 package org.apache.qpid.server.virtualhost;

 

 import org.apache.qpid.common.Closeable;

-import org.apache.qpid.server.registry.ApplicationRegistry;

 import org.apache.qpid.server.configuration.ConfigStore;

+import org.apache.qpid.server.registry.ApplicationRegistry;

 

 import java.util.ArrayList;

 import java.util.Collection;

diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/ConfiguredQueueBindingListener.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/ConfiguredQueueBindingListener.java
index 1220601..12886f4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/ConfiguredQueueBindingListener.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/ConfiguredQueueBindingListener.java
@@ -20,19 +20,18 @@
  */
 package org.apache.qpid.server.virtualhost.plugins;
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.server.binding.Binding;
 import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionQueueConfiguration;
-import org.apache.qpid.server.exchange.AbstractExchange;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.exchange.Exchange.BindingListener;
 import org.apache.qpid.server.queue.AMQQueue;
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * This is a listener that caches queues that are configured for slow consumer disconnection.
  * 
@@ -93,7 +92,7 @@
     /**
      * Lookup and return the cache of configured {@link AMQQueue}s.
      * 
-	 * Note that when accessing the cached queues, the {@link Iterator} is not thread safe
+	 * Note that when accessing the cached queues, the {@link java.util.Iterator} is not thread safe
 	 * (see the {@link Collections#synchronizedSet(Set)} documentation) so a copy of the
 	 * cache is returned.
      * 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetection.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetection.java
index 248b3b2..2c6705b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetection.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetection.java
@@ -19,21 +19,20 @@
  */
 package org.apache.qpid.server.virtualhost.plugins;
 
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionConfiguration;
 import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionQueueConfiguration;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.exchange.ExchangeRegistry;
 import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.plugins.Plugin;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.virtualhost.plugins.logging.SlowConsumerDetectionMessages;
 import org.apache.qpid.slowconsumerdetection.policies.SlowConsumerPolicyPlugin;
 
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
 public class SlowConsumerDetection extends VirtualHostHouseKeepingPlugin
 {
     private SlowConsumerDetectionConfiguration _config;
@@ -61,7 +60,7 @@
      * virtual host to record all the configured queues in a cache for processing by the housekeeping
      * thread.
      * 
-     * @see Plugin#configure(ConfigurationPlugin)
+     * @see org.apache.qpid.server.plugins.Plugin#configure(ConfigurationPlugin)
      */
     public void configure(ConfigurationPlugin config)
     {        
@@ -98,7 +97,7 @@
                     if (policy == null)
                     {
                         // We would only expect to see this during shutdown
-                        _logger.warn("No slow consumer policy for queue " + q.getName());
+                        getLogger().warn("No slow consumer policy for queue " + q.getName());
                     }
                     else
                     {
@@ -110,7 +109,7 @@
             catch (Exception e)
             {
                 // Don't throw exceptions as this will stop the house keeping task from running.
-                _logger.error("Exception in SlowConsumersDetection for queue: " + q.getName(), e);
+                getLogger().error("Exception in SlowConsumersDetection for queue: " + q.getName(), e);
             }
         }
 
@@ -139,9 +138,9 @@
     {
         if (config != null)
         {
-            if (_logger.isInfoEnabled())
+            if (getLogger().isInfoEnabled())
             {
-                _logger.info("Retrieved Queue(" + q.getName() + ") Config:" + config);
+                getLogger().info("Retrieved Queue(" + q.getName() + ") Config:" + config);
             }
 
             int count = q.getMessageCount();
@@ -157,12 +156,12 @@
                  ((count > 0) && q.getOldestMessageArrivalTime() >= config.getMessageAge())))
             {
                 
-                if (_logger.isDebugEnabled())
+                if (getLogger().isDebugEnabled())
                 {
-                    _logger.debug("Detected Slow Consumer on Queue(" + q.getName() + ")");
-                    _logger.debug("Queue Count:" + q.getMessageCount() + ":" + config.getMessageCount());
-                    _logger.debug("Queue Depth:" + q.getQueueDepth() + ":" + config.getDepth());
-                    _logger.debug("Queue Arrival:" + q.getOldestMessageArrivalTime() + ":" + config.getMessageAge());
+                    getLogger().debug("Detected Slow Consumer on Queue(" + q.getName() + ")");
+                    getLogger().debug("Queue Count:" + q.getMessageCount() + ":" + config.getMessageCount());
+                    getLogger().debug("Queue Depth:" + q.getQueueDepth() + ":" + config.getDepth());
+                    getLogger().debug("Queue Arrival:" + q.getOldestMessageArrivalTime() + ":" + config.getMessageAge());
                 }
 
                 return true;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/VirtualHostHouseKeepingPlugin.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/VirtualHostHouseKeepingPlugin.java
index 3798f47..191f804 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/VirtualHostHouseKeepingPlugin.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/VirtualHostHouseKeepingPlugin.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.virtualhost.plugins;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.server.virtualhost.HouseKeepingTask;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
@@ -28,7 +29,7 @@
 
 public abstract class VirtualHostHouseKeepingPlugin extends HouseKeepingTask implements VirtualHostPlugin
 {
-    protected final Logger _logger = Logger.getLogger(getClass());
+    private final Logger _logger = Logger.getLogger(getClass());
 
     public VirtualHostHouseKeepingPlugin(VirtualHost vhost)
     {
@@ -51,4 +52,10 @@
      * @see java.util.concurrent.TimeUnit for valid value.
      */
     public abstract TimeUnit getTimeUnit();
+
+
+    protected Logger getLogger()
+    {
+        return _logger;
+    }
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/VirtualHostPlugin.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/VirtualHostPlugin.java
index 1886c2d..35f6228 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/VirtualHostPlugin.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/VirtualHostPlugin.java
@@ -20,10 +20,9 @@
  */
 package org.apache.qpid.server.virtualhost.plugins;
 
-import java.util.concurrent.TimeUnit;
-
 import org.apache.qpid.server.plugins.Plugin;
-import org.apache.qpid.server.virtualhost.VirtualHost;
+
+import java.util.concurrent.TimeUnit;
 
 public interface VirtualHostPlugin extends Runnable, Plugin
 {
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicy.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicy.java
index 6028f63..f2f61f2 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicy.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicy.java
@@ -22,10 +22,10 @@
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.binding.Binding;
-import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionPolicyConfiguration;
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.exchange.TopicExchange;
 import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -37,7 +37,7 @@
 
 public class TopicDeletePolicy implements SlowConsumerPolicyPlugin
 {
-    Logger _logger = Logger.getLogger(TopicDeletePolicy.class);
+    private Logger _logger = Logger.getLogger(TopicDeletePolicy.class);
     private TopicDeletePolicyConfiguration _configuration;
 
     public static class TopicDeletePolicyFactory implements SlowConsumerPolicyPluginFactory
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyConfiguration.java
index 7dfd22c..48158b7 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyConfiguration.java
@@ -20,14 +20,15 @@
  */
 package org.apache.qpid.server.virtualhost.plugins.policies;
 
-import java.util.Arrays;
-import java.util.List;
-
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory;
 
+import java.util.Arrays;
+import java.util.List;
+
 public class TopicDeletePolicyConfiguration extends ConfigurationPlugin
 {
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/tools/security/Passwd.java b/qpid/java/broker/src/main/java/org/apache/qpid/tools/security/Passwd.java
index 3d3c7b6..cd833c8 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/tools/security/Passwd.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/tools/security/Passwd.java
@@ -14,9 +14,9 @@
  *  "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.    
+ *  under the License.
  *
- * 
+ *
  */
 package org.apache.qpid.tools.security;
 
@@ -26,8 +26,12 @@
 import java.security.DigestException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
+
 import org.apache.commons.codec.binary.Base64;
 
+/**
+ * Utility to generate user:encodedPassword string for use in md5passwd
+ */
 public class Passwd
 {
     public static void main(String args[]) throws NoSuchAlgorithmException, DigestException, IOException
@@ -63,5 +67,4 @@
         String encodedStr = new String(encoded, Charset.forName("utf-8"));
         return userName + ":" + encodedStr;
     }
-
 }
diff --git a/qpid/java/broker/src/test/java/org/apache/log4j/xml/QpidLog4JConfiguratorTest.java b/qpid/java/broker/src/test/java/org/apache/log4j/xml/QpidLog4JConfiguratorTest.java
index 445c7d5..c06ce5e 100644
--- a/qpid/java/broker/src/test/java/org/apache/log4j/xml/QpidLog4JConfiguratorTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/log4j/xml/QpidLog4JConfiguratorTest.java
@@ -21,15 +21,14 @@
 package org.apache.log4j.xml;
 
 
+import junit.framework.TestCase;
+import org.apache.log4j.xml.QpidLog4JConfigurator.IllegalLoggerLevelException;
+
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 
-import org.apache.log4j.xml.QpidLog4JConfigurator.IllegalLoggerLevelException;
-
-import junit.framework.TestCase;
-
 public class QpidLog4JConfiguratorTest extends TestCase
 {
     private static final String NEWLINE = System.getProperty("line.separator");
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
index 7d128f2..d34d1bb 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
@@ -20,10 +20,8 @@
  */
 package org.apache.qpid.server;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.management.common.mbeans.ManagedBroker;
 import org.apache.qpid.server.configuration.ServerConfiguration;
@@ -40,10 +38,13 @@
 import org.apache.qpid.server.registry.IApplicationRegistry;
 import org.apache.qpid.server.store.TestableMemoryMessageStore;
 import org.apache.qpid.server.util.TestApplicationRegistry;
-import org.apache.qpid.server.virtualhost.VirtualHostImpl;
 import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.virtualhost.VirtualHostImpl;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public class AMQBrokerManagerMBeanTest extends QpidTestCase
 {
     private QueueRegistry _queueRegistry;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java
index 131f3163..bb20e02 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.server;
 
+import org.apache.qpid.test.utils.QpidTestCase;
+
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.qpid.test.utils.QpidTestCase;
-
 
 public class BrokerOptionsTest extends QpidTestCase
 {
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/ExtractResendAndRequeueTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/ExtractResendAndRequeueTest.java
index d2408ba..616ee74 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/ExtractResendAndRequeueTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/ExtractResendAndRequeueTest.java
@@ -21,23 +21,24 @@
 package org.apache.qpid.server;
 
 import junit.framework.TestCase;
+
+import org.apache.qpid.AMQException;
 import org.apache.qpid.server.ack.UnacknowledgedMessageMapImpl;
-import org.apache.qpid.server.queue.QueueEntry;
-import org.apache.qpid.server.queue.SimpleQueueEntryList;
-import org.apache.qpid.server.queue.MockAMQMessage;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.MockAMQQueue;
 import org.apache.qpid.server.message.AMQMessage;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.MockAMQMessage;
+import org.apache.qpid.server.queue.MockAMQQueue;
+import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.queue.QueueEntryIterator;
-import org.apache.qpid.server.subscription.Subscription;
-import org.apache.qpid.server.subscription.MockSubscription;
+import org.apache.qpid.server.queue.SimpleQueueEntryList;
 import org.apache.qpid.server.store.MemoryMessageStore;
 import org.apache.qpid.server.store.MessageStore;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.subscription.MockSubscription;
+import org.apache.qpid.server.subscription.Subscription;
 
-import java.util.Map;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
+import java.util.Map;
 
 /**
  * QPID-1385 : Race condition between added to unacked map and resending due to a rollback.
@@ -59,7 +60,7 @@
 public class ExtractResendAndRequeueTest extends TestCase
 {
 
-    UnacknowledgedMessageMapImpl _unacknowledgedMessageMap;
+    private UnacknowledgedMessageMapImpl _unacknowledgedMessageMap;
     private static final int INITIAL_MSG_COUNT = 10;
     private AMQQueue _queue = new MockAMQQueue(getName());
     private MessageStore _messageStore = new MemoryMessageStore();
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/MainTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/MainTest.java
index 3e4c302..31d5028 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/MainTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/MainTest.java
@@ -20,10 +20,11 @@
  */
 package org.apache.qpid.server;
 
-import java.util.EnumSet;
-
+import org.apache.commons.cli.CommandLine;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import java.util.EnumSet;
+
 /**
  * Test to verify the command line parsing within the Main class, by
  * providing it a series of command line arguments and verifying the
@@ -145,6 +146,22 @@
         assertEquals(9, options.getLogWatchFrequency());
     }
 
+    public void testVersion()
+    {
+        final TestMain main = new TestMain("-v".split("\\s"));
+
+        assertNotNull("Command line not parsed correctly", main.getCommandLine());
+        assertTrue("Parsed command line didnt pick up version option", main.getCommandLine().hasOption("v"));
+    }
+
+    public void testHelp()
+    {
+        final TestMain main = new TestMain("-h".split("\\s"));
+
+        assertNotNull("Command line not parsed correctly", main.getCommandLine());
+        assertTrue("Parsed command line didnt pick up help option", main.getCommandLine().hasOption("h"));
+    }
+
     private BrokerOptions startDummyMain(String commandLine)
     {
         return (new TestMain(commandLine.split("\\s"))).getOptions();
@@ -174,5 +191,10 @@
         {
             return _options;
         }
+
+        public CommandLine getCommandLine()
+        {
+            return _commandLine;
+        }
     }
 }
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/SelectorParserTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/SelectorParserTest.java
index a0304a7..3e0e217 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/SelectorParserTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/SelectorParserTest.java
@@ -1,8 +1,4 @@
-package org.apache.qpid.server;
-
-import junit.framework.TestCase;
-import org.apache.qpid.server.filter.JMSSelectorFilter;
-import org.apache.qpid.AMQException;/*
+/*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -23,6 +19,14 @@
  *
  */
 
+package org.apache.qpid.server;
+
+import junit.framework.TestCase;
+
+import org.apache.qpid.filter.SelectorParsingException;
+import org.apache.qpid.filter.selector.ParseException;
+import org.apache.qpid.server.filter.JMSSelectorFilter;
+
 public class SelectorParserTest extends TestCase
 {
     public void testSelectorWithHyphen()
@@ -106,7 +110,11 @@
         {
             new JMSSelectorFilter(selector);
         }
-        catch (AMQException e)
+        catch (ParseException e)
+        {
+            fail("Selector '" + selector + "' was not parsed :" + e.getMessage());
+        }
+        catch (SelectorParsingException e)
         {
             fail("Selector '" + selector + "' was not parsed :" + e.getMessage());
         }
@@ -119,7 +127,11 @@
             new JMSSelectorFilter(selector);
             fail("Selector '" + selector + "' was parsed ");
         }
-        catch (AMQException e)
+        catch (ParseException e)
+        {
+            //normal path
+        }
+        catch (SelectorParsingException e)
         {
             //normal path
         }
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java
index e1a5e7d..36f131a 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java
@@ -24,6 +24,7 @@
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
+
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.util.TestApplicationRegistry;
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
index eb4a90d..4caefc2 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
@@ -20,16 +20,9 @@
  */
 package org.apache.qpid.server.configuration;
 
-import static org.apache.qpid.transport.ConnectionSettings.WILDCARD_ADDRESS;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Locale;
-
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.registry.ApplicationRegistry;
@@ -39,6 +32,16 @@
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import static org.apache.qpid.transport.ConnectionSettings.WILDCARD_ADDRESS;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
+
+import javax.net.ssl.KeyManagerFactory;
+
 public class ServerConfigurationTest extends QpidTestCase
 {
     private XMLConfiguration _config = new XMLConfiguration();
@@ -490,19 +493,6 @@
         assertEquals(false, _serverConfig.getTcpNoDelay());
     }
 
-    public void testGetEnableExecutorPool() throws ConfigurationException
-    {
-        // Check default
-        _serverConfig.initialise();
-        assertEquals(false, _serverConfig.getEnableExecutorPool());
-
-        // Check value we set
-        _config.setProperty("advanced.filterchain[@enableExecutorPool]", true);
-        _serverConfig = new ServerConfiguration(_config);
-        _serverConfig.initialise();
-        assertEquals(true, _serverConfig.getEnableExecutorPool());
-    }
-
     public void testGetEnableSSL() throws ConfigurationException
     {
         // Check default
@@ -587,17 +577,24 @@
         assertEquals("b", _serverConfig.getConnectorKeyStorePassword());
     }
 
-    public void testGetConnectorCertType() throws ConfigurationException
+    public void testConnectorGetKeyManagerAlgorithm() throws ConfigurationException
     {
         // Check default
         _serverConfig.initialise();
-        assertEquals("SunX509", _serverConfig.getConnectorCertType());
+        assertEquals(KeyManagerFactory.getDefaultAlgorithm(), _serverConfig.getConnectorKeyManagerFactoryAlgorithm());
 
         // Check value we set
-        _config.setProperty("connector.ssl.certType", "a");
+        _config.setProperty("connector.ssl.keyManagerFactoryAlgorithm", "a");
         _serverConfig = new ServerConfiguration(_config);
         _serverConfig.initialise();
-        assertEquals("a", _serverConfig.getConnectorCertType());
+        assertEquals("a", _serverConfig.getConnectorKeyManagerFactoryAlgorithm());
+
+        // Ensure we continue to support the old name certType
+        _config.clearProperty("connector.ssl.keyManagerFactoryAlgorithm");
+        _config.setProperty("connector.ssl.certType", "b");
+        _serverConfig = new ServerConfiguration(_config);
+        _serverConfig.initialise();
+        assertEquals("b", _serverConfig.getConnectorKeyManagerFactoryAlgorithm());
     }
 
     public void testGetHousekeepingCheckPeriod() throws ConfigurationException
@@ -1539,6 +1536,58 @@
         assertTrue("C3P0 queue DLQ should be enabled, using broker default", c3p0.isDeadLetterQueueEnabled());
     }
 
+    public void testIsAmqp010enabled() throws ConfigurationException
+    {
+        // Check default
+        _serverConfig.initialise();
+        assertEquals(true, _serverConfig.isAmqp010enabled());
+
+        // Check value we set
+        _config.setProperty(ServerConfiguration.CONNECTOR_AMQP010ENABLED, false);
+        _serverConfig = new ServerConfiguration(_config);
+        _serverConfig.initialise();
+        assertEquals(false, _serverConfig.isAmqp010enabled());
+    }
+
+    public void testIsAmqp091enabled() throws ConfigurationException
+    {
+        // Check default
+        _serverConfig.initialise();
+        assertEquals(true, _serverConfig.isAmqp091enabled());
+
+        // Check value we set
+        _config.setProperty(ServerConfiguration.CONNECTOR_AMQP091ENABLED, false);
+        _serverConfig = new ServerConfiguration(_config);
+        _serverConfig.initialise();
+        assertEquals(false, _serverConfig.isAmqp091enabled());
+    }
+
+    public void testIsAmqp09enabled() throws ConfigurationException
+    {
+        // Check default
+        _serverConfig.initialise();
+        assertEquals(true, _serverConfig.isAmqp09enabled());
+
+        // Check value we set
+        _config.setProperty(ServerConfiguration.CONNECTOR_AMQP09ENABLED, false);
+        _serverConfig = new ServerConfiguration(_config);
+        _serverConfig.initialise();
+        assertEquals(false, _serverConfig.isAmqp09enabled());
+    }
+
+    public void testIsAmqp08enabled() throws ConfigurationException
+    {
+        // Check default
+        _serverConfig.initialise();
+        assertEquals(true, _serverConfig.isAmqp08enabled());
+
+        // Check value we set
+        _config.setProperty(ServerConfiguration.CONNECTOR_AMQP08ENABLED, false);
+        _serverConfig = new ServerConfiguration(_config);
+        _serverConfig.initialise();
+        assertEquals(false, _serverConfig.isAmqp08enabled());
+    }
+
     /**
      * Convenience method to output required security preamble for broker config
      */
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TopicConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TopicConfigurationTest.java
index 7fc3b2d..59cd0cf 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TopicConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TopicConfigurationTest.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.configuration;
 
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQInternalException;
 import org.apache.qpid.AMQSecurityException;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java
index f6cd397..50e7f05 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java
@@ -21,6 +21,7 @@
 
 
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.queue.AMQPriorityQueue;
 import org.apache.qpid.server.queue.AMQQueue;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/plugins/ConfigurationPluginTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/plugins/ConfigurationPluginTest.java
index ee2f77f..14c7b8c 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/plugins/ConfigurationPluginTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/plugins/ConfigurationPluginTest.java
@@ -20,10 +20,10 @@
  */
 package org.apache.qpid.server.configuration.plugins;
 
-import junit.framework.TestCase;
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
 import java.util.List;
@@ -68,7 +68,7 @@
 
     }
 
-    ConfigPlugin _plugin;
+    private ConfigPlugin _plugin;
 
     @Override
     public void setUp() throws Exception
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java
index 7bd711a..9011e50 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java
@@ -20,17 +20,8 @@
  */
 package org.apache.qpid.server.exchange;
 
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.BasicContentHeaderProperties;
@@ -55,11 +46,21 @@
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.store.MemoryMessageStore;
-import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.store.StoredMessage;
 import org.apache.qpid.server.subscription.Subscription;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
+
 public class AbstractHeadersExchangeTestBase extends InternalBrokerBaseCase
 {
     private static final Logger _log = Logger.getLogger(AbstractHeadersExchangeTestBase.class);
@@ -75,7 +76,7 @@
     private MemoryMessageStore _store = new MemoryMessageStore();
 
 
-    BindingFactory bindingFactory = new BindingFactory(new DurableConfigurationStore.Source()
+    private BindingFactory bindingFactory = new BindingFactory(new DurableConfigurationStore.Source()
                                                         {
 
                                                             public DurableConfigurationStore getDurableConfigurationStore()
@@ -122,7 +123,7 @@
 
     protected int route(Message m) throws AMQException
     {
-        m.getIncomingMessage().headersReceived();
+        m.getIncomingMessage().headersReceived(System.currentTimeMillis());
         m.route(exchange);
         if(m.getIncomingMessage().allContentReceived())
         {
@@ -287,7 +288,7 @@
 
     static class TestQueue extends SimpleAMQQueue
     {
-        final List<HeadersExchangeTest.Message> messages = new ArrayList<HeadersExchangeTest.Message>();
+        private final List<HeadersExchangeTest.Message> messages = new ArrayList<HeadersExchangeTest.Message>();
 
         public String toString()
         {
@@ -496,18 +497,15 @@
                     return null;
                 }
 
-                @Override
                 public int getDeliveryCount()
                 {
                     return 0;
                 }
 
-                @Override
                 public void incrementDeliveryCount()
                 {
                 }
 
-                @Override
                 public void decrementDeliveryCount()
                 {
                 }
@@ -594,8 +592,8 @@
             int pos = 0;
             for(ContentBody body : bodies)
             {
-                storedMessage.addContent(pos, ByteBuffer.wrap(body._payload));
-                pos += body._payload.length;
+                storedMessage.addContent(pos, ByteBuffer.wrap(body.getPayload()));
+                pos += body.getPayload().length;
             }
 
             _incoming = new TestIncomingMessage(getMessageId(),publish, protocolsession);
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
index 68021f0..1fac4af 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
@@ -21,17 +21,18 @@
 package org.apache.qpid.server.exchange;
 
 import org.apache.commons.lang.ArrayUtils;
-import org.apache.qpid.management.common.mbeans.ManagedExchange;
-import org.apache.qpid.server.queue.QueueRegistry;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.AMQQueueFactory;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.registry.IApplicationRegistry;
-import org.apache.qpid.server.management.ManagedObject;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
-import org.apache.qpid.server.virtualhost.VirtualHost;
+
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.management.common.mbeans.ManagedExchange;
+import org.apache.qpid.server.management.ManagedObject;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.AMQQueueFactory;
+import org.apache.qpid.server.queue.QueueRegistry;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.server.virtualhost.VirtualHost;
 
 import javax.management.JMException;
 import javax.management.openmbean.CompositeDataSupport;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
index a7c226c..4305cda 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
@@ -20,16 +20,16 @@
  */
 package org.apache.qpid.server.exchange;
 
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-
 import junit.framework.TestCase;
-import org.apache.qpid.framing.FieldTable;
+
 import org.apache.qpid.server.binding.Binding;
 import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.queue.MockAMQQueue;
 
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
 /**
  */
 public class HeadersBindingTest extends TestCase
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
index ac638e4..326d36d 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
@@ -21,14 +21,14 @@
 package org.apache.qpid.server.exchange;
 
 import org.apache.qpid.AMQException;
+import org.apache.qpid.server.protocol.AMQProtocolSession;
+import org.apache.qpid.server.protocol.InternalTestProtocolSession;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.protocol.InternalTestProtocolSession;
-import org.apache.qpid.server.protocol.AMQProtocolSession;
 
 public class HeadersExchangeTest extends AbstractHeadersExchangeTestBase
 {
-    AMQProtocolSession _protocolSession;
+    private AMQProtocolSession _protocolSession;
 
     @Override
     public void setUp() throws Exception
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java
index 403a290..00c8a18 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java
@@ -20,33 +20,36 @@
  */
 package org.apache.qpid.server.exchange;
 
-import junit.framework.TestCase;
 import junit.framework.Assert;
-import org.apache.qpid.server.queue.*;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.store.MessageStore;
-import org.apache.qpid.server.store.MemoryMessageStore;
-import org.apache.qpid.server.protocol.InternalTestProtocolSession;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 import org.apache.qpid.server.binding.Binding;
 import org.apache.qpid.server.message.AMQMessage;
 import org.apache.qpid.server.message.MessageMetaData;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
-import org.apache.qpid.framing.abstraction.MessagePublishInfo;
+import org.apache.qpid.server.protocol.InternalTestProtocolSession;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.AMQQueueFactory;
+import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.server.queue.IncomingMessage;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.store.MemoryMessageStore;
+import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.server.virtualhost.VirtualHost;
 
 public class TopicExchangeTest extends InternalBrokerBaseCase
 {
 
-    TopicExchange _exchange;
+    private TopicExchange _exchange;
 
-    VirtualHost _vhost;
-    MessageStore _store;
+    private VirtualHost _vhost;
+    private MessageStore _store;
 
-    InternalTestProtocolSession _protocolSession;
+    private InternalTestProtocolSession _protocolSession;
 
 
     @Override
@@ -347,7 +350,7 @@
     private int routeMessage(final IncomingMessage message)
             throws AMQException
     {
-        MessageMetaData mmd = message.headersReceived();
+        MessageMetaData mmd = message.headersReceived(System.currentTimeMillis());
         message.setStoredMessage(_store.addMessage(mmd));
 
         message.enqueue(_exchange.route(message));
@@ -406,7 +409,7 @@
 
     class PublishInfo implements MessagePublishInfo
     {
-        AMQShortString _routingkey;
+        private AMQShortString _routingkey;
 
         PublishInfo(AMQShortString routingkey)
         {
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/flow/WindowCreditManagerTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/flow/WindowCreditManagerTest.java
index 2011dfb..bc651c9 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/flow/WindowCreditManagerTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/flow/WindowCreditManagerTest.java
@@ -24,7 +24,7 @@
 
 public class WindowCreditManagerTest extends QpidTestCase
 {
-    WindowCreditManager _creditManager;
+    private WindowCreditManager _creditManager;
 
     protected void setUp() throws Exception
     {
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/Log4jMessageLoggerTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/Log4jMessageLoggerTest.java
index a845bff..e2a6a56 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/Log4jMessageLoggerTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/Log4jMessageLoggerTest.java
@@ -20,23 +20,23 @@
  */
 package org.apache.qpid.server.logging;
 
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-
 import junit.framework.TestCase;
-
 import org.apache.log4j.AppenderSkeleton;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.log4j.spi.LoggingEvent;
+
 import org.apache.qpid.server.logging.actors.BrokerActor;
 
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
 /** Test that the Log4jMessageLogger defaults behave as expected */
 public class Log4jMessageLoggerTest extends TestCase
 {
-    Level _rootLevel;
-    Log4jTestAppender _appender;
+    private Level _rootLevel;
+    private Log4jTestAppender _appender;
 
     @Override
     public void setUp() throws IOException
@@ -242,7 +242,7 @@
      */
     private class Log4jTestAppender extends AppenderSkeleton
     {
-        List<LoggingEvent> _log = new LinkedList<LoggingEvent>();
+        private List<LoggingEvent> _log = new LinkedList<LoggingEvent>();
 
         protected void append(LoggingEvent loggingEvent)
         {
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/LogMessageTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/LogMessageTest.java
index 956bb6f..b0cb0ca 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/LogMessageTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/LogMessageTest.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.logging;
 
 import junit.framework.TestCase;
+
 import org.apache.qpid.server.logging.messages.BrokerMessages;
 
 import java.util.Locale;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/UnitTestMessageLogger.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/UnitTestMessageLogger.java
index e8defd0..fabbe86 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/UnitTestMessageLogger.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/UnitTestMessageLogger.java
@@ -20,12 +20,11 @@
  */
 package org.apache.qpid.server.logging;
 
+import org.apache.qpid.server.configuration.ServerConfiguration;
+
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.logging.AbstractRootMessageLogger;
-
 public class UnitTestMessageLogger extends AbstractRootMessageLogger
 {
     private final List<Object> _log = new LinkedList<Object>();
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java
index 6346fff..f739d3f 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java
@@ -20,11 +20,12 @@
  */
 package org.apache.qpid.server.logging.actors;
 
-import java.util.List;
-
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.AMQException;
 
+import java.util.List;
+
 /**
  * Test : AMQPChannelActorTest
  * Validate the AMQPChannelActor class.
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java
index 60ecbef..ec2cdd5 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java
@@ -21,12 +21,11 @@
 package org.apache.qpid.server.logging.actors;
 
 import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.logging.LogMessage;
 import org.apache.qpid.server.logging.LogSubject;
 import org.apache.qpid.server.logging.RootMessageLogger;
-import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.logging.UnitTestMessageLogger;
-
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
 public class BaseActorTestCase extends InternalBrokerBaseCase
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
index 9a065ea..f73765f 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.logging.actors;
 
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.logging.LogActor;
@@ -202,7 +203,7 @@
      */
     public class LogMessagesWithAConnectionActor extends Thread
     {
-        Throwable _exception;
+        private Throwable _exception;
 
         public LogMessagesWithAConnectionActor()
         {
@@ -228,13 +229,17 @@
 
                 // Verify it was the same actor as we set earlier
                 if(!actor.equals(CurrentActor.get()))
-                   throw new IllegalArgumentException("Retrieved actor is not as expected ");
+                {
+                    throw new IllegalArgumentException("Retrieved actor is not as expected ");
+                }
 
                 // Verify that removing the actor works for this thread
                 CurrentActor.remove();
 
                 if(CurrentActor.get() != defaultActor)
-                   throw new IllegalArgumentException("CurrentActor ("+CurrentActor.get()+") should be default actor" + defaultActor);
+                {
+                    throw new IllegalArgumentException("CurrentActor ("+CurrentActor.get()+") should be default actor" + defaultActor);
+                }
             }
             catch (Throwable e)
             {
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java
index d6b790d..b431047 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.server.logging.actors;
 
+import javax.management.remote.JMXPrincipal;
+import javax.security.auth.Subject;
 import java.security.PrivilegedAction;
 import java.util.Collections;
 import java.util.List;
 
-import javax.management.remote.JMXPrincipal;
-import javax.security.auth.Subject;
-
 /**
  * Test : AMQPManagementActorTest
  * Validate the AMQPManagementActor class.
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java
index a2272cc..8eaa165 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java
@@ -20,10 +20,10 @@
  */
 package org.apache.qpid.server.logging.actors;
 
-import java.util.List;
-
 import org.apache.qpid.server.subscription.MockSubscription;
 
+import java.util.List;
+
 /**
  * Test : AMQPConnectionActorTest
  * Validate the AMQPConnectionActor class.
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/management/LoggingManagementMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/management/LoggingManagementMBeanTest.java
index 2d25a76..f9ad81a 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/management/LoggingManagementMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/management/LoggingManagementMBeanTest.java
@@ -20,9 +20,17 @@
  */
 package org.apache.qpid.server.logging.management;
 
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.server.util.InternalBrokerBaseCase;
+
 import static org.apache.qpid.management.common.mbeans.LoggingManagement.LOGGER_LEVEL;
 import static org.apache.qpid.management.common.mbeans.LoggingManagement.LOGGER_NAME;
 
+import javax.management.JMException;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularDataSupport;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
@@ -31,17 +39,6 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.management.JMException;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularDataSupport;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.qpid.management.common.mbeans.LoggingManagement;
-
-import junit.framework.TestCase;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
-
 public class LoggingManagementMBeanTest extends InternalBrokerBaseCase
 {
     private static final String TEST_LOGGER = "LoggingManagementMBeanTestLogger";
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
index e253881..24e7225 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
@@ -20,10 +20,9 @@
  */
 package org.apache.qpid.server.logging.messages;
 
-import java.util.List;
-
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.PropertiesConfiguration;
+
 import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.logging.LogMessage;
 import org.apache.qpid.server.logging.LogSubject;
@@ -32,6 +31,8 @@
 import org.apache.qpid.server.logging.subjects.TestBlankSubject;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
+import java.util.List;
+
 public abstract class AbstractTestMessages extends InternalBrokerBaseCase
 {
     protected Configuration _config = new PropertiesConfiguration();
@@ -62,16 +63,21 @@
         return _logger.getLogMessages();
     }
 
+    protected void validateLogMessage(List<Object> logs, String tag, String[] expected)
+    {
+        validateLogMessage(logs, tag, false, expected);
+    }
+
     /**
-     * Validate that only a single log messasge occured and that the message
+     * Validate that only a single log message occurred and that the message
      * section starts with the specified tag
      *
      * @param logs     the logs generated during test run
      * @param tag      the tag to check for
      * @param expected the expected log messages
-     *
+     * @param useStringForNull replace a null String reference with "null"
      */
-    protected void validateLogMessage(List<Object> logs, String tag, String[] expected)
+    protected void validateLogMessage(List<Object> logs, String tag, boolean useStringForNull, String[] expected)
     {
         assertEquals("Log has incorrect message count", 1, logs.size());
 
@@ -96,6 +102,10 @@
         int index = 0;
         for (String text : expected)
         {
+            if(useStringForNull && text == null)
+            {
+                text = "null";
+            }
             index = message.indexOf(text, index);
             assertTrue("Message does not contain expected (" + text + ") text :" + message, index != -1);
             index = index + text.length();
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BrokerMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BrokerMessagesTest.java
index a3d46f57..e87d292 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BrokerMessagesTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BrokerMessagesTest.java
@@ -22,6 +22,8 @@
 
 import java.util.List;
 
+import org.apache.derby.iapi.services.io.FileUtil;
+
 /**
  * Test BRK log Messages
  */
@@ -64,7 +66,7 @@
 
         List<Object> log = performLog();
 
-        String[] expected = {"Shuting down", transport, "port ", String.valueOf(port)};
+        String[] expected = {"Shutting down", transport, "port ", String.valueOf(port)};
 
         validateLogMessage(log, "BRK-1003", expected);
     }
@@ -113,4 +115,33 @@
         validateLogMessage(log, "BRK-1007", expected);
     }
 
+    public void testBrokerPlatform()
+    {
+        String javaVendor = "jvendor";
+        String javaVersion = "j1.0";
+
+        String osName = "os";
+        String osVersion = "o1.0";
+        String osArch = "oarch";
+
+        _logMessage = BrokerMessages.PLATFORM(javaVendor, javaVersion, osName, osVersion, osArch);
+        List<Object> log = performLog();
+
+        String[] expected = {"Platform :", "JVM :", javaVendor, " version: ", " OS : ", osName, " version: ", osVersion, " arch: ", osArch};
+
+        validateLogMessage(log, "BRK-1010", expected);
+    }
+
+    public void testBrokerMemory()
+    {
+        long oneGiga = 1024*1024*1024;
+
+        _logMessage = BrokerMessages.MAX_MEMORY(oneGiga);
+        List<Object> log = performLog();
+
+        String[] expected = {"Maximum Memory :", "1,073,741,824", "bytes"};
+
+        validateLogMessage(log, "BRK-1011", expected);
+    }
+
 }
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ConnectionMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ConnectionMessagesTest.java
index 24fccf8..b2951ae 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ConnectionMessagesTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ConnectionMessagesTest.java
@@ -27,25 +27,27 @@
  */
 public class ConnectionMessagesTest extends AbstractTestMessages
 {
-    public void testConnectionOpen_WithClientIDProtocolVersion()
+    public void testConnectionOpen_WithClientIDProtocolVersionClientVersion()
     {
         String clientID = "client";
         String protocolVersion = "8-0";
+        String clientVersion = "1.2.3_4";
 
-        _logMessage = ConnectionMessages.OPEN(clientID, protocolVersion, true , true);
+        _logMessage = ConnectionMessages.OPEN(clientID, protocolVersion, clientVersion, true , true, true);
         List<Object> log = performLog();
 
         String[] expected = {"Open :", "Client ID", clientID,
-                             ": Protocol Version :", protocolVersion};
+                             ": Protocol Version :", protocolVersion,
+                             ": Client Version :", clientVersion};
 
         validateLogMessage(log, "CON-1001", expected);
     }
 
-    public void testConnectionOpen_WithClientIDNoProtocolVersion()
+    public void testConnectionOpen_WithClientIDNoProtocolVersionNoClientVersion()
     {
         String clientID = "client";        
 
-        _logMessage = ConnectionMessages.OPEN(clientID, null,true, false);
+        _logMessage = ConnectionMessages.OPEN(clientID, null, null, true, false, false);
         List<Object> log = performLog();
 
         String[] expected = {"Open :", "Client ID", clientID};
@@ -53,11 +55,11 @@
         validateLogMessage(log, "CON-1001", expected);
     }
 
-    public void testConnectionOpen_WithNOClientIDProtocolVersion()
+    public void testConnectionOpen_WithNOClientIDProtocolVersionNoClientVersion()
     {
         String protocolVersion = "8-0";
 
-        _logMessage = ConnectionMessages.OPEN(null, protocolVersion, false , true);
+        _logMessage = ConnectionMessages.OPEN(null, protocolVersion, null, false , true, false);
         List<Object> log = performLog();
 
         String[] expected = {"Open", ": Protocol Version :", protocolVersion};
@@ -65,9 +67,33 @@
         validateLogMessage(log, "CON-1001", expected);
     }
 
-    public void testConnectionOpen_WithNoClientIDNoProtocolVersion()
+    public void testConnectionOpen_WithNOClientIDNoProtocolVersionClientVersion()
     {
-        _logMessage = ConnectionMessages.OPEN(null, null,false, false);
+        String clientVersion = "1.2.3_4";
+
+        _logMessage = ConnectionMessages.OPEN(null, null, clientVersion, false , false, true);
+        List<Object> log = performLog();
+
+        String[] expected = {"Open", ": Client Version :", clientVersion};
+
+        validateLogMessage(log, "CON-1001", expected);
+    }
+
+    public void testConnectionOpen_WithNOClientIDNoProtocolVersionNullClientVersion()
+    {
+        String clientVersion = null;
+
+        _logMessage = ConnectionMessages.OPEN(null, null, clientVersion , false , false, true);
+        List<Object> log = performLog();
+
+        String[] expected = {"Open", ": Client Version :", clientVersion};
+
+        validateLogMessage(log, "CON-1001", true, expected);
+    }
+
+    public void testConnectionOpen_WithNoClientIDNoProtocolVersionNoClientVersion()
+    {
+        _logMessage = ConnectionMessages.OPEN(null, null, null, false, false, false);
         List<Object> log = performLog();
 
         String[] expected = {"Open"};
@@ -75,8 +101,6 @@
         validateLogMessage(log, "CON-1001", expected);
     }
 
-
-
     public void testConnectionClose()
     {
         _logMessage = ConnectionMessages.CLOSE();
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
index 1cd8d55..c2558d2 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
@@ -20,26 +20,21 @@
  */
 package org.apache.qpid.server.logging.subjects;
 
-import junit.framework.TestCase;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
+
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.logging.LogMessage;
 import org.apache.qpid.server.logging.LogSubject;
-import org.apache.qpid.server.logging.RootMessageLogger;
-import org.apache.qpid.server.logging.AbstractRootMessageLogger;
 import org.apache.qpid.server.logging.UnitTestMessageLogger;
 import org.apache.qpid.server.logging.actors.TestLogActor;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.protocol.InternalTestProtocolSession;
-import org.apache.qpid.server.protocol.AMQProtocolSession;
 
 import java.util.List;
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java
index 7e16516..cc06b05 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java
@@ -30,8 +30,8 @@
  */
 public class ExchangeLogSubjectTest extends AbstractTestLogSubject
 {
-    Exchange _exchange;
-    VirtualHost _testVhost;
+    private Exchange _exchange;
+    private VirtualHost _testVhost;
 
     public void setUp() throws Exception
     {
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java
index 9c868ea..158fb66 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java
@@ -20,15 +20,15 @@
  */
 package org.apache.qpid.server.logging.subjects;
 
-import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.virtualhost.VirtualHost;
 
 /**
  * Validate MessageStoreLogSubjects are logged as expected
  */
 public class MessageStoreLogSubjectTest extends AbstractTestLogSubject
 {
-    VirtualHost _testVhost;
+    private VirtualHost _testVhost;
 
     public void setUp() throws Exception
     {
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java
index 89688e1..7684db0 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java
@@ -27,7 +27,7 @@
 {
     public TestBlankSubject()
     {
-       _logString = "[TestBlankSubject]";
+       setLogString("[TestBlankSubject]");
     }
         
 }
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/management/AMQUserManagementMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/management/AMQUserManagementMBeanTest.java
index f3ee270..f7d85c1 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/management/AMQUserManagementMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/management/AMQUserManagementMBeanTest.java
@@ -21,22 +21,18 @@
 
 package org.apache.qpid.server.management;
 
+import org.apache.qpid.management.common.mbeans.UserManagement;
+import org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase;
+import org.apache.qpid.server.security.auth.management.AMQUserManagementMBean;
+import org.apache.qpid.server.util.InternalBrokerBaseCase;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
-
-
-import org.apache.commons.lang.NotImplementedException;
-import org.apache.qpid.management.common.mbeans.UserManagement;
-import org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase;
-import org.apache.qpid.server.security.auth.management.AMQUserManagementMBean;
-
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
-
 /** 
  * 
  * Tests the AMQUserManagementMBean and its interaction with the PrincipalDatabase.
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/plugins/OsgiSystemPackageUtilTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/plugins/OsgiSystemPackageUtilTest.java
index f2249c5..267545c 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/plugins/OsgiSystemPackageUtilTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/plugins/OsgiSystemPackageUtilTest.java
@@ -20,11 +20,12 @@
  */
 package org.apache.qpid.server.plugins;
 
-import java.util.Map;
-import java.util.TreeMap;
+import org.osgi.framework.Version;
 
 import org.apache.qpid.test.utils.QpidTestCase;
-import org.osgi.framework.Version;
+
+import java.util.Map;
+import java.util.TreeMap;
 
 /**
  *
@@ -72,11 +73,11 @@
         _map.put("org.apache.qpid.xyz", "1.0.0");
         _map.put("org.abc", "1.2.3");
 
-        _util = new OsgiSystemPackageUtil(new Version("0.15"), _map);
+        _util = new OsgiSystemPackageUtil(new Version("0.17"), _map);
 
         final String systemPackageString = _util.getFormattedSystemPackageString();
 
-        assertEquals("org.abc; version=1.2.3, org.apache.qpid.xyz; version=0.15.0", systemPackageString);   
+        assertEquals("org.abc; version=1.2.3, org.apache.qpid.xyz; version=0.17.0", systemPackageString);   
     }
 
     public void testWithQpidPackageWithoutQpidReleaseNumberSet() throws Exception
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/plugins/PluginTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/plugins/PluginTest.java
index 8c945aa..b4bda9a 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/plugins/PluginTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/plugins/PluginTest.java
@@ -21,7 +21,6 @@
 import org.apache.qpid.server.exchange.ExchangeType;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
-
 import java.util.Map;
 
 public class PluginTest extends InternalBrokerBaseCase
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
index e1dae5f..71d5211 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
@@ -20,10 +20,8 @@
  */
 package org.apache.qpid.server.protocol;
 
-import javax.management.JMException;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.management.common.mbeans.ManagedConnection;
@@ -36,6 +34,10 @@
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
+import javax.management.JMException;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
 
 /** Test class to test MBean operations for AMQMinaProtocolSession. */
 public class AMQProtocolSessionMBeanTest extends InternalBrokerBaseCase
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/InternalTestProtocolSession.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/InternalTestProtocolSession.java
index 3c76252..96c6794 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/InternalTestProtocolSession.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/InternalTestProtocolSession.java
@@ -20,17 +20,6 @@
  */
 package org.apache.qpid.server.protocol;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.security.auth.Subject;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.ContentHeaderBody;
@@ -49,10 +38,20 @@
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.transport.TestNetworkConnection;
 
+import javax.security.auth.Subject;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
 public class InternalTestProtocolSession extends AMQProtocolEngine implements ProtocolOutputConverter
 {
     // ChannelID(LIST)  -> LinkedList<Pair>
-    final Map<Integer, Map<AMQShortString, LinkedList<DeliveryPair>>> _channelDelivers;
+    private final Map<Integer, Map<AMQShortString, LinkedList<DeliveryPair>>> _channelDelivers;
     private AtomicInteger _deliveryCount = new AtomicInteger(0);
     private static final AtomicLong ID_GENERATOR = new AtomicLong(0);
 
@@ -199,11 +198,6 @@
         }
     }
 
-    public boolean isClosed()
-    {
-        return _closed;
-    }
-
     public void closeProtocolSession()
     {
         // Override as we don't have a real IOSession to close.
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
index f6e83e6..e8ee2c4 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.server.protocol;
 
-import junit.framework.TestCase;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.AMQChannel;
+import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.registry.ApplicationRegistry;
 
 /** Test class to test MBean operations for AMQMinaProtocolSession. */
 public class MaxChannelsTest extends InternalBrokerBaseCase
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java
index 9d76d5e..d8b5cd0 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java
@@ -20,11 +20,8 @@
 */
 package org.apache.qpid.server.protocol;
 
-import java.nio.ByteBuffer;
-import java.util.EnumSet;
-import java.util.Set;
-
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.protocol.ServerProtocolEngine;
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.registry.ApplicationRegistry;
@@ -32,6 +29,10 @@
 import org.apache.qpid.test.utils.QpidTestCase;
 import org.apache.qpid.transport.TestNetworkConnection;
 
+import java.nio.ByteBuffer;
+import java.util.EnumSet;
+import java.util.Set;
+
 public class MultiVersionProtocolEngineFactoryTest extends QpidTestCase
 {
     protected void setUp() throws Exception
@@ -120,10 +121,10 @@
         Set<AmqpProtocolVersion> versions = EnumSet.allOf(AmqpProtocolVersion.class);
 
         MultiVersionProtocolEngineFactory factory =
-            new MultiVersionProtocolEngineFactory("localhost", versions);
+            new MultiVersionProtocolEngineFactory(versions, null);
 
         //create a dummy to retrieve the 'current' ID number
-        long previousId = factory.newProtocolEngine(new TestNetworkConnection()).getConnectionId();
+        long previousId = factory.newProtocolEngine().getConnectionId();
 
         //create a protocol engine and send the AMQP header for all supported AMQP verisons,
         //ensuring the ID assigned increases as expected
@@ -133,7 +134,9 @@
             byte[] header = getAmqpHeader(version);
             assertNotNull("protocol header should not be null", header);
 
-            ServerProtocolEngine engine = factory.newProtocolEngine(new TestNetworkConnection());
+            ServerProtocolEngine engine = factory.newProtocolEngine();
+            TestNetworkConnection conn = new TestNetworkConnection();
+            engine.setNetworkConnection(conn, conn.getSender());
             assertEquals("ID did not increment as expected", expectedID, engine.getConnectionId());
 
             //actually feed in the AMQP header for this protocol version, and ensure the ID remains consistent
@@ -143,4 +146,24 @@
             previousId = expectedID;
         }
     }
+
+    /**
+     * Test to verify that when requesting a ProtocolEngineFactory to produce engines having a default reply to unsupported
+     * version initiations, there is enforcement that the default reply is itself a supported protocol version.
+     */
+    public void testUnsupportedDefaultReplyCausesIllegalArgumentException()
+    {
+        Set<AmqpProtocolVersion> versions = EnumSet.allOf(AmqpProtocolVersion.class);
+        versions.remove(AmqpProtocolVersion.v0_9);
+
+        try
+        {
+            new MultiVersionProtocolEngineFactory(versions, AmqpProtocolVersion.v0_9);
+            fail("should not have been allowed to create the factory");
+        }
+        catch(IllegalArgumentException iae)
+        {
+            //expected
+        }
+    }
 }
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQPriorityQueueTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQPriorityQueueTest.java
index d5f8ef3..01a2178 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQPriorityQueueTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQPriorityQueueTest.java
@@ -20,14 +20,16 @@
  *
  */
 
-import java.util.ArrayList;
 import junit.framework.AssertionFailedError;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.BasicContentHeaderProperties;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.server.message.AMQMessage;
 
+import java.util.ArrayList;
+
 public class AMQPriorityQueueTest extends SimpleAMQQueueTest
 {
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
index 47b8b7e..25d35aa 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
@@ -22,8 +22,8 @@
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.ContentHeaderBody;
 import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.ContentHeaderBody;
 import org.apache.qpid.framing.abstraction.ContentChunk;
 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 import org.apache.qpid.server.AMQChannel;
@@ -35,6 +35,8 @@
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
 import javax.management.Notification;
+
+import java.nio.ByteBuffer;
 import java.util.ArrayList;
 
 /** This class tests all the alerts an AMQQueue can throw based on threshold values of different parameters */
@@ -277,7 +279,7 @@
         ContentHeaderBody contentHeaderBody = new ContentHeaderBody();
         BasicContentHeaderProperties props = new BasicContentHeaderProperties();
         contentHeaderBody.setProperties(props);
-        contentHeaderBody.bodySize = size;   // in bytes
+        contentHeaderBody.setBodySize(size);   // in bytes
         IncomingMessage message = new IncomingMessage(publish);
         message.setContentHeaderBody(contentHeaderBody);
 
@@ -300,7 +302,7 @@
             messages[i] = message(false, size);
             ArrayList<AMQQueue> qs = new ArrayList<AMQQueue>();
             qs.add(getQueue());
-            metaData[i] = messages[i].headersReceived();
+            metaData[i] = messages[i].headersReceived(System.currentTimeMillis());
             messages[i].setStoredMessage(getMessageStore().addMessage(metaData[i]));
 
             messages[i].enqueue(qs);
@@ -309,9 +311,9 @@
 
         for (int i = 0; i < messageCount; i++)
         {
-            messages[i].addContentBodyFrame(new ContentChunk(){
-
-                byte[] _data = new byte[(int)size];
+            ContentChunk contentChunk = new ContentChunk()
+            {
+                private byte[] _data = new byte[(int)size];
 
                 public int getSize()
                 {
@@ -325,12 +327,13 @@
 
                 public void reduceToFit()
                 {
-
                 }
-            });
+            };
+
+            messages[i].addContentBodyFrame(contentChunk);
+            messages[i].getStoredMessage().addContent(0, ByteBuffer.wrap(contentChunk.getData()));
 
             getQueue().enqueue(new AMQMessage(messages[i].getStoredMessage()));
-
         }
     }
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
index 2b7d1d7..337ff19 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.queue;
 
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
@@ -40,8 +41,8 @@
 
 public class AMQQueueFactoryTest extends QpidTestCase
 {
-    QueueRegistry _queueRegistry;
-    VirtualHost _virtualHost;
+    private QueueRegistry _queueRegistry;
+    private VirtualHost _virtualHost;
 
     @Override
     public void setUp() throws Exception
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
index f702501..45933e7 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
@@ -21,30 +21,32 @@
 package org.apache.qpid.server.queue;
 
 import org.apache.commons.lang.time.FastDateFormat;
+
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.ContentHeaderBody;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.BasicContentHeaderProperties;
 import org.apache.qpid.framing.ContentBody;
+import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.abstraction.ContentChunk;
 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 import org.apache.qpid.management.common.mbeans.ManagedQueue;
 import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
 import org.apache.qpid.server.message.AMQMessage;
 import org.apache.qpid.server.message.MessageMetaData;
-import org.apache.qpid.server.subscription.Subscription;
-import org.apache.qpid.server.subscription.SubscriptionFactory;
-import org.apache.qpid.server.subscription.SubscriptionFactoryImpl;
 import org.apache.qpid.server.protocol.InternalTestProtocolSession;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.store.TestableMemoryMessageStore;
+import org.apache.qpid.server.subscription.Subscription;
+import org.apache.qpid.server.subscription.SubscriptionFactory;
+import org.apache.qpid.server.subscription.SubscriptionFactoryImpl;
+import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
 import javax.management.JMException;
 import javax.management.openmbean.CompositeData;
 import javax.management.openmbean.CompositeDataSupport;
 import javax.management.openmbean.TabularData;
-
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -457,15 +459,16 @@
             currentMessage.enqueue(qs);
 
             // route header
-            MessageMetaData mmd = currentMessage.headersReceived();
-            currentMessage.setStoredMessage(getMessageStore().addMessage(mmd));
+            MessageMetaData mmd = currentMessage.headersReceived(System.currentTimeMillis());
 
-            // Add the body so we have something to test later
-            currentMessage.addContentBodyFrame(
-                    getSession().getMethodRegistry()
-                                                       .getProtocolVersionMethodConverter()
-                                                       .convertToContentChunk(
-                                                       new ContentBody(new byte[(int) MESSAGE_SIZE])));
+            // Add the message to the store so we have something to test later
+            currentMessage.setStoredMessage(getMessageStore().addMessage(mmd));
+            ContentChunk chunk = getSession().getMethodRegistry()
+                                               .getProtocolVersionMethodConverter()
+                                               .convertToContentChunk(
+                                               new ContentBody(new byte[(int) MESSAGE_SIZE]));
+            currentMessage.addContentBodyFrame(chunk);
+            currentMessage.getStoredMessage().addContent(0, ByteBuffer.wrap(chunk.getData()));
 
             AMQMessage m = new AMQMessage(currentMessage.getStoredMessage());
             for(BaseQueue q : currentMessage.getDestinationQueues())
@@ -510,7 +513,7 @@
         };
 
         ContentHeaderBody contentHeaderBody = new ContentHeaderBody();
-        contentHeaderBody.bodySize = MESSAGE_SIZE;   // in bytes
+        contentHeaderBody.setBodySize(MESSAGE_SIZE);   // in bytes
         final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
         contentHeaderBody.setProperties(props);
         props.setDeliveryMode((byte) (persistent ? 2 : 1));
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java
index 5d559c9..273f0dc 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java
@@ -20,30 +20,30 @@
  */
 package org.apache.qpid.server.queue;
 
-import junit.framework.TestCase;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.BasicContentHeaderProperties;
 import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.message.AMQMessage;
-import org.apache.qpid.server.message.MessageMetaData;
-import org.apache.qpid.server.store.StoredMessage;
-import org.apache.qpid.server.txn.ServerTransaction;
-import org.apache.qpid.server.txn.AutoCommitTransaction;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.protocol.InternalTestProtocolSession;
-import org.apache.qpid.server.protocol.AMQProtocolSession;
-import org.apache.qpid.server.subscription.Subscription;
-import org.apache.qpid.server.subscription.SubscriptionFactoryImpl;
+import org.apache.qpid.server.ack.UnacknowledgedMessageMap;
 import org.apache.qpid.server.flow.LimitlessCreditManager;
 import org.apache.qpid.server.flow.Pre0_10CreditManager;
-import org.apache.qpid.server.ack.UnacknowledgedMessageMap;
+import org.apache.qpid.server.message.AMQMessage;
+import org.apache.qpid.server.message.MessageMetaData;
+import org.apache.qpid.server.protocol.AMQProtocolSession;
+import org.apache.qpid.server.protocol.InternalTestProtocolSession;
 import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.store.StoredMessage;
 import org.apache.qpid.server.store.TestMemoryMessageStore;
+import org.apache.qpid.server.subscription.Subscription;
+import org.apache.qpid.server.subscription.SubscriptionFactoryImpl;
+import org.apache.qpid.server.txn.AutoCommitTransaction;
+import org.apache.qpid.server.txn.ServerTransaction;
+import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.server.virtualhost.VirtualHost;
 
 import java.util.ArrayList;
 import java.util.Set;
@@ -143,7 +143,7 @@
             ArrayList<AMQQueue> qs = new ArrayList<AMQQueue>();
             qs.add(_queue);
             msg.enqueue(qs);
-            MessageMetaData mmd = msg.headersReceived();
+            MessageMetaData mmd = msg.headersReceived(System.currentTimeMillis());
             final StoredMessage storedMessage = _messageStore.addMessage(mmd);
             msg.setStoredMessage(storedMessage);
             final AMQMessage message = new AMQMessage(storedMessage);
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
index f97ac56..afaa417 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
@@ -20,24 +20,25 @@
  */
 package org.apache.qpid.server.queue;
 
+import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.server.configuration.*;
+import org.apache.qpid.server.binding.Binding;
+import org.apache.qpid.server.configuration.ConfigStore;
+import org.apache.qpid.server.configuration.ConfiguredObject;
+import org.apache.qpid.server.configuration.QueueConfigType;
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.logging.LogSubject;
-import org.apache.qpid.server.subscription.Subscription;
-import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.management.ManagedObject;
 import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.security.AuthorizationHolder;
 import org.apache.qpid.server.protocol.AMQSessionModel;
-import org.apache.qpid.server.binding.Binding;
-import org.apache.qpid.server.txn.ServerTransaction;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.security.AuthorizationHolder;
+import org.apache.qpid.server.subscription.Subscription;
+import org.apache.qpid.server.virtualhost.VirtualHost;
 
 import java.util.List;
-import java.util.Set;
 import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -355,12 +356,12 @@
         return null;
     }
 
-    public void moveMessagesToAnotherQueue(long fromMessageId, long toMessageId, String queueName, ServerTransaction storeContext)
+    public void moveMessagesToAnotherQueue(long fromMessageId, long toMessageId, String queueName)
     {
       
     }
 
-    public void copyMessagesToAnotherQueue(long fromMessageId, long toMessageId, String queueName, ServerTransaction storeContext)
+    public void copyMessagesToAnotherQueue(long fromMessageId, long toMessageId, String queueName)
     {
       
     }
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockMessagePublishInfo.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockMessagePublishInfo.java
index 5a5ffaa..bcf4c7e 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockMessagePublishInfo.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockMessagePublishInfo.java
@@ -20,8 +20,8 @@
  */
 package org.apache.qpid.server.queue;
 
-import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 
 public class MockMessagePublishInfo implements MessagePublishInfo
 {
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockQueueEntry.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockQueueEntry.java
index 7ad002c..b3482f0 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockQueueEntry.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockQueueEntry.java
@@ -21,10 +21,10 @@
 package org.apache.qpid.server.queue;
 
 import org.apache.qpid.AMQException;
-import org.apache.qpid.server.subscription.Subscription;
-import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.message.AMQMessage;
+import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.subscription.Subscription;
 
 public class MockQueueEntry implements QueueEntry
 {
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockStoredMessage.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockStoredMessage.java
index b4f8c6d..205dbf2 100755
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockStoredMessage.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockStoredMessage.java
@@ -20,14 +20,13 @@
 */
 package org.apache.qpid.server.queue;
 
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.ContentHeaderBody;
 import org.apache.qpid.framing.FieldTable;
-
+import org.apache.qpid.framing.abstraction.MessagePublishInfo;
+import org.apache.qpid.server.message.MessageMetaData;
 import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.store.StoredMessage;
-import org.apache.qpid.server.message.MessageMetaData;
-import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
-import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 
 import java.nio.ByteBuffer;
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java
index d336132..8be6061 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java
@@ -18,14 +18,16 @@
  */
 package org.apache.qpid.server.queue;
 
-import java.lang.reflect.Field;
 import junit.framework.TestCase;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.message.AMQMessage;
 import org.apache.qpid.server.queue.QueueEntry.EntryState;
 import org.apache.qpid.server.subscription.MockSubscription;
 import org.apache.qpid.server.subscription.Subscription;
 
+import java.lang.reflect.Field;
+
 /**
  * Tests for {@link QueueEntryImpl}
  */
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/QueueEntryListTestBase.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/QueueEntryListTestBase.java
index cf91020..4b40c3b 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/QueueEntryListTestBase.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/QueueEntryListTestBase.java
@@ -20,6 +20,7 @@
 package org.apache.qpid.server.queue;
 
 import junit.framework.TestCase;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.message.ServerMessage;
 
@@ -30,6 +31,7 @@
 {
     protected static final AMQQueue _testQueue = new MockAMQQueue("test");
     public abstract QueueEntryList<QueueEntry> getTestList();
+    public abstract QueueEntryList<QueueEntry> getTestList(boolean newList);
     public abstract long getExpectedFirstMsgId();
     public abstract int getExpectedListLength();
     public abstract ServerMessage getTestMessageToAdd() throws AMQException;
@@ -187,4 +189,36 @@
                         .getMessage().getMessageNumber(), third.getMessage().getMessageNumber());
     }
 
+    /**
+     * Tests that after the last node of the list is marked deleted but has not yet been removed,
+     * the iterator still ignores it and returns that it is 'atTail()' and can't 'advance()'
+     *
+     * @see QueueEntryListTestBase#getTestList()
+     * @see QueueEntryListTestBase#getExpectedListLength()
+     */
+    public void testIteratorIgnoresDeletedFinalNode() throws Exception
+    {
+        QueueEntryList<QueueEntry> list = getTestList(true);
+        int i = 0;
+
+        QueueEntry queueEntry1 = list.add(new MockAMQMessage(i++));
+        QueueEntry queueEntry2 = list.add(new MockAMQMessage(i++));
+
+        assertSame(queueEntry2, list.next(queueEntry1));
+        assertNull(list.next(queueEntry2));
+
+        //'delete' the 2nd QueueEntry
+        assertTrue("Deleting node should have succeeded", queueEntry2.delete());
+
+        QueueEntryIterator<QueueEntry> iter = list.iterator();
+
+        //verify the iterator isn't 'atTail', can advance, and returns the 1st QueueEntry
+        assertFalse("Iterator should not have been 'atTail'", iter.atTail());
+        assertTrue("Iterator should have been able to advance", iter.advance());
+        assertSame("Iterator returned unexpected QueueEntry", queueEntry1, iter.getNode());
+
+        //verify the iterator is atTail() and can't advance
+        assertTrue("Iterator should have been 'atTail'", iter.atTail());
+        assertFalse("Iterator should not have been able to advance", iter.advance());
+    }
 }
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SelfValidatingSortedQueueEntryList.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SelfValidatingSortedQueueEntryList.java
index 7ff693e..674af36 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SelfValidatingSortedQueueEntryList.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SelfValidatingSortedQueueEntryList.java
@@ -20,6 +20,7 @@
 package org.apache.qpid.server.queue;
 
 import junit.framework.Assert;
+
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.queue.SortedQueueEntryImpl.Colour;
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java
index 28d52f4..79c7449 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java
@@ -21,12 +21,8 @@
 
 package org.apache.qpid.server.queue;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
 import org.apache.commons.configuration.PropertiesConfiguration;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQInternalException;
 import org.apache.qpid.AMQSecurityException;
@@ -49,12 +45,17 @@
 import org.apache.qpid.server.subscription.MockSubscription;
 import org.apache.qpid.server.subscription.Subscription;
 import org.apache.qpid.server.txn.AutoCommitTransaction;
-import org.apache.qpid.server.txn.LocalTransaction;
 import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.virtualhost.VirtualHostImpl;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
 public class SimpleAMQQueueTest extends InternalBrokerBaseCase
 {
 
@@ -68,7 +69,7 @@
     protected MockSubscription _subscription = new MockSubscription();
     protected FieldTable _arguments = null;
 
-    MessagePublishInfo info = new MessagePublishInfo()
+    private MessagePublishInfo info = new MessagePublishInfo()
     {
 
         public AMQShortString getExchange()
@@ -196,7 +197,7 @@
         {
         }
         assertEquals(messageA, _subscription.getQueueContext().getLastSeenEntry().getMessage());
-        assertNull(((QueueContext)_subscription.getQueueContext())._releasedEntry);
+        assertNull(((QueueContext)_subscription.getQueueContext()).getReleasedEntry());
 
         // Check removing the subscription removes it's information from the queue
         _queue.unregisterSubscription(_subscription);
@@ -218,7 +219,7 @@
         _queue.registerSubscription(_subscription, false);
         Thread.sleep(150);
         assertEquals(messageA, _subscription.getQueueContext().getLastSeenEntry().getMessage());
-        assertNull("There should be no releasedEntry after an enqueue", ((QueueContext)_subscription.getQueueContext())._releasedEntry);
+        assertNull("There should be no releasedEntry after an enqueue", ((QueueContext)_subscription.getQueueContext()).getReleasedEntry());
     }
 
     /**
@@ -233,7 +234,7 @@
         _queue.registerSubscription(_subscription, false);
         Thread.sleep(150);
         assertEquals(messageB, _subscription.getQueueContext().getLastSeenEntry().getMessage());
-        assertNull("There should be no releasedEntry after enqueues", ((QueueContext)_subscription.getQueueContext())._releasedEntry);
+        assertNull("There should be no releasedEntry after enqueues", ((QueueContext)_subscription.getQueueContext()).getReleasedEntry());
     }
 
     /**
@@ -280,7 +281,7 @@
         assertTrue("Redelivery flag should now be set", queueEntries.get(0).isRedelivered());
         assertFalse("Redelivery flag should remain be unset", queueEntries.get(1).isRedelivered());
         assertFalse("Redelivery flag should remain be unset",queueEntries.get(2).isRedelivered());
-        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)_subscription.getQueueContext())._releasedEntry);
+        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)_subscription.getQueueContext()).getReleasedEntry());
     }
 
     /**
@@ -324,7 +325,7 @@
         assertTrue("Expecting the queue entry to be now expired", queueEntries.get(0).expired());
         assertEquals("Total number of messages sent should not have changed", 1, _subscription.getMessages().size());
         assertFalse("Redelivery flag should not be set", queueEntries.get(0).isRedelivered());
-        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)_subscription.getQueueContext())._releasedEntry);
+        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)_subscription.getQueueContext()).getReleasedEntry());
 
     }
 
@@ -375,7 +376,7 @@
         assertTrue("Redelivery flag should now be set", queueEntries.get(0).isRedelivered());
         assertFalse("Redelivery flag should remain be unset", queueEntries.get(1).isRedelivered());
         assertTrue("Redelivery flag should now be set",queueEntries.get(2).isRedelivered());
-        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)_subscription.getQueueContext())._releasedEntry);
+        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)_subscription.getQueueContext()).getReleasedEntry());
     }
 
 
@@ -418,8 +419,8 @@
         Thread.sleep(150); // Work done by SubFlushRunner/QueueRunner Threads
 
         assertEquals("Unexpected total number of messages sent to both subscriptions after release", 3, subscription1.getMessages().size() + subscription2.getMessages().size());
-        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)subscription1.getQueueContext())._releasedEntry);
-        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)subscription2.getQueueContext())._releasedEntry);
+        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)subscription1.getQueueContext()).getReleasedEntry());
+        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)subscription2.getQueueContext()).getReleasedEntry());
     }
 
     public void testExclusiveConsumer() throws AMQException
@@ -632,7 +633,7 @@
         // Send persistent message
 
         qs.add(_queue);
-        MessageMetaData metaData = msg.headersReceived();
+        MessageMetaData metaData = msg.headersReceived(System.currentTimeMillis());
         StoredMessage handle = _store.addMessage(metaData);
         msg.setStoredMessage(handle);
 
@@ -837,7 +838,7 @@
 
     /**
      * Tests that dequeued message is not copied as part of invocation of
-     * {@link SimpleAMQQueue#copyMessagesToAnotherQueue(long, long, String, ServerTransaction)}
+     * {@link SimpleAMQQueue#copyMessagesToAnotherQueue(long, long, String)}
      */
     public void testCopyMessagesWithDequeuedEntry()
     {
@@ -854,14 +855,8 @@
         // create another queue
         SimpleAMQQueue queue = createQueue(anotherQueueName);
 
-        // create transaction
-        ServerTransaction txn = new LocalTransaction(_queue.getVirtualHost().getMessageStore());
-
         // copy messages into another queue
-        _queue.copyMessagesToAnotherQueue(0, messageNumber, anotherQueueName, txn);
-
-        // commit transaction
-        txn.commit();
+        _queue.copyMessagesToAnotherQueue(0, messageNumber, anotherQueueName);
 
         // get messages on another queue
         List<QueueEntry> entries = queue.getMessagesOnTheQueue();
@@ -887,7 +882,7 @@
 
     /**
      * Tests that dequeued message is not moved as part of invocation of
-     * {@link SimpleAMQQueue#moveMessagesToAnotherQueue(long, long, String, ServerTransaction)}
+     * {@link SimpleAMQQueue#moveMessagesToAnotherQueue(long, long, String)}
      */
     public void testMovedMessagesWithDequeuedEntry()
     {
@@ -904,14 +899,8 @@
         // create another queue
         SimpleAMQQueue queue = createQueue(anotherQueueName);
 
-        // create transaction
-        ServerTransaction txn = new LocalTransaction(_queue.getVirtualHost().getMessageStore());
-
         // move messages into another queue
-        _queue.moveMessagesToAnotherQueue(0, messageNumber, anotherQueueName, txn);
-
-        // commit transaction
-        txn.commit();
+        _queue.moveMessagesToAnotherQueue(0, messageNumber, anotherQueueName);
 
         // get messages on another queue
         List<QueueEntry> entries = queue.getMessagesOnTheQueue();
@@ -1183,6 +1172,62 @@
                 ((AMQMessage) messages.get(1).getMessage()).getMessageId());
     }
 
+    public void testActiveConsumerCount() throws Exception
+    {
+        final SimpleAMQQueue queue = new SimpleAMQQueue(new AMQShortString("testActiveConsumerCount"), false, new AMQShortString("testOwner"),
+                false, false, _virtualHost, new SimpleQueueEntryList.Factory(), null);
+
+        //verify adding an active subscription increases the count
+        final MockSubscription subscription1 = new MockSubscription();
+        subscription1.setActive(true);
+        assertEquals("Unexpected active consumer count", 0, queue.getActiveConsumerCount());
+        queue.registerSubscription(subscription1, false);
+        assertEquals("Unexpected active consumer count", 1, queue.getActiveConsumerCount());
+
+        //verify adding an inactive subscription doesn't increase the count
+        final MockSubscription subscription2 = new MockSubscription();
+        subscription2.setActive(false);
+        assertEquals("Unexpected active consumer count", 1, queue.getActiveConsumerCount());
+        queue.registerSubscription(subscription2, false);
+        assertEquals("Unexpected active consumer count", 1, queue.getActiveConsumerCount());
+
+        //verify behaviour in face of expected state changes:
+
+        //verify a subscription going suspended->active increases the count
+        queue.stateChange(subscription2, Subscription.State.SUSPENDED, Subscription.State.ACTIVE);
+        assertEquals("Unexpected active consumer count", 2, queue.getActiveConsumerCount());
+
+        //verify a subscription going active->suspended decreases the count
+        queue.stateChange(subscription2, Subscription.State.ACTIVE, Subscription.State.SUSPENDED);
+        assertEquals("Unexpected active consumer count", 1, queue.getActiveConsumerCount());
+
+        //verify a subscription going suspended->closed doesn't change the count
+        queue.stateChange(subscription2, Subscription.State.SUSPENDED, Subscription.State.CLOSED);
+        assertEquals("Unexpected active consumer count", 1, queue.getActiveConsumerCount());
+
+        //verify a subscription going active->closed  decreases the count
+        queue.stateChange(subscription2, Subscription.State.ACTIVE, Subscription.State.CLOSED);
+        assertEquals("Unexpected active consumer count", 0, queue.getActiveConsumerCount());
+
+        //verify behaviour in face of unexpected state changes:
+
+        //verify a subscription going closed->active increases the count
+        queue.stateChange(subscription2, Subscription.State.CLOSED, Subscription.State.ACTIVE);
+        assertEquals("Unexpected active consumer count", 1, queue.getActiveConsumerCount());
+
+        //verify a subscription going active->active doesn't change the count
+        queue.stateChange(subscription2, Subscription.State.ACTIVE, Subscription.State.ACTIVE);
+        assertEquals("Unexpected active consumer count", 1, queue.getActiveConsumerCount());
+
+        //verify a subscription going closed->suspended doesn't change the count
+        queue.stateChange(subscription2, Subscription.State.CLOSED, Subscription.State.SUSPENDED);
+        assertEquals("Unexpected active consumer count", 1, queue.getActiveConsumerCount());
+
+        //verify a subscription going suspended->suspended doesn't change the count
+        queue.stateChange(subscription2, Subscription.State.SUSPENDED, Subscription.State.SUSPENDED);
+        assertEquals("Unexpected active consumer count", 1, queue.getActiveConsumerCount());
+    }
+
     /**
      * A helper method to create a queue with given name
      *
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java
index a40dc56..39ddd1d 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java
@@ -20,15 +20,13 @@
  */
 package org.apache.qpid.server.queue;
 
-import junit.framework.TestCase;
+import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.pool.ReferenceCountingExecutorService;
+import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.AMQException;
-
 public class SimpleAMQQueueThreadPoolTest extends InternalBrokerBaseCase
 {
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryListTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryListTest.java
index a873739..caf1eea 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryListTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryListTest.java
@@ -20,18 +20,20 @@
 */
 package org.apache.qpid.server.queue;
 
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.message.AMQMessage;
 import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.queue.SimpleQueueEntryList.QueueEntryIteratorImpl;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 public class SimpleQueueEntryListTest extends QueueEntryListTestBase
 {
     private SimpleQueueEntryList _sqel;
 
     private static final String SCAVENGE_PROP = "qpid.queue.scavenge_count";
-    String oldScavengeValue = null;
+    private String oldScavengeValue = null;
 
     @Override
     protected void setUp()
@@ -58,11 +60,24 @@
             System.clearProperty(SCAVENGE_PROP);
         }
     }
-    
+
     @Override
     public QueueEntryList getTestList()
     {
-        return _sqel;
+        return getTestList(false);
+    }
+
+    @Override
+    public QueueEntryList getTestList(boolean newList)
+    {
+        if(newList)
+        {
+            return new SimpleQueueEntryList(_testQueue);
+        }
+        else
+        {
+            return _sqel;
+        }
     }
 
     @Override
@@ -215,5 +230,4 @@
         next = next.getNextValidEntry();
         assertNull("The next entry after the last should be null", next);
     }
-
 }
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java
index d177993..38b12f8 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java
@@ -19,11 +19,11 @@
  */
 package org.apache.qpid.server.queue;
 
+import org.apache.qpid.AMQException;
 import org.apache.qpid.server.message.AMQMessage;
+import org.apache.qpid.server.message.ServerMessage;
 
 import java.util.Arrays;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.message.ServerMessage;
 
 public class SortedQueueEntryListTest extends QueueEntryListTestBase
 {
@@ -77,9 +77,23 @@
 
     }
 
+    @Override
     public QueueEntryList getTestList()
     {
-        return _sqel;
+        return getTestList(false);
+    }
+
+    @Override
+    public QueueEntryList getTestList(boolean newList)
+    {
+        if(newList)
+        {
+            return new SelfValidatingSortedQueueEntryList(_testQueue, "KEY");
+        }
+        else
+        {
+            return _sqel;
+        }
     }
 
     public int getExpectedListLength()
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java
index e45c8d7..9ff8f0a 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java
@@ -22,10 +22,10 @@
 
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
-import java.security.Security;
 import java.security.Provider;
-import java.util.List;
+import java.security.Security;
 import java.util.LinkedList;
+import java.util.List;
 
 /**
  * QPID-1390 : Test to validate that the AuthenticationManger can successfully unregister any new SASL providers when
@@ -36,7 +36,7 @@
 public class ApplicationRegistryShutdownTest extends InternalBrokerBaseCase
 {
 
-    Provider[] _defaultProviders;
+    private Provider[] _defaultProviders;
     @Override
     public void setUp() throws Exception
     {
@@ -80,11 +80,10 @@
             }
         }
 
-        // Not using isEmpty as that is not in Java 5
-        assertTrue("No new SASL mechanisms added by initialisation.", additions.size() != 0 );
+        assertFalse("No new SASL mechanisms added by initialisation.", additions.isEmpty());
 
         //Close the registry which will perform the close the AuthenticationManager
-        getRegistry().close();
+        stopBroker();
 
         //Validate that the SASL plugFins have been removed.
         Provider[] providersAfterClose = Security.getProviders();
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java
index 2ab15d4..33740af 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/Base64MD5PasswordFilePrincipalDatabaseTest.java
@@ -21,13 +21,12 @@
 package org.apache.qpid.server.security.auth.database;
 
 import junit.framework.TestCase;
+import org.apache.commons.codec.binary.Base64;
+
+import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
 
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.login.AccountNotFoundException;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
-
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java
index aa85cac..abb0b15 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/HashedUserTest.java
@@ -21,8 +21,6 @@
 package org.apache.qpid.server.security.auth.database;
 
 import junit.framework.TestCase;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
 
 import java.io.UnsupportedEncodingException;
 
@@ -32,9 +30,9 @@
 public class HashedUserTest extends TestCase
 {
 
-    String USERNAME = "username";
-    String PASSWORD = "password";
-    String B64_ENCODED_PASSWORD = "cGFzc3dvcmQ=";
+    private String USERNAME = "username";
+    private String PASSWORD = "password";
+    private String B64_ENCODED_PASSWORD = "cGFzc3dvcmQ=";
 
     public void testToLongArrayConstructor()
     {
@@ -47,49 +45,39 @@
         {
             assertEquals("User Data should be length 2, username, password", e.getMessage());
         }
-        catch (UnsupportedEncodingException e)
-        {
-            fail(e.getMessage());
-        }
+
     }
 
     public void testArrayConstructor()
     {
+        HashedUser user = new HashedUser(new String[]{USERNAME, B64_ENCODED_PASSWORD});
+        assertEquals("Username incorrect", USERNAME, user.getName());
+        int index = 0;
+
+        char[] hash = B64_ENCODED_PASSWORD.toCharArray();
+
         try
         {
-            HashedUser user = new HashedUser(new String[]{USERNAME, B64_ENCODED_PASSWORD});
-            assertEquals("Username incorrect", USERNAME, user.getName());
-            int index = 0;
-
-            char[] hash = B64_ENCODED_PASSWORD.toCharArray();
-
-            try
+            for (byte c : user.getEncodedPassword())
             {
-                for (byte c : user.getEncodedPassword())
-                {
-                    assertEquals("Password incorrect", hash[index], (char) c);
-                    index++;
-                }
-            }
-            catch (Exception e)
-            {
-                fail(e.getMessage());
-            }
-
-            hash = PASSWORD.toCharArray();
-
-            index=0;
-            for (char c : user.getPassword())
-            {
-                assertEquals("Password incorrect", hash[index], c);
+                assertEquals("Password incorrect", hash[index], (char) c);
                 index++;
             }
-
         }
-        catch (UnsupportedEncodingException e)
+        catch (Exception e)
         {
             fail(e.getMessage());
         }
+
+        hash = PASSWORD.toCharArray();
+
+        index=0;
+        for (char c : user.getPassword())
+        {
+            assertEquals("Password incorrect", hash[index], c);
+            index++;
+        }
+
     }
 }
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabaseTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabaseTest.java
index a3dad19..b8601f0 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabaseTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabaseTest.java
@@ -22,10 +22,9 @@
 
 import junit.framework.TestCase;
 
-import javax.security.auth.login.AccountNotFoundException;
-
 import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
 
+import javax.security.auth.login.AccountNotFoundException;
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainUserTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainUserTest.java
index 7f0843d..44faa57 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainUserTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/database/PlainUserTest.java
@@ -28,8 +28,8 @@
 public class PlainUserTest extends TestCase
 {
 
-    String USERNAME = "username";
-    String PASSWORD = "password";
+    private String USERNAME = "username";
+    private String PASSWORD = "password";
 
     public void testTooLongArrayConstructor()
     {
@@ -54,7 +54,7 @@
 
         try            
         {
-            for (byte c : user.getPasswordBytes())
+            for (byte c : user.getEncodedPassword())
             {
                 assertEquals("Password incorrect", password[index], (char) c);
                 index++;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManagerTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManagerTest.java
index b10442d..1a42fe3 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManagerTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManagerTest.java
@@ -20,20 +20,10 @@
  */
 package org.apache.qpid.server.security.auth.manager;
 
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.security.Provider;
-import java.security.Security;
-
-import javax.security.auth.Subject;
-import javax.security.sasl.SaslException;
-import javax.security.sasl.SaslServer;
-
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.security.auth.AuthenticationResult;
 import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus;
@@ -41,6 +31,16 @@
 import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
+import javax.security.auth.Subject;
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.security.Provider;
+import java.security.Security;
+
 /**
  *
  * Tests the public methods of PrincipalDatabaseAuthenticationManager.
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java
index f356673..0163533 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java
@@ -20,13 +20,6 @@
  */
 package org.apache.qpid.server.security.auth.rmi;
 
-import java.util.Collections;
-
-import javax.management.remote.JMXPrincipal;
-import javax.security.auth.Subject;
-import javax.security.sasl.SaslException;
-import javax.security.sasl.SaslServer;
-
 import junit.framework.TestCase;
 
 import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
@@ -34,6 +27,12 @@
 import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus;
 import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
 
+import javax.management.remote.JMXPrincipal;
+import javax.security.auth.Subject;
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+import java.util.Collections;
+
 /**
  * Tests the RMIPasswordAuthenticator and its collaboration with the AuthenticationManager.
  *
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/CRAMMD5HexInitialiserTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/CRAMMD5HexInitialiserTest.java
index 3c5ed1d..e408fd7 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/CRAMMD5HexInitialiserTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/CRAMMD5HexInitialiserTest.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.security.auth.sasl;
 
 import junit.framework.TestCase;
+
 import org.apache.qpid.server.security.auth.database.PropertiesPrincipalDatabase;
 import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HexInitialiser;
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/CRAMMD5HexServerTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/CRAMMD5HexServerTest.java
index 86e4e23..51c2a0a 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/CRAMMD5HexServerTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/CRAMMD5HexServerTest.java
@@ -21,24 +21,23 @@
 
 package org.apache.qpid.server.security.auth.sasl;
 
-import java.io.File;
-import java.io.IOException;
-import java.security.MessageDigest;
-import java.security.Principal;
+import junit.framework.TestCase;
+import org.apache.commons.codec.binary.Hex;
+
+import org.apache.qpid.server.security.auth.database.Base64MD5PasswordFilePrincipalDatabase;
+import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HexInitialiser;
+import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HexSaslServer;
+import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HexServerFactory;
 
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
 import javax.security.auth.login.AccountNotFoundException;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.codec.binary.Hex;
-import org.apache.qpid.server.security.auth.database.Base64MD5PasswordFilePrincipalDatabase;
-import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HexInitialiser;
-import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HexSaslServer;
-import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HexServerFactory;
+import java.io.File;
+import java.io.IOException;
+import java.security.MessageDigest;
+import java.security.Principal;
 
 /**
  * Test for the CRAM-MD5-HEX SASL mechanism.
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/SaslServerTestCase.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/SaslServerTestCase.java
index f80413d..f524763 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/SaslServerTestCase.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/SaslServerTestCase.java
@@ -21,12 +21,12 @@
 
 package org.apache.qpid.server.security.auth.sasl;
 
-import javax.security.sasl.SaslException;
-import javax.security.sasl.SaslServer;
+import junit.framework.TestCase;
 
 import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
 
-import junit.framework.TestCase;
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
 
 public abstract class SaslServerTestCase extends TestCase
 {
@@ -54,7 +54,7 @@
         }
         catch (SaslException e)
         {
-            assertEquals("Authentication failed", e.getCause().getMessage());
+            assertTrue(e.getMessage().contains("Authentication failed"));
             exceptionCaught = true;
         }
         if (!exceptionCaught)
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/TestPrincipalDatabase.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/TestPrincipalDatabase.java
index 8507e49..8c7f3ad 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/TestPrincipalDatabase.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/TestPrincipalDatabase.java
@@ -21,17 +21,15 @@
 
 package org.apache.qpid.server.security.auth.sasl;
 
+import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
+
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.login.AccountNotFoundException;
 import java.io.IOException;
 import java.security.Principal;
 import java.util.List;
 import java.util.Map;
 
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.login.AccountNotFoundException;
-
-import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
-import org.apache.qpid.server.security.auth.sasl.AuthenticationProviderInitialiser;
-
 public class TestPrincipalDatabase implements PrincipalDatabase
 {
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/TestPrincipalUtils.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/TestPrincipalUtils.java
index 8b9b2df..7ce03ea 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/TestPrincipalUtils.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/TestPrincipalUtils.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.server.security.auth.sasl;
 
+import javax.security.auth.Subject;
 import java.security.Principal;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.security.auth.Subject;
-
 public class TestPrincipalUtils
 {
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/UsernamePrincipalTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/UsernamePrincipalTest.java
index 541f14d..75bc76c 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/UsernamePrincipalTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/auth/sasl/UsernamePrincipalTest.java
@@ -20,10 +20,11 @@
  */
 package org.apache.qpid.server.security.auth.sasl;
 
-import java.security.Principal;
-import javax.security.auth.Subject;
 import junit.framework.TestCase;
 
+import javax.security.auth.Subject;
+import java.security.Principal;
+
 /**
  * Tests the UsernamePrincipal.
  *
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/signal/SignalHandlerTaskTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/signal/SignalHandlerTaskTest.java
index 886cb08..23ee82e 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/signal/SignalHandlerTaskTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/signal/SignalHandlerTaskTest.java
@@ -20,13 +20,14 @@
  */
 package org.apache.qpid.server.signal;
 
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.test.utils.QpidTestCase;
+
 import java.lang.management.ManagementFactory;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.log4j.Logger;
-import org.apache.qpid.test.utils.QpidTestCase;
-
 public class SignalHandlerTaskTest extends QpidTestCase
 {
     private static final Logger LOGGER = Logger.getLogger(SignalHandlerTaskTest.class);
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/stats/StatisticsCounterTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/stats/StatisticsCounterTest.java
index fbaa134..147879f 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/stats/StatisticsCounterTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/stats/StatisticsCounterTest.java
@@ -106,7 +106,12 @@
         Thread.sleep(1500);
         assertEquals(0.0, counter.getPeak());
         counter.registerEvent(2000, start + 1500);
-        Thread.sleep(1000L);
+
+        // make sure, that getPeak invocation occurs at "start + 2500"
+        // if test thread over-sleeps for 500+ mls
+        // the peak value can be incremented and test will fail
+        long sleep = start + 2500 - System.currentTimeMillis();
+        Thread.sleep(sleep < 0 ? 0 : sleep);
         assertEquals(0.0, counter.getPeak());
         counter.registerEvent(1000, start + 500);
         Thread.sleep(1500);
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
index 90adaa1..d49f058 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
@@ -20,12 +20,8 @@
  */
 package org.apache.qpid.server.store;
 
-import java.io.File;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.commons.configuration.PropertiesConfiguration;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.common.AMQPFilterTypes;
 import org.apache.qpid.framing.AMQShortString;
@@ -58,6 +54,11 @@
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.util.FileUtils;
 
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * This tests the MessageStores by using the available interfaces.
  *
@@ -70,26 +71,26 @@
     public static final String SELECTOR_VALUE = "Test = 'MST'";
     public static final String LVQ_KEY = "MST-LVQ-KEY";
 
-    AMQShortString nonDurableExchangeName = new AMQShortString("MST-NonDurableDirectExchange");
-    AMQShortString directExchangeName = new AMQShortString("MST-DirectExchange");
-    AMQShortString topicExchangeName = new AMQShortString("MST-TopicExchange");
+    private AMQShortString nonDurableExchangeName = new AMQShortString("MST-NonDurableDirectExchange");
+    private AMQShortString directExchangeName = new AMQShortString("MST-DirectExchange");
+    private AMQShortString topicExchangeName = new AMQShortString("MST-TopicExchange");
 
-    AMQShortString durablePriorityTopicQueueName = new AMQShortString("MST-PriorityTopicQueue-Durable");
-    AMQShortString durableTopicQueueName = new AMQShortString("MST-TopicQueue-Durable");
-    AMQShortString priorityTopicQueueName = new AMQShortString("MST-PriorityTopicQueue");
-    AMQShortString topicQueueName = new AMQShortString("MST-TopicQueue");
+    private AMQShortString durablePriorityTopicQueueName = new AMQShortString("MST-PriorityTopicQueue-Durable");
+    private AMQShortString durableTopicQueueName = new AMQShortString("MST-TopicQueue-Durable");
+    private AMQShortString priorityTopicQueueName = new AMQShortString("MST-PriorityTopicQueue");
+    private AMQShortString topicQueueName = new AMQShortString("MST-TopicQueue");
 
-    AMQShortString durableExclusiveQueueName = new AMQShortString("MST-Queue-Durable-Exclusive");
-    AMQShortString durablePriorityQueueName = new AMQShortString("MST-PriorityQueue-Durable");
-    AMQShortString durableLastValueQueueName = new AMQShortString("MST-LastValueQueue-Durable");
-    AMQShortString durableQueueName = new AMQShortString("MST-Queue-Durable");
-    AMQShortString priorityQueueName = new AMQShortString("MST-PriorityQueue");
-    AMQShortString queueName = new AMQShortString("MST-Queue");
+    private AMQShortString durableExclusiveQueueName = new AMQShortString("MST-Queue-Durable-Exclusive");
+    private AMQShortString durablePriorityQueueName = new AMQShortString("MST-PriorityQueue-Durable");
+    private AMQShortString durableLastValueQueueName = new AMQShortString("MST-LastValueQueue-Durable");
+    private AMQShortString durableQueueName = new AMQShortString("MST-Queue-Durable");
+    private AMQShortString priorityQueueName = new AMQShortString("MST-PriorityQueue");
+    private AMQShortString queueName = new AMQShortString("MST-Queue");
 
-    AMQShortString directRouting = new AMQShortString("MST-direct");
-    AMQShortString topicRouting = new AMQShortString("MST-topic");
+    private AMQShortString directRouting = new AMQShortString("MST-direct");
+    private AMQShortString topicRouting = new AMQShortString("MST-topic");
 
-    AMQShortString queueOwner = new AMQShortString("MST");
+    private AMQShortString queueOwner = new AMQShortString("MST");
 
     protected PropertiesConfiguration _config;
 
@@ -586,11 +587,7 @@
 
         currentMessage.setExchange(exchange);
 
-        ContentHeaderBody headerBody = new ContentHeaderBody();
-        headerBody.classId = BasicConsumeBodyImpl.CLASS_ID;
-        headerBody.bodySize = 0;
-
-        headerBody.setProperties(properties);
+        ContentHeaderBody headerBody = new ContentHeaderBody(BasicConsumeBodyImpl.CLASS_ID,0,properties,0l);
 
         try
         {
@@ -603,7 +600,7 @@
 
         currentMessage.setExpiration();
 
-        MessageMetaData mmd = currentMessage.headersReceived();
+        MessageMetaData mmd = currentMessage.headersReceived(System.currentTimeMillis());
         currentMessage.setStoredMessage(getVirtualHost().getMessageStore().addMessage(mmd));
         currentMessage.getStoredMessage().flushToStore();
         currentMessage.route();
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/SkeletonMessageStore.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/SkeletonMessageStore.java
index 44006df..09d865c 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/SkeletonMessageStore.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/SkeletonMessageStore.java
@@ -21,21 +21,14 @@
 package org.apache.qpid.server.store;
 
 import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.AMQException;
+
 import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.framing.abstraction.ContentChunk;
-import org.apache.qpid.server.message.EnqueableMessage;
-import org.apache.qpid.server.message.MessageMetaData;
-import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.logging.LogSubject;
-
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-import java.nio.ByteBuffer;
+import org.apache.qpid.server.message.EnqueableMessage;
+import org.apache.qpid.server.queue.AMQQueue;
 
 /**
  * A message store that does nothing. Designed to be used in tests that do not want to use any message store
@@ -153,6 +146,14 @@
             {
 
             }
+
+            public void removeXid(long format, byte[] globalId, byte[] branchId)
+            {
+            }
+
+            public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
+            {
+            }
         };
     }
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStore.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStore.java
index fa698f4..8a261b3 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStore.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStore.java
@@ -20,14 +20,8 @@
  */
 package org.apache.qpid.server.store;
 
-import org.apache.qpid.server.message.MessageMetaData;
-import org.apache.qpid.framing.abstraction.ContentChunk;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.List;
 import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Adds some extra methods to the memory message store for testing purposes.
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java
index 3804d0d..104e06d 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java
@@ -20,22 +20,21 @@
  */
 package org.apache.qpid.server.store;
 
+import org.apache.qpid.AMQStoreException;
+import org.apache.qpid.server.message.EnqueableMessage;
+import org.apache.qpid.server.queue.AMQQueue;
+
 import java.nio.ByteBuffer;
 import java.util.HashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.qpid.AMQStoreException;
-import org.apache.qpid.server.message.EnqueableMessage;
-import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.queue.AMQQueue;
-
 /**
  * Adds some extra methods to the memory message store for testing purposes.
  */
 public class TestableMemoryMessageStore extends MemoryMessageStore
 {
 
-    MemoryMessageStore _mms = null;
+    private MemoryMessageStore _mms = null;
     private HashMap<Long, AMQQueue> _messages = new HashMap<Long, AMQQueue>();
     private AtomicInteger _messageCount = new AtomicInteger(0);
 
@@ -101,6 +100,14 @@
         public void abortTran() throws AMQStoreException
         {
         }
+
+        public void removeXid(long format, byte[] globalId, byte[] branchId)
+        {
+        }
+
+        public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
+        {
+        }
     }
 
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java
index 4a74596..f1eb228 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java
@@ -21,12 +21,6 @@
 *
 */
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.AMQChannel;
@@ -35,6 +29,12 @@
 import org.apache.qpid.server.queue.QueueEntry;
 import org.apache.qpid.server.queue.QueueEntry.SubscriptionAcquiredState;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
 public class MockSubscription implements Subscription
 {
 
@@ -55,6 +55,7 @@
     private static final AtomicLong idGenerator = new AtomicLong(0);
     // Create a simple ID that increments for ever new Subscription
     private final long _subscriptionID = idGenerator.getAndIncrement();
+    private boolean _isActive = true;
 
     public MockSubscription()
     {
@@ -150,7 +151,7 @@
 
     public boolean isActive()
     {
-        return true;
+        return _isActive ;
     }
 
     public void set(String key, Object value)
@@ -270,4 +271,9 @@
     {
         //TODO
     }
+
+    public void setActive(final boolean isActive)
+    {
+        _isActive = isActive;
+    }
 }
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/QueueBrowserUsesNoAckTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/QueueBrowserUsesNoAckTest.java
index b315a79..3272bd5 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/QueueBrowserUsesNoAckTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/QueueBrowserUsesNoAckTest.java
@@ -20,10 +20,10 @@
  */
 package org.apache.qpid.server.subscription;
 
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
-import org.apache.qpid.server.protocol.InternalTestProtocolSession;
-import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.protocol.InternalTestProtocolSession;
+import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
 import java.util.List;
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/transport/ServerConnectionMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/transport/ServerConnectionMBeanTest.java
index 78ba8c1..dcb3692 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/transport/ServerConnectionMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/transport/ServerConnectionMBeanTest.java
@@ -20,15 +20,6 @@
  */
 package org.apache.qpid.server.transport;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicLong;
-import javax.management.JMException;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
 import org.apache.qpid.management.common.mbeans.ManagedConnection;
 import org.apache.qpid.server.configuration.MockConnectionConfig;
 import org.apache.qpid.server.registry.ApplicationRegistry;
@@ -38,6 +29,16 @@
 import org.apache.qpid.transport.Connection;
 import org.apache.qpid.transport.Session;
 
+import javax.management.JMException;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicLong;
+
 public class ServerConnectionMBeanTest extends InternalBrokerBaseCase
 {
     private ServerConnection _serverConnection;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/AutoCommitTransactionTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/AutoCommitTransactionTest.java
index 98484db..cd3fe3c 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/AutoCommitTransactionTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/AutoCommitTransactionTest.java
@@ -20,10 +20,6 @@
  */
 package org.apache.qpid.server.txn;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.MockAMQQueue;
@@ -33,6 +29,10 @@
 import org.apache.qpid.server.txn.MockStoreTransaction.TransactionState;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
 /**
  * A unit test ensuring that AutoCommitTransaction creates a separate transaction for
  * each dequeue/enqueue operation that involves enlistable messages. Verifies
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/LocalTransactionTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/LocalTransactionTest.java
index 484beb8..5992829 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/LocalTransactionTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/LocalTransactionTest.java
@@ -20,10 +20,6 @@
  */
 package org.apache.qpid.server.txn;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.MockAMQQueue;
@@ -33,6 +29,10 @@
 import org.apache.qpid.server.txn.MockStoreTransaction.TransactionState;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
 /**
  * A unit test ensuring that LocalTransactionTest creates a long-lived store transaction
  * that spans many dequeue/enqueue operations of enlistable messages.  Verifies
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/MockServerMessage.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/MockServerMessage.java
index 063023f..1dc4619 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/MockServerMessage.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/MockServerMessage.java
@@ -20,15 +20,16 @@
  */
 package org.apache.qpid.server.txn;
 
-import java.nio.ByteBuffer;
-
 import org.apache.commons.lang.NotImplementedException;
+
 import org.apache.qpid.server.configuration.SessionConfig;
 import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.message.MessageReference;
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.store.StoredMessage;
 
+import java.nio.ByteBuffer;
+
 /**
  * Mock Server Message allowing its persistent flag to be controlled from test.
  */
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java
index bf8fda3..801549e 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java
@@ -22,13 +22,18 @@
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.lang.NotImplementedException;
+
 import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.server.logging.LogSubject;
 import org.apache.qpid.server.message.EnqueableMessage;
-import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.store.*;
+import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.store.MessageStore.StoreFuture;
 import org.apache.qpid.server.store.MessageStore.Transaction;
+import org.apache.qpid.server.store.MessageStoreRecoveryHandler;
+import org.apache.qpid.server.store.StorableMessageMetaData;
+import org.apache.qpid.server.store.StoredMessage;
+import org.apache.qpid.server.store.TransactionLogRecoveryHandler;
+import org.apache.qpid.server.store.TransactionLogResource;
 
 /**
  * Mock implementation of a (Store) Transaction allow its state to be observed.
@@ -107,6 +112,14 @@
         _state = TransactionState.ABORTED;
     }
 
+    public void removeXid(long format, byte[] globalId, byte[] branchId)
+    {
+    }
+
+    public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
+    {
+    }
+
     public static MessageStore createTestTransactionLog(final MockStoreTransaction storeTransaction)
     {
         return new MessageStore()
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
index a97134a..9df0aec 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.util;
 
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.common.AMQPFilterTypes;
 import org.apache.qpid.exchange.ExchangeDefaults;
@@ -30,10 +31,10 @@
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.logging.SystemOutMessageLogger;
-import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.logging.SystemOutMessageLogger;
+import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.actors.TestLogActor;
 import org.apache.qpid.server.protocol.InternalTestProtocolSession;
 import org.apache.qpid.server.queue.AMQQueue;
@@ -231,7 +232,7 @@
 
             //Set the body size
             ContentHeaderBody _headerBody = new ContentHeaderBody();
-            _headerBody.bodySize = 0;
+            _headerBody.setBodySize(0);
 
             //Set Minimum properties
             BasicContentHeaderProperties properties = new BasicContentHeaderProperties();
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java
deleted file mode 100644
index c7db510..0000000
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java
+++ /dev/null
@@ -1,88 +0,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.
- *
- */
-package org.apache.qpid.server.util;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public class LoggingProxyTest extends TestCase
-{
-    static interface IFoo {
-        void foo();
-        void foo(int i, Collection c);
-        String bar();
-        String bar(String s, List l);
-    }
-
-    static class Foo implements IFoo {
-        public void foo()
-        {
-        }
-
-        public void foo(int i, Collection c)
-        {
-        }
-
-        public String bar()
-        {
-            return null;
-        }
-
-        public String bar(String s, List l)
-        {
-            return "ha";
-        }
-    }
-
-    public void testSimple() {
-        LoggingProxy proxy = new LoggingProxy(new Foo(), 20);
-        IFoo foo = (IFoo)proxy.getProxy(IFoo.class);
-        foo.foo();
-        assertEquals(2, proxy.getBufferSize());
-        assertTrue(proxy.getBuffer().get(0).toString().matches(".*: foo\\(\\) entered$"));
-        assertTrue(proxy.getBuffer().get(1).toString().matches(".*: foo\\(\\) returned$"));
-
-        foo.foo(3, Arrays.asList(0, 1, 2));
-        assertEquals(4, proxy.getBufferSize());
-        assertTrue(proxy.getBuffer().get(2).toString().matches(".*: foo\\(\\[3, \\[0, 1, 2\\]\\]\\) entered$"));
-        assertTrue(proxy.getBuffer().get(3).toString().matches(".*: foo\\(\\) returned$"));
-
-        foo.bar();
-        assertEquals(6, proxy.getBufferSize());
-        assertTrue(proxy.getBuffer().get(4).toString().matches(".*: bar\\(\\) entered$"));
-        assertTrue(proxy.getBuffer().get(5).toString().matches(".*: bar\\(\\) returned null$"));
-
-        foo.bar("hello", Arrays.asList(1, 2, 3));
-        assertEquals(8, proxy.getBufferSize());
-        assertTrue(proxy.getBuffer().get(6).toString().matches(".*: bar\\(\\[hello, \\[1, 2, 3\\]\\]\\) entered$"));
-        assertTrue(proxy.getBuffer().get(7).toString().matches(".*: bar\\(\\) returned ha$"));
-
-        proxy.dump();
-    }
-
-    public static junit.framework.Test suite()
-    {
-        return new junit.framework.TestSuite(LoggingProxyTest.class);
-    }
-}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java
index 3c6857e..7aa5ed2 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java
@@ -20,20 +20,21 @@
  */
 package org.apache.qpid.server.util;
 
-import java.util.Properties;
-
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.logging.NullRootMessageLogger;
 import org.apache.qpid.server.logging.actors.BrokerActor;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.actors.GenericActor;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.security.auth.database.PropertiesPrincipalDatabase;
 import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
 import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
 
+import java.util.Properties;
+
 public class TestApplicationRegistry extends ApplicationRegistry
 {
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/HouseKeepingTaskTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/HouseKeepingTaskTest.java
index 98bf381..0794154 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/HouseKeepingTaskTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/HouseKeepingTaskTest.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.server.virtualhost;
 
-import java.util.concurrent.CountDownLatch;
-
 import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.logging.NullRootMessageLogger;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.actors.TestLogActor;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import java.util.concurrent.CountDownLatch;
+
 public class HouseKeepingTaskTest extends QpidTestCase
 {
     /**
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
index b2cdff8..54c44d8 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
@@ -20,9 +20,7 @@
  */
 package org.apache.qpid.server.virtualhost;
 
-import java.util.Map;
-import java.util.UUID;
-
+import java.util.concurrent.ScheduledFuture;
 import org.apache.qpid.server.binding.BindingFactory;
 import org.apache.qpid.server.configuration.BrokerConfig;
 import org.apache.qpid.server.configuration.ConfigStore;
@@ -43,6 +41,10 @@
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.protocol.v1_0.LinkRegistry;
+import org.apache.qpid.server.txn.DtxRegistry;
+
+import java.util.Map;
+import java.util.UUID;
 
 
 public class MockVirtualHost implements VirtualHost
@@ -96,6 +98,11 @@
         return null;
     }
 
+    public DtxRegistry getDtxRegistry()
+    {
+        return null;
+    }
+
     public VirtualHostConfiguration getConfiguration()
     {
         return null;
@@ -172,6 +179,11 @@
 
     }
 
+    public ScheduledFuture<?> scheduleTask(long delay, Runnable timeoutTask)
+    {
+        return null;
+    }
+
     public void scheduleHouseKeepingTask(long period, HouseKeepingTask task)
     {
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostImplTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostImplTest.java
index c87e5a1..df7b4da 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostImplTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostImplTest.java
@@ -20,13 +20,9 @@
  */
 package org.apache.qpid.server.virtualhost;
 
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.queue.AMQQueue;
@@ -35,6 +31,11 @@
 import org.apache.qpid.server.util.TestApplicationRegistry;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
 public class VirtualHostImplTest extends QpidTestCase
 {
     private ServerConfiguration _configuration;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionConfigurationTest.java
index cc11d68..e2375c5 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionConfigurationTest.java
@@ -23,6 +23,7 @@
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionConfiguration;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionPolicyConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionPolicyConfigurationTest.java
index efb898e..ea07632 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionPolicyConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionPolicyConfigurationTest.java
@@ -23,6 +23,7 @@
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionPolicyConfiguration;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionQueueConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionQueueConfigurationTest.java
index be86037..96e524a 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionQueueConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/SlowConsumerDetectionQueueConfigurationTest.java
@@ -21,6 +21,7 @@
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.server.configuration.plugins.SlowConsumerDetectionQueueConfiguration;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyConfigurationTest.java
index 3d3cc81..f034d05 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyConfigurationTest.java
@@ -23,6 +23,7 @@
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 
 /**
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyTest.java
index a2e83ad..fdd163b 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/plugins/policies/TopicDeletePolicyTest.java
@@ -22,6 +22,7 @@
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.binding.Binding;
@@ -38,10 +39,10 @@
 public class TopicDeletePolicyTest extends InternalBrokerBaseCase
 {
 
-    TopicDeletePolicyConfiguration _config;
+    private TopicDeletePolicyConfiguration _config;
 
-    VirtualHost _defaultVhost;
-    InternalTestProtocolSession _connection;
+    private VirtualHost _defaultVhost;
+    private InternalTestProtocolSession _connection;
 
     public void setUp() throws Exception
     {
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/tools/security/PasswdTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/tools/security/PasswdTest.java
new file mode 100644
index 0000000..b2a7234
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/tools/security/PasswdTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.tools.security;
+
+import junit.framework.TestCase;
+
+public class PasswdTest extends TestCase
+{
+    public void testUserGuestAndPasswordGuest() throws Exception
+    {
+        Passwd passwd = new Passwd();
+        String output = passwd.getOutput("guest", "guest");
+        assertEquals("guest:CE4DQ6BIb/BVMN9scFyLtA==", output);
+    }
+
+    public void testUser1AndPasswordFoo() throws Exception
+    {
+        Passwd passwd = new Passwd();
+        String output = passwd.getOutput("user1", "foo");
+        assertEquals("user1:rL0Y20zC+Fzt72VPzMSk2A==", output);
+    }
+}
diff --git a/qpid/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java b/qpid/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java
index a39799a..a10d3b6 100644
--- a/qpid/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java
+++ b/qpid/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java
@@ -68,8 +68,7 @@
         }
         catch (InvalidTypeException e)
         {
-            // This occurs when a type other than 'number' appears in the
-            // paramater config {0, number...}
+            // This occurs when a type other than 'number' appears in the paramater config {0, number...}.
             System.err.println(e.getMessage());
             System.exit(-1);
         }
@@ -365,9 +364,9 @@
         // Taking an example of:
         // 'Text {n,type,format} [option] text {m} [option with param{p}] more'
         // This would give us:
-        // 0 - Text {n,type,format}
-        // 1 - option] text {m}
-        // 2 - option with param{p}] more
+        // 0 - Text {n,type,format}.
+        // 1 - option] text {m}.
+        // 2 - option with param{p}] more.
 
         // Create the parameter list for this item
         List<HashMap<String, String>> options = new LinkedList<HashMap<String, String>>();
@@ -442,17 +441,20 @@
         String[] parametersString = logMessage.split("\\{");
         // Taking an example of 'Text {n[,type]} text {m} more text {p}'
         // This would give us:
-        // 0 - Text
-        // 1 - n[,type]} text
-        // 2 - m} more text
-        // 3 - p}
+        // 0 - Text.
+        // 1 - n[,type]} text.
+        // 2 - m} more text.
+        // 3 - p}.
 
         // Create the parameter list for this item
         List<HashMap<String, String>> parameters = new LinkedList<HashMap<String, String>>();
 
-        // Check that we have some parameters to process
-        // Skip 0 as that will not be the first entry
-        //  Text {n[,type]} text {m} more text {p}
+        /*
+          Check that we have some parameters to process
+          Skip 0 as that will not be the first entry
+          Text {n[,type]} text {m} more text {p}.
+        */
+
         if (parametersString.length > 1)
         {
             for (int index = 1; index < parametersString.length; index++)
@@ -461,8 +463,11 @@
                 // for easy retrieval in the macro template
                 HashMap<String, String> parameter = new HashMap<String, String>();
 
-                // Check for any properties of the parameter :
-                // e.g. {0} vs {0,number} vs {0,number,xxxx}
+                /*
+                  Check for any properties of the parameter :
+                  e.g. {0} vs {0,number} vs {0,number,xxxx}.
+                */
+
                 int typeIndex = parametersString[index].indexOf(",");
 
                 // The parameter type
diff --git a/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm b/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
index fd847fd..02bf155 100644
--- a/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
+++ b/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
@@ -43,8 +43,8 @@
  */
 public class ${type.name}Messages
 {
-    static ResourceBundle _messages;
-    static Locale _currentLocale;
+    private static ResourceBundle _messages;
+    private static Locale _currentLocale;
     
     public static final String ${type.name.toUpperCase()}_LOG_HIERARCHY = DEFAULT_LOG_HIERARCHY_PREFIX + "${type.name.toLowerCase()}";
 #foreach( $message in ${type.list} )
@@ -146,7 +146,7 @@
 ## append it to the log.
 #foreach($option in ${message.options})
 
-            // Add Option : ${option.value}
+            // Add Option : ${option.value}.
             end = parts[${velocityCount}].indexOf(']');
             if (${option.name})
             {
@@ -197,4 +197,8 @@
 
 #end
 
+    private ${type.name}Messages()
+    {
+    }
+
 }
diff --git a/qpid/java/broker/src/xsl/qmf.xsl b/qpid/java/broker/src/xsl/qmf.xsl
index 1e98c97..c45d1e4 100644
--- a/qpid/java/broker/src/xsl/qmf.xsl
+++ b/qpid/java/broker/src/xsl/qmf.xsl
@@ -794,9 +794,14 @@
 <xsl:when test="$type='objId'">OBJECTREFERENCE</xsl:when>
 <xsl:when test="$type='sstr'">STR8</xsl:when>
 <xsl:when test="$type='lstr'">STR16</xsl:when>
+<xsl:when test="$type='uint8'">UINT8</xsl:when>
 <xsl:when test="$type='uint16'">UINT16</xsl:when>
 <xsl:when test="$type='uint32'">UINT32</xsl:when>
 <xsl:when test="$type='uint64'">UINT64</xsl:when>
+<xsl:when test="$type='int8'">INT8</xsl:when>
+<xsl:when test="$type='int16'">INT16</xsl:when>
+<xsl:when test="$type='int32'">INT32</xsl:when>
+<xsl:when test="$type='int64'">INT64</xsl:when>
 <xsl:when test="$type='uuid'">UUID</xsl:when>
 <xsl:when test="$type='deltaTime'">DELTATIME</xsl:when>    
 <xsl:when test="$type='count32'">UINT32</xsl:when>
@@ -813,9 +818,14 @@
             <xsl:when test="$type='objId'"><xsl:value-of select="$referenceType"/>Object</xsl:when>
             <xsl:when test="$type='sstr'">String</xsl:when>
             <xsl:when test="$type='lstr'">String</xsl:when>
+            <xsl:when test="$type='uint8'">Integer</xsl:when>
             <xsl:when test="$type='uint16'">Integer</xsl:when>
             <xsl:when test="$type='uint32'">Long</xsl:when>
             <xsl:when test="$type='uint64'">Long</xsl:when>
+            <xsl:when test="$type='int8'">Integer</xsl:when>
+            <xsl:when test="$type='int16'">Integer</xsl:when>
+            <xsl:when test="$type='int32'">Long</xsl:when>
+            <xsl:when test="$type='int64'">Long</xsl:when>
             <xsl:when test="$type='uuid'">UUID</xsl:when>
             <xsl:when test="$type='deltaTime'">Long</xsl:when>    
             <xsl:when test="$type='count32'">Long</xsl:when>
@@ -831,9 +841,14 @@
             <xsl:when test="$type='objId'">writeBin128( <xsl:value-of select="$var"/>.getId() )</xsl:when>
             <xsl:when test="$type='sstr'">writeStr8( <xsl:value-of select="$var"/> )</xsl:when>
             <xsl:when test="$type='lstr'">writeStr16( <xsl:value-of select="$var"/> )</xsl:when>
+            <xsl:when test="$type='uint8'">writeUint8( <xsl:value-of select="$var"/> )</xsl:when>
             <xsl:when test="$type='uint16'">writeUint16( <xsl:value-of select="$var"/> )</xsl:when>
             <xsl:when test="$type='uint32'">writeUint32( <xsl:value-of select="$var"/> )</xsl:when>
             <xsl:when test="$type='uint64'">writeUint64( <xsl:value-of select="$var"/> )</xsl:when>
+            <xsl:when test="$type='int8'">writeInt8( <xsl:value-of select="$var"/> )</xsl:when>
+            <xsl:when test="$type='int16'">writeInt16( <xsl:value-of select="$var"/> )</xsl:when>
+            <xsl:when test="$type='int32'">writeInt32( <xsl:value-of select="$var"/> )</xsl:when>
+            <xsl:when test="$type='int64'">writeInt64( <xsl:value-of select="$var"/> )</xsl:when>
             <xsl:when test="$type='uuid'">writeUuid( <xsl:value-of select="$var"/> )</xsl:when>
             <xsl:when test="$type='deltaTime'">writeUint64( <xsl:value-of select="$var"/> )</xsl:when>    
             <xsl:when test="$type='count32'">writeUint32( <xsl:value-of select="$var"/> )</xsl:when>
@@ -849,9 +864,14 @@
             <xsl:when test="$type='objId'">readBin128()</xsl:when>
             <xsl:when test="$type='sstr'">readStr8()</xsl:when>
             <xsl:when test="$type='lstr'">readStr16()</xsl:when>
+            <xsl:when test="$type='uint8'">readUint8()</xsl:when>
             <xsl:when test="$type='uint16'">readUint16()</xsl:when>
             <xsl:when test="$type='uint32'">readUint32()</xsl:when>
             <xsl:when test="$type='uint64'">readUint64()</xsl:when>
+            <xsl:when test="$type='int8'">readInt8()</xsl:when>
+            <xsl:when test="$type='int16'">readInt16()</xsl:when>
+            <xsl:when test="$type='int32'">readInt32()</xsl:when>
+            <xsl:when test="$type='int64'">readInt64()</xsl:when>
             <xsl:when test="$type='uuid'">readUuid()</xsl:when>
             <xsl:when test="$type='deltaTime'">readUint64()</xsl:when>    
             <xsl:when test="$type='count32'">readUint32()</xsl:when>
diff --git a/qpid/java/client/README.txt b/qpid/java/client/README.txt
index b9cde71..a8c7da3 100644
--- a/qpid/java/client/README.txt
+++ b/qpid/java/client/README.txt
@@ -47,5 +47,3 @@
 This will build the various Java modules, leaving binary .jar files output in:
 <installation path>/qpid/java/build/lib
 
-Taking the above the 'distribution directory', consult the README.txt file at:
-<installation path>/qpid/java/client/example/src/main/java
diff --git a/qpid/java/client/build.xml b/qpid/java/client/build.xml
index d52de8d..5a72d67 100644
--- a/qpid/java/client/build.xml
+++ b/qpid/java/client/build.xml
@@ -32,14 +32,6 @@
 
   <property name="output.dir" value="${module.precompiled}/org/apache/qpid/filter/selector"/>
 
-  <target name="precompile">
-    <mkdir dir="${output.dir}"/>
-    <javacc target="src/main/grammar/SelectorParser.jj"
-            outputdirectory="${output.dir}"
-            javacchome="${project.root}/lib"/>
-  </target>
-
-
   <uptodate property="doc-release.done" targetfile="${module.release}/api/index.html">
     <srcfiles dir="${module.src}" includes="**/*.java"/>
   </uptodate>
diff --git a/qpid/java/client/example/src/main/java/README.txt b/qpid/java/client/example/src/main/java/README.txt
deleted file mode 100644
index 757054e..0000000
--- a/qpid/java/client/example/src/main/java/README.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-In order to use the runSample script, you are required to set two environment
-variables, QPID_HOME and QPID_SAMPLE. If not the default values will be used.
-
-QPID_HOME
----------
-This is the directory that contains the QPID distribution. If you are running the Qpid
-Java broker on the same machine as the examples, you have already set QPID_HOME to this 
-directory.
-
-default: /usr/share/java/
-
-QPID_SAMPLE
------------
-
-This is the examples directory, which is the parent directory of the
-'java' directory in which you find 'runSample.sh'
-
-(Ex:- $QPID_SRC_HOME/java/client/example/src/main)
-
-default: $PWD
-
-Note: you must have write privileges to this directory in order to run
-the examples.
-
-
-Running the Examples
-===========================
-
-To run these programs, do the following:
-
-   1. Make sure that a Qpid broker is running.
-   2. In the java directory, use runSample.sh to run the program:
-      $  ./runSample.sh <class name> <arguments>
\ No newline at end of file
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Drain.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/Drain.java
index b43031a..28e1d5a 100644
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Drain.java
+++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/Drain.java
@@ -27,8 +27,6 @@
 import javax.jms.Session;
 
 import org.apache.qpid.client.AMQAnyDestination;
-import org.apache.qpid.client.AMQConnection;
-import org.slf4j.Logger;
 
 public class Drain extends OptionParser
 {
@@ -50,13 +48,13 @@
 
     static 
     {        
-        optDefs.add(BROKER);
-        optDefs.add(HELP);
-        optDefs.add(TIMEOUT);
-        optDefs.add(FOREVER);
-        optDefs.add(COUNT);
-        optDefs.add(CON_OPTIONS);
-        optDefs.add(BROKER_OPTIONS);
+        addOption(BROKER);
+        addOption(HELP);
+        addOption(TIMEOUT);
+        addOption(FOREVER);
+        addOption(COUNT);
+        addOption(CON_OPTIONS);
+        addOption(BROKER_OPTIONS);
     }
     
     public Drain(String[] args, String usage, String desc) throws Exception
@@ -66,7 +64,7 @@
         Connection con = createConnection();
         con.start();
         Session ssn = con.createSession(false,Session.AUTO_ACKNOWLEDGE);     
-        Destination dest = new AMQAnyDestination(address);
+        Destination dest = new AMQAnyDestination(getAddress());
         MessageConsumer consumer = ssn.createConsumer(dest);
         Message msg;
         
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java
index f4e17c5..6aa12f0 100644
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java
+++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java
@@ -68,12 +68,12 @@
             String.class);
     
     
-    protected Map<String,Object> optMap = new HashMap<String,Object>();
-    protected static final List<Option> optDefs = new ArrayList<Option>();
+    private Map<String,Object> optMap = new HashMap<String,Object>();
+    private static final List<Option> optDefs = new ArrayList<Option>();
     
-    protected String usage;
-    protected String desc;
-    protected String address;
+    private String usage;
+    private String desc;
+    private String address;
     
     public OptionParser(String[] args, String usage, String desc)
     {   
@@ -147,8 +147,8 @@
                 for (Option option: optDefs)
                 {
                     
-                    if ((op.startsWith("-") && option.shortForm != null && option.shortForm.equals(key)) ||
-                        (op.startsWith("--") && option.longForm != null && option.longForm.equals(key)) )
+                    if ((op.startsWith("-") && option.getShortForm() != null && option.getShortForm().equals(key)) ||
+                        (op.startsWith("--") && option.getLongForm() != null && option.getLongForm().equals(key)) )
                     {
                         match = true;
                         break;
@@ -205,7 +205,9 @@
         if (op.startsWith("'"))
         {
             if (!op.endsWith("'")) 
+            {
                 throw new IllegalArgumentException(" The option " + op + " needs to be inside quotes");
+            }
             
             return op.substring(1,op.length() -1);
         }
@@ -217,18 +219,18 @@
     
     protected boolean containsOp(Option op)
     {
-        return optMap.containsKey(op.shortForm) || optMap.containsKey(op.longForm);
+        return optMap.containsKey(op.getShortForm()) || optMap.containsKey(op.getLongForm());
     }
     
     protected String getOp(Option op)
     {
-        if (optMap.containsKey(op.shortForm))
+        if (optMap.containsKey(op.getShortForm()))
         {
-            return (String)optMap.get(op.shortForm);
+            return (String)optMap.get(op.getShortForm());
         }
-        else if (optMap.containsKey(op.longForm))
+        else if (optMap.containsKey(op.getLongForm()))
         {
-            return (String)optMap.get(op.longForm);
+            return (String)optMap.get(op.getLongForm());
         }
         else
         {
@@ -281,15 +283,25 @@
         Connection con = new AMQConnection(buf.toString());
         return con;
     }
-    
+
+    public static void addOption(Option opt)
+    {
+        optDefs.add(opt);
+    }
+
+    protected String getAddress()
+    {
+        return address;
+    }
+
     static class Option
     {
-        private String shortForm;
-        private String longForm;
-        private String desc;
-        private String valueLabel;
-        private String defaultValue;
-        private Class type;
+        private final String shortForm;
+        private final String longForm;
+        private final String desc;
+        private final String valueLabel;
+        private final String defaultValue;
+        private final Class type;
         
         public Option(String shortForm, String longForm, String desc,
                       String valueLabel, String defaultValue, Class type)
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Spout.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/Spout.java
index 5da319a6..61ff2df 100644
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Spout.java
+++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/Spout.java
@@ -69,15 +69,15 @@
 
     static 
     {        
-        optDefs.add(BROKER);
-        optDefs.add(HELP);
-        optDefs.add(TIMEOUT);
-        optDefs.add(COUNT);
-        optDefs.add(MSG_PROPERTY);
-        optDefs.add(MAP_ENTRY);
-        optDefs.add(CONTENT);
-        optDefs.add(CON_OPTIONS);
-        optDefs.add(BROKER_OPTIONS);
+        addOption(BROKER);
+        addOption(HELP);
+        addOption(TIMEOUT);
+        addOption(COUNT);
+        addOption(MSG_PROPERTY);
+        addOption(MAP_ENTRY);
+        addOption(CONTENT);
+        addOption(CON_OPTIONS);
+        addOption(BROKER_OPTIONS);
     }
     
     public Spout(String[] args, String usage, String desc) throws Exception
@@ -87,7 +87,7 @@
         Connection con = createConnection();
         con.start();
         Session ssn = con.createSession(false,Session.AUTO_ACKNOWLEDGE);     
-        Destination dest = new AMQAnyDestination(address);
+        Destination dest = new AMQAnyDestination(getAddress());
         MessageProducer producer = ssn.createProducer(dest);
         
         int count = Integer.parseInt(getOp(COUNT));
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java
deleted file mode 100644
index 1849f73..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java
+++ /dev/null
@@ -1,163 +0,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.
- *
- */
-package org.apache.qpid.example.publisher;
-
-import java.io.File;
-
-import javax.jms.JMSException;
-
-
-import org.apache.qpid.example.shared.FileUtils;
-import org.apache.qpid.example.shared.Statics;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-/**
- * 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 = LoggerFactory.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.out.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;
-    }
-
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/FileMessageFactory.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/FileMessageFactory.java
deleted file mode 100644
index 04339b2..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/FileMessageFactory.java
+++ /dev/null
@@ -1,138 +0,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.
- */
-
-package org.apache.qpid.example.publisher;
-
-import org.apache.qpid.util.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.readFileAsString(filename);
-            _session = session;
-        }
-        catch (Exception e)
-        {
-            MessageFactoryException mfe = new MessageFactoryException(e.toString(), e);
-            throw mfe;
-        }
-    }
-
-    /**
-     * 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;
-        }
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MessageFactoryException.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MessageFactoryException.java
deleted file mode 100644
index d709da6..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MessageFactoryException.java
+++ /dev/null
@@ -1,29 +0,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.
- *
- */
-package org.apache.qpid.example.publisher;
-
-public class MessageFactoryException extends Exception
-{
-    public MessageFactoryException(String msg, Throwable t)
-    {
-        super(msg, t);
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java
deleted file mode 100644
index 3d16e01..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java
+++ /dev/null
@@ -1,141 +0,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.
- */
-package org.apache.qpid.example.publisher;
-
-
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-
-/**
- * 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 = LoggerFactory.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
-     * Sends 1000 messages with no delay 
-     *
-     * @param args
-     */
-    public static void main(String[] args)
-    {
-        //Switch on logging appropriately for your app
-        try
-        {
-            int i =0;
-            while (i < 1000)
-            {
-                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(1000);
-                    i++   ;
-                }
-                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()));
-
-        getMonitorPublisher().sendMessage
-                (getMonitorPublisher()._session,
-                 FileMessageFactory.createSimpleEventMessage(getMonitorPublisher().getSession(), "monitor:" + System.currentTimeMillis()),
-                 DeliveryMode.PERSISTENT, false, true);
-
-    }
-
-    /** 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;
-    }
-
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorPublisher.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorPublisher.java
deleted file mode 100644
index 750f57d..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorPublisher.java
+++ /dev/null
@@ -1,105 +0,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.
- */
-package org.apache.qpid.example.publisher;
-
-import org.apache.qpid.client.BasicMessageProducer;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-
-/**
- * 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 = LoggerFactory.getLogger(Publisher.class);
-
-    BasicMessageProducer _producer;
-
-    public MonitorPublisher()
-    {
-        super();
-    }
-
-    /*
-    * Publishes a message using given details
-    */
-    public boolean sendMessage(Session session, Message message, int deliveryMode,
-                                        boolean immediate, boolean commit) throws UndeliveredMessageException
-    {
-        try
-        {
-            _producer = (BasicMessageProducer) session.createProducer(_destination);
-
-            _producer.send(message, deliveryMode, immediate);
-
-            if (commit)
-            {
-                //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("JMSException", e);
-            e.printStackTrace();
-            throw new UndeliveredMessageException("Cannot deliver immediate message", e);
-        }
-
-        _log.info(_name + " finished sending message: " + message);
-        return true;
-    }
-
-    /*
-    * 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("JMSException", e);
-            e.printStackTrace();
-            throw new UndeliveredMessageException("Cannot deliver immediate message", e);
-        }
-
-        _log.info(_name + " finished sending message: " + message);
-        return true;
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MultiMessageDispatcher.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MultiMessageDispatcher.java
deleted file mode 100644
index a92efe9..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MultiMessageDispatcher.java
+++ /dev/null
@@ -1,141 +0,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.
- *
- */
-package org.apache.qpid.example.publisher;
-
-import java.io.File;
-
-import javax.jms.JMSException;
-import javax.jms.TextMessage;
-
-
-import org.apache.qpid.example.shared.FileUtils;
-import org.apache.qpid.example.shared.Statics;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-/**
- * Class that sends parameterised number of message files to the Publisher
- * Must set properties for host in properties file or uses in vm broker
- */
-public class MultiMessageDispatcher
-{
-
-    protected static final Logger _logger = LoggerFactory.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 < 2)
-        {
-            System.out.println("Usage: MultiMessageDispatcher <numberOfMessagesToSend> <topic(true|false)>" + "");
-        }
-        else
-        {
-            boolean topicPublisher = true;
-            
-            try
-            {
-                // publish message(s)
-                topicPublisher = new Boolean(args[1]).booleanValue();
-                publish(new Integer(args[0]).intValue(),topicPublisher);
-
-                // 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
-            {
-
-                cleanup(topicPublisher);
-            }
-        }
-
-        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 numMessages - from main args
-     * @throws javax.jms.JMSException
-     * @throws org.apache.qpid.example.publisher.MessageFactoryException - if cannot create message from file content
-     */
-    public static void publish(int numMessages, boolean topicPublisher) throws JMSException, MessageFactoryException
-    {
-        {
-            // Send the message generated from the payload using the _publisher
-            getPublisher(topicPublisher).sendMessage(numMessages);
-        }
-    }
-
-    /**
-     * Cleanup before exit
-     */
-    public static void cleanup(boolean topicPublisher)
-    {
-        if (getPublisher(topicPublisher) != null)
-        {
-            getPublisher(topicPublisher).cleanup();
-        }
-    }
-
-    /**
-     * @return A Publisher instance
-     */
-    private static Publisher getPublisher(boolean topic)
-    {
-        if (_publisher != null)
-        {
-            return _publisher;
-        }
-
-        if (!topic)
-        {
-            // Create a _publisher
-            _publisher = new Publisher();
-        }
-        else
-        {
-            _publisher = new TopicPublisher();
-        }
-        return _publisher;
-    }
-
-}
\ No newline at end of file
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/Publisher.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/Publisher.java
deleted file mode 100644
index b5f4455..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/Publisher.java
+++ /dev/null
@@ -1,208 +0,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.
- */
-package org.apache.qpid.example.publisher;
-
-import org.apache.qpid.client.AMQConnectionFactory;
-
-import javax.jms.*;
-
-import javax.naming.InitialContext;
-
-import org.apache.qpid.example.shared.InitialContextHelper;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-public class Publisher
-{
-    private static final Logger _log = LoggerFactory.getLogger(Publisher.class);
-
-    protected InitialContextHelper _contextHelper;
-
-    protected Connection _connection;
-
-    protected Session _session;
-
-    protected MessageProducer _producer;
-
-    protected String _destinationDir;
-
-    protected String _name = "Publisher";
-
-    protected Destination _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();
-
-            _connection.setExceptionListener(new ExceptionListener()
-            {
-                public void onException(JMSException jmse)
-                {
-                    // The connection may have broken invoke reconnect code if available.
-                    // The connection may have broken invoke reconnect code if available.
-                    System.err.println("ExceptionListener caught: " + jmse);
-                    //System.exit(0);
-                }
-            });
-
-            //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 = (Queue) 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("Exception", e);
-        }
-    }
-
-    /**
-     * Creates and sends the number of messages specified in the param
-     */
-    public void sendMessage(int numMessages)
-    {
-        try
-        {
-            TextMessage txtMessage = _session.createTextMessage("msg");
-            for (int i=0;i<numMessages;i++)
-            {
-                sendMessage(txtMessage);
-                _log.info("Sent: " + i);
-            }
-        }
-        catch (JMSException j)
-        {
-            _log.error("Exception in sendMessage" + j);
-        }
-
-
-    }
-
-    /**
-     * 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.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("JMSException", 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;
-    }
-}
-
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/TopicPublisher.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/TopicPublisher.java
deleted file mode 100644
index 8645e41..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/TopicPublisher.java
+++ /dev/null
@@ -1,59 +0,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.
- */
-package org.apache.qpid.example.publisher;
-
-import org.apache.qpid.client.BasicMessageProducer;
-import org.apache.qpid.example.shared.InitialContextHelper;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-import javax.jms.*;
-import javax.naming.InitialContext;
-
-/**
- * Subclass of Publisher which sends messages to a topic destination defined in example.properties
- */
-public class TopicPublisher extends Publisher
-{
-
-    private static final Logger _log = LoggerFactory.getLogger(Publisher.class);
-
-    public TopicPublisher()
-    {
-        super();
-
-        try
-        {
-            _contextHelper = new InitialContextHelper(null);
-            InitialContext ctx = _contextHelper.getInitialContext();
-
-           //lookup the example topic and use it
-           _destination = (Topic) ctx.lookup("MyTopic");
-
-           //create a message producer
-           _producer = _session.createProducer(_destination);
-        }
-        catch (Exception e)
-        {
-            //argh
-            _log.error("Exception trying to construct TopicPublisher" + e);
-        }
-
-    }
-}
\ No newline at end of file
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java
deleted file mode 100644
index 245008b..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java
+++ /dev/null
@@ -1,32 +0,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.
- *
- */
-package org.apache.qpid.example.publisher;
-
-/**
- * Exception thrown by monitor when cannot send a message marked for immediate delivery
- */
-public class UndeliveredMessageException extends Exception
-{
-    public UndeliveredMessageException(String msg, Throwable t)
-    {
-        super(msg, t);
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/Client.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/Client.java
deleted file mode 100644
index e32ee0b..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/Client.java
+++ /dev/null
@@ -1,72 +0,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.    
- *
- * 
- */
-package org.apache.qpid.example.pubsub;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Session;
-import javax.naming.NamingException;
-
-/**
- * An abstract base class that wraps up the creation of a JMS client utilising JNDI
- */
-public abstract class Client
-{
-    protected ConnectionSetup _setup;
-
-    protected Connection _connection;
-    protected Destination _destination;
-    protected Session _session;
-
-    public Client(String destination)
-    {
-        if (destination == null)
-        {
-            destination = ConnectionSetup.TOPIC_JNDI_NAME;
-        }
-
-        try
-        {
-            _setup = new ConnectionSetup();
-        }
-        catch (NamingException e)
-        {
-            //ignore
-        }
-
-        if (_setup != null)
-        {
-            try
-            {
-                _connection = _setup.getConnectionFactory().createConnection();
-                _destination = _setup.getDestination(destination);
-            }
-            catch (JMSException e)
-            {
-                System.err.println(e.getMessage());
-            }
-        }
-    }
-
-    public abstract void start();
-
-}
\ No newline at end of file
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/ConnectionSetup.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/ConnectionSetup.java
deleted file mode 100644
index 0734704..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/ConnectionSetup.java
+++ /dev/null
@@ -1,121 +0,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.    
- *
- * 
- */
-package org.apache.qpid.example.pubsub;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.Properties;
-
-/**
- * This ConnectionSetup is a wrapper around JNDI it creates a number of entries.
- *
- * It is equivalent to a PropertyFile of value:
- *
- * connectionfactory.local=amqp://guest:guest@clientid/test?brokerlist='localhost'
- *
- * queue.queue=example.MyQueue
- * topic.topic=example.hierarical.topic
- *
- */
-public class ConnectionSetup
-{
-    final static String INITIAL_CONTEXT_FACTORY = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
-
-    final static String CONNECTION_JNDI_NAME = "local";
-    final static String CONNECTION_NAME = "amqp://guest:guest@clientid/test?brokerlist='localhost'";
-
-    public static final String QUEUE_JNDI_NAME = "queue";
-    final static String QUEUE_NAME = "example.MyQueue";
-
-    public static final String TOPIC_JNDI_NAME = "topic";
-    final static String TOPIC_NAME = "usa.news";
-
-    private Context _ctx;
-
-    public ConnectionSetup() throws NamingException
-    {
-
-        // Set the properties ...
-        Properties properties = new Properties();
-        properties.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
-        properties.put("connectionfactory." + CONNECTION_JNDI_NAME, CONNECTION_NAME);
-
-        properties.put("queue." + QUEUE_JNDI_NAME, QUEUE_NAME);
-        properties.put("topic." + TOPIC_JNDI_NAME, TOPIC_NAME);
-        // Create the initial context
-        _ctx = new InitialContext(properties);
-
-    }
-
-    public ConnectionSetup(Properties properties) throws NamingException
-    {
-        _ctx = new InitialContext(properties);
-    }
-
-    public ConnectionFactory getConnectionFactory()
-    {
-
-        // Perform the lookups
-        try
-        {
-            return (ConnectionFactory) _ctx.lookup(CONNECTION_JNDI_NAME);
-        }
-        catch (NamingException e)
-        {
-            //ignore
-        }
-        return null;
-    }
-
-    public Destination getDestination(String jndiName)
-    {
-        // Perform the lookups
-        try
-        {
-            return (Destination) _ctx.lookup(jndiName);
-        }
-        catch (ClassCastException cce)
-        {
-            //ignore
-        }
-        catch (NamingException ne)
-        {
-            //ignore
-        }
-        return null;
-    }
-
-
-    public void close()
-    {
-        try
-        {
-            _ctx.close();
-        }
-        catch (NamingException e)
-        {
-            //ignore
-        }
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/Publisher.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/Publisher.java
deleted file mode 100644
index ac3829d..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/Publisher.java
+++ /dev/null
@@ -1,81 +0,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.    
- *
- * 
- */
-package org.apache.qpid.example.pubsub;
-
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-/**
- * A simple Publisher example.
- *
- * The class can take two arguments.
- * java Publisher <destination> <msgCount>
- * Where:
- * destination is either 'topic' or 'queue'  (Default: topic)
- * msgCount is the number of messages to send (Default : 100)
- *
- */
-public class Publisher extends Client
-{
-    int _msgCount;
-
-    public Publisher(String destination, int msgCount)
-    {
-        super(destination);
-        _msgCount = msgCount;
-    }
-
-    public void start()
-    {
-        try
-        {
-            _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-            MessageProducer _producer = _session.createProducer(_destination);
-
-            for (int msgCount = 0; msgCount < _msgCount; msgCount++)
-            {
-                _producer.send(_session.createTextMessage("msg:" + msgCount));
-                System.out.println("Sent:" + msgCount);
-            }
-
-            System.out.println("Done.");
-            _connection.close();
-        }
-        catch (JMSException e)
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
-    }
-
-
-    public static void main(String[] args)
-    {
-
-        String destination = args.length > 2 ? args[1] : "usa.news";
-
-        int msgCount = args.length > 2 ? Integer.parseInt(args[2]) : 100;
-
-        new Publisher(destination, msgCount).start();
-    }
-
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/Subscriber.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/Subscriber.java
deleted file mode 100644
index f2d7367..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/Subscriber.java
+++ /dev/null
@@ -1,98 +0,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.    
- *
- * 
- */
-package org.apache.qpid.example.pubsub;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import java.util.concurrent.CountDownLatch;
-
-
-/**
- * Simple client that listens for the specified number of msgs on the given Destinaton
- *
- * The class can take two arguments.
- * java Subscriber <destination> <msgCount>
- * Where:
- * destination is either 'topic' or 'queue'  (Default: topic)
- * msgCount is the number of messages to send (Default : 100)
- */
-public class Subscriber extends Client implements MessageListener
-{
-
-    CountDownLatch _count;
-
-    public Subscriber(String destination, int msgCount)
-    {
-        super(destination);
-        _count = new CountDownLatch(msgCount);
-    }
-
-
-    public void start()
-    {
-        try
-        {
-            _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-            _session.createDurableSubscriber((Topic) _setup.getDestination(ConnectionSetup.TOPIC_JNDI_NAME),
-                                             "exampleClient").setMessageListener(this);
-            _connection.start();
-            _count.await();
-
-            System.out.println("Done");
-
-            _connection.close();
-        }
-        catch (JMSException e)
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
-        catch (InterruptedException e)
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
-    }
-
-    public static void main(String[] args)
-    {
-        String destination = args.length > 2 ? args[1] : null;
-        int msgCount = args.length > 2 ? Integer.parseInt(args[2]) : 100;
-
-        new Subscriber(destination, msgCount).start();
-    }
-
-    public void onMessage(Message message)
-    {
-        try
-        {
-            _count.countDown();
-            System.out.println("Received msg:" + ((TextMessage) message).getText());
-        }
-        catch (JMSException e)
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ConnectionException.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ConnectionException.java
deleted file mode 100644
index 1a3d596..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ConnectionException.java
+++ /dev/null
@@ -1,29 +0,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.
- *
- */
-package org.apache.qpid.example.shared;
-
-public class ConnectionException extends Exception
-{
-    public ConnectionException(String msg, Throwable t)
-    {
-        super(msg, t);
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ContextException.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ContextException.java
deleted file mode 100644
index 2987a95..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ContextException.java
+++ /dev/null
@@ -1,29 +0,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.
- *
- */
-package org.apache.qpid.example.shared;
-
-public class ContextException extends Exception
-{
-    public ContextException(String msg, Throwable t)
-    {
-        super(msg, t);
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/FileUtils.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/FileUtils.java
deleted file mode 100644
index 54446cb..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/FileUtils.java
+++ /dev/null
@@ -1,168 +0,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.
- */
-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;
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/InitialContextHelper.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/InitialContextHelper.java
deleted file mode 100644
index 16a1851..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/InitialContextHelper.java
+++ /dev/null
@@ -1,81 +0,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.
- *
- */
-package org.apache.qpid.example.shared;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-/**
- * Class that provides helper methods for JNDI
- */
-public class InitialContextHelper
-{
-
-    public static final String _defaultPropertiesName = "example.properties";
-    protected Properties _fileProperties;
-    protected InitialContext _initialContext;
-    protected static final Logger _log = LoggerFactory.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(e.toString(), e);
-        }
-        catch (NamingException n)
-        {
-            throw new ContextException(n.toString(), n);
-        }
-    }
-
-    public Properties getFileProperties()
-    {
-        return _fileProperties;
-    }
-
-    public InitialContext getInitialContext()
-    {
-        return _initialContext;
-    }
-
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/Statics.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/Statics.java
deleted file mode 100644
index c056f8a..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/Statics.java
+++ /dev/null
@@ -1,57 +0,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.
- */
-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";
-
-
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/example.properties b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/example.properties
deleted file mode 100644
index c76acbd..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/example.properties
+++ /dev/null
@@ -1,40 +0,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.
-
-
-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/test?brokerlist='tcp://localhost:5672'
-
-# 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
-topic.MyTopic = example.MyTopic
-
-# Register an AMQP destination in JNDI
-#   NOTE: Qpid currently only supports direct,topics and headers
-# destination.[jniName] = [BindingURL]
-destination.direct = direct://amq.direct//directQueue
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/simple/reqresp/Client.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/simple/reqresp/Client.java
deleted file mode 100644
index 8a0ff88..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/simple/reqresp/Client.java
+++ /dev/null
@@ -1,263 +0,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.
- *
- */
-
-package org.apache.qpid.example.simple.reqresp;
-
-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.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
-
-public class Client implements MessageListener
-{
-    final String BROKER = "localhost";
-
-    final String INITIAL_CONTEXT_FACTORY = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
-
-    final String CONNECTION_JNDI_NAME = "local";
-    final String CONNECTION_NAME = "amqp://guest:guest@clientid/test?brokerlist='" + BROKER + "'";
-
-    final String QUEUE_JNDI_NAME = "queue";
-    final String QUEUE_NAME = "example.RequestQueue";
-
-
-    private InitialContext _ctx;
-
-    private CountDownLatch _shutdownHook = new CountDownLatch(1);
-
-    public Client()
-    {
-        setupJNDI();
-
-        Connection connection;
-        Session session;
-        Destination responseQueue;
-
-        //Setup the connection. Create producer to sent message and consumer to receive the repsonse.
-        MessageProducer _producer;
-        try
-        {
-            connection = ((ConnectionFactory) lookupJNDI(CONNECTION_JNDI_NAME)).createConnection();
-
-            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-            Destination requestQueue = (Queue) lookupJNDI(QUEUE_JNDI_NAME);
-
-            closeJNDI();
-
-            //Setup a message _producer to send message to the queue the server is consuming from
-            _producer = session.createProducer(requestQueue);
-
-            //Create a temporary queue that this client will listen for responses on then create a consumer
-            //that consumes message from this temporary queue.
-            responseQueue = session.createTemporaryQueue();
-
-            MessageConsumer responseConsumer = session.createConsumer(responseQueue);
-
-            //Set a listener to asynchronously deal with responses.
-            responseConsumer.setMessageListener(this);
-
-            // Now the connection is setup up start it.
-            connection.start();
-        }
-        catch (JMSException e)
-        {
-            System.err.println("Unable to setup connection, client and producer on broker");
-            return;
-        }
-
-        // Setup the message to send
-        TextMessage txtMessage;
-        try
-        {
-            //Now create the actual message you want to send
-            txtMessage = session.createTextMessage("Request Process");
-
-            //Set the reply to field to the temp queue you created above, this is the queue the server will respond to
-            txtMessage.setJMSReplyTo(responseQueue);
-
-            //Set a correlation ID so when you get a response you know which sent message the response is for
-            //If there is never more than one outstanding message to the server then the
-            //same correlation ID can be used for all the messages...if there is more than one outstanding
-            //message to the server you would presumably want to associate the correlation ID with this message
-
-            txtMessage.setJMSCorrelationID(txtMessage.getJMSMessageID());
-        }
-        catch (JMSException e)
-        {
-            System.err.println("Unable to create message");
-            return;
-
-        }
-
-        try
-        {
-            _producer.send(txtMessage);
-        }
-        catch (JMSException e)
-        {
-            //Handle the exception appropriately
-        }
-
-        try
-        {
-            System.out.println("Sent Request Message ID :" + txtMessage.getJMSMessageID());
-        }
-        catch (JMSException e)
-        {
-            //Handle exception more appropriately.
-        }
-
-        //Wait for the return message to arrive
-        try
-        {
-            _shutdownHook.await();
-        }
-        catch (InterruptedException e)
-        {
-            // Ignore this as we are quitting anyway.
-        }
-
-        //Close the connection
-        try
-        {
-            connection.close();
-        }
-        catch (JMSException e)
-        {
-            System.err.println("A problem occured while shutting down the connection : " + e);
-        }
-    }
-
-
-    /**
-     * Implementation of the Message Listener interface.
-     * This is where message will be asynchronously delivered.
-     *
-     * @param message
-     */
-    public void onMessage(Message message)
-    {
-        String messageText;
-        try
-        {
-            if (message instanceof TextMessage)
-            {
-                TextMessage textMessage = (TextMessage) message;
-                messageText = textMessage.getText();
-                System.out.println("messageText = " + messageText);
-                System.out.println("Correlation ID " + message.getJMSCorrelationID());
-
-                _shutdownHook.countDown();
-            }
-            else
-            {
-                System.err.println("Unexpected message delivered");
-            }
-        }
-        catch (JMSException e)
-        {
-            //Handle the exception appropriately
-        }
-    }
-
-    /**
-     * Lookup the specified name in the JNDI Context.
-     *
-     * @param name The string name of the object to lookup
-     *
-     * @return The object or null if nothing exists for specified name
-     */
-    private Object lookupJNDI(String name)
-    {
-        try
-        {
-            return _ctx.lookup(name);
-        }
-        catch (NamingException e)
-        {
-            System.err.println("Error looking up '" + name + "' in JNDI Context:" + e);
-        }
-
-        return null;
-    }
-
-    /**
-     * Setup the JNDI context.
-     *
-     * In this case we are simply using a Properties object to store the pairing information.
-     *
-     * Further details can be found on the wiki site here:
-     *
-     * @see : http://cwiki.apache.org/qpid/how-to-use-jndi.html
-     */
-    private void setupJNDI()
-    {
-        // Set the properties ...
-        Properties properties = new Properties();
-        properties.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
-        properties.put("connectionfactory." + CONNECTION_JNDI_NAME, CONNECTION_NAME);
-        properties.put("queue." + QUEUE_JNDI_NAME, QUEUE_NAME);
-
-        // Create the initial context
-        Context ctx = null;
-        try
-        {
-            _ctx = new InitialContext(properties);
-        }
-        catch (NamingException e)
-        {
-            System.err.println("Error Setting up JNDI Context:" + e);
-        }
-    }
-
-    /** Close the JNDI Context to keep everything happy. */
-    private void closeJNDI()
-    {
-        try
-        {
-            _ctx.close();
-        }
-        catch (NamingException e)
-        {
-            System.err.println("Unable to close JNDI Context : " + e);
-        }
-    }
-
-
-    public static void main(String[] args)
-    {
-        new Client();
-    }
-}
-
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/simple/reqresp/Server.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/simple/reqresp/Server.java
deleted file mode 100644
index 9c284ee..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/simple/reqresp/Server.java
+++ /dev/null
@@ -1,236 +0,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.
- *
- */
-
-package org.apache.qpid.example.simple.reqresp;
-
-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.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
-import java.io.BufferedReader;
-import java.io.BufferedInputStream;
-import java.io.Reader;
-import java.io.InputStreamReader;
-import java.io.IOException;
-
-public class Server implements MessageListener
-{
-    final String BROKER = "localhost";
-
-    final String INITIAL_CONTEXT_FACTORY = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
-
-    final String CONNECTION_JNDI_NAME = "local";
-    final String CONNECTION_NAME = "amqp://guest:guest@clientid/test?brokerlist='" + BROKER + "'";
-
-    final String QUEUE_JNDI_NAME = "queue";
-    final String QUEUE_NAME = "example.RequestQueue";
-
-
-    private InitialContext _ctx;
-    private Session _session;
-    private MessageProducer _replyProducer;
-    private CountDownLatch _shutdownHook = new CountDownLatch(1);
-
-    public Server()
-    {
-        setupJNDI();
-
-        Connection connection;
-        try
-        {
-            connection = ((ConnectionFactory) lookupJNDI(CONNECTION_JNDI_NAME)).createConnection();
-
-            _session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-            Destination requestQueue = (Queue) lookupJNDI(QUEUE_JNDI_NAME);
-
-            closeJNDI();
-
-            //Setup a message producer to respond to messages from clients, we will get the destination
-            //to send to from the JMSReplyTo header field from a Message so we MUST set the destination here to null.
-            this._replyProducer = _session.createProducer(null);
-
-            //Set up a consumer to consume messages off of the request queue
-            MessageConsumer consumer = _session.createConsumer(requestQueue);
-            consumer.setMessageListener(this);
-
-            //Now start the connection
-            connection.start();
-        }
-        catch (JMSException e)
-        {
-            //Handle the exception appropriately
-            System.err.println("JMSException occured setting up server :" + e);
-            return;
-        }
-
-        System.out.println("Server process started and waiting for messages.");
-
-        //Wait to process an single message then quit.
-        while (_shutdownHook.getCount() != 0)
-        {
-            try
-            {
-                _shutdownHook.await();
-            }
-            catch (InterruptedException e)
-            {
-                // Ignore this as we are quitting anyway.
-            }
-        }
-
-        //Close the connection
-        try
-        {
-            connection.close();
-        }
-        catch (JMSException e)
-        {
-            System.err.println("A problem occured while shutting down the connection : " + e);
-        }
-    }
-
-    public void onMessage(Message message)
-    {
-        try
-        {
-            TextMessage response = this._session.createTextMessage();
-
-            //Check we have the right message type.
-            if (message instanceof TextMessage)
-            {
-                TextMessage txtMsg = (TextMessage) message;
-                String messageText = txtMsg.getText();
-
-                //Perform the request
-                System.out.println("Received request:" + messageText + " for message :" + message.getJMSMessageID());
-
-                //Set the response back to the client
-                response.setText("Response to Request:" + messageText);
-            }
-
-            //Set the correlation ID from the received message to be the correlation id of the response message
-            //this lets the client identify which message this is a response to if it has more than
-            //one outstanding message to the server
-            response.setJMSCorrelationID(message.getJMSMessageID());
-
-            try
-            {
-                System.out.println("Received message press enter to send response....");
-                new BufferedReader(new InputStreamReader(System.in)).readLine();
-            }
-            catch (IOException e)
-            {
-                //Error attemptying to pause
-            }
-
-            //Send the response to the Destination specified by the JMSReplyTo field of the received message.            
-            _replyProducer.send(message.getJMSReplyTo(), response);
-        }
-        catch (JMSException e)
-        {
-            //Handle the exception appropriately
-        }
-
-        _shutdownHook.countDown();
-    }
-
-    /**
-     * Lookup the specified name in the JNDI Context.
-     *
-     * @param name The string name of the object to lookup
-     *
-     * @return The object or null if nothing exists for specified name
-     */
-    private Object lookupJNDI(String name)
-    {
-        try
-        {
-            return _ctx.lookup(name);
-        }
-        catch (NamingException e)
-        {
-            System.err.println("Error looking up '" + name + "' in JNDI Context:" + e);
-        }
-
-        return null;
-    }
-
-    /**
-     * Setup the JNDI context.
-     *
-     * In this case we are simply using a Properties object to store the pairing information.
-     *
-     * Further details can be found on the wiki site here:
-     *
-     * @see : http://cwiki.apache.org/qpid/how-to-use-jndi.html
-     */
-    private void setupJNDI()
-    {
-        // Set the properties ...
-        Properties properties = new Properties();
-        properties.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
-        properties.put("connectionfactory." + CONNECTION_JNDI_NAME, CONNECTION_NAME);
-        properties.put("queue." + QUEUE_JNDI_NAME, QUEUE_NAME);
-
-        // Create the initial context
-        Context ctx = null;
-        try
-        {
-            _ctx = new InitialContext(properties);
-        }
-        catch (NamingException e)
-        {
-            System.err.println("Error Setting up JNDI Context:" + e);
-        }
-    }
-
-    /** Close the JNDI Context to keep everything happy. */
-    private void closeJNDI()
-    {
-        try
-        {
-            _ctx.close();
-        }
-        catch (NamingException e)
-        {
-            System.err.println("Unable to close JNDI Context : " + e);
-        }
-    }
-
-
-    public static void main(String[] args)
-    {
-        new Server();
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java
deleted file mode 100644
index e4eb5ac..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java
+++ /dev/null
@@ -1,139 +0,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.
- */
-package org.apache.qpid.example.subscriber;
-
-import org.apache.qpid.example.shared.Statics;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-import javax.jms.*;
-/**
- * Subclass of Subscriber which consumes a heartbeat message
- */
-
-public class MonitoredSubscriber extends Subscriber
-{
-    protected String _monitorDestinationName;
-
-    private static final Logger _logger = LoggerFactory.getLogger(MonitoredSubscriber.class);
-
-    private MessageConsumer _monitorConsumer;
-
-    public MonitoredSubscriber()
-    {
-        super();
-        //lookup queue name and append suffix
-        _monitorDestinationName = _destination.toString() + 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 ...");
-
-            _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());
-        }
-    }
-
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java
deleted file mode 100644
index 5e78107..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java
+++ /dev/null
@@ -1,47 +0,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.
- */
-package org.apache.qpid.example.subscriber;
-
-
-/**
- * Allows you to simply start a monitored subscriber
- */
-public class MonitoredSubscriptionWrapper {
-
-    private static MonitoredSubscriber _subscriber;
-
-    /**
-     * Create a monitored subscriber and start it
-     * @param args - no params required
-     */
-    public static void main(String args[])
-    {      
-        _subscriber = new MonitoredSubscriber();
-
-        _subscriber.subscribe();
-    }
-
-    /**
-     * Stop subscribing now ...
-     */
-    public static void stop()
-    {
-        _subscriber.stop();
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/Subscriber.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/Subscriber.java
deleted file mode 100644
index c366685..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/Subscriber.java
+++ /dev/null
@@ -1,182 +0,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.
- */
-package org.apache.qpid.example.subscriber;
-
-import org.apache.qpid.client.AMQConnectionFactory;
-
-import javax.jms.*;
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.naming.InitialContext;
-
-import org.apache.qpid.example.shared.InitialContextHelper;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-/**
- * Subscriber which consumes messages from a queue
- */
-
-public class Subscriber
-{
-    private static final Logger _log = LoggerFactory.getLogger(Subscriber.class);
-
-    protected Connection _connection;
-
-    protected MessageConsumer _consumer;
-
-    protected InitialContextHelper _contextHelper;
-
-    protected AMQConnectionFactory _connectionFactory;
-
-    protected Destination _destination;
-
-    public Subscriber()
-    {
-        try
-        {
-            //get an initial context from default properties
-            _contextHelper = new InitialContextHelper(null);
-            InitialContext ctx = _contextHelper.getInitialContext();
-
-            //then create a connection using the AMQConnectionFactory
-            _connectionFactory = (AMQConnectionFactory) ctx.lookup("local");
-
-            //lookup queue from context
-            _destination = (Destination) ctx.lookup("MyQueue");
-
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-            _log.error("Exception", e);
-        }
-    }
-
-    /**
-     * Listener class that handles messages
-     */
-    public static class ExampleMessageListener implements MessageListener
-    {
-        private String _name;
-
-        public ExampleMessageListener(String name)
-        {
-            _name = name;
-        }
-
-        /**
-         * Listens for message callbacks, handles and then acknowledges them
-         * @param message - the message received
-         */
-        public void onMessage(javax.jms.Message message)
-        {
-            _log.info(_name + " got message '" + message + "'");
-
-            try
-            {
-                //NB: Handle your message appropriately for your application here
-                //do some stuff
-
-                _log.debug("Acknowledging recieved message");
-
-                //Now acknowledge the message to clear it from our queue
-                message.acknowledge();
-            }
-            catch(JMSException j)
-            {
-                _log.error("JMSException trying to acknowledge message receipt");
-                j.printStackTrace();
-            }
-            catch(Exception e)
-            {
-                _log.error("Unexpected exception trying to handle message");
-                e.printStackTrace();
-            }
-        }
-    }
-
-    /**
-     * Subscribes to example Queue and attaches listener
-     */
-    public void subscribe()
-    {
-        _log.info("Starting subscription ...");
-
-        try
-        {
-             _connection = _connectionFactory.createConnection();
-
-            //Non transactional session using client acknowledgement
-            Session session =  _connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-            //Create a consumer with a destination of our queue which will use defaults for prefetch etc
-            _consumer = session.createConsumer(_destination);
-
-            //give the message listener a name of it's own
-            _consumer.setMessageListener(new ExampleMessageListener("MessageListener " + System.currentTimeMillis()));
-
-            _connection.start();
-        }
-        catch (Throwable t)
-        {
-            _log.error("Fatal error: " + t);
-            t.printStackTrace();
-        }
-
-        _log.info("Waiting for messages ...");
-
-        //wait for messages and sleep to survive failover
-        try
-        {
-            while(true)
-            {
-                Thread.sleep(Long.MAX_VALUE);
-            }
-        }
-        catch (Exception e)
-        {
-            _log.warn("Exception while Subscriber sleeping",e);
-        }
-    }
-
-    /**
-     * Stop consuming and close connection
-     */
-    public void stop()
-    {
-        try
-        {
-            _consumer.close();
-            _consumer = null;
-            _connection.stop();
-            _connection.close();
-        }
-        catch(JMSException j)
-        {
-            _log.error("JMSException trying to Subscriber.stop: " + j.getStackTrace());
-        }
-    }
-
-}
-
-
-
-
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java
deleted file mode 100644
index f8fbf63..0000000
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java
+++ /dev/null
@@ -1,46 +0,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.
- */
-package org.apache.qpid.example.subscriber;
-
-/**
- * Allows you to simply start a subscriber
- */
-public class SubscriptionWrapper {
-
-    private static Subscriber _subscriber;
-
-    /**
-     * Create a subscriber and start it
-     * @param args
-     */
-    public static void main(String args[])
-    {
-         _subscriber = new Subscriber();
-
-        _subscriber.subscribe();
-    }
-
-    /**
-     * Stop subscribing now ...
-     */
-    public static void stop()
-    {
-        _subscriber.stop();
-    }
-}
diff --git a/qpid/java/client/example/src/main/java/runSample.sh b/qpid/java/client/example/src/main/java/runSample.sh
deleted file mode 100755
index 6633855..0000000
--- a/qpid/java/client/example/src/main/java/runSample.sh
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/bash
-
-#
-# 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.
-#
-
-
-# Work out the CLASSPATH divider
-UNAME=`uname -s`
-case $UNAME in
-    CYGWIN*)
-	DIVIDER=";"
-    ;;
-    *)
-	DIVIDER=":"
-;;
-esac
-
-if test "'x$QPID_HOME'" != "'x'"
-then
-    QPID_HOME=$QPID_HOME
-else
-    QPID_HOME="/usr/share/java/"
-fi
-echo "Using QPID_HOME: $QPID_HOME"
-
-if test "'x$QPID_SAMPLE'" != "'x'"
-then
-    QPID_SAMPLE=$QPID_SAMPLE
-else
-    QPID_SAMPLE=$PWD
-fi
-echo "Using QPID_SAMPLE: $QPID_SAMPLE"
-
-
-# set the CLASSPATH
-CLASSPATH=`find "$QPID_HOME" -name '*.jar' | tr '\n' "$DIVIDER"`
-
-
-# compile the samples
-javac -cp  "$CLASSPATH" -sourcepath "$QPID_SAMPLE" -d . `find $QPID_SAMPLE -name '*.java'`
-
-# Add output classes to CLASSPATH
-CLASSPATH="$CLASSPATH$DIVIDER$."
-
-# Set VM parameters
-QPID_PARAM="$QPID_PARAM -Dlog4j.configuration=file://$PWD/log4j.xml"
-
-
-# Check if the user supplied a sample classname
-if test "'x$1'" = "'x'"
-then
-    echo "No sample classname specified"
-    exit;
-else
-    java -cp $CLASSPATH $QPID_PARAM $*
-fi
diff --git a/qpid/java/client/src/main/java/client.bnd b/qpid/java/client/src/main/java/client.bnd
index d92d582..495ea67 100755
--- a/qpid/java/client/src/main/java/client.bnd
+++ b/qpid/java/client/src/main/java/client.bnd
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-ver: 0.15.0
+ver: 0.17.0
 
 Bundle-SymbolicName: qpid-client
 Bundle-Version: ${ver}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
index 8311aa8..c324e22 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
@@ -20,15 +20,14 @@
  */
 package org.apache.qpid.client;
 
-import java.net.URISyntaxException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.messaging.Address;
+import org.apache.qpid.url.BindingURL;
 
 import javax.jms.JMSException;
 import javax.jms.Queue;
 import javax.jms.Topic;
-
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.messaging.Address;
-import org.apache.qpid.url.BindingURL;
+import java.net.URISyntaxException;
 
 /**
  * In order to support JMS 1.0 the Qpid implementation maps the 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java
index b343820..09cb942 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java
@@ -20,16 +20,16 @@
  */
 package org.apache.qpid.client;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.transport.ConnectionSettings;
 import org.apache.qpid.url.URLHelper;
 import org.apache.qpid.url.URLSyntaxException;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+
 public class AMQBrokerDetails implements BrokerDetails
 {
     private String _host;
@@ -264,30 +264,12 @@
     
     public boolean getBooleanProperty(String propName)
     {
-        return getBooleanProperty(propName, false);
-    }
-    
-    public boolean getBooleanProperty(String propName, boolean defaultValue)
-    {
-    	if (_options.containsKey(propName))
-    	{
-            if (_options.get(propName).equalsIgnoreCase("false"))
-            {
-                return false;
-            }
-            else if (_options.get(propName).equalsIgnoreCase("true"))
-            {
-                return true;
-            }
-            else
-            {
-               return defaultValue;
-            }
-    	}
-    	else
-    	{
-    		return defaultValue;
-    	}
+        if (_options.containsKey(propName))
+        {
+            return Boolean.parseBoolean(_options.get(propName));
+        }
+
+        return false;
     }    
 
     public void setTimeout(long timeout)
@@ -319,18 +301,18 @@
 
         BrokerDetails bd = (BrokerDetails) o;
 
-        return _host.equalsIgnoreCase(bd.getHost()) &&
+        return _host.toLowerCase().equals(bd.getHost() == null ? null : bd.getHost().toLowerCase()) &&
                (_port == bd.getPort()) &&
-               _transport.equalsIgnoreCase(bd.getTransport());
+               _transport.toLowerCase().equals(bd.getTransport() == null ? null : bd.getTransport().toLowerCase());
         //TODO do we need to compare all the options as well?
     }
 
     @Override
     public int hashCode()
     {
-        int result = _host != null ? _host.hashCode() : 0;
+        int result = _host != null ? _host.toLowerCase().hashCode() : 0;
         result = 31 * result + _port;
-        result = 31 * result + (_transport != null ? _transport.hashCode() : 0);
+        result = 31 * result + (_transport != null ? _transport.toLowerCase().hashCode() : 0);
         return result;
     }
 
@@ -457,7 +439,7 @@
         if (getProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY) != null)
         {
             conSettings.setTcpNodelay(
-                    getBooleanProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY,true));
+                    getBooleanProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY));
         }
 
         return conSettings;
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
index 6879fe0..1f61e0d 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
@@ -20,42 +20,14 @@
  */
 package org.apache.qpid.client;
 
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.ConnectException;
-import java.net.UnknownHostException;
-import java.nio.channels.UnresolvedAddressException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.ConnectionConsumer;
-import javax.jms.ConnectionMetaData;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.IllegalStateException;
-import javax.jms.JMSException;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueSession;
-import javax.jms.ServerSessionPool;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicSession;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.StringRefAddr;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQConnectionFailureException;
+import org.apache.qpid.AMQDisconnectedException;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQProtocolException;
 import org.apache.qpid.AMQUnresolvedAddressException;
-import org.apache.qpid.AMQDisconnectedException;
 import org.apache.qpid.client.failover.FailoverException;
 import org.apache.qpid.client.failover.FailoverProtectedOperation;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
@@ -76,8 +48,36 @@
 import org.apache.qpid.jms.FailoverPolicy;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.url.URLSyntaxException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.ConnectionConsumer;
+import javax.jms.ConnectionMetaData;
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.IllegalStateException;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueSession;
+import javax.jms.ServerSessionPool;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicSession;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.StringRefAddr;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.ConnectException;
+import java.net.UnknownHostException;
+import java.nio.channels.UnresolvedAddressException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 public class AMQConnection extends Closeable implements Connection, QueueConnection, TopicConnection, Referenceable
 {
@@ -106,7 +106,7 @@
      * the handler deals with this. It also deals with the initial dispatch of any protocol frames to their appropriate
      * handler.
      */
-    protected AMQProtocolHandler _protocolHandler;
+    private AMQProtocolHandler _protocolHandler;
 
     /** Maps from session id (Integer) to AMQSession instance */
     private final ChannelToSessionMap _sessions = new ChannelToSessionMap();
@@ -122,7 +122,7 @@
     /** The virtual path to connect to on the AMQ server */
     private String _virtualHost;
 
-    protected ExceptionListener _exceptionListener;
+    private ExceptionListener _exceptionListener;
 
     private ConnectionListener _connectionListener;
 
@@ -132,15 +132,15 @@
      * Whether this connection is started, i.e. whether messages are flowing to consumers. It has no meaning for message
      * publication.
      */
-    protected volatile boolean _started;
+    private volatile boolean _started;
 
     /** Policy dictating how to failover */
-    protected FailoverPolicy _failoverPolicy;
+    private FailoverPolicy _failoverPolicy;
 
     /*
      * _Connected should be refactored with a suitable wait object.
      */
-    protected boolean _connected;
+    private boolean _connected;
 
     /*
      * The connection meta data
@@ -156,7 +156,7 @@
     private final ExecutorService _taskPool = Executors.newCachedThreadPool();
     private static final long DEFAULT_TIMEOUT = 1000 * 30;
 
-    protected AMQConnectionDelegate _delegate;
+    private AMQConnectionDelegate _delegate;
 
     // this connection maximum number of prefetched messages
     private int _maxPrefetch;
@@ -308,9 +308,9 @@
             _delegate = new AMQConnectionDelegate_0_10(this);
         }
 
-        if (_logger.isInfoEnabled())
+        if (_logger.isDebugEnabled())
         {
-            _logger.info("Connection:" + connectionURL);
+            _logger.debug("Connection:" + connectionURL);
         }
 
         _connectionURL = connectionURL;
@@ -343,14 +343,17 @@
 
         _protocolHandler = new AMQProtocolHandler(this);
 
-        _logger.info("Connecting with ProtocolHandler Version:"+_protocolHandler.getProtocolVersion());
+        if (_logger.isDebugEnabled())
+        {
+        	_logger.debug("Connecting with ProtocolHandler Version:"+_protocolHandler.getProtocolVersion());
+        }
 
         // We are not currently connected
-        _connected = false;
+        setConnected(false);
 
         boolean retryAllowed = true;
         Exception connectionException = null;
-        while (!_connected && retryAllowed && brokerDetails != null)
+        while (!isConnected() && retryAllowed && brokerDetails != null)
         {
             ProtocolVersion pe = null;
             try
@@ -374,7 +377,7 @@
                 // broker
                 initDelegate(pe);
             }
-            else if (!_connected)
+            else if (!isConnected())
             {
                 retryAllowed = _failoverPolicy.failoverAllowed();
                 brokerDetails = _failoverPolicy.getNextBrokerDetails();
@@ -384,10 +387,10 @@
 
         if (_logger.isDebugEnabled())
         {
-            _logger.debug("Are we connected:" + _connected);
+            _logger.debug("Are we connected:" + isConnected());
         }
 
-        if (!_connected)
+        if (!isConnected())
         {
             if (_logger.isDebugEnabled())
             {
@@ -435,7 +438,10 @@
             throw new AMQConnectionFailureException(message, connectionException);
         }
 
-        _logger.info("Connected with ProtocolHandler Version:"+_protocolHandler.getProtocolVersion());
+        if (_logger.isDebugEnabled())
+        {
+        	_logger.debug("Connected with ProtocolHandler Version:"+_protocolHandler.getProtocolVersion());
+        }
 
         _sessions.setMaxChannelID(_delegate.getMaxChannelID());
         _sessions.setMinChannelID(_delegate.getMinChannelID());
@@ -462,7 +468,10 @@
             String delegateClassName = String.format
                                     ("org.apache.qpid.client.AMQConnectionDelegate_%s_%s",
                                      pe.getMajorVersion(), pe.getMinorVersion());
-            _logger.info("Looking up delegate '" + delegateClassName + "' Based on PE:" + pe);
+            if (_logger.isDebugEnabled())
+            {
+            	_logger.debug("Looking up delegate '" + delegateClassName + "' Based on PE:" + pe);
+            }
             Class c = Class.forName(delegateClassName);
             Class partypes[] = new Class[1];
             partypes[0] = AMQConnection.class;
@@ -590,7 +599,7 @@
 
     public boolean failoverAllowed()
     {
-        if (!_connected)
+        if (!isConnected())
         {
             return false;
         }
@@ -729,6 +738,11 @@
 
     }
 
+    protected final ExceptionListener getExceptionListenerNoCheck()
+    {
+        return _exceptionListener;
+    }
+
     public ExceptionListener getExceptionListener() throws JMSException
     {
         checkNotClosed();
@@ -804,13 +818,13 @@
 
     public void close(List<AMQSession> sessions, long timeout) throws JMSException
     {
-        if (!_closed.getAndSet(true))
+        if (!setClosed())
         {
-            _closing.set(true);
+            setClosing(true);
             try{
                 doClose(sessions, timeout);
             }finally{
-                _closing.set(false);
+                setClosing(false);
             }
         }
     }
@@ -963,7 +977,8 @@
     {
         checkNotClosed();
 
-        return null;
+        throw new JmsNotImplementedException();
+
     }
 
     public ConnectionConsumer createConnectionConsumer(Queue queue, String messageSelector, ServerSessionPool sessionPool,
@@ -971,7 +986,7 @@
     {
         checkNotClosed();
 
-        return null;
+        throw new JmsNotImplementedException();
     }
 
     public ConnectionConsumer createConnectionConsumer(Topic topic, String messageSelector, ServerSessionPool sessionPool,
@@ -979,7 +994,7 @@
     {
         checkNotClosed();
 
-        return null;
+        throw new JmsNotImplementedException();
     }
 
     public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector,
@@ -988,7 +1003,7 @@
         // TODO Auto-generated method stub
         checkNotClosed();
 
-        return null;
+        throw new JmsNotImplementedException();
     }
 
     public long getMaximumChannelCount() throws JMSException
@@ -1048,16 +1063,26 @@
         return _virtualHost;
     }
 
-    public AMQProtocolHandler getProtocolHandler()
+    public final AMQProtocolHandler getProtocolHandler()
     {
         return _protocolHandler;
     }
 
-    public boolean started()
+    public final boolean started()
     {
         return _started;
     }
 
+    protected final boolean isConnected()
+    {
+        return _connected;
+    }
+
+    protected final void setConnected(boolean connected)
+    {
+        _connected = connected;
+    }
+
     public void bytesSent(long writtenBytes)
     {
         if (_connectionListener != null)
@@ -1226,8 +1251,8 @@
         if (cause instanceof IOException || cause instanceof AMQDisconnectedException)
         {
             // If we have an IOE/AMQDisconnect there is no connection to close on.
-            _closing.set(false);
-            closer = !_closed.getAndSet(true);
+            setClosing(false);
+            closer = !setClosed();
 
             _protocolHandler.getProtocolSession().notifyError(je);
         }
@@ -1238,7 +1263,7 @@
             // decide if we are going to close the session
             if (hardError(cause))
             {
-                closer = (!_closed.getAndSet(true)) || closer;
+                closer = (!setClosed()) || closer;
                 {
                     _logger.info("Closing AMQConnection due to :" + cause);
                 }
@@ -1489,4 +1514,8 @@
          return _lastFailoverTime;
     }
 
+    protected AMQConnectionDelegate getDelegate()
+    {
+        return _delegate;
+    }
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java
index 7fc1d25..b6f25a2 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java
@@ -20,11 +20,6 @@
  */
 package org.apache.qpid.client;
 
-import java.io.IOException;
-
-import javax.jms.JMSException;
-import javax.jms.XASession;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.failover.FailoverException;
 import org.apache.qpid.client.failover.FailoverProtectedOperation;
@@ -32,6 +27,10 @@
 import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.jms.Session;
 
+import javax.jms.JMSException;
+import javax.jms.XASession;
+import java.io.IOException;
+
 public interface AMQConnectionDelegate
 {
     ProtocolVersion makeBrokerConnection(BrokerDetails brokerDetail) throws IOException, AMQException;
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
index 0ded689..56ee56d 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
@@ -21,16 +21,8 @@
 
 package org.apache.qpid.client;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.XASession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.failover.FailoverException;
@@ -42,6 +34,7 @@
 import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.jms.ChannelLimitReachedException;
 import org.apache.qpid.jms.Session;
+import org.apache.qpid.properties.ConnectionStartProperties;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.transport.Connection;
 import org.apache.qpid.transport.ConnectionClose;
@@ -53,8 +46,16 @@
 import org.apache.qpid.transport.SessionDetachCode;
 import org.apache.qpid.transport.SessionException;
 import org.apache.qpid.transport.TransportException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.XASession;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
 
 public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, ConnectionListener
 {
@@ -71,7 +72,7 @@
     /**
      * The QpidConeection instance that is mapped with this JMS connection.
      */
-    org.apache.qpid.transport.Connection _qpidConnection;
+    private org.apache.qpid.transport.Connection _qpidConnection;
     private ConnectionException exception = null;
 
     //--- constructor
@@ -109,7 +110,7 @@
             session = new AMQSession_0_10(_qpidConnection, _conn, channelId, transacted, acknowledgeMode, prefetchHigh,
                     prefetchLow,name);
             _conn.registerSession(channelId, session);
-            if (_conn._started)
+            if (_conn.started())
             {
                 session.start();
             }
@@ -152,7 +153,7 @@
         {
             session = new XASessionImpl(_qpidConnection, _conn, channelId, prefetchHigh, prefetchLow);
             _conn.registerSession(channelId, session);
-            if (_conn._started)
+            if (_conn.started())
             {
                 session.start();
             }
@@ -164,7 +165,6 @@
         return session;
     }
 
-    @Override
     public XASession createXASession(int ackMode)
         throws JMSException
     {
@@ -182,7 +182,7 @@
         {
             session = new XASessionImpl(_qpidConnection, _conn, channelId, ackMode, (int)_conn.getMaxPrefetch(), (int)_conn.getMaxPrefetch() / 2);
             _conn.registerSession(channelId, session);
-            if (_conn._started)
+            if (_conn.started())
             {
                 session.start();
             }
@@ -218,10 +218,10 @@
             _qpidConnection.setConnectionDelegate(new ClientConnectionDelegate(conSettings, _conn.getConnectionURL()));
             _qpidConnection.connect(conSettings);
 
-            _conn._connected = true;
+            _conn.setConnected(true);
             _conn.setUsername(_qpidConnection.getUserID());
             _conn.setMaximumChannelCount(_qpidConnection.getChannelMax());
-            _conn._failoverPolicy.attainedConnection();
+            _conn.getFailoverPolicy().attainedConnection();
         }
         catch (ProtocolVersionException pe)
         {
@@ -327,7 +327,7 @@
             }
         }
 
-        ExceptionListener listener = _conn._exceptionListener;
+        ExceptionListener listener = _conn.getExceptionListenerNoCheck();
         if (listener == null)
         {
             _logger.error("connection exception: " + conn, exc);
@@ -429,7 +429,7 @@
         Map<String, Object> clientProps = new HashMap<String, Object>();
         try
         {
-            clientProps.put("clientName", _conn.getClientID());
+            clientProps.put(ConnectionStartProperties.CLIENT_ID_0_10, _conn.getClientID());
 	        conSettings.setClientProperties(clientProps);
         }
         catch (JMSException e)
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
index 74a0956..08ee7c3 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
@@ -20,19 +20,8 @@
  */
 package org.apache.qpid.client;
 
-import java.io.IOException;
-import java.net.ConnectException;
-import java.nio.channels.UnresolvedAddressException;
-import java.security.GeneralSecurityException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.jms.JMSException;
-import javax.jms.XASession;
-import javax.net.ssl.SSLContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQTimeoutException;
@@ -60,8 +49,19 @@
 import org.apache.qpid.transport.network.Transport;
 import org.apache.qpid.transport.network.security.SecurityLayer;
 import org.apache.qpid.transport.network.security.SecurityLayerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.JMSException;
+import javax.jms.XASession;
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.net.ConnectException;
+import java.nio.channels.UnresolvedAddressException;
+import java.security.GeneralSecurityException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.Set;
 
 public class AMQConnectionDelegate_8_0 implements AMQConnectionDelegate
 {
@@ -71,30 +71,7 @@
 
     public void closeConnection(long timeout) throws JMSException, AMQException
     {
-        final AMQStateManager stateManager = _conn.getProtocolHandler().getStateManager();
-        final AMQState currentState = stateManager.getCurrentState();
-
-        if (currentState.equals(AMQState.CONNECTION_CLOSED))
-        {
-            _logger.debug("Connection already closed.");
-        }
-        else if (currentState.equals(AMQState.CONNECTION_CLOSING))
-        {
-            _logger.debug("Connection already closing, awaiting closed state.");
-            final StateWaiter closeWaiter = new StateWaiter(stateManager, currentState, EnumSet.of(AMQState.CONNECTION_CLOSED));
-            try
-            {
-                closeWaiter.await(timeout);
-            }
-            catch (AMQTimeoutException te)
-            {
-                throw new AMQTimeoutException("Close did not complete in timely fashion", te);
-            }
-        }
-        else
-        {
-            _conn.getProtocolHandler().closeConnection(timeout);
-        }
+        _conn.getProtocolHandler().closeConnection(timeout);
     }
 
     public AMQConnectionDelegate_8_0(AMQConnection conn)
@@ -120,7 +97,7 @@
                 EnumSet.of(AMQState.CONNECTION_OPEN, AMQState.CONNECTION_CLOSED);
 
 
-        StateWaiter waiter = _conn._protocolHandler.createWaiter(openOrClosedStates);
+        StateWaiter waiter = _conn.getProtocolHandler().createWaiter(openOrClosedStates);
 
         ConnectionSettings settings = brokerDetail.buildConnectionSettings();
         settings.setProtocol(brokerDetail.getTransport());
@@ -133,10 +110,10 @@
                 sslContext = SSLContextFactory.buildClientContext(
                                 settings.getTrustStorePath(),
                                 settings.getTrustStorePassword(),
-                                settings.getTrustStoreCertType(),
+                                settings.getTrustManagerFactoryAlgorithm(),
                                 settings.getKeyStorePath(),
                                 settings.getKeyStorePassword(),
-                                settings.getKeyStoreCertType(),
+                                settings.getKeyManagerFactoryAlgorithm(),
                                 settings.getCertAlias());
             }
             catch (GeneralSecurityException e)
@@ -148,9 +125,9 @@
         SecurityLayer securityLayer = SecurityLayerFactory.newInstance(settings);
 
         OutgoingNetworkTransport transport = Transport.getOutgoingTransportInstance(getProtocolVersion());
-        NetworkConnection network = transport.connect(settings, securityLayer.receiver(_conn._protocolHandler), sslContext);
-        _conn._protocolHandler.setNetworkConnection(network, securityLayer.sender(network.getSender()));
-        _conn._protocolHandler.getProtocolSession().init();
+        NetworkConnection network = transport.connect(settings, securityLayer.receiver(_conn.getProtocolHandler()), sslContext);
+        _conn.getProtocolHandler().setNetworkConnection(network, securityLayer.sender(network.getSender()));
+        _conn.getProtocolHandler().getProtocolSession().init();
         // this blocks until the connection has been set up or when an error
         // has prevented the connection being set up
 
@@ -158,13 +135,13 @@
 
         if(state == AMQState.CONNECTION_OPEN)
         {
-            _conn._failoverPolicy.attainedConnection();
-            _conn._connected = true;
+            _conn.getFailoverPolicy().attainedConnection();
+            _conn.setConnected(true);
             return null;
         }
         else
         {
-            return _conn._protocolHandler.getSuggestedProtocolVersion();
+            return _conn.getProtocolHandler().getSuggestedProtocolVersion();
         }
 
     }
@@ -213,7 +190,6 @@
                         AMQSession session =
                                 new AMQSession_0_8(_conn, channelId, transacted, acknowledgeMode, prefetchHigh,
                                                prefetchLow);
-                        // _protocolHandler.addSessionByChannel(channelId, session);
                         _conn.registerSession(channelId, session);
 
                         boolean success = false;
@@ -237,7 +213,7 @@
                             }
                         }
 
-                        if (_conn._started)
+                        if (_conn.started())
                         {
                             try
                             {
@@ -271,12 +247,12 @@
     {
         ChannelOpenBody channelOpenBody = _conn.getProtocolHandler().getMethodRegistry().createChannelOpenBody(null);
         // TODO: Be aware of possible changes to parameter order as versions change.
-        _conn._protocolHandler.syncWrite(channelOpenBody.generateFrame(channelId),  ChannelOpenOkBody.class);
+        _conn.getProtocolHandler().syncWrite(channelOpenBody.generateFrame(channelId),  ChannelOpenOkBody.class);
 
         // todo send low water mark when protocol allows.
         // todo Be aware of possible changes to parameter order as versions change.
         BasicQosBody basicQosBody = _conn.getProtocolHandler().getMethodRegistry().createBasicQosBody(0,prefetchHigh,false);
-        _conn._protocolHandler.syncWrite(basicQosBody.generateFrame(channelId),BasicQosOkBody.class);
+        _conn.getProtocolHandler().syncWrite(basicQosBody.generateFrame(channelId),BasicQosOkBody.class);
 
         if (transacted)
         {
@@ -287,7 +263,7 @@
             TxSelectBody body = _conn.getProtocolHandler().getMethodRegistry().createTxSelectBody();
 
             // TODO: Be aware of possible changes to parameter order as versions change.
-            _conn._protocolHandler.syncWrite(body.generateFrame(channelId), TxSelectOkBody.class);
+            _conn.getProtocolHandler().syncWrite(body.generateFrame(channelId), TxSelectOkBody.class);
         }
     }
 
@@ -307,7 +283,6 @@
         for (Iterator it = sessions.iterator(); it.hasNext();)
         {
             AMQSession s = (AMQSession) it.next();
-            // _protocolHandler.addSessionByChannel(s.getChannelId(), s);
             reopenChannel(s.getChannelId(), s.getDefaultPrefetchHigh(), s.getDefaultPrefetchLow(), s.isTransacted());
             s.resubscribe();
         }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
index 7000734..e684cf9 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
@@ -20,12 +20,23 @@
  */
 package org.apache.qpid.client;
 
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Hashtable;
-import java.util.UUID;
+import org.apache.qpid.jms.ConnectionURL;
+import org.apache.qpid.url.AMQBindingURL;
+import org.apache.qpid.url.URLSyntaxException;
 
-import javax.jms.*;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.XAConnection;
+import javax.jms.XAConnectionFactory;
+import javax.jms.XAQueueConnection;
+import javax.jms.XAQueueConnectionFactory;
+import javax.jms.XATopicConnection;
+import javax.jms.XATopicConnectionFactory;
 import javax.naming.Context;
 import javax.naming.Name;
 import javax.naming.NamingException;
@@ -34,10 +45,10 @@
 import javax.naming.Referenceable;
 import javax.naming.StringRefAddr;
 import javax.naming.spi.ObjectFactory;
-
-import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.url.AMQBindingURL;
-import org.apache.qpid.url.URLSyntaxException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Hashtable;
+import java.util.UUID;
 
 
 public class AMQConnectionFactory implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory,
@@ -46,12 +57,6 @@
 {
     private final ConnectionURL _connectionDetails;
 
-    // The default constructor is necessary to allow AMQConnectionFactory to be deserialised from JNDI
-    public AMQConnectionFactory()
-    {
-        _connectionDetails = null;
-    }
-
     public AMQConnectionFactory(final String url) throws URLSyntaxException
     {
         if (url == null)
@@ -119,35 +124,27 @@
     
     public Connection createConnection(String userName, String password, String id) throws JMSException
     {
-        if (_connectionDetails != null)
+        try
         {
-            try
+            _connectionDetails.setUsername(userName);
+            _connectionDetails.setPassword(password);
+            
+            if (id != null && !id.equals(""))
             {
-                ConnectionURL connectionDetails = new AMQConnectionURL(_connectionDetails.toString());
-                connectionDetails.setUsername(userName);
-                connectionDetails.setPassword(password);
-                
-                if (id != null && !id.equals(""))
-                {
-                    connectionDetails.setClientName(id);
-                } 
-                else if (connectionDetails.getClientName() == null || connectionDetails.getClientName().equals(""))
-                {
-                    connectionDetails.setClientName(getUniqueClientID());
-                }
-                return new AMQConnection(connectionDetails);
-            }
-            catch (Exception e)
+                _connectionDetails.setClientName(id);
+            } 
+            else if (_connectionDetails.getClientName() == null || _connectionDetails.getClientName().equals(""))
             {
-                JMSException jmse = new JMSException("Error creating connection: " + e.getMessage());
-                jmse.setLinkedException(e);
-                jmse.initCause(e);
-                throw jmse;
+                _connectionDetails.setClientName(getUniqueClientID());
             }
+            return new AMQConnection(_connectionDetails);
         }
-        else
+        catch (Exception e)
         {
-            throw new JMSException("The connection factory wasn't created with a proper URL, the connection details are empty");
+            JMSException jmse = new JMSException("Error creating connection: " + e.getMessage());
+            jmse.setLinkedException(e);
+            jmse.initCause(e);
+            throw jmse;
         }
     }
 
@@ -266,7 +263,7 @@
      *
      * @return A newly created XAConnection
      * @throws JMSException         If creating the XAConnection fails due to some internal error.
-     * @throws JMSSecurityException If client authentication fails due to an invalid user name or password.
+     * @throws javax.jms.JMSSecurityException If client authentication fails due to an invalid user name or password.
      */
     public XAConnection createXAConnection() throws JMSException
     {
@@ -293,36 +290,25 @@
      * @param password the caller's password
      * @return A newly created XAConnection.
      * @throws JMSException         If creating the XAConnection fails due to some internal error.
-     * @throws JMSSecurityException If client authentication fails due to an invalid user name or password.
+     * @throws javax.jms.JMSSecurityException If client authentication fails due to an invalid user name or password.
      */
     public XAConnection createXAConnection(String username, String password) throws JMSException
     {
         if (_connectionDetails != null)
         {
-            try
+            _connectionDetails.setUsername(username);
+            _connectionDetails.setPassword(password);
+
+            if (_connectionDetails.getClientName() == null || _connectionDetails.getClientName().equals(""))
             {
-                ConnectionURL connectionDetails = new AMQConnectionURL(_connectionDetails.toString());
-                connectionDetails.setUsername(username);
-                connectionDetails.setPassword(password);
-    
-                if (connectionDetails.getClientName() == null || connectionDetails.getClientName().equals(""))
-                {
-                    connectionDetails.setClientName(getUniqueClientID());
-                }
-                return new XAConnectionImpl(connectionDetails);
-            }
-            catch (Exception e)
-            {
-                JMSException jmse = new JMSException("Error creating XA Connection: " + e.getMessage());
-                jmse.setLinkedException(e);
-                jmse.initCause(e);
-                throw jmse;
+                _connectionDetails.setClientName(getUniqueClientID());
             }
         }
         else
         {
-            throw new JMSException("The connection factory wasn't created with a proper URL, the connection details are empty");
-        }        
+            throw new JMSException("A URL must be specified to access XA connections");
+        }
+        return createXAConnection();
     }
 
 
@@ -334,7 +320,7 @@
      *
      * @return A newly created XATopicConnection
      * @throws JMSException         If creating the XATopicConnection fails due to some internal error.
-     * @throws JMSSecurityException If client authentication fails due to an invalid user name or password.
+     * @throws javax.jms.JMSSecurityException If client authentication fails due to an invalid user name or password.
      */
     public XATopicConnection createXATopicConnection() throws JMSException
     {
@@ -351,7 +337,7 @@
      * @param password the caller's password
      * @return A newly created XATopicConnection.
      * @throws JMSException         If creating the XATopicConnection fails due to some internal error.
-     * @throws JMSSecurityException If client authentication fails due to an invalid user name or password.
+     * @throws javax.jms.JMSSecurityException If client authentication fails due to an invalid user name or password.
      */
     public XATopicConnection createXATopicConnection(String username, String password) throws JMSException
     {
@@ -366,7 +352,7 @@
      *
      * @return A newly created XAQueueConnection
      * @throws JMSException         If creating the XAQueueConnection fails due to some internal error.
-     * @throws JMSSecurityException If client authentication fails due to an invalid user name or password.
+     * @throws javax.jms.JMSSecurityException If client authentication fails due to an invalid user name or password.
      */
     public XAQueueConnection createXAQueueConnection() throws JMSException
     {
@@ -383,7 +369,7 @@
      * @param password the caller's password
      * @return A newly created XAQueueConnection.
      * @throws JMSException         If creating the XAQueueConnection fails due to some internal error.
-     * @throws JMSSecurityException If client authentication fails due to an invalid user name or password.
+     * @throws javax.jms.JMSSecurityException If client authentication fails due to an invalid user name or password.
      */
     public XAQueueConnection createXAQueueConnection(String username, String password) throws JMSException
     {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java
index ee55eb9..d59f485 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java
@@ -20,11 +20,6 @@
  */
 package org.apache.qpid.client;
 
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.qpid.client.url.URLParser;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.jms.BrokerDetails;
@@ -32,6 +27,11 @@
 import org.apache.qpid.url.URLHelper;
 import org.apache.qpid.url.URLSyntaxException;
 
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
 public class AMQConnectionURL implements ConnectionURL
 {
     private String _url;
@@ -50,7 +50,10 @@
 
     public AMQConnectionURL(String fullURL) throws URLSyntaxException
     {
-        if (fullURL == null) throw new IllegalArgumentException("URL cannot be null");
+        if (fullURL == null)
+        {
+            throw new IllegalArgumentException("URL cannot be null");
+        }
         _url = fullURL;
         _options = new HashMap<String, String>();
         _brokers = new LinkedList<BrokerDetails>();
@@ -273,7 +276,8 @@
         if (_failoverMethod != null)
         {
             sb.append(URLHelper.DEFAULT_OPTION_SEPERATOR);
-            sb.append(OPTIONS_FAILOVER + "='");
+            sb.append(OPTIONS_FAILOVER);
+            sb.append("='");
             sb.append(_failoverMethod);
             sb.append(URLHelper.printOptions(_failoverOptions));
             sb.append("'");
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
index 61fe722..530186b 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
@@ -20,15 +20,8 @@
  */
 package org.apache.qpid.client;
 
-import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.jms.Destination;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.StringRefAddr;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.messaging.address.AddressHelper;
 import org.apache.qpid.client.messaging.address.Link;
@@ -40,23 +33,30 @@
 import org.apache.qpid.url.AMQBindingURL;
 import org.apache.qpid.url.BindingURL;
 import org.apache.qpid.url.URLHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.Destination;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.StringRefAddr;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
 
 
 public abstract class AMQDestination implements Destination, Referenceable
 {
     private static final Logger _logger = LoggerFactory.getLogger(AMQDestination.class);
     
-    protected AMQShortString _exchangeName;
+    private AMQShortString _exchangeName;
 
-    protected AMQShortString _exchangeClass;
+    private AMQShortString _exchangeClass;
 
-    protected boolean _isDurable;
+    private boolean _isDurable;
 
-    protected boolean _isExclusive;
+    private boolean _isExclusive;
 
-    protected boolean _isAutoDelete;
+    private boolean _isAutoDelete;
 
     private boolean _browseOnly;
     
@@ -81,6 +81,41 @@
     public static final int TOPIC_TYPE = 2;
     public static final int UNKNOWN_TYPE = 3;
 
+    protected void setExclusive(boolean exclusive)
+    {
+        _isExclusive = exclusive;
+    }
+
+    protected AddressHelper getAddrHelper()
+    {
+        return _addrHelper;
+    }
+
+    protected void setAddrHelper(AddressHelper addrHelper)
+    {
+        _addrHelper = addrHelper;
+    }
+
+    protected String getName()
+    {
+        return _name;
+    }
+
+    protected void setName(String name)
+    {
+        _name = name;
+    }
+
+    protected Link getTargetLink()
+    {
+        return _targetLink;
+    }
+
+    protected void setTargetLink(Link targetLink)
+    {
+        _targetLink = targetLink;
+    }
+
     // ----- Fields required to support new address syntax -------
     
     public enum DestSyntax {        
@@ -109,31 +144,46 @@
         
       public static AddressOption getOption(String str)
       {
-          if ("always".equals(str)) return ALWAYS;
-          else if ("never".equals(str)) return NEVER;
-          else if ("sender".equals(str)) return SENDER;
-          else if ("receiver".equals(str)) return RECEIVER;
-          else throw new IllegalArgumentException(str + " is not an allowed value");
+          if ("always".equals(str))
+          {
+              return ALWAYS;
+          }
+          else if ("never".equals(str))
+          {
+              return NEVER;
+          }
+          else if ("sender".equals(str))
+          {
+              return SENDER;
+          }
+          else if ("receiver".equals(str))
+          {
+              return RECEIVER;
+          }
+          else
+          {
+              throw new IllegalArgumentException(str + " is not an allowed value");
+          }
       }
     }
     
-    protected final static DestSyntax defaultDestSyntax;
+    private final static DestSyntax defaultDestSyntax;
     
-    protected DestSyntax _destSyntax = DestSyntax.ADDR;
+    private DestSyntax _destSyntax = DestSyntax.ADDR;
 
-    protected AddressHelper _addrHelper;
-    protected Address _address;
-    protected int _addressType = AMQDestination.UNKNOWN_TYPE;
-    protected String _name;
-    protected String _subject;
-    protected AddressOption _create = AddressOption.NEVER;
-    protected AddressOption _assert = AddressOption.NEVER;
-    protected AddressOption _delete = AddressOption.NEVER; 
+    private AddressHelper _addrHelper;
+    private Address _address;
+    private int _addressType = AMQDestination.UNKNOWN_TYPE;
+    private String _name;
+    private String _subject;
+    private AddressOption _create = AddressOption.NEVER;
+    private AddressOption _assert = AddressOption.NEVER;
+    private AddressOption _delete = AddressOption.NEVER;
 
-    protected Node _targetNode;
-    protected Node _sourceNode;
-    protected Link _targetLink;
-    protected Link _link;    
+    private Node _targetNode;
+    private Node _sourceNode;
+    private Link _targetLink;
+    private Link _link;
         
     // ----- / Fields required to support new address syntax -------
     
@@ -543,7 +593,7 @@
         {
             return true;
         }
-        if (o == null || getClass() != o.getClass())
+        if (!(o instanceof AMQDestination))
         {
             return false;
         }
@@ -572,7 +622,6 @@
         int result;
         result = _exchangeName == null ? "".hashCode() : _exchangeName.hashCode();
         result = 29 * result + (_exchangeClass == null ? "".hashCode() :_exchangeClass.hashCode());
-        //result = 29 * result + _destinationName.hashCode();
         if (_queueName != null)
         {
             result = 29 * result + _queueName.hashCode();
@@ -631,10 +680,10 @@
     
     public static class Binding
     {
-        String exchange;
-        String bindingKey;
-        String queue;
-        Map<String,Object> args;
+        private String exchange;
+        private String bindingKey;
+        private String queue;
+        private Map<String,Object> args;
         
         public Binding(String exchange,
                        String queue,
@@ -887,4 +936,5 @@
         return _rejectBehaviour;
     }
 
+
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueue.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueue.java
index 5ecb5d5..4e9b53c 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueue.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueue.java
@@ -20,14 +20,13 @@
  */
 package org.apache.qpid.client;
 
-import java.net.URISyntaxException;
-
-import javax.jms.Queue;
-
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.url.BindingURL;
 
+import javax.jms.Queue;
+import java.net.URISyntaxException;
+
 public class AMQQueue extends AMQDestination implements Queue
 {
     protected AMQQueue()
@@ -156,7 +155,6 @@
 
     public AMQShortString getRoutingKey()
     {
-        //return getAMQQueueName();
         if (getAMQQueueName() != null && getAMQQueueName().equals(super.getRoutingKey()))
         {
             return getAMQQueueName();
@@ -173,4 +171,10 @@
         //remain valid if we failover (see BLZ-24)
         return getQueueName() == null;
     }
+
+    @Override
+    public boolean equals(Object o)
+    {
+        return super.equals(o) && o instanceof Queue;
+    }
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java
index 3f9eade..0c6031e 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java
@@ -20,6 +20,12 @@
  */
 package org.apache.qpid.client;
 
+import javax.jms.InvalidDestinationException;
+import javax.jms.InvalidSelectorException;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.AMQInternalException;
+import org.apache.qpid.client.filter.JMSSelectorFilter;
+import org.apache.qpid.protocol.AMQConstant;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,21 +45,59 @@
 
     private AtomicBoolean _isClosed = new AtomicBoolean();
     private final AMQSession _session;
-    private final AMQQueue _queue;
+    private final Queue _queue;
     private final ArrayList<BasicMessageConsumer> _consumers = new ArrayList<BasicMessageConsumer>();
     private final String _messageSelector;
 
-    AMQQueueBrowser(AMQSession session, AMQQueue queue, String messageSelector) throws JMSException
+    AMQQueueBrowser(AMQSession session, Queue queue, String messageSelector) throws JMSException
     {
         _session = session;
         _queue = queue;
         _messageSelector = ((messageSelector == null) || (messageSelector.trim().length() == 0)) ? null : messageSelector;
-        // Create Consumer to verify message selector.
-        BasicMessageConsumer consumer =
-                (BasicMessageConsumer) _session.createBrowserConsumer(_queue, _messageSelector, false);
-        // Close this consumer as we are not looking to consume only to establish that, at least for now,
-        // the QB can be created
-        consumer.close();
+
+
+        validateQueue((AMQDestination) queue);
+
+        if(_messageSelector != null)
+        {
+            validateSelector(_messageSelector);
+        }
+    }
+
+    private void validateSelector(String messageSelector) throws InvalidSelectorException
+    {
+        try
+        {
+            new JMSSelectorFilter(messageSelector);
+        }
+        catch (AMQInternalException e)
+        {
+            throw new InvalidSelectorException(e.getMessage());
+        }
+    }
+
+    private void validateQueue(AMQDestination queue) throws JMSException
+    {
+        try
+        {
+            // Essentially just test the connection/session is still active
+            _session.sync();
+            // TODO - should really validate queue exists, but we often rely on creating the consumer to create the queue :(
+            // _session.declareQueuePassive( queue );
+        }
+        catch (AMQException e)
+        {
+            if(e.getErrorCode() == AMQConstant.NOT_FOUND)
+            {
+                throw new InvalidDestinationException(e.getMessage());
+            }
+            else
+            {
+                final JMSException jmsException = new JMSException(e.getMessage(), String.valueOf(e.getErrorCode().getCode()));
+                jmsException.setLinkedException(e);
+                throw jmsException;
+            }
+        }
     }
 
     public Queue getQueue() throws JMSException
@@ -88,6 +132,10 @@
     public Enumeration getEnumeration() throws JMSException
     {
         checkState();
+        if(!_session.getAMQConnection().started())
+        {
+            throw new IllegalStateException("Cannot enumerate message on the queue while the Connection is stopped");
+        }
         final BasicMessageConsumer consumer =
                 (BasicMessageConsumer) _session.createBrowserConsumer(_queue, _messageSelector, false);
 
@@ -108,7 +156,7 @@
 
     private class QueueBrowserEnumeration implements Enumeration
     {
-        Message _nextMessage;
+        private Message _nextMessage;
         private BasicMessageConsumer _consumer;
 
         public QueueBrowserEnumeration(BasicMessageConsumer consumer) throws JMSException
@@ -118,12 +166,12 @@
                 _consumer = consumer;
                 prefetchMessage();
             }
-            _logger.info("QB:created with first element:" + _nextMessage);
+            _logger.debug("QB:created with first element:" + _nextMessage);
         }
 
         public boolean hasMoreElements()
         {
-            _logger.info("QB:hasMoreElements:" + (_nextMessage != null));
+            _logger.debug("QB:hasMoreElements:" + (_nextMessage != null));
             return (_nextMessage != null);
         }
 
@@ -136,9 +184,9 @@
             }
             try
             {
-                _logger.info("QB:nextElement about to receive");
+                _logger.debug("QB:nextElement about to receive");
                 prefetchMessage();
-                _logger.info("QB:nextElement received:" + _nextMessage);
+                _logger.debug("QB:nextElement received:" + _nextMessage);
             }
             catch (JMSException e)
             {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueSessionAdaptor.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueSessionAdaptor.java
index a8c83d8..c8cb49b 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueSessionAdaptor.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueSessionAdaptor.java
@@ -20,185 +20,64 @@
  */
 package org.apache.qpid.client;
 
-import java.io.Serializable;
-
-import javax.jms.BytesMessage;
-import javax.jms.Destination;
+import javax.jms.*;
 import javax.jms.IllegalStateException;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.QueueBrowser;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSender;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TemporaryQueue;
-import javax.jms.TemporaryTopic;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicSubscriber;
 
 /**
  * Need this adaptor class to conform to JMS spec and throw IllegalStateException
  * from createDurableSubscriber, unsubscribe, createTopic & createTemporaryTopic
  */
-public class AMQQueueSessionAdaptor implements QueueSession, AMQSessionAdapter
+class AMQQueueSessionAdaptor extends AMQSessionAdapter<QueueSession> implements QueueSession
 {
-    //holds a session for delegation
-    protected final AMQSession _session;
-
     /**
      * Construct an adaptor with a session to wrap
      * @param session
      */
-    public AMQQueueSessionAdaptor(Session session)
+    protected AMQQueueSessionAdaptor(QueueSession session)
     {
-        _session = (AMQSession) session;
+        super(session);
     }
 
-    public TemporaryQueue createTemporaryQueue() throws JMSException {
-        return _session.createTemporaryQueue();
+    public QueueReceiver createReceiver(Queue queue) throws JMSException
+    {
+        return getSession().createReceiver(queue);
     }
 
-    public Queue createQueue(String string) throws JMSException {
-        return _session.createQueue(string);
+    public QueueReceiver createReceiver(Queue queue, String string) throws JMSException
+    {
+        return getSession().createReceiver(queue, string);
     }
 
-    public QueueReceiver createReceiver(Queue queue) throws JMSException {
-        return _session.createReceiver(queue);
-    }
-
-    public QueueReceiver createReceiver(Queue queue, String string) throws JMSException {
-        return _session.createReceiver(queue, string);
-    }
-
-    public QueueSender createSender(Queue queue) throws JMSException {
-        return _session.createSender(queue);
-    }
-
-    public QueueBrowser createBrowser(Queue queue) throws JMSException {
-        return _session.createBrowser(queue);
-    }
-
-    public QueueBrowser createBrowser(Queue queue, String string) throws JMSException {
-        return _session.createBrowser(queue, string);
-    }
-
-    public BytesMessage createBytesMessage() throws JMSException {
-        return _session.createBytesMessage();
-    }
-
-    public MapMessage createMapMessage() throws JMSException {
-        return _session.createMapMessage();
-    }
-
-    public Message createMessage() throws JMSException {
-        return _session.createMessage();
-    }
-
-    public ObjectMessage createObjectMessage() throws JMSException {
-        return _session.createObjectMessage();
-    }
-
-    public ObjectMessage createObjectMessage(Serializable serializable) throws JMSException {
-        return _session.createObjectMessage(serializable);
-    }
-
-    public StreamMessage createStreamMessage() throws JMSException {
-        return _session.createStreamMessage();
-    }
-
-    public TextMessage createTextMessage() throws JMSException {
-        return _session.createTextMessage();
-    }
-
-    public TextMessage createTextMessage(String string) throws JMSException {
-        return _session.createTextMessage(string);
-    }
-
-    public boolean getTransacted() throws JMSException {
-        return _session.getTransacted();
-    }
-
-    public int getAcknowledgeMode() throws JMSException {
-       return _session.getAcknowledgeMode();
-    }
-
-    public void commit() throws JMSException {
-        _session.commit();
-    }
-
-    public void rollback() throws JMSException {
-        _session.rollback();
-    }
-
-    public void close() throws JMSException {
-        _session.close();
-    }
-
-    public void recover() throws JMSException {
-        _session.recover();
-    }
-
-    public MessageListener getMessageListener() throws JMSException {
-       return _session.getMessageListener();
-    }
-
-    public void setMessageListener(MessageListener messageListener) throws JMSException {
-        _session.setMessageListener(messageListener);
-    }
-
-    public void run() {
-        _session.run();
-    }
-
-    public MessageProducer createProducer(Destination destination) throws JMSException {
-        return _session.createProducer(destination);
-    }
-
-    public MessageConsumer createConsumer(Destination destination) throws JMSException {
-        return _session.createConsumer(destination);
-    }
-
-    public MessageConsumer createConsumer(Destination destination, String string) throws JMSException {
-        return _session.createConsumer(destination,string);
-    }
-
-    public MessageConsumer createConsumer(Destination destination, String string, boolean b) throws JMSException {
-        return _session.createConsumer(destination,string,b);
+    public QueueSender createSender(Queue queue) throws JMSException
+    {
+        return getSession().createSender(queue);
     }
 
     //The following methods cannot be called from a QueueSession as per JMS spec
 
-    public Topic createTopic(String string) throws JMSException {
+    public Topic createTopic(String string) throws JMSException
+    {
         throw new IllegalStateException("Cannot call createTopic from QueueSession");
     }
 
-    public TopicSubscriber createDurableSubscriber(Topic topic, String string) throws JMSException {
+    public TopicSubscriber createDurableSubscriber(Topic topic, String string) throws JMSException
+    {
         throw new IllegalStateException("Cannot call createDurableSubscriber from QueueSession");
     }
 
-    public TopicSubscriber createDurableSubscriber(Topic topic, String string, String string1, boolean b) throws JMSException {
+    public TopicSubscriber createDurableSubscriber(Topic topic, String string, String string1, boolean b) throws JMSException
+    {
          throw new IllegalStateException("Cannot call createDurableSubscriber from QueueSession");
     }
 
-    public TemporaryTopic createTemporaryTopic() throws JMSException {
+    public TemporaryTopic createTemporaryTopic() throws JMSException
+    {
         throw new IllegalStateException("Cannot call createTemporaryTopic from QueueSession");
     }
 
-    public void unsubscribe(String string) throws JMSException {
+    public void unsubscribe(String string) throws JMSException
+    {
         throw new IllegalStateException("Cannot call unsubscribe from QueueSession");
     }
 
-    public AMQSession getSession()
-    {
-        return _session;
-    }
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
index 48c4e3e..efc5982 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
@@ -20,50 +20,8 @@
  */
 package org.apache.qpid.client;
 
-import java.io.Serializable;
-import java.net.URISyntaxException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-import javax.jms.BytesMessage;
-import javax.jms.Destination;
-import javax.jms.IllegalStateException;
-import javax.jms.InvalidDestinationException;
-import javax.jms.InvalidSelectorException;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.QueueBrowser;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSender;
-import javax.jms.QueueSession;
-import javax.jms.StreamMessage;
-import javax.jms.TemporaryQueue;
-import javax.jms.TemporaryTopic;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicPublisher;
-import javax.jms.TopicSession;
-import javax.jms.TopicSubscriber;
-import javax.jms.TransactionRolledBackException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQChannelClosedException;
 import org.apache.qpid.AMQDisconnectedException;
@@ -89,7 +47,7 @@
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
 import org.apache.qpid.client.util.FlowControllingBlockingQueue;
 import org.apache.qpid.common.AMQPFilterTypes;
-import org.apache.qpid.filter.MessageFilter;
+import org.apache.qpid.configuration.ClientProperties;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.framing.MethodRegistry;
@@ -98,8 +56,27 @@
 import org.apache.qpid.thread.Threading;
 import org.apache.qpid.transport.SessionException;
 import org.apache.qpid.transport.TransportException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.*;
+import javax.jms.IllegalStateException;
+import java.io.Serializable;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
 
 /**
  * <p/><table id="crc"><caption>CRC Card</caption>
@@ -119,6 +96,237 @@
  */
 public abstract class AMQSession<C extends BasicMessageConsumer, P extends BasicMessageProducer> extends Closeable implements Session, QueueSession, TopicSession
 {
+    /** Used for debugging. */
+    private static final Logger _logger = LoggerFactory.getLogger(AMQSession.class);
+
+    /** System property to enable strict AMQP compliance. */
+    public static final String STRICT_AMQP = "STRICT_AMQP";
+
+    /** Strict AMQP default setting. */
+    public static final String STRICT_AMQP_DEFAULT = "false";
+
+    /** System property to enable failure if strict AMQP compliance is violated. */
+    public static final String STRICT_AMQP_FATAL = "STRICT_AMQP_FATAL";
+
+    /** Strickt AMQP failure default. */
+    public static final String STRICT_AMQP_FATAL_DEFAULT = "true";
+
+    /** System property to enable immediate message prefetching. */
+    public static final String IMMEDIATE_PREFETCH = "IMMEDIATE_PREFETCH";
+
+    /** Immediate message prefetch default. */
+    public static final String IMMEDIATE_PREFETCH_DEFAULT = "false";
+
+    public static final long DEFAULT_FLOW_CONTROL_WAIT_FAILURE = 120000L;
+
+    /**
+     * The period to wait while flow controlled before sending a log message confirming that the session is still
+     * waiting on flow control being revoked
+     */
+    private final long _flowControlWaitPeriod = Long.getLong("qpid.flow_control_wait_notify_period",5000L);
+
+    /**
+     * The period to wait while flow controlled before declaring a failure
+     */
+    private final long _flowControlWaitFailure = Long.getLong("qpid.flow_control_wait_failure",
+                                                                  DEFAULT_FLOW_CONTROL_WAIT_FAILURE);
+
+    private final boolean _delareQueues =
+        Boolean.parseBoolean(System.getProperty("qpid.declare_queues", "true"));
+
+    private final boolean _declareExchanges =
+        Boolean.parseBoolean(System.getProperty("qpid.declare_exchanges", "true"));
+
+    private final boolean _useAMQPEncodedMapMessage;
+
+    /**
+     * Flag indicating to start dispatcher as a daemon thread
+     */
+    protected final boolean DEAMON_DISPATCHER_THREAD = Boolean.getBoolean(ClientProperties.DAEMON_DISPATCHER);
+
+    /** The connection to which this session belongs. */
+    private AMQConnection _connection;
+
+    /** Used to indicate whether or not this is a transactional session. */
+    private final boolean _transacted;
+
+    /** Holds the sessions acknowledgement mode. */
+    private final int _acknowledgeMode;
+
+    /** Holds this session unique identifier, used to distinguish it from other sessions. */
+    private int _channelId;
+
+    private int _ticket;
+
+    /** Holds the high mark for prefetched message, at which the session is suspended. */
+    private int _prefetchHighMark;
+
+    /** Holds the low mark for prefetched messages, below which the session is resumed. */
+    private int _prefetchLowMark;
+
+    /** Holds the message listener, if any, which is attached to this session. */
+    private MessageListener _messageListener = null;
+
+    /** Used to indicate that this session has been started at least once. */
+    private AtomicBoolean _startedAtLeastOnce = new AtomicBoolean(false);
+
+    private final ConcurrentHashMap<String, TopicSubscriberAdaptor<C>> _subscriptions =
+            new ConcurrentHashMap<String, TopicSubscriberAdaptor<C>>();
+
+    private final ConcurrentHashMap<C, String> _reverseSubscriptionMap = new ConcurrentHashMap<C, String>();
+
+    private final Lock _subscriberDetails = new ReentrantLock(true);
+    private final Lock _subscriberAccess = new ReentrantLock(true);
+
+    private final FlowControllingBlockingQueue _queue;
+
+    private final AtomicLong _highestDeliveryTag = new AtomicLong(-1);
+    private final AtomicLong _rollbackMark = new AtomicLong(-1);
+
+    private ConcurrentLinkedQueue<Long> _prefetchedMessageTags = new ConcurrentLinkedQueue<Long>();
+
+    private ConcurrentLinkedQueue<Long> _unacknowledgedMessageTags = new ConcurrentLinkedQueue<Long>();
+
+    private ConcurrentLinkedQueue<Long> _deliveredMessageTags = new ConcurrentLinkedQueue<Long>();
+
+    private volatile Dispatcher _dispatcher;
+
+    private volatile Thread _dispatcherThread;
+
+    private MessageFactoryRegistry _messageFactoryRegistry;
+
+    /** Holds all of the producers created by this session, keyed by their unique identifiers. */
+    private Map<Long, MessageProducer> _producers = new ConcurrentHashMap<Long, MessageProducer>();
+
+    /**
+     * Used as a source of unique identifiers so that the consumers can be tagged to match them to BasicConsume
+     * methods.
+     */
+    private int _nextTag = 1;
+
+    private final IdToConsumerMap<C> _consumers = new IdToConsumerMap<C>();
+
+    /**
+     * Contains a list of consumers which have been removed but which might still have
+     * messages to acknowledge, eg in client ack or transacted modes
+     */
+    private CopyOnWriteArrayList<C> _removedConsumers = new CopyOnWriteArrayList<C>();
+
+    /** Provides a count of consumers on destinations, in order to be able to know if a destination has consumers. */
+    private ConcurrentHashMap<Destination, AtomicInteger> _destinationConsumerCount =
+            new ConcurrentHashMap<Destination, AtomicInteger>();
+
+    /**
+     * Used as a source of unique identifiers for producers within the session.
+     *
+     * <p/> Access to this id does not require to be synchronized since according to the JMS specification only one
+     * thread of control is allowed to create producers for any given session instance.
+     */
+    private long _nextProducerId;
+
+    /**
+     * Set when recover is called. This is to handle the case where recover() is called by application code during
+     * onMessage() processing to ensure that an auto ack is not sent.
+     */
+    private volatile boolean _sessionInRecovery;
+
+    private volatile boolean _usingDispatcherForCleanup;
+
+    /** Used to indicates that the connection to which this session belongs, has been stopped. */
+    private boolean _connectionStopped;
+
+    /** Used to indicate that this session has a message listener attached to it. */
+    private boolean _hasMessageListeners;
+
+    /** Used to indicate that this session has been suspended. */
+    private boolean _suspended;
+
+    /**
+     * Used to protect the suspension of this session, so that critical code can be executed during suspension,
+     * without the session being resumed by other threads.
+     */
+    private final Object _suspensionLock = new Object();
+
+    private final AtomicBoolean _firstDispatcher = new AtomicBoolean(true);
+
+    private final boolean _immediatePrefetch;
+
+    private final boolean _strictAMQP;
+
+    private final boolean _strictAMQPFATAL;
+    private final Object _messageDeliveryLock = new Object();
+
+    /** Session state : used to detect if commit is a) required b) allowed , i.e. does the tx span failover. */
+    private boolean _dirty;
+    /** Has failover occured on this session with outstanding actions to commit? */
+    private boolean _failedOverDirty;
+
+    /** Flow control */
+    private FlowControlIndicator _flowControl = new FlowControlIndicator();
+
+
+
+    /** Holds the highest received delivery tag. */
+    protected AtomicLong getHighestDeliveryTag()
+    {
+        return _highestDeliveryTag;
+    }
+
+    /** Pre-fetched message tags */
+    protected ConcurrentLinkedQueue<Long> getPrefetchedMessageTags()
+    {
+        return _prefetchedMessageTags;
+    }
+
+    /** All the not yet acknowledged message tags */
+    protected ConcurrentLinkedQueue<Long> getUnacknowledgedMessageTags()
+    {
+        return _unacknowledgedMessageTags;
+    }
+
+    /** All the delivered message tags */
+    protected ConcurrentLinkedQueue<Long> getDeliveredMessageTags()
+    {
+        return _deliveredMessageTags;
+    }
+
+    /** Holds the dispatcher thread for this session. */
+    protected Dispatcher getDispatcher()
+    {
+        return _dispatcher;
+    }
+
+    protected Thread getDispatcherThread()
+    {
+        return _dispatcherThread;
+    }
+
+    /** Holds the message factory factory for this session. */
+    protected MessageFactoryRegistry getMessageFactoryRegistry()
+    {
+        return _messageFactoryRegistry;
+    }
+
+    /**
+     * Maps from identifying tags to message consumers, in order to pass dispatch incoming messages to the right
+     * consumer.
+     */
+    protected IdToConsumerMap<C> getConsumers()
+    {
+        return _consumers;
+    }
+
+    protected void setUsingDispatcherForCleanup(boolean usingDispatcherForCleanup)
+    {
+        _usingDispatcherForCleanup = usingDispatcherForCleanup;
+    }
+
+    /** Used to indicate that the session should start pre-fetching messages as soon as it is started. */
+    protected boolean isImmediatePrefetch()
+    {
+        return _immediatePrefetch;
+    }
+
     public static final class IdToConsumerMap<C extends BasicMessageConsumer>
     {
         private final BasicMessageConsumer[] _fastAccessConsumers = new BasicMessageConsumer[16];
@@ -196,220 +404,6 @@
         }
     }
 
-    final AMQSession<C, P> _thisSession = this;
-    
-    /** Used for debugging. */
-    private static final Logger _logger = LoggerFactory.getLogger(AMQSession.class);
-
-    /**
-     * The default value for immediate flag used by producers created by this session is false. That is, a consumer does
-     * not need to be attached to a queue.
-     */
-    protected final boolean DEFAULT_IMMEDIATE = Boolean.parseBoolean(System.getProperty("qpid.default_immediate", "false"));
-
-    /**
-     * The default value for mandatory flag used by producers created by this session is true. That is, server will not
-     * silently drop messages where no queue is connected to the exchange for the message.
-     */
-    protected final boolean DEFAULT_MANDATORY = Boolean.parseBoolean(System.getProperty("qpid.default_mandatory", "true"));
-
-    /**
-     * The period to wait while flow controlled before sending a log message confirming that the session is still
-     * waiting on flow control being revoked
-     */
-    protected final long FLOW_CONTROL_WAIT_PERIOD = Long.getLong("qpid.flow_control_wait_notify_period",5000L);
-
-    /**
-     * The period to wait while flow controlled before declaring a failure
-     */
-    public static final long DEFAULT_FLOW_CONTROL_WAIT_FAILURE = 120000L;
-    protected final long FLOW_CONTROL_WAIT_FAILURE = Long.getLong("qpid.flow_control_wait_failure",
-                                                                  DEFAULT_FLOW_CONTROL_WAIT_FAILURE);
-
-    protected final boolean DECLARE_QUEUES =
-        Boolean.parseBoolean(System.getProperty("qpid.declare_queues", "true"));
-
-    protected final boolean DECLARE_EXCHANGES =
-        Boolean.parseBoolean(System.getProperty("qpid.declare_exchanges", "true"));
-    
-    protected final boolean USE_AMQP_ENCODED_MAP_MESSAGE;
-
-    /** System property to enable strict AMQP compliance. */
-    public static final String STRICT_AMQP = "STRICT_AMQP";
-
-    /** Strict AMQP default setting. */
-    public static final String STRICT_AMQP_DEFAULT = "false";
-
-    /** System property to enable failure if strict AMQP compliance is violated. */
-    public static final String STRICT_AMQP_FATAL = "STRICT_AMQP_FATAL";
-
-    /** Strickt AMQP failure default. */
-    public static final String STRICT_AMQP_FATAL_DEFAULT = "true";
-
-    /** System property to enable immediate message prefetching. */
-    public static final String IMMEDIATE_PREFETCH = "IMMEDIATE_PREFETCH";
-
-    /** Immediate message prefetch default. */
-    public static final String IMMEDIATE_PREFETCH_DEFAULT = "false";
-
-    /** The connection to which this session belongs. */
-    protected AMQConnection _connection;
-
-    /** Used to indicate whether or not this is a transactional session. */
-    protected final boolean _transacted;
-
-    /** Holds the sessions acknowledgement mode. */
-    protected final int _acknowledgeMode;
-
-    /** Holds this session unique identifier, used to distinguish it from other sessions. */
-    protected int _channelId;
-
-    private int _ticket;
-
-    /** Holds the high mark for prefetched message, at which the session is suspended. */
-    private int _prefetchHighMark;
-
-    /** Holds the low mark for prefetched messages, below which the session is resumed. */
-    private int _prefetchLowMark;
-
-    /** Holds the message listener, if any, which is attached to this session. */
-    private MessageListener _messageListener = null;
-
-    /** Used to indicate that this session has been started at least once. */
-    private AtomicBoolean _startedAtLeastOnce = new AtomicBoolean(false);
-
-    /**
-     * Used to reference durable subscribers so that requests for unsubscribe can be handled correctly.  Note this only
-     * keeps a record of subscriptions which have been created in the current instance. It does not remember
-     * subscriptions between executions of the client.
-     */
-    protected final ConcurrentHashMap<String, TopicSubscriberAdaptor<C>> _subscriptions =
-            new ConcurrentHashMap<String, TopicSubscriberAdaptor<C>>();
-
-    /**
-     * Holds a mapping from message consumers to their identifying names, so that their subscriptions may be looked
-     * up in the {@link #_subscriptions} map.
-     */
-    protected final ConcurrentHashMap<C, String> _reverseSubscriptionMap = new ConcurrentHashMap<C, String>();
-
-    /**
-     * Locks to keep access to subscriber details atomic.
-     * <p>
-     * Added for QPID2418
-     */
-    protected final Lock _subscriberDetails = new ReentrantLock(true);
-    protected final Lock _subscriberAccess = new ReentrantLock(true);
-
-    /**
-     * Used to hold incoming messages.
-     *
-     * @todo Weaken the type once {@link FlowControllingBlockingQueue} implements Queue.
-     */
-    protected final FlowControllingBlockingQueue _queue;
-
-    /** Holds the highest received delivery tag. */
-    protected final AtomicLong _highestDeliveryTag = new AtomicLong(-1);
-    private final AtomicLong _rollbackMark = new AtomicLong(-1);
-
-    /** Pre-fetched message tags */
-    protected ConcurrentLinkedQueue<Long> _prefetchedMessageTags = new ConcurrentLinkedQueue<Long>();
-
-    /** All the not yet acknowledged message tags */
-    protected ConcurrentLinkedQueue<Long> _unacknowledgedMessageTags = new ConcurrentLinkedQueue<Long>();
-
-    /** All the delivered message tags */
-    protected ConcurrentLinkedQueue<Long> _deliveredMessageTags = new ConcurrentLinkedQueue<Long>();
-
-    /** Holds the dispatcher thread for this session. */
-    protected Dispatcher _dispatcher;
-
-    protected Thread _dispatcherThread;
-
-    /** Holds the message factory factory for this session. */
-    protected MessageFactoryRegistry _messageFactoryRegistry;
-
-    /** Holds all of the producers created by this session, keyed by their unique identifiers. */
-    private Map<Long, MessageProducer> _producers = new ConcurrentHashMap<Long, MessageProducer>();
-
-    /**
-     * Used as a source of unique identifiers so that the consumers can be tagged to match them to BasicConsume
-     * methods.
-     */
-    private int _nextTag = 1;
-
-    /**
-     * Maps from identifying tags to message consumers, in order to pass dispatch incoming messages to the right
-     * consumer.
-     */
-    protected final IdToConsumerMap<C> _consumers = new IdToConsumerMap<C>();
-
-    /**
-     * Contains a list of consumers which have been removed but which might still have
-     * messages to acknowledge, eg in client ack or transacted modes
-     */
-    private CopyOnWriteArrayList<C> _removedConsumers = new CopyOnWriteArrayList<C>();
-
-    /** Provides a count of consumers on destinations, in order to be able to know if a destination has consumers. */
-    private ConcurrentHashMap<Destination, AtomicInteger> _destinationConsumerCount =
-            new ConcurrentHashMap<Destination, AtomicInteger>();
-
-    /**
-     * Used as a source of unique identifiers for producers within the session.
-     *
-     * <p/> Access to this id does not require to be synchronized since according to the JMS specification only one
-     * thread of control is allowed to create producers for any given session instance.
-     */
-    private long _nextProducerId;
-
-    /**
-     * Set when recover is called. This is to handle the case where recover() is called by application code during
-     * onMessage() processing to ensure that an auto ack is not sent.
-     */
-    private volatile boolean _sessionInRecovery;
-
-    /**
-     * Set when the dispatcher should direct incoming messages straight into the UnackedMessage list instead of
-     * to the syncRecieveQueue or MessageListener. Used during cleanup, e.g. in Session.recover().
-     */
-    private volatile boolean _usingDispatcherForCleanup;
-
-    /** Used to indicates that the connection to which this session belongs, has been stopped. */
-    private boolean _connectionStopped;
-
-    /** Used to indicate that this session has a message listener attached to it. */
-    private boolean _hasMessageListeners;
-
-    /** Used to indicate that this session has been suspended. */
-    private boolean _suspended;
-
-    /**
-     * Used to protect the suspension of this session, so that critical code can be executed during suspension,
-     * without the session being resumed by other threads.
-     */
-    private final Object _suspensionLock = new Object();
-
-    /**
-     * Used to ensure that only the first call to start the dispatcher can unsuspend the channel.
-     *
-     * @todo This is accessed only within a synchronized method, so does not need to be atomic.
-     */
-    protected final AtomicBoolean _firstDispatcher = new AtomicBoolean(true);
-
-    /** Used to indicate that the session should start pre-fetching messages as soon as it is started. */
-    protected final boolean _immediatePrefetch;
-
-    /** Indicates that warnings should be generated on violations of the strict AMQP. */
-    protected final boolean _strictAMQP;
-
-    /** Indicates that runtime exceptions should be generated on vilations of the strict AMQP. */
-    protected final boolean _strictAMQPFATAL;
-    private final Object _messageDeliveryLock = new Object();
-
-    /** Session state : used to detect if commit is a) required b) allowed , i.e. does the tx span failover. */
-    private boolean _dirty;
-    /** Has failover occured on this session with outstanding actions to commit? */
-    private boolean _failedOverDirty;
-    
     private static final class FlowControlIndicator
     {
         private volatile boolean _flowControl = true;
@@ -426,9 +420,6 @@
         }
     }
 
-    /** Flow control */
-    private FlowControlIndicator _flowControl = new FlowControlIndicator();
-
     /**
      * Creates a new session on a connection.
      *
@@ -443,7 +434,7 @@
     protected AMQSession(AMQConnection con, int channelId, boolean transacted, int acknowledgeMode,
                MessageFactoryRegistry messageFactoryRegistry, int defaultPrefetchHighMark, int defaultPrefetchLowMark)
     {
-        USE_AMQP_ENCODED_MAP_MESSAGE = con == null ? true : !con.isUseLegacyMapMessageFormat();
+        _useAMQPEncodedMapMessage = con == null ? true : !con.isUseLegacyMapMessageFormat();
         _strictAMQP = Boolean.parseBoolean(System.getProperties().getProperty(STRICT_AMQP, STRICT_AMQP_DEFAULT));
         _strictAMQPFATAL =
                 Boolean.parseBoolean(System.getProperties().getProperty(STRICT_AMQP_FATAL, STRICT_AMQP_FATAL_DEFAULT));
@@ -479,7 +470,7 @@
                                                          {
                                                              // If the session has been closed don't waste time creating a thread to do
                                                              // flow control
-                                                             if (!(_thisSession.isClosed() || _thisSession.isClosing()))
+                                                             if (!(AMQSession.this.isClosed() || AMQSession.this.isClosing()))
                                                              {   
                                                                  // Only execute change if previous state
                                                                  // was False
@@ -507,7 +498,7 @@
                                                          {
                                                              // If the session has been closed don't waste time creating a thread to do
                                                              // flow control
-                                                             if (!(_thisSession.isClosed() || _thisSession.isClosing()))
+                                                             if (!(AMQSession.this.isClosed() || AMQSession.this.isClosing()))
                                                              {
                                                                  // Only execute change if previous state
                                                                  // was true
@@ -539,9 +530,9 @@
         }
 
         // Add creation logging to tie in with the existing close logging
-        if (_logger.isInfoEnabled())
+        if (_logger.isDebugEnabled())
         {
-            _logger.info("Created session:" + this);
+            _logger.debug("Created session:" + this);
         }
     }
 
@@ -730,17 +721,15 @@
 
     private void close(long timeout, boolean sendClose) throws JMSException
     {
-        if (_logger.isInfoEnabled())
+        if (_logger.isDebugEnabled())
         {
-            // StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
-            _logger.info("Closing session: " + this); // + ":"
-            // Arrays.asList(stackTrace).subList(3, stackTrace.length - 1));
+            _logger.debug("Closing session: " + this);
         }
 
         // Ensure we only try and close an open session.
-        if (!_closed.getAndSet(true))
+        if (!setClosed())
         {
-            _closing.set(true);
+            setClosing(true);
             synchronized (getFailoverMutex())
             {
                 // We must close down all producers and consumers in an orderly fashion. This is the only method
@@ -808,7 +797,7 @@
 
         if (e instanceof AMQDisconnectedException)
         {
-            if (_dispatcher != null)
+            if (_dispatcherThread != null)
             {
                 // Failover failed and ain't coming back. Knife the dispatcher.
                 _dispatcherThread.interrupt();
@@ -817,9 +806,9 @@
        }
 
         //if we don't have an exception then we can perform closing operations
-        _closing.set(e == null);
+        setClosing(e == null);
 
-        if (!_closed.getAndSet(true))
+        if (!setClosed())
         {
             synchronized (_messageDeliveryLock)
             {
@@ -903,11 +892,11 @@
                 // Flush any pending messages for this consumerTag
                 if (_dispatcher != null)
                 {
-                    _logger.info("Dispatcher is not null");
+                    _logger.debug("Dispatcher is not null");
                 }
                 else
                 {
-                    _logger.info("Dispatcher is null so created stopped dispatcher");
+                    _logger.debug("Dispatcher is null so created stopped dispatcher");
                     startDispatcherIfNecessary(true);
                 }
 
@@ -918,18 +907,16 @@
                 // Just close the consumer
                 // fixme  the CancelOK is being processed before the arriving messages..
                 // The dispatcher is still to process them so the server sent in order but the client
-                // has yet to receive before the close comes in.
-
-                // consumer.markClosed();
+                // has yet to receive before the close comes in
 
                 if (consumer.isAutoClose())
                 {
                     // There is a small window where the message is between the two queues in the dispatcher.
                     if (consumer.isClosed())
                     {
-                        if (_logger.isInfoEnabled())
+                        if (_logger.isDebugEnabled())
                         {
-                            _logger.info("Closing consumer:" + consumer.debugIdentity());
+                            _logger.debug("Closing consumer:" + consumer.debugIdentity());
                         }
 
                         deregisterConsumer(consumer);
@@ -953,6 +940,9 @@
         return createBrowser(queue, null);
     }
 
+    /**
+     * Create a queue browser if the destination is a valid queue.
+     */
     public QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSException
     {
         if (isStrictAMQP())
@@ -963,7 +953,7 @@
         checkNotClosed();
         checkValidQueue(queue);
 
-        return new AMQQueueBrowser(this, (AMQQueue) queue, messageSelector);
+        return new AMQQueueBrowser(this, queue, messageSelector);
     }
 
     protected MessageConsumer createBrowserConsumer(Destination destination, String messageSelector, boolean noLocal)
@@ -1043,7 +1033,7 @@
         {
             try
             {
-                handleAddressBasedDestination(dest,false,true);
+                handleAddressBasedDestination(dest,false,noLocal,true);
                 if (dest.getAddressType() !=  AMQDestination.TOPIC_TYPE)
                 {
                     throw new JMSException("Durable subscribers can only be created for Topics");
@@ -1099,6 +1089,10 @@
                     // possible to determine  when querying the broker whether there are no arguments or just a non-matching selector
                     // argument, as specifying null for the arguments when querying means they should not be checked at all
                     args.put(AMQPFilterTypes.JMS_SELECTOR.getValue().toString(), messageSelector == null ? "" : messageSelector);
+                    if(noLocal)
+                    {
+                        args.put(AMQPFilterTypes.NO_LOCAL.getValue().toString(), true);
+                    }
 
                     // if the queue is bound to the exchange but NOT for this topic and selector, then the JMS spec
                     // says we must trash the subscription.
@@ -1159,7 +1153,7 @@
     public MapMessage createMapMessage() throws JMSException
     {
         checkNotClosed();
-        if (USE_AMQP_ENCODED_MAP_MESSAGE)
+        if (_useAMQPEncodedMapMessage)
         {
             AMQPEncodedMapMessage msg = new AMQPEncodedMapMessage(getMessageDelegateFactory());
             msg.setAMQSession(this);
@@ -1196,12 +1190,12 @@
 
     public P createProducer(Destination destination) throws JMSException
     {
-        return createProducerImpl(destination, DEFAULT_MANDATORY, DEFAULT_IMMEDIATE);
+        return createProducerImpl(destination, null, null);
     }
 
     public P createProducer(Destination destination, boolean immediate) throws JMSException
     {
-        return createProducerImpl(destination, DEFAULT_MANDATORY, immediate);
+        return createProducerImpl(destination, null, immediate);
     }
 
     public P createProducer(Destination destination, boolean mandatory, boolean immediate)
@@ -1600,7 +1594,6 @@
 
     public MessageListener getMessageListener() throws JMSException
     {
-        // checkNotClosed();
         return _messageListener;
     }
 
@@ -1648,6 +1641,7 @@
         return (counter != null) && (counter.get() != 0);
     }
 
+    /** Indicates that warnings should be generated on violations of the strict AMQP. */
     public boolean isStrictAMQP()
     {
         return _strictAMQP;
@@ -1690,7 +1684,7 @@
     {
         AMQProtocolHandler protocolHandler = getProtocolHandler();
         declareExchange(amqd, protocolHandler, false);
-        AMQShortString queueName = declareQueue(amqd, protocolHandler, false);
+        AMQShortString queueName = declareQueue(amqd, false);
         bindQueue(queueName, amqd.getRoutingKey(), new FieldTable(), amqd.getExchangeName(), amqd);
     }
 
@@ -1886,31 +1880,6 @@
 
     public void setMessageListener(MessageListener listener) throws JMSException
     {
-        // checkNotClosed();
-        //
-        // if (_dispatcher != null && !_dispatcher.connectionStopped())
-        // {
-        // throw new javax.njms.IllegalStateException("Attempt to set listener while session is started.");
-        // }
-        //
-        // // We are stopped
-        // for (Iterator<BasicMessageConsumer> i = _consumers.values().iterator(); i.hasNext();)
-        // {
-        // BasicMessageConsumer consumer = i.next();
-        //
-        // if (consumer.isReceiving())
-        // {
-        // throw new javax.njms.IllegalStateException("Another thread is already receiving synchronously.");
-        // }
-        // }
-        //
-        // _messageListener = listener;
-        //
-        // for (Iterator<BasicMessageConsumer> i = _consumers.values().iterator(); i.hasNext();)
-        // {
-        // i.next().setMessageListener(_messageListener);
-        // }
-
     }
     
     /**
@@ -2184,7 +2153,7 @@
      */
     void markClosed()
     {
-        _closed.set(true);
+        setClosed();
         _connection.deregisterSession(_channelId);
         markClosedProducersAndConsumers();
 
@@ -2199,7 +2168,7 @@
     {
         if (Thread.currentThread() == _dispatcherThread)
         {
-            while (!_closed.get() && !_queue.isEmpty())
+            while (!super.isClosed() && !_queue.isEmpty())
             {
                 Dispatchable disp;
                 try
@@ -2247,6 +2216,58 @@
         }
     }
 
+    void drainDispatchQueue()
+    {
+        if (Thread.currentThread() == _dispatcherThread)
+        {
+            while (!super.isClosed() && !_queue.isEmpty())
+            {
+                Dispatchable disp;
+                try
+                {
+                    disp = (Dispatchable) _queue.take();
+                }
+                catch (InterruptedException e)
+                {
+                    throw new RuntimeException(e);
+                }
+
+                // Check just in case _queue becomes empty, it shouldn't but
+                // better than an NPE.
+                if (disp == null)
+                {
+                    _logger.debug("_queue became empty during sync.");
+                    break;
+                }
+
+                disp.dispatch(AMQSession.this);
+            }
+        }
+        else
+        {
+            startDispatcherIfNecessary(false);
+
+            final CountDownLatch signal = new CountDownLatch(1);
+
+            _queue.add(new Dispatchable()
+            {
+                public void dispatch(AMQSession ssn)
+                {
+                    signal.countDown();
+                }
+            });
+
+            try
+            {
+                signal.await();
+            }
+            catch (InterruptedException e)
+            {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
     /**
      * Resubscribes all producers and consumers. This is called when performing failover.
      *
@@ -2289,7 +2310,7 @@
      */
     void start() throws AMQException
     {
-        // Check if the session has perviously been started and suspended, in which case it must be unsuspended.
+        // Check if the session has previously been started and suspended, in which case it must be unsuspended.
         if (_startedAtLeastOnce.getAndSet(true))
         {
             suspendChannel(false);
@@ -2323,7 +2344,7 @@
                 }
                 catch (AMQException e)
                 {
-                    _logger.info("Unsuspending channel threw an exception:" + e);
+                    _logger.info("Unsuspending channel threw an exception:", e);
                 }
             }
         }
@@ -2346,12 +2367,12 @@
                 throw new Error("Error creating Dispatcher thread",e);
             }
             _dispatcherThread.setName("Dispatcher-Channel-" + _channelId);
-            _dispatcherThread.setDaemon(true);
+            _dispatcherThread.setDaemon(DEAMON_DISPATCHER_THREAD);
             _dispatcher.setConnectionStopped(initiallyStopped);
             _dispatcherThread.start();
-            if (_dispatcherLogger.isInfoEnabled())
+            if (_dispatcherLogger.isDebugEnabled())
             {
-                _dispatcherLogger.info(_dispatcherThread.getName() + " created");
+                _dispatcherLogger.debug(_dispatcherThread.getName() + " created");
             }
         }
         else
@@ -2371,32 +2392,6 @@
         }
     }
 
-    /*
-     * Binds the named queue, with the specified routing key, to the named exchange.
-     *
-     * <p/>Note that this operation automatically retries in the event of fail-over.
-     *
-     * @param queueName    The name of the queue to bind.
-     * @param routingKey   The routing key to bind the queue with.
-     * @param arguments    Additional arguments.
-     * @param exchangeName The exchange to bind the queue on.
-     *
-     * @throws AMQException If the queue cannot be bound for any reason.
-     */
-    /*private void bindQueue(AMQDestination amqd, AMQShortString queueName, AMQProtocolHandler protocolHandler, FieldTable ft)
-        throws AMQException, FailoverException
-    {
-        AMQFrame queueBind =
-            QueueBindBody.createAMQFrame(_channelId, getProtocolMajorVersion(), getProtocolMinorVersion(), ft, // arguments
-                amqd.getExchangeName(), // exchange
-                false, // nowait
-                queueName, // queue
-                amqd.getRoutingKey(), // routingKey
-                getTicket()); // ticket
-
-        protocolHandler.syncWrite(queueBind, QueueBindOkBody.class);
-    }*/
-
     private void checkNotTransacted() throws JMSException
     {
         if (getTransacted())
@@ -2580,7 +2575,7 @@
      * @param queueName
      */
     private void consumeFromQueue(C consumer, AMQShortString queueName,
-                                  AMQProtocolHandler protocolHandler, boolean nowait, MessageFilter messageSelector) throws AMQException, FailoverException
+                                  AMQProtocolHandler protocolHandler, boolean nowait) throws AMQException, FailoverException
     {
         int tagId = _nextTag++;
 
@@ -2597,7 +2592,7 @@
 
         try
         {
-            sendConsume(consumer, queueName, protocolHandler, nowait, messageSelector, tagId);
+            sendConsume(consumer, queueName, protocolHandler, nowait, tagId);
         }
         catch (AMQException e)
         {
@@ -2608,9 +2603,9 @@
     }
 
     public abstract void sendConsume(C consumer, AMQShortString queueName,
-                                     AMQProtocolHandler protocolHandler, boolean nowait, MessageFilter messageSelector, int tag) throws AMQException, FailoverException;
+                                     AMQProtocolHandler protocolHandler, boolean nowait, int tag) throws AMQException, FailoverException;
 
-    private P createProducerImpl(final Destination destination, final boolean mandatory, final boolean immediate)
+    private P createProducerImpl(final Destination destination, final Boolean mandatory, final Boolean immediate)
             throws JMSException
     {
         return new FailoverRetrySupport<P, JMSException>(
@@ -2639,8 +2634,8 @@
                 }, _connection).execute();
     }
 
-    public abstract P createMessageProducer(final Destination destination, final boolean mandatory,
-                                                               final boolean immediate, final long producerId) throws JMSException;
+    public abstract P createMessageProducer(final Destination destination, final Boolean mandatory,
+                                            final Boolean immediate, final long producerId) throws JMSException;
 
     private void declareExchange(AMQDestination amqd, AMQProtocolHandler protocolHandler, boolean nowait) throws AMQException
     {
@@ -2661,18 +2656,38 @@
     public long getQueueDepth(final AMQDestination amqd)
             throws AMQException
     {
-        return new FailoverNoopSupport<Long, AMQException>(
-                new FailoverProtectedOperation<Long, AMQException>()
-                {
-                    public Long execute() throws AMQException, FailoverException
-                    {
-                        return requestQueueDepth(amqd);
-                    }
-                }, _connection).execute();
-
+        return getQueueDepth(amqd, false);
     }
 
-    protected abstract Long requestQueueDepth(AMQDestination amqd) throws AMQException, FailoverException;
+    /**
+     * Returns the number of messages currently queued by the given
+     * destination. Syncs session before receiving the queue depth if sync is
+     * set to true.
+     *
+     * @param amqd AMQ destination to get the depth value
+     * @param sync flag to sync session before receiving the queue depth
+     * @return queue depth
+     * @throws AMQException
+     */
+    public long getQueueDepth(final AMQDestination amqd, final boolean sync) throws AMQException
+    {
+        return new FailoverNoopSupport<Long, AMQException>(new FailoverProtectedOperation<Long, AMQException>()
+        {
+            public Long execute() throws AMQException, FailoverException
+            {
+                try
+                {
+                    return requestQueueDepth(amqd, sync);
+                }
+                catch (TransportException e)
+                {
+                    throw new AMQException(AMQConstant.getConstant(getErrorCode(e)), e.getMessage(), e);
+                }
+            }
+        }, _connection).execute();
+    }
+
+    protected abstract Long requestQueueDepth(AMQDestination amqd, boolean sync) throws AMQException, FailoverException;
 
     /**
      * Declares the named exchange and type of exchange.
@@ -2703,6 +2718,12 @@
     public abstract void sendExchangeDeclare(final AMQShortString name, final AMQShortString type, final AMQProtocolHandler protocolHandler,
                                              final boolean nowait) throws AMQException, FailoverException;
 
+
+    void declareQueuePassive(AMQDestination queue) throws AMQException
+    {
+        declareQueue(queue,false,false,true);
+    }
+
     /**
      * Declares a queue for a JMS destination.
      *
@@ -2712,27 +2733,35 @@
      *
      * <p/>Note that this operation automatically retries in the event of fail-over.
      *
-     * @param amqd            The destination to declare as a queue.
-     * @param protocolHandler The protocol handler to communicate through.
      *
+     * @param amqd            The destination to declare as a queue.
      * @return The name of the decalred queue. This is useful where the broker is generating a queue name on behalf of
      *         the client.
      *
+     *
+     *
      * @throws AMQException If the queue cannot be declared for any reason.
      * @todo Verify the destiation is valid or throw an exception.
      * @todo Be aware of possible changes to parameter order as versions change.
      */
-    protected AMQShortString declareQueue(final AMQDestination amqd, final AMQProtocolHandler protocolHandler,
+    protected AMQShortString declareQueue(final AMQDestination amqd,
                                           final boolean noLocal) throws AMQException
     {
-        return declareQueue(amqd, protocolHandler, noLocal, false);
+        return declareQueue(amqd, noLocal, false);
     }
 
-    protected AMQShortString declareQueue(final AMQDestination amqd, final AMQProtocolHandler protocolHandler,
+    protected AMQShortString declareQueue(final AMQDestination amqd,
                                           final boolean noLocal, final boolean nowait)
+                throws AMQException
+    {
+        return declareQueue(amqd, noLocal, nowait, false);
+    }
+
+    protected AMQShortString declareQueue(final AMQDestination amqd,
+                                          final boolean noLocal, final boolean nowait, final boolean passive)
             throws AMQException
     {
-        /*return new FailoverRetrySupport<AMQShortString, AMQException>(*/
+        final AMQProtocolHandler protocolHandler = getProtocolHandler();
         return new FailoverNoopSupport<AMQShortString, AMQException>(
                 new FailoverProtectedOperation<AMQShortString, AMQException>()
                 {
@@ -2744,7 +2773,7 @@
                             amqd.setQueueName(protocolHandler.generateQueueName());
                         }
 
-                        sendQueueDeclare(amqd, protocolHandler, nowait);
+                        sendQueueDeclare(amqd, protocolHandler, nowait, passive);
 
                         return amqd.getAMQQueueName();
                     }
@@ -2752,7 +2781,7 @@
     }
 
     public abstract void sendQueueDeclare(final AMQDestination amqd, final AMQProtocolHandler protocolHandler,
-                                          final boolean nowait) throws AMQException, FailoverException;
+                                          final boolean nowait, boolean passive) throws AMQException, FailoverException;
 
     /**
      * Undeclares the specified queue.
@@ -2882,18 +2911,18 @@
 
         if (amqd.getDestSyntax() == DestSyntax.ADDR)
         {
-            handleAddressBasedDestination(amqd,true,nowait);            
+            handleAddressBasedDestination(amqd,true,consumer.isNoLocal(),nowait);
         }
         else
         {
-            if (DECLARE_EXCHANGES)
+            if (_declareExchanges)
             {
                 declareExchange(amqd, protocolHandler, nowait);
             }
     
-            if (DECLARE_QUEUES || amqd.isNameRequired())
+            if (_delareQueues || amqd.isNameRequired())
             {
-                declareQueue(amqd, protocolHandler, consumer.isNoLocal(), nowait);
+                declareQueue(amqd, consumer.isNoLocal(), nowait);
             }
             bindQueue(amqd.getAMQQueueName(), amqd.getRoutingKey(), consumer.getArguments(), amqd.getExchangeName(), amqd, nowait);
         }
@@ -2916,24 +2945,24 @@
                     try
                     {
                         suspendChannel(true);
-                        _logger.info(
+                        _logger.debug(
                                 "Prefetching delayed existing messages will not flow until requested via receive*() or setML().");
                     }
                     catch (AMQException e)
                     {
-                        _logger.info("Suspending channel threw an exception:" + e);
+                        _logger.info("Suspending channel threw an exception:", e);
                     }
                 }
             }
         }
         else
         {
-            _logger.info("Immediately prefetching existing messages to new consumer.");
+            _logger.debug("Immediately prefetching existing messages to new consumer.");
         }
 
         try
         {
-            consumeFromQueue(consumer, queueName, protocolHandler, nowait, consumer.getMessageSelectorFilter());
+            consumeFromQueue(consumer, queueName, protocolHandler, nowait);
         }
         catch (FailoverException e)
         {
@@ -2943,6 +2972,7 @@
 
     public abstract void handleAddressBasedDestination(AMQDestination dest, 
                                                        boolean isConsumer,
+                                                       boolean noLocal,
                                                        boolean noWait) throws AMQException;
     
     private void registerProducer(long producerId, MessageProducer producer)
@@ -2959,18 +2989,18 @@
     private void rejectMessagesForConsumerTag(int consumerTag, boolean requeue, boolean rejectAllConsumers)
     {
         Iterator messages = _queue.iterator();
-        if (_logger.isInfoEnabled())
+        if (_logger.isDebugEnabled())
         {
-            _logger.info("Rejecting messages from _queue for Consumer tag(" + consumerTag + ") (PDispatchQ) requeue:"
+            _logger.debug("Rejecting messages from _queue for Consumer tag(" + consumerTag + ") (PDispatchQ) requeue:"
                          + requeue);
 
             if (messages.hasNext())
             {
-                _logger.info("Checking all messages in _queue for Consumer tag(" + consumerTag + ")");
+                _logger.debug("Checking all messages in _queue for Consumer tag(" + consumerTag + ")");
             }
             else
             {
-                _logger.info("No messages in _queue to reject");
+                _logger.debug("No messages in _queue to reject");
             }
         }
         while (messages.hasNext())
@@ -3013,7 +3043,7 @@
     private void resubscribeProducers() throws AMQException
     {
         ArrayList producers = new ArrayList(_producers.values());
-        _logger.info(MessageFormat.format("Resubscribing producers = {0} producers.size={1}", producers, producers.size())); // FIXME: removeKey
+        _logger.debug(MessageFormat.format("Resubscribing producers = {0} producers.size={1}", producers, producers.size())); // FIXME: removeKey
         for (Iterator it = producers.iterator(); it.hasNext();)
         {
             P producer = (P) it.next();
@@ -3103,7 +3133,10 @@
     public void setFlowControl(final boolean active)
     {
         _flowControl.setFlowControl(active);
-        _logger.warn("Broker enforced flow control " + (active ? "no longer in effect" : "has been enforced"));
+        if (_logger.isInfoEnabled())
+        {
+            _logger.info("Broker enforced flow control " + (active ? "no longer in effect" : "has been enforced"));
+        }
     }
 
     public void checkFlowControl() throws InterruptedException, JMSException
@@ -3112,17 +3145,20 @@
         synchronized (_flowControl)
         {
             while (!_flowControl.getFlowControl() &&
-                   (expiryTime == 0L ? (expiryTime = System.currentTimeMillis() + FLOW_CONTROL_WAIT_FAILURE)
+                   (expiryTime == 0L ? (expiryTime = System.currentTimeMillis() + _flowControlWaitFailure)
                                      : expiryTime) >= System.currentTimeMillis() )
             {
 
-                _flowControl.wait(FLOW_CONTROL_WAIT_PERIOD);
-                _logger.warn("Message send delayed by " + (System.currentTimeMillis() + FLOW_CONTROL_WAIT_FAILURE - expiryTime)/1000 + "s due to broker enforced flow control");
+                _flowControl.wait(_flowControlWaitPeriod);
+                if (_logger.isInfoEnabled())
+                {
+                    _logger.info("Message send delayed by " + (System.currentTimeMillis() + _flowControlWaitFailure - expiryTime)/1000 + "s due to broker enforced flow control");
+                }
             }
             if(!_flowControl.getFlowControl())
             {
                 _logger.error("Message send failed due to timeout waiting on broker enforced flow control");
-                throw new JMSException("Unable to send message for " + FLOW_CONTROL_WAIT_FAILURE/1000 + " seconds due to broker enforced flow control");
+                throw new JMSException("Unable to send message for " + _flowControlWaitFailure /1000 + " seconds due to broker enforced flow control");
             }
         }
 
@@ -3154,7 +3190,7 @@
         private final AtomicBoolean _closed = new AtomicBoolean(false);
 
         private final Object _lock = new Object();
-        private String dispatcherID = "" + System.identityHashCode(this);
+        private final String dispatcherID = "" + System.identityHashCode(this);
 
         public Dispatcher()
         {
@@ -3169,6 +3205,11 @@
 
         }
 
+        private AtomicBoolean getClosed()
+        {
+            return _closed;
+        }
+
         public void rejectPending(C consumer)
         {
             synchronized (_lock)
@@ -3220,7 +3261,6 @@
                     else
                     {
                         // should perhaps clear the _SQ here.
-                        // consumer._synchronousQueue.clear();
                         consumer.clearReceiveQueue();
                     }
 
@@ -3266,13 +3306,11 @@
         
         public void run()
         {
-            if (_dispatcherLogger.isInfoEnabled())
+            if (_dispatcherLogger.isDebugEnabled())
             {
-                _dispatcherLogger.info(_dispatcherThread.getName() + " started");
+                _dispatcherLogger.debug(_dispatcherThread.getName() + " started");
             }
 
-            UnprocessedMessage message;
-
             // Allow disptacher to start stopped
             synchronized (_lock)
             {
@@ -3284,7 +3322,7 @@
                     }
                     catch (InterruptedException e)
                     {
-                        // ignore
+                        Thread.currentThread().interrupt();
                     }
                 }
             }
@@ -3299,12 +3337,12 @@
             }
             catch (InterruptedException e)
             {
-                // ignore
+                // ignored as run will exit immediately
             }
 
-            if (_dispatcherLogger.isInfoEnabled())
+            if (_dispatcherLogger.isDebugEnabled())
             {
-                _dispatcherLogger.info(_dispatcherThread.getName() + " thread terminating for channel " + _channelId + ":" + _thisSession);
+                _dispatcherLogger.debug(_dispatcherThread.getName() + " thread terminating for channel " + _channelId + ":" + AMQSession.this);
             }
 
         }
@@ -3350,7 +3388,7 @@
                 }
                 catch (InterruptedException e)
                 {
-                    // pass
+                    Thread.currentThread().interrupt();
                 }
 
                 if (!(message instanceof CloseConsumerMessage)
@@ -3425,7 +3463,7 @@
                     if (_logger.isDebugEnabled())
                     {
                         _logger.debug("Rejecting message with delivery tag " + message.getDeliveryTag()
-                                + " for closing consumer " + String.valueOf(consumer == null? null: consumer._consumerTag));
+                                + " for closing consumer " + String.valueOf(consumer == null? null: consumer.getConsumerTag()));
                     }
                     rejectMessage(message, true);
                 }
@@ -3443,30 +3481,6 @@
 
     public abstract AMQMessageDelegateFactory getMessageDelegateFactory();
 
-    /*public void requestAccess(AMQShortString realm, boolean exclusive, boolean passive, boolean active, boolean write,
-        boolean read) throws AMQException
-    {
-        getProtocolHandler().writeCommandFrameAndWaitForReply(AccessRequestBody.createAMQFrame(getChannelId(),
-                getProtocolMajorVersion(), getProtocolMinorVersion(), active, exclusive, passive, read, realm, write),
-            new BlockingMethodFrameListener(_channelId)
-            {
-
-                public boolean processMethod(int channelId, AMQMethodBody frame) // throws AMQException
-                {
-                    if (frame instanceof AccessRequestOkBody)
-                    {
-                        setTicket(((AccessRequestOkBody) frame).getTicket());
-
-                        return true;
-                    }
-                    else
-                    {
-                        return false;
-                    }
-                }
-            });
-    }*/
-
     private class SuspenderRunner implements Runnable
     {
         private AtomicBoolean _suspend;
@@ -3484,7 +3498,7 @@
                 {
                     // If the session has closed by the time we get here
                     // then we should not attempt to write to the sesion/channel.
-                    if (!(_thisSession.isClosed() || _thisSession.isClosing()))
+                    if (!(AMQSession.this.isClosed() || AMQSession.this.isClosing()))
                     {
                         suspendChannel(_suspend.get());
                     }
@@ -3492,11 +3506,11 @@
             }
             catch (AMQException e)
             {
-                _logger.warn("Unable to " + (_suspend.get() ? "suspend" : "unsuspend") + " session " + _thisSession + " due to: " + e);
+                _logger.warn("Unable to " + (_suspend.get() ? "suspend" : "unsuspend") + " session " + AMQSession.this + " due to: ", e);
                 if (_logger.isDebugEnabled())
                 {
                     _logger.debug("Is the _queue empty?" + _queue.isEmpty());
-                    _logger.debug("Is the dispatcher closed?" + (_dispatcher == null ? "it's Null" : _dispatcher._closed));
+                    _logger.debug("Is the dispatcher closed?" + (_dispatcher == null ? "it's Null" : _dispatcher.getClosed()));
                 }
             }
         }
@@ -3510,7 +3524,7 @@
     @Override
     public boolean isClosed()
     {
-        return _closed.get() || _connection.isClosed();
+        return super.isClosed() || _connection.isClosed();
     }
 
     /**
@@ -3522,12 +3536,12 @@
     @Override
     public boolean isClosing()
     {
-        return _closing.get()|| _connection.isClosing();
+        return super.isClosing() || _connection.isClosing();
     }
     
     public boolean isDeclareExchanges()
     {
-    	return DECLARE_EXCHANGES;
+    	return _declareExchanges;
     }
 
     JMSException toJMSException(String message, TransportException e)
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSessionAdapter.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSessionAdapter.java
index 7e257e0..e94099f 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSessionAdapter.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSessionAdapter.java
@@ -20,7 +20,172 @@
  */
 package org.apache.qpid.client;
 
-public interface AMQSessionAdapter
+import javax.jms.*;
+import java.io.Serializable;
+
+public abstract class AMQSessionAdapter<T extends Session> implements Session
 {
-    public AMQSession getSession();
+    private final T _session;
+
+    protected AMQSessionAdapter(final T session)
+    {
+        _session = session;
+    }
+
+    public T getSession()
+    {
+        return _session;
+    }
+
+    public BytesMessage createBytesMessage() throws JMSException
+    {
+        return _session.createBytesMessage();
+    }
+
+    public MapMessage createMapMessage() throws JMSException
+    {
+        return _session.createMapMessage();
+    }
+
+    public Message createMessage() throws JMSException
+    {
+        return _session.createMessage();
+    }
+
+    public ObjectMessage createObjectMessage() throws JMSException
+    {
+        return _session.createObjectMessage();
+    }
+
+    public ObjectMessage createObjectMessage(final Serializable serializable) throws JMSException
+    {
+        return _session.createObjectMessage(serializable);
+    }
+
+    public StreamMessage createStreamMessage() throws JMSException
+    {
+        return _session.createStreamMessage();
+    }
+
+    public TextMessage createTextMessage() throws JMSException
+    {
+        return _session.createTextMessage();
+    }
+
+    public TextMessage createTextMessage(final String s) throws JMSException
+    {
+        return _session.createTextMessage(s);
+    }
+
+    public boolean getTransacted() throws JMSException
+    {
+        return _session.getTransacted();
+    }
+
+    public int getAcknowledgeMode() throws JMSException
+    {
+        return _session.getAcknowledgeMode();
+    }
+
+    public void commit() throws JMSException
+    {
+        _session.commit();
+    }
+
+    public void rollback() throws JMSException
+    {
+        _session.rollback();
+    }
+
+    public void close() throws JMSException
+    {
+        _session.close();
+    }
+
+    public void recover() throws JMSException
+    {
+        _session.recover();
+    }
+
+    public MessageListener getMessageListener() throws JMSException
+    {
+        return _session.getMessageListener();
+    }
+
+    public void setMessageListener(final MessageListener messageListener) throws JMSException
+    {
+        _session.setMessageListener(messageListener);
+    }
+
+    public void run()
+    {
+        _session.run();
+    }
+
+    public MessageProducer createProducer(final Destination destination) throws JMSException
+    {
+        return _session.createProducer(destination);
+    }
+
+    public MessageConsumer createConsumer(final Destination destination) throws JMSException
+    {
+        return _session.createConsumer(destination);
+    }
+
+    public MessageConsumer createConsumer(final Destination destination, final String s) throws JMSException
+    {
+        return _session.createConsumer(destination, s);
+    }
+
+    public MessageConsumer createConsumer(final Destination destination, final String s, final boolean b)
+            throws JMSException
+    {
+        return _session.createConsumer(destination, s, b);
+    }
+
+    public Queue createQueue(final String s) throws JMSException
+    {
+        return _session.createQueue(s);
+    }
+
+    public Topic createTopic(final String s) throws JMSException
+    {
+        return _session.createTopic(s);
+    }
+
+    public TopicSubscriber createDurableSubscriber(final Topic topic, final String s) throws JMSException
+    {
+        return _session.createDurableSubscriber(topic, s);
+    }
+
+    public TopicSubscriber createDurableSubscriber(final Topic topic, final String s, final String s1, final boolean b)
+            throws JMSException
+    {
+        return _session.createDurableSubscriber(topic, s, s1, b);
+    }
+
+    public QueueBrowser createBrowser(final Queue queue) throws JMSException
+    {
+        return _session.createBrowser(queue);
+    }
+
+    public QueueBrowser createBrowser(final Queue queue, final String s) throws JMSException
+    {
+        return _session.createBrowser(queue, s);
+    }
+
+    public TemporaryQueue createTemporaryQueue() throws JMSException
+    {
+        return _session.createTemporaryQueue();
+    }
+
+    public TemporaryTopic createTemporaryTopic() throws JMSException
+    {
+        return _session.createTemporaryTopic();
+    }
+
+    public void unsubscribe(final String s) throws JMSException
+    {
+        _session.unsubscribe(s);
+    }
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
index 8395c8f..3902c72 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
@@ -17,11 +17,6 @@
  */
 package org.apache.qpid.client;
 
-import static org.apache.qpid.transport.Option.BATCH;
-import static org.apache.qpid.transport.Option.NONE;
-import static org.apache.qpid.transport.Option.SYNC;
-import static org.apache.qpid.transport.Option.UNRELIABLE;
-
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -34,10 +29,8 @@
 import java.util.TimerTask;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentLinkedQueue;
-
 import javax.jms.Destination;
 import javax.jms.JMSException;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQDestination.AddressOption;
 import org.apache.qpid.client.AMQDestination.Binding;
@@ -55,11 +48,14 @@
 import org.apache.qpid.client.messaging.address.Node.QueueNode;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
 import org.apache.qpid.exchange.ExchangeDefaults;
-import org.apache.qpid.filter.MessageFilter;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.transport.*;
+import static org.apache.qpid.transport.Option.BATCH;
+import static org.apache.qpid.transport.Option.NONE;
+import static org.apache.qpid.transport.Option.SYNC;
+import static org.apache.qpid.transport.Option.UNRELIABLE;
 import org.apache.qpid.util.Serial;
 import org.apache.qpid.util.Strings;
 import org.slf4j.Logger;
@@ -78,6 +74,7 @@
     private static final Logger _logger = LoggerFactory.getLogger(AMQSession_0_10.class);
 
     private static Timer timer = new Timer("ack-flusher", true);
+
     private static class Flusher extends TimerTask
     {
 
@@ -120,7 +117,7 @@
     private AMQException _currentException;
 
     // a ref on the qpid connection
-    protected org.apache.qpid.transport.Connection _qpidConnection;
+    private org.apache.qpid.transport.Connection _qpidConnection;
 
     private long maxAckDelay = Long.getLong("qpid.session.max_ack_delay", 1000);
     private TimerTask flushTask = null;
@@ -163,7 +160,7 @@
             _qpidSession = _qpidConnection.createSession(name,1);
         }
         _qpidSession.setSessionListener(this);
-        if (_transacted)
+        if (isTransacted())
         {
             _qpidSession.txSelect();
             _qpidSession.setTransacted(true);
@@ -214,6 +211,11 @@
         }
     }
 
+    protected Connection getQpidConnection()
+    {
+        return _qpidConnection;
+    }
+
     //------- overwritten methods of class AMQSession
 
     void failoverPrep()
@@ -234,17 +236,17 @@
     {
         if (_logger.isDebugEnabled())
         {
-            _logger.debug("Sending ack for delivery tag " + deliveryTag + " on session " + _channelId);
+            _logger.debug("Sending ack for delivery tag " + deliveryTag + " on session " + getChannelId());
         }
         // acknowledge this message
         if (multiple)
         {
-            for (Long messageTag : _unacknowledgedMessageTags)
+            for (Long messageTag : getUnacknowledgedMessageTags())
             {
                 if( messageTag <= deliveryTag )
                 {
                     addUnacked(messageTag.intValue());
-                    _unacknowledgedMessageTags.remove(messageTag);
+                    getUnacknowledgedMessageTags().remove(messageTag);
                 }
             }
             //empty the list of unack messages
@@ -253,12 +255,12 @@
         else
         {
             addUnacked((int) deliveryTag);
-            _unacknowledgedMessageTags.remove(deliveryTag);
+            getUnacknowledgedMessageTags().remove(deliveryTag);
         }
 
         long prefetch = getAMQConnection().getMaxPrefetch();
 
-        if (unackedCount >= prefetch/2 || maxAckDelay <= 0 || _acknowledgeMode == javax.jms.Session.AUTO_ACKNOWLEDGE)
+        if (unackedCount >= prefetch/2 || maxAckDelay <= 0 || getAcknowledgeMode() == javax.jms.Session.AUTO_ACKNOWLEDGE)
         {
             flushAcknowledgments();
         }
@@ -276,7 +278,7 @@
             if (unackedCount > 0)
             {
                 messageAcknowledge
-                    (unacked, _acknowledgeMode != org.apache.qpid.jms.Session.NO_ACKNOWLEDGE,setSyncBit);
+                    (unacked, getAcknowledgeMode() != org.apache.qpid.jms.Session.NO_ACKNOWLEDGE,setSyncBit);
                 clearUnacked();
             }
         }
@@ -444,8 +446,8 @@
     {
         // release all unacked messages
         RangeSet all = RangeSetFactory.createRangeSet();
-        RangeSet delivered = gatherRangeSet(_unacknowledgedMessageTags);
-        RangeSet prefetched = gatherRangeSet(_prefetchedMessageTags);
+        RangeSet delivered = gatherRangeSet(getUnacknowledgedMessageTags());
+        RangeSet prefetched = gatherRangeSet(getPrefetchedMessageTags());
         for (Iterator<Range> deliveredIter = delivered.iterator(); deliveredIter.hasNext();)
         {
             Range range = deliveredIter.next();
@@ -526,9 +528,9 @@
     {
 
         final AMQProtocolHandler protocolHandler = getProtocolHandler();
-        return new BasicMessageConsumer_0_10(_channelId, _connection, destination, messageSelector, noLocal,
-                                             _messageFactoryRegistry, this, protocolHandler, rawSelector, prefetchHigh,
-                                             prefetchLow, exclusive, _acknowledgeMode, noConsume, autoClose);
+        return new BasicMessageConsumer_0_10(getChannelId(), getAMQConnection(), destination, messageSelector, noLocal,
+                getMessageFactoryRegistry(), this, protocolHandler, rawSelector, prefetchHigh,
+                                             prefetchLow, exclusive, getAcknowledgeMode(), noConsume, autoClose);
     }
 
     /**
@@ -593,7 +595,7 @@
      * Registers the consumer with the broker
      */
     public void sendConsume(BasicMessageConsumer_0_10 consumer, AMQShortString queueName, AMQProtocolHandler protocolHandler,
-                            boolean nowait, MessageFilter messageSelector, int tag)
+                            boolean nowait, int tag)
             throws AMQException, FailoverException
     {        
         boolean preAcquire = consumer.isPreAcquire();
@@ -630,7 +632,7 @@
         getQpidSession().messageFlow(consumerTag, MessageCreditUnit.BYTE, 0xFFFFFFFF,
                                      Option.UNRELIABLE);
 
-        if(capacity > 0 && _dispatcher != null && (isStarted() || _immediatePrefetch))
+        if(capacity > 0 && getDispatcher() != null && (isStarted() || isImmediatePrefetch()))
         {
             // set the flow
             getQpidSession().messageFlow(consumerTag,
@@ -648,12 +650,12 @@
     /**
      * Create an 0_10 message producer
      */
-    public BasicMessageProducer_0_10 createMessageProducer(final Destination destination, final boolean mandatory,
-                                                      final boolean immediate, final long producerId) throws JMSException
+    public BasicMessageProducer_0_10 createMessageProducer(final Destination destination, final Boolean mandatory,
+                                                           final Boolean immediate, final long producerId) throws JMSException
     {
         try
         {
-            return new BasicMessageProducer_0_10(_connection, (AMQDestination) destination, _transacted, _channelId, this,
+            return new BasicMessageProducer_0_10(getAMQConnection(), (AMQDestination) destination, isTransacted(), getChannelId(), this,
                                              getProtocolHandler(), producerId, immediate, mandatory);
         }
         catch (AMQException e)
@@ -719,7 +721,7 @@
      * Declare a queue with the given queueName
      */
     public void sendQueueDeclare(final AMQDestination amqd, final AMQProtocolHandler protocolHandler,
-                                 final boolean nowait)
+                                 final boolean nowait, boolean passive)
             throws AMQException, FailoverException
     {
         // do nothing this is only used by 0_8
@@ -729,7 +731,7 @@
      * Declare a queue with the given queueName
      */
     public AMQShortString send0_10QueueDeclare(final AMQDestination amqd, final AMQProtocolHandler protocolHandler,
-                                               final boolean noLocal, final boolean nowait)
+                                               final boolean noLocal, final boolean nowait, boolean passive)
             throws AMQException
     {
         AMQShortString queueName;
@@ -755,13 +757,20 @@
             getQpidSession().queueDeclare(queueName.toString(), "" , arguments,
                                           amqd.isAutoDelete() ? Option.AUTO_DELETE : Option.NONE,
                                           amqd.isDurable() ? Option.DURABLE : Option.NONE,
-                                          amqd.isExclusive() ? Option.EXCLUSIVE : Option.NONE);   
+                                          amqd.isExclusive() ? Option.EXCLUSIVE : Option.NONE,
+                                          passive ? Option.PASSIVE : Option.NONE);
         }
         else
         {
             QueueNode node = (QueueNode)amqd.getSourceNode();
+            Map<String,Object> arguments = new HashMap<String,Object>();
+            arguments.putAll((Map<? extends String, ? extends Object>) node.getDeclareArgs());
+            if (arguments == null || arguments.get(AddressHelper.NO_LOCAL) == null)
+            {
+                arguments.put(AddressHelper.NO_LOCAL, noLocal);
+            }
             getQpidSession().queueDeclare(queueName.toString(), node.getAlternateExchange() ,
-                    node.getDeclareArgs(),
+                    arguments,
                     node.isAutoDelete() ? Option.AUTO_DELETE : Option.NONE,
                     node.isDurable() ? Option.DURABLE : Option.NONE,
                     node.isExclusive() ? Option.EXCLUSIVE : Option.NONE);   
@@ -795,15 +804,16 @@
     {
         if (suspend)
         {
-            for (BasicMessageConsumer consumer : _consumers.values())
+            for (BasicMessageConsumer consumer : getConsumers().values())
             {
                 getQpidSession().messageStop(String.valueOf(consumer.getConsumerTag()),
                                              Option.UNRELIABLE);
             }
+            sync();
         }
         else
         {
-            for (BasicMessageConsumer_0_10 consumer : _consumers.values())
+            for (BasicMessageConsumer_0_10 consumer : getConsumers().values())
             {
                 String consumerTag = String.valueOf(consumer.getConsumerTag());
                 //only set if msg list is null
@@ -918,11 +928,12 @@
         return getCurrentException();
     }
 
-    protected AMQShortString declareQueue(final AMQDestination amqd, final AMQProtocolHandler protocolHandler,
-                                          final boolean noLocal, final boolean nowait)
+    protected AMQShortString declareQueue(final AMQDestination amqd,
+                                          final boolean noLocal, final boolean nowait, final boolean passive)
             throws AMQException
     {
-        /*return new FailoverRetrySupport<AMQShortString, AMQException>(*/
+        final AMQProtocolHandler protocolHandler = getProtocolHandler();
+
         return new FailoverNoopSupport<AMQShortString, AMQException>(
                 new FailoverProtectedOperation<AMQShortString, AMQException>()
                 {
@@ -939,14 +950,18 @@
                             amqd.setQueueName(new AMQShortString( binddingKey + "@"
                                     + amqd.getExchangeName().toString() + "_" + UUID.randomUUID()));
                         }
-                        return send0_10QueueDeclare(amqd, protocolHandler, noLocal, nowait);
+                        return send0_10QueueDeclare(amqd, protocolHandler, noLocal, nowait, passive);
                     }
-                }, _connection).execute();
+                }, getAMQConnection()).execute();
     }
 
-    protected Long requestQueueDepth(AMQDestination amqd)
+    protected Long requestQueueDepth(AMQDestination amqd, boolean sync)
     {
         flushAcknowledgments();
+        if (sync)
+        {
+            getQpidSession().sync();
+        }
         return getQpidSession().queueQuery(amqd.getQueueName()).get().getMessageCount();
     }
 
@@ -968,8 +983,8 @@
     protected void sendTxCompletionsIfNecessary()
     {
         // this is a heuristic, we may want to have that configurable
-        if (_txSize > 0 && (_connection.getMaxPrefetch() == 1 ||
-                _connection.getMaxPrefetch() != 0 && _txSize % (_connection.getMaxPrefetch() / 2) == 0))
+        if (_txSize > 0 && (getAMQConnection().getMaxPrefetch() == 1 ||
+                getAMQConnection().getMaxPrefetch() != 0 && _txSize % (getAMQConnection().getMaxPrefetch() / 2) == 0))
         {
             // send completed so consumer credits don't dry up
             messageAcknowledge(_txRangeSet, false);
@@ -1039,7 +1054,7 @@
             AMQException amqe = new AMQException(AMQConstant.getConstant(code), se.getMessage(), se.getCause());
             _currentException = amqe;
         }
-        _connection.exceptionReceived(_currentException);
+        getAMQConnection().exceptionReceived(_currentException);
     }
 
     public AMQMessageDelegateFactory getMessageDelegateFactory()
@@ -1156,13 +1171,14 @@
     @SuppressWarnings("deprecation")
     public void handleAddressBasedDestination(AMQDestination dest, 
                                               boolean isConsumer,
+                                              boolean noLocal,
                                               boolean noWait) throws AMQException
     {
-        if (dest.isAddressResolved() && dest.isResolvedAfter(_connection.getLastFailoverTime()))
+        if (dest.isAddressResolved() && dest.isResolvedAfter(getAMQConnection().getLastFailoverTime()))
         {
             if (isConsumer && AMQDestination.TOPIC_TYPE == dest.getAddressType()) 
             {
-                createSubscriptionQueue(dest);
+                createSubscriptionQueue(dest,noLocal);
             }
         }
         else
@@ -1191,7 +1207,7 @@
                     else if(createNode)
                     {
                         setLegacyFiledsForQueueType(dest);
-                        send0_10QueueDeclare(dest,null,false,noWait);
+                        send0_10QueueDeclare(dest,null,noLocal,noWait, false);
                         sendQueueBind(dest.getAMQQueueName(), dest.getRoutingKey(),
                                       null,dest.getExchangeName(),dest, false);
                         break;
@@ -1206,7 +1222,7 @@
                         verifySubject(dest);
                         if (isConsumer && !isQueueExist(dest,(QueueNode)dest.getSourceNode(),true)) 
                         {  
-                            createSubscriptionQueue(dest);
+                            createSubscriptionQueue(dest, noLocal);
                         }
                         break;
                     }
@@ -1221,7 +1237,7 @@
                                 false);        
                         if (isConsumer && !isQueueExist(dest,(QueueNode)dest.getSourceNode(),true)) 
                         {
-                            createSubscriptionQueue(dest);
+                            createSubscriptionQueue(dest,noLocal);
                         }
                         break;
                     }
@@ -1284,7 +1300,7 @@
         }
     }
     
-    private void createSubscriptionQueue(AMQDestination dest) throws AMQException
+    private void createSubscriptionQueue(AMQDestination dest, boolean noLocal) throws AMQException
     {
         QueueNode node = (QueueNode)dest.getSourceNode();  // source node is never null
         
@@ -1297,11 +1313,11 @@
         }
         node.setExclusive(true);
         node.setAutoDelete(!node.isDurable());
-        send0_10QueueDeclare(dest,null,false,true);
-        node.addBinding(new Binding(dest.getAddressName(),
-                                    dest.getQueueName(),// should have one by now
-                                    dest.getSubject(),
-                                    Collections.<String,Object>emptyMap()));
+        send0_10QueueDeclare(dest,null,noLocal,true, false);
+        getQpidSession().exchangeBind(dest.getQueueName(), 
+        		              dest.getAddressName(), 
+        		              dest.getSubject(), 
+        		              Collections.<String,Object>emptyMap());
         sendQueueBind(dest.getAMQQueueName(), dest.getRoutingKey(),
                 null,dest.getExchangeName(),dest, false);
     }
@@ -1328,7 +1344,7 @@
     
     protected void acknowledgeImpl()
     {
-        RangeSet ranges = gatherRangeSet(_unacknowledgedMessageTags);
+        RangeSet ranges = gatherRangeSet(getUnacknowledgedMessageTags());
 
         if(ranges.size() > 0 )
         {
@@ -1344,15 +1360,53 @@
         // return the first <total number of msgs received on session>
         // messages sent by the brokers following the first rollback
         // after failover
-        _highestDeliveryTag.set(-1);
+        getHighestDeliveryTag().set(-1);
         // Clear txRangeSet/unacknowledgedMessageTags so we don't complete commands corresponding to
         //messages that came from the old broker.
         _txRangeSet.clear();
         _txSize = 0;
-        _unacknowledgedMessageTags.clear();
-        _prefetchedMessageTags.clear();
+        getUnacknowledgedMessageTags().clear();
+        getPrefetchedMessageTags().clear();
         super.resubscribe();
         getQpidSession().sync();
     }
+
+    @Override
+    void stop() throws AMQException
+    {
+        super.stop();
+        setUsingDispatcherForCleanup(true);
+        drainDispatchQueue();
+        setUsingDispatcherForCleanup(false);
+
+        for (BasicMessageConsumer consumer : getConsumers().values())
+        {
+            List<Long> tags = consumer.drainReceiverQueueAndRetrieveDeliveryTags();
+            getPrefetchedMessageTags().addAll(tags);
+        }
+        
+        RangeSet delivered = gatherRangeSet(getUnacknowledgedMessageTags());
+		RangeSet prefetched = gatherRangeSet(getPrefetchedMessageTags());
+		RangeSet all = RangeSetFactory.createRangeSet(delivered.size()
+					+ prefetched.size());
+
+		for (Iterator<Range> deliveredIter = delivered.iterator(); deliveredIter.hasNext();)
+		{
+			Range range = deliveredIter.next();
+			all.add(range);
+		}
+
+		for (Iterator<Range> prefetchedIter = prefetched.iterator(); prefetchedIter.hasNext();)
+		{
+			Range range = prefetchedIter.next();
+			all.add(range);
+		}
+
+		flushProcessed(all, false);
+		getQpidSession().messageRelease(delivered,Option.SET_REDELIVERED);
+		getQpidSession().messageRelease(prefetched);
+		sync();
+    }
+
 }
 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java
index 7daebbf..8ab23a2 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java
@@ -21,13 +21,8 @@
 package org.apache.qpid.client;
 
 
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.ArrayList;
-import java.util.Map;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQUndeliveredException;
@@ -43,44 +38,20 @@
 import org.apache.qpid.client.state.AMQState;
 import org.apache.qpid.client.state.AMQStateManager;
 import org.apache.qpid.client.state.listener.SpecificMethodFrameListener;
-import org.apache.qpid.filter.MessageFilter;
-import org.apache.qpid.framing.AMQFrame;
-import org.apache.qpid.framing.AMQMethodBody;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.BasicAckBody;
-import org.apache.qpid.framing.BasicConsumeBody;
-import org.apache.qpid.framing.BasicConsumeOkBody;
-import org.apache.qpid.framing.BasicQosBody;
-import org.apache.qpid.framing.BasicQosOkBody;
-import org.apache.qpid.framing.BasicRecoverBody;
-import org.apache.qpid.framing.BasicRecoverOkBody;
-import org.apache.qpid.framing.BasicRecoverSyncBody;
-import org.apache.qpid.framing.BasicRecoverSyncOkBody;
-import org.apache.qpid.framing.BasicRejectBody;
-import org.apache.qpid.framing.ChannelCloseOkBody;
-import org.apache.qpid.framing.ChannelFlowBody;
-import org.apache.qpid.framing.ChannelFlowOkBody;
-import org.apache.qpid.framing.ExchangeBoundOkBody;
-import org.apache.qpid.framing.ExchangeDeclareBody;
-import org.apache.qpid.framing.ExchangeDeclareOkBody;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.framing.ProtocolVersion;
-import org.apache.qpid.framing.QueueBindOkBody;
-import org.apache.qpid.framing.QueueDeclareBody;
-import org.apache.qpid.framing.QueueDeclareOkBody;
-import org.apache.qpid.framing.QueueDeleteBody;
-import org.apache.qpid.framing.QueueDeleteOkBody;
-import org.apache.qpid.framing.TxCommitOkBody;
-import org.apache.qpid.framing.TxRollbackBody;
-import org.apache.qpid.framing.TxRollbackOkBody;
+import org.apache.qpid.framing.*;
 import org.apache.qpid.framing.amqp_0_9.MethodRegistry_0_9;
 import org.apache.qpid.framing.amqp_0_91.MethodRegistry_0_91;
 import org.apache.qpid.jms.Session;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.protocol.AMQMethodEvent;
 import org.apache.qpid.transport.TransportException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 public class AMQSession_0_8 extends AMQSession<BasicMessageConsumer_0_8, BasicMessageProducer_0_8>
 {
@@ -131,7 +102,7 @@
     {
         while (true)
         {
-            Long tag = _unacknowledgedMessageTags.poll();
+            Long tag = getUnacknowledgedMessageTags().poll();
             if (tag == null)
             {
                 break;
@@ -145,15 +116,15 @@
     {
         BasicAckBody body = getMethodRegistry().createBasicAckBody(deliveryTag, multiple);
 
-        final AMQFrame ackFrame = body.generateFrame(_channelId);
+        final AMQFrame ackFrame = body.generateFrame(getChannelId());
 
         if (_logger.isDebugEnabled())
         {
-            _logger.debug("Sending ack for delivery tag " + deliveryTag + " on channel " + _channelId);
+            _logger.debug("Sending ack for delivery tag " + deliveryTag + " on channel " + getChannelId());
         }
 
         getProtocolHandler().writeFrame(ackFrame, !isTransacted());
-        _unacknowledgedMessageTags.remove(deliveryTag);
+        getUnacknowledgedMessageTags().remove(deliveryTag);
     }
 
     public void sendQueueBind(final AMQShortString queueName, final AMQShortString routingKey, final FieldTable arguments,
@@ -162,7 +133,7 @@
     {
         getProtocolHandler().syncWrite(getProtocolHandler().getMethodRegistry().createQueueBindBody
                                         (getTicket(),queueName,exchangeName,routingKey,false,arguments).
-                                        generateFrame(_channelId), QueueBindOkBody.class);
+                                        generateFrame(getChannelId()), QueueBindOkBody.class);
     }
 
     public void sendClose(long timeout) throws AMQException, FailoverException
@@ -179,7 +150,7 @@
 
             getProtocolHandler().closeSession(this);
             getProtocolHandler().syncWrite(getProtocolHandler().getMethodRegistry().createChannelCloseBody(AMQConstant.REPLY_SUCCESS.getCode(),
-                                                                                                           new AMQShortString("JMS client closing channel"), 0, 0).generateFrame(_channelId),
+                                                                                                           new AMQShortString("JMS client closing channel"), 0, 0).generateFrame(getChannelId()),
                                            ChannelCloseOkBody.class, timeout);
             // When control resumes at this point, a reply will have been received that
             // indicates the broker has closed the channel successfully.
@@ -191,7 +162,7 @@
         // Acknowledge all delivered messages
         while (true)
         {
-            Long tag = _deliveredMessageTags.poll();
+            Long tag = getDeliveredMessageTags().poll();
             if (tag == null)
             {
                 break;
@@ -202,7 +173,7 @@
 
         final AMQProtocolHandler handler = getProtocolHandler();
 
-        handler.syncWrite(getProtocolHandler().getMethodRegistry().createTxCommitBody().generateFrame(_channelId), TxCommitOkBody.class);
+        handler.syncWrite(getProtocolHandler().getMethodRegistry().createTxCommitBody().generateFrame(getChannelId()), TxCommitOkBody.class);
     }
 
     public void sendCreateQueue(AMQShortString name, final boolean autoDelete, final boolean durable, final boolean exclusive, final Map<String, Object> arguments) throws AMQException,
@@ -218,22 +189,22 @@
             }
         }
         QueueDeclareBody body = getMethodRegistry().createQueueDeclareBody(getTicket(),name,false,durable,exclusive,autoDelete,false,table);
-        AMQFrame queueDeclare = body.generateFrame(_channelId);
+        AMQFrame queueDeclare = body.generateFrame(getChannelId());
         getProtocolHandler().syncWrite(queueDeclare, QueueDeclareOkBody.class);
     }
 
     public void sendRecover() throws AMQException, FailoverException
     {
         enforceRejectBehaviourDuringRecover();
-        _prefetchedMessageTags.clear();
-        _unacknowledgedMessageTags.clear();
+        getPrefetchedMessageTags().clear();
+        getUnacknowledgedMessageTags().clear();
 
         if (isStrictAMQP())
         {
             // We can't use the BasicRecoverBody-OK method as it isn't part of the spec.
 
             BasicRecoverBody body = getMethodRegistry().createBasicRecoverBody(false);
-            _connection.getProtocolHandler().writeFrame(body.generateFrame(_channelId));
+            getAMQConnection().getProtocolHandler().writeFrame(body.generateFrame(getChannelId()));
             _logger.warn("Session Recover cannot be guaranteed with STRICT_AMQP. Messages may arrive out of order.");
         }
         else
@@ -243,17 +214,17 @@
             if(getProtocolHandler().getProtocolVersion().equals(ProtocolVersion.v8_0))
             {
                 BasicRecoverBody body = getMethodRegistry().createBasicRecoverBody(false);
-                _connection.getProtocolHandler().syncWrite(body.generateFrame(_channelId), BasicRecoverOkBody.class);
+                getAMQConnection().getProtocolHandler().syncWrite(body.generateFrame(getChannelId()), BasicRecoverOkBody.class);
             }
             else if(getProtocolVersion().equals(ProtocolVersion.v0_9))
             {
                 BasicRecoverSyncBody body = ((MethodRegistry_0_9)getMethodRegistry()).createBasicRecoverSyncBody(false);
-                _connection.getProtocolHandler().syncWrite(body.generateFrame(_channelId), BasicRecoverSyncOkBody.class);
+                getAMQConnection().getProtocolHandler().syncWrite(body.generateFrame(getChannelId()), BasicRecoverSyncOkBody.class);
             }
             else if(getProtocolVersion().equals(ProtocolVersion.v0_91))
             {
                 BasicRecoverSyncBody body = ((MethodRegistry_0_91)getMethodRegistry()).createBasicRecoverSyncBody(false);
-                _connection.getProtocolHandler().syncWrite(body.generateFrame(_channelId), BasicRecoverSyncOkBody.class);
+                getAMQConnection().getProtocolHandler().syncWrite(body.generateFrame(getChannelId()), BasicRecoverSyncOkBody.class);
             }
             else
             {
@@ -266,9 +237,9 @@
     {
         if (_logger.isDebugEnabled())
         {
-            _logger.debug("Prefetched message: _unacknowledgedMessageTags :" + _unacknowledgedMessageTags);
+            _logger.debug("Prefetched message: _unacknowledgedMessageTags :" + getUnacknowledgedMessageTags());
         }
-        ArrayList<BasicMessageConsumer_0_8> consumersToCheck = new ArrayList<BasicMessageConsumer_0_8>(_consumers.values());
+        ArrayList<BasicMessageConsumer_0_8> consumersToCheck = new ArrayList<BasicMessageConsumer_0_8>(getConsumers().values());
         boolean messageListenerFound = false;
         boolean serverRejectBehaviourFound = false;
         for(BasicMessageConsumer_0_8 consumer : consumersToCheck)
@@ -287,7 +258,7 @@
         if (serverRejectBehaviourFound)
         {
             //reject(false) any messages we don't want returned again
-            switch(_acknowledgeMode)
+            switch(getAcknowledgeMode())
             {
                 case Session.DUPS_OK_ACKNOWLEDGE:
                 case Session.AUTO_ACKNOWLEDGE:
@@ -296,7 +267,7 @@
                         break;
                     }
                 case Session.CLIENT_ACKNOWLEDGE:
-                    for(Long tag : _unacknowledgedMessageTags)
+                    for(Long tag : getUnacknowledgedMessageTags())
                     {
                         rejectMessage(tag, false);
                     }
@@ -314,7 +285,7 @@
         // consumer on the queue. Whilst this is within the JMS spec it is not
         // user friendly and avoidable.
         boolean normalRejectBehaviour = true;
-        for (BasicMessageConsumer_0_8 consumer : _consumers.values())
+        for (BasicMessageConsumer_0_8 consumer : getConsumers().values())
         {
             if(RejectBehaviour.SERVER.equals(consumer.getRejectBehaviour()))
             {
@@ -326,7 +297,7 @@
 
         while (true)
         {
-            Long tag = _deliveredMessageTags.poll();
+            Long tag = getDeliveredMessageTags().poll();
             if (tag == null)
             {
                 break;
@@ -338,8 +309,8 @@
 
     public void rejectMessage(long deliveryTag, boolean requeue)
     {
-        if ((_acknowledgeMode == CLIENT_ACKNOWLEDGE) || (_acknowledgeMode == SESSION_TRANSACTED)||
-                ((_acknowledgeMode == AUTO_ACKNOWLEDGE || _acknowledgeMode == DUPS_OK_ACKNOWLEDGE ) && hasMessageListeners()))
+        if ((getAcknowledgeMode() == CLIENT_ACKNOWLEDGE) || (getAcknowledgeMode() == SESSION_TRANSACTED)||
+                ((getAcknowledgeMode() == AUTO_ACKNOWLEDGE || getAcknowledgeMode() == DUPS_OK_ACKNOWLEDGE ) && hasMessageListeners()))
         {
             if (_logger.isDebugEnabled())
             {
@@ -347,9 +318,9 @@
             }
 
             BasicRejectBody body = getMethodRegistry().createBasicRejectBody(deliveryTag, requeue);
-            AMQFrame frame = body.generateFrame(_channelId);
+            AMQFrame frame = body.generateFrame(getChannelId());
 
-            _connection.getProtocolHandler().writeFrame(frame);
+            getAMQConnection().getProtocolHandler().writeFrame(frame);
         }
     }
 
@@ -370,12 +341,12 @@
                         public AMQMethodEvent execute() throws AMQException, FailoverException
                         {
                             AMQFrame boundFrame = getProtocolHandler().getMethodRegistry().createExchangeBoundBody
-                                                    (exchangeName, routingKey, queueName).generateFrame(_channelId);
+                                                    (exchangeName, routingKey, queueName).generateFrame(getChannelId());
 
                             return getProtocolHandler().syncWrite(boundFrame, ExchangeBoundOkBody.class);
 
                         }
-                    }, _connection).execute();
+                    }, getAMQConnection()).execute();
 
             // Extract and return the response code from the query.
             ExchangeBoundOkBody responseBody = (ExchangeBoundOkBody) response.getMethod();
@@ -392,7 +363,6 @@
                                       AMQShortString queueName,
                                       AMQProtocolHandler protocolHandler,
                                       boolean nowait,
-                                      MessageFilter messageSelector,
                                       int tag) throws AMQException, FailoverException
     {
 
@@ -406,7 +376,7 @@
                                                                            consumer.getArguments());
 
 
-        AMQFrame jmsConsume = body.generateFrame(_channelId);
+        AMQFrame jmsConsume = body.generateFrame(getChannelId());
 
         if (nowait)
         {
@@ -424,17 +394,25 @@
         ExchangeDeclareBody body = getMethodRegistry().createExchangeDeclareBody(getTicket(),name,type,
                                                                                  name.toString().startsWith("amq."),
                                                                                  false,false,false,false,null);
-        AMQFrame exchangeDeclare = body.generateFrame(_channelId);
+        AMQFrame exchangeDeclare = body.generateFrame(getChannelId());
 
         protocolHandler.syncWrite(exchangeDeclare, ExchangeDeclareOkBody.class);
     }
 
     public void sendQueueDeclare(final AMQDestination amqd, final AMQProtocolHandler protocolHandler,
-                                 final boolean nowait) throws AMQException, FailoverException
+                                 final boolean nowait, boolean passive) throws AMQException, FailoverException
     {
-        QueueDeclareBody body = getMethodRegistry().createQueueDeclareBody(getTicket(),amqd.getAMQQueueName(),false,amqd.isDurable(),amqd.isExclusive(),amqd.isAutoDelete(),false,null);
+        QueueDeclareBody body =
+                getMethodRegistry().createQueueDeclareBody(getTicket(),
+                                                           amqd.getAMQQueueName(),
+                                                           passive,
+                                                           amqd.isDurable(),
+                                                           amqd.isExclusive(),
+                                                           amqd.isAutoDelete(),
+                                                           false,
+                                                           null);
 
-        AMQFrame queueDeclare = body.generateFrame(_channelId);
+        AMQFrame queueDeclare = body.generateFrame(getChannelId());
 
         protocolHandler.syncWrite(queueDeclare, QueueDeclareOkBody.class);
     }
@@ -446,7 +424,7 @@
                                                                          false,
                                                                          false,
                                                                          true);
-        AMQFrame queueDeleteFrame = body.generateFrame(_channelId);
+        AMQFrame queueDeleteFrame = body.generateFrame(getChannelId());
 
         getProtocolHandler().syncWrite(queueDeleteFrame, QueueDeleteOkBody.class);
     }
@@ -454,8 +432,8 @@
     public void sendSuspendChannel(boolean suspend) throws AMQException, FailoverException
     {
         ChannelFlowBody body = getMethodRegistry().createChannelFlowBody(!suspend);
-        AMQFrame channelFlowFrame = body.generateFrame(_channelId);
-        _connection.getProtocolHandler().syncWrite(channelFlowFrame, ChannelFlowOkBody.class);
+        AMQFrame channelFlowFrame = body.generateFrame(getChannelId());
+        getAMQConnection().getProtocolHandler().syncWrite(channelFlowFrame, ChannelFlowOkBody.class);
     }
 
     public BasicMessageConsumer_0_8 createMessageConsumer(final AMQDestination destination, final int prefetchHigh,
@@ -464,18 +442,18 @@
     {
 
         final AMQProtocolHandler protocolHandler = getProtocolHandler();
-       return new BasicMessageConsumer_0_8(_channelId, _connection, destination, messageSelector, noLocal,
-                                 _messageFactoryRegistry,this, protocolHandler, arguments, prefetchHigh, prefetchLow,
-                                 exclusive, _acknowledgeMode, noConsume, autoClose);
+       return new BasicMessageConsumer_0_8(getChannelId(), getAMQConnection(), destination, messageSelector, noLocal,
+               getMessageFactoryRegistry(),this, protocolHandler, arguments, prefetchHigh, prefetchLow,
+                                 exclusive, getAcknowledgeMode(), noConsume, autoClose);
     }
 
 
-    public BasicMessageProducer_0_8 createMessageProducer(final Destination destination, final boolean mandatory,
-            final boolean immediate, long producerId) throws JMSException
+    public BasicMessageProducer_0_8 createMessageProducer(final Destination destination, final Boolean mandatory,
+            final Boolean immediate, long producerId) throws JMSException
     {
        try
        {
-           return new BasicMessageProducer_0_8(_connection, (AMQDestination) destination, _transacted, _channelId,
+           return new BasicMessageProducer_0_8(getAMQConnection(), (AMQDestination) destination, isTransacted(), getChannelId(),
                                  this, getProtocolHandler(), producerId, immediate, mandatory);
        }
        catch (AMQException e)
@@ -505,7 +483,7 @@
 
     private void returnBouncedMessage(final ReturnMessage msg)
     {
-        _connection.performConnectionTask(new Runnable()
+        getAMQConnection().performConnectionTask(new Runnable()
         {
             public void run()
             {
@@ -513,8 +491,8 @@
                 {
                     // Bounced message is processed here, away from the mina thread
                     AbstractJMSMessage bouncedMessage =
-                            _messageFactoryRegistry.createMessage(0, false, msg.getExchange(),
-                                                                  msg.getRoutingKey(), msg.getContentHeader(), msg.getBodies(),_queueDestinationCache,_topicDestinationCache);
+                            getMessageFactoryRegistry().createMessage(0, false, msg.getExchange(),
+                                    msg.getRoutingKey(), msg.getContentHeader(), msg.getBodies(), _queueDestinationCache, _topicDestinationCache);
                     AMQConstant errorCode = AMQConstant.getConstant(msg.getReplyCode());
                     AMQShortString reason = msg.getReplyText();
                     _logger.debug("Message returned with error code " + errorCode + " (" + reason + ")");
@@ -522,20 +500,17 @@
                     // @TODO should this be moved to an exception handler of sorts. Somewhere errors are converted to correct execeptions.
                     if (errorCode == AMQConstant.NO_CONSUMERS)
                     {
-                        _connection.exceptionReceived(new AMQNoConsumersException("Error: " + reason, bouncedMessage, null));
-                    }
-                    else if (errorCode == AMQConstant.NO_ROUTE)
+                        getAMQConnection().exceptionReceived(new AMQNoConsumersException("Error: " + reason, bouncedMessage, null));
+                    } else if (errorCode == AMQConstant.NO_ROUTE)
                     {
-                        _connection.exceptionReceived(new AMQNoRouteException("Error: " + reason, bouncedMessage, null));
-                    }
-                    else
+                        getAMQConnection().exceptionReceived(new AMQNoRouteException("Error: " + reason, bouncedMessage, null));
+                    } else
                     {
-                        _connection.exceptionReceived(
+                        getAMQConnection().exceptionReceived(
                                 new AMQUndeliveredException(errorCode, "Error: " + reason, bouncedMessage, null));
                     }
 
-                }
-                catch (Exception e)
+                } catch (Exception e)
                 {
                     _logger.error(
                             "Caught exception trying to raise undelivered message exception (dump follows) - ignoring...",
@@ -571,7 +546,7 @@
                   
                         return null;
                     }
-                 }, _connection).execute();
+                 }, getAMQConnection()).execute();
     }
 
     public DestinationCache<AMQQueue> getQueueDestinationCache()
@@ -607,9 +582,18 @@
             return matches;
         }
 
+        public long getMessageCount()
+        {
+            return _messageCount;
+        }
+
+        public long getConsumerCount()
+        {
+            return _consumerCount;
+        }
     }
 
-    protected Long requestQueueDepth(AMQDestination amqd) throws AMQException, FailoverException
+    protected Long requestQueueDepth(AMQDestination amqd, boolean sync) throws AMQException, FailoverException
     {
         AMQFrame queueDeclare =
             getMethodRegistry().createQueueDeclareBody(getTicket(),
@@ -619,10 +603,10 @@
                                                        amqd.isExclusive(),
                                                        amqd.isAutoDelete(),
                                                        false,
-                                                       null).generateFrame(_channelId);
+                                                       null).generateFrame(getChannelId());
         QueueDeclareOkHandler okHandler = new QueueDeclareOkHandler();
         getProtocolHandler().writeCommandFrameAndWaitForReply(queueDeclare, okHandler);        
-        return okHandler._messageCount;
+        return okHandler.getMessageCount();
     }
 
     protected boolean tagLE(long tag1, long tag2)
@@ -647,6 +631,7 @@
 
     public void handleAddressBasedDestination(AMQDestination dest, 
                                               boolean isConsumer,
+                                              boolean noLocal,
                                               boolean noWait) throws AMQException
     {
         throw new UnsupportedOperationException("The new addressing based sytanx is "
@@ -683,7 +668,7 @@
     {
         // if the Connection has closed then we should throw any exception that
         // has occurred that we were not waiting for
-        AMQStateManager manager = _connection.getProtocolHandler()
+        AMQStateManager manager = getAMQConnection().getProtocolHandler()
                 .getStateManager();
         
         Exception e = manager.getLastException();
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java
index 28f8380..11145e1 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java
@@ -20,12 +20,11 @@
  */
 package org.apache.qpid.client;
 
-import java.util.UUID;
+import org.apache.qpid.framing.AMQShortString;
 
 import javax.jms.JMSException;
 import javax.jms.TemporaryQueue;
-
-import org.apache.qpid.framing.AMQShortString;
+import java.util.UUID;
 
 /** AMQ implementation of a TemporaryQueue. */
 final class AMQTemporaryQueue extends AMQQueue implements TemporaryQueue, TemporaryDestination
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java
index 5969d9a..f09ef5e 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java
@@ -20,17 +20,16 @@
  */
 package org.apache.qpid.client;
 
-import java.net.URISyntaxException;
-
-import javax.jms.InvalidDestinationException;
-import javax.jms.JMSException;
-import javax.jms.Topic;
-
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.messaging.Address;
 import org.apache.qpid.url.BindingURL;
 
+import javax.jms.InvalidDestinationException;
+import javax.jms.JMSException;
+import javax.jms.Topic;
+import java.net.URISyntaxException;
+
 public class AMQTopic extends AMQDestination implements Topic
 {
     public AMQTopic(String address) throws URISyntaxException
@@ -175,7 +174,7 @@
         }
         else
         {
-            return _exchangeName;
+            return super.getExchangeName();
         }
     }
 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopicSessionAdaptor.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopicSessionAdaptor.java
index ec482a8..0f44ac5 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopicSessionAdaptor.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopicSessionAdaptor.java
@@ -20,182 +20,30 @@
  */
 package org.apache.qpid.client;
 
-import java.io.Serializable;
-
-import javax.jms.BytesMessage;
-import javax.jms.Destination;
+import javax.jms.*;
 import javax.jms.IllegalStateException;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.QueueBrowser;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TemporaryQueue;
-import javax.jms.TemporaryTopic;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicPublisher;
-import javax.jms.TopicSession;
-import javax.jms.TopicSubscriber;
 
-public class AMQTopicSessionAdaptor implements TopicSession, AMQSessionAdapter
+class AMQTopicSessionAdaptor extends AMQSessionAdapter<TopicSession> implements TopicSession
 {
-    protected final AMQSession _session;
 
-    public AMQTopicSessionAdaptor(Session session)
+    public AMQTopicSessionAdaptor(TopicSession session)
     {
-        _session = (AMQSession) session;
-    }
-
-    public Topic createTopic(String string) throws JMSException
-    {
-        return _session.createTopic(string);
+        super(session);
     }
 
     public TopicSubscriber createSubscriber(Topic topic) throws JMSException
     {
-        return _session.createSubscriber(topic);
+        return getSession().createSubscriber(topic);
     }
 
     public TopicSubscriber createSubscriber(Topic topic, String string, boolean b) throws JMSException
     {
-        return _session.createSubscriber(topic, string, b);
-    }
-
-    public TopicSubscriber createDurableSubscriber(Topic topic, String string) throws JMSException
-    {
-        return _session.createDurableSubscriber(topic, string);
-    }
-
-    public TopicSubscriber createDurableSubscriber(Topic topic, String string, String string1, boolean b) throws JMSException
-    {
-        return _session.createDurableSubscriber(topic, string, string1, b);
+        return getSession().createSubscriber(topic, string, b);
     }
 
     public TopicPublisher createPublisher(Topic topic) throws JMSException
     {
-        return _session.createPublisher(topic);
-    }
-
-    public TemporaryTopic createTemporaryTopic() throws JMSException
-    {
-        return _session.createTemporaryTopic();
-    }
-
-    public void unsubscribe(String string) throws JMSException
-    {
-        _session.unsubscribe(string);
-    }
-
-    public BytesMessage createBytesMessage() throws JMSException
-    {
-        return _session.createBytesMessage();
-    }
-
-    public MapMessage createMapMessage() throws JMSException
-    {
-        return _session.createMapMessage();
-    }
-
-    public Message createMessage() throws JMSException
-    {
-        return _session.createMessage();
-    }
-
-    public ObjectMessage createObjectMessage() throws JMSException
-    {
-        return _session.createObjectMessage();
-    }
-
-    public ObjectMessage createObjectMessage(Serializable serializable) throws JMSException
-    {
-        return _session.createObjectMessage(serializable);
-    }
-
-    public StreamMessage createStreamMessage() throws JMSException
-    {
-        return _session.createStreamMessage();
-    }
-
-    public TextMessage createTextMessage() throws JMSException
-    {
-        return _session.createTextMessage();
-    }
-
-    public TextMessage createTextMessage(String string) throws JMSException
-    {
-        return _session.createTextMessage(string);
-    }
-
-    public boolean getTransacted() throws JMSException
-    {
-        return _session.getTransacted();
-    }
-
-    public int getAcknowledgeMode() throws JMSException
-    {
-        return _session.getAcknowledgeMode();
-    }
-
-    public void commit() throws JMSException
-    {
-        _session.commit();
-    }
-
-    public void rollback() throws JMSException
-    {
-        _session.rollback();
-    }
-
-    public void close() throws JMSException
-    {
-        _session.close();
-    }
-
-    public void recover() throws JMSException
-    {
-        _session.recover();
-    }
-
-    public MessageListener getMessageListener() throws JMSException
-    {
-        return _session.getMessageListener();
-    }
-
-    public void setMessageListener(MessageListener messageListener) throws JMSException
-    {
-        _session.setMessageListener(messageListener);
-    }
-
-    public void run()
-    {
-        _session.run();
-    }
-
-    public MessageProducer createProducer(Destination destination) throws JMSException
-    {
-        return _session.createProducer(destination);
-    }
-
-    public MessageConsumer createConsumer(Destination destination) throws JMSException
-    {
-        return _session.createConsumer(destination);
-    }
-
-    public MessageConsumer createConsumer(Destination destination, String string) throws JMSException
-    {
-        return _session.createConsumer(destination, string);
-    }
-
-    public MessageConsumer createConsumer(Destination destination, String string, boolean b) throws JMSException
-    {
-        return _session.createConsumer(destination, string, b);
+        return getSession().createPublisher(topic);
     }
 
     //The following methods cannot be called from a TopicSession as per JMS spec
@@ -219,8 +67,4 @@
         throw new IllegalStateException("Cannot call createTemporaryQueue from TopicSession");
     }
 
-    public AMQSession getSession()
-    {
-        return _session;
-    }
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
index c6e5fbb..0d717a3 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
@@ -20,29 +20,35 @@
  */
 package org.apache.qpid.client;
 
-import org.apache.qpid.AMQInternalException;
-import org.apache.qpid.filter.JMSSelectorFilter;
-import org.apache.qpid.filter.MessageFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
+import org.apache.qpid.AMQInternalException;
 import org.apache.qpid.client.failover.FailoverException;
-import org.apache.qpid.client.message.*;
+import org.apache.qpid.client.filter.MessageFilter;
+import org.apache.qpid.client.message.AMQMessageDelegateFactory;
+import org.apache.qpid.client.message.AbstractJMSMessage;
+import org.apache.qpid.client.message.CloseConsumerMessage;
+import org.apache.qpid.client.message.MessageFactoryRegistry;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
 import org.apache.qpid.common.AMQPFilterTypes;
-import org.apache.qpid.framing.*;
+import org.apache.qpid.client.filter.JMSSelectorFilter;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.FieldTableFactory;
 import org.apache.qpid.jms.MessageConsumer;
 import org.apache.qpid.jms.Session;
 import org.apache.qpid.transport.TransportException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.jms.InvalidSelectorException;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
-import java.util.ArrayList;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -54,14 +60,13 @@
 {
     private static final Logger _logger = LoggerFactory.getLogger(BasicMessageConsumer.class);
 
-    /** The connection being used by this consumer */
-    protected final AMQConnection _connection;
+    private final AMQConnection _connection;
 
-    protected final MessageFilter _messageSelectorFilter;
+    private final MessageFilter _messageSelectorFilter;
 
     private final boolean _noLocal;
 
-    protected AMQDestination _destination;
+    private AMQDestination _destination;
 
     /**
      * When true indicates that a blocking receive call is in progress
@@ -72,23 +77,17 @@
      */
     private final AtomicReference<MessageListener> _messageListener = new AtomicReference<MessageListener>();
 
-    /** The consumer tag allows us to close the consumer by sending a jmsCancel method to the broker */
-    protected int _consumerTag;
+    private int _consumerTag;
 
-    /** We need to know the channel id when constructing frames */
-    protected final int _channelId;
+    private final int _channelId;
 
-    /**
-     * Used in the blocking receive methods to receive a message from the Session thread. <p/> Or to notify of errors
-     * <p/> Argument true indicates we want strict FIFO semantics
-     */
-    protected final BlockingQueue _synchronousQueue;
+    private final BlockingQueue _synchronousQueue;
 
-    protected final MessageFactoryRegistry _messageFactory;
+    private final MessageFactoryRegistry _messageFactory;
 
-    protected final AMQSession _session;
+    private final AMQSession _session;
 
-    protected final AMQProtocolHandler _protocolHandler;
+    private final AMQProtocolHandler _protocolHandler;
 
     /**
      * We need to store the "raw" field table so that we can resubscribe in the event of failover being required
@@ -107,17 +106,9 @@
      */
     private final int _prefetchLow;
 
-    /**
-     * We store the exclusive field in order to be able to reuse it when resubscribing in the event of failover
-     */
-    protected boolean _exclusive;
+    private boolean _exclusive;
 
-    /**
-     * The acknowledge mode in force for this consumer. Note that the AMQP protocol allows different ack modes per
-     * consumer whereas JMS defines this at the session level, hence why we associate it with the consumer in our
-     * implementation.
-     */
-    protected final int _acknowledgeMode;
+    private final int _acknowledgeMode;
 
     /**
      * List of tags delievered, The last of which which should be acknowledged on commit in transaction mode.
@@ -208,6 +199,10 @@
         // possible to determine  when querying the broker whether there are no arguments or just a non-matching selector
         // argument, as specifying null for the arguments when querying means they should not be checked at all
         ft.put(AMQPFilterTypes.JMS_SELECTOR.getValue(), messageSelector == null ? "" : messageSelector);
+        if(noLocal)
+        {
+            ft.put(AMQPFilterTypes.NO_LOCAL.getValue(), noLocal);
+        }
 
         _arguments = ft;
 
@@ -232,6 +227,11 @@
         return _messageListener.get();
     }
 
+    /**
+     * The acknowledge mode in force for this consumer. Note that the AMQP protocol allows different ack modes per
+     * consumer whereas JMS defines this at the session level, hence why we associate it with the consumer in our
+     * implementation.
+     */
     public int getAcknowledgeMode()
     {
         return _acknowledgeMode;
@@ -279,7 +279,10 @@
                 throw new javax.jms.IllegalStateException("Attempt to alter listener while session is started.");
             }
 
-            _logger.debug("Message listener set for destination " + _destination);
+            if (_logger.isDebugEnabled())
+            {
+            	_logger.debug("Message listener set for destination " + _destination);
+            }
 
             if (messageListener != null)
             {
@@ -371,6 +374,9 @@
         return _noLocal;
     }
 
+    /**
+     * We store the exclusive field in order to be able to reuse it when resubscribing in the event of failover
+     */
     public boolean isExclusive()
     {
         return _exclusive;
@@ -537,7 +543,7 @@
         }
         else if (o instanceof CloseConsumerMessage)
         {
-            _closed.set(true);
+            setClosed();
             deregisterConsumer();
             return null;
         }
@@ -554,14 +560,14 @@
 
     public void close(boolean sendClose) throws JMSException
     {
-        if (_logger.isInfoEnabled())
+        if (_logger.isDebugEnabled())
         {
-            _logger.info("Closing consumer:" + debugIdentity());
+            _logger.debug("Closing consumer:" + debugIdentity());
         }
 
-        if (!_closed.getAndSet(true))
+        if (!setClosed())
         {
-            _closing.set(true);
+            setClosing(true);
             if (_logger.isDebugEnabled())
             {
                 StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
@@ -607,12 +613,8 @@
             }
             else
             {
-            	// FIXME: wow this is ugly
-                // //fixme this probably is not right
-                // if (!isNoConsume())
-                { // done in BasicCancelOK Handler but not sending one so just deregister.
-                    deregisterConsumer();
-                }
+            	// FIXME?
+                deregisterConsumer();
             }
 
             // This will occur if session.close is called closing all consumers we may be blocked waiting for a receive
@@ -641,7 +643,7 @@
     {
         // synchronized (_closed)
         {
-            _closed.set(true);
+            setClosed();
 
             if (_logger.isDebugEnabled())
             {
@@ -818,7 +820,7 @@
     {
         // synchronized (_closed)
         {
-            _closed.set(true);
+            setClosed();
             if (_logger.isDebugEnabled())
             {
                 StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
@@ -859,6 +861,7 @@
         _session.deregisterConsumer(this);
     }
 
+    /** The consumer tag allows us to close the consumer by sending a jmsCancel method to the broker */
     public int getConsumerTag()
     {
         return _consumerTag;
@@ -1002,10 +1005,44 @@
     public void failedOverPre()
     {
         clearReceiveQueue();
-        // TGM FIXME: think this should just be removed
-        // clearUnackedMessages();
     }
 
     public void failedOverPost() {}
 
+    /** The connection being used by this consumer */
+    protected AMQConnection getConnection()
+    {
+        return _connection;
+    }
+
+    protected void setDestination(AMQDestination destination)
+    {
+        _destination = destination;
+    }
+
+    /** We need to know the channel id when constructing frames */
+    protected int getChannelId()
+    {
+        return _channelId;
+    }
+
+    /**
+     * Used in the blocking receive methods to receive a message from the Session thread. <p/> Or to notify of errors
+     * <p/> Argument true indicates we want strict FIFO semantics
+     */
+    protected BlockingQueue getSynchronousQueue()
+    {
+        return _synchronousQueue;
+    }
+
+    protected MessageFactoryRegistry getMessageFactory()
+    {
+        return _messageFactory;
+    }
+
+    protected AMQProtocolHandler getProtocolHandler()
+    {
+        return _protocolHandler;
+    }
+
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java
index 3b6179d..26bb51b 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java
@@ -19,21 +19,32 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQDestination.AddressOption;
 import org.apache.qpid.client.failover.FailoverException;
-import org.apache.qpid.client.message.*;
+import org.apache.qpid.client.message.AMQMessageDelegateFactory;
+import org.apache.qpid.client.message.AMQMessageDelegate_0_10;
+import org.apache.qpid.client.message.AbstractJMSMessage;
+import org.apache.qpid.client.message.MessageFactoryRegistry;
+import org.apache.qpid.client.message.UnprocessedMessage_0_10;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
 import org.apache.qpid.common.ServerPropertyNames;
 import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.protocol.AMQConstant;
-import org.apache.qpid.transport.*;
 import org.apache.qpid.jms.Session;
+import org.apache.qpid.protocol.AMQConstant;
+import org.apache.qpid.transport.Acquired;
+import org.apache.qpid.transport.MessageCreditUnit;
+import org.apache.qpid.transport.Option;
+import org.apache.qpid.transport.Range;
+import org.apache.qpid.transport.RangeSet;
+import org.apache.qpid.transport.RangeSetFactory;
+import org.apache.qpid.transport.SessionException;
+import org.apache.qpid.transport.TransportException;
 
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
-
 import java.util.Iterator;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -46,7 +57,7 @@
     /**
      * This class logger
      */
-    protected final Logger _logger = LoggerFactory.getLogger(getClass());
+    private final Logger _logger = LoggerFactory.getLogger(getClass());
 
     /**
      * The underlying QpidSession
@@ -67,7 +78,7 @@
     private final long _capacity;
 
     /** Flag indicating if the server supports message selectors */
-    protected final boolean _serverJmsSelectorSupport;
+    private final boolean _serverJmsSelectorSupport;
 
     protected BasicMessageConsumer_0_10(int channelId, AMQConnection connection, AMQDestination destination,
                                         String messageSelector, boolean noLocal, MessageFactoryRegistry messageFactory,
@@ -80,11 +91,10 @@
                 rawSelector, prefetchHigh, prefetchLow, exclusive, acknowledgeMode, browseOnly, autoClose);
         _0_10session = (AMQSession_0_10) session;
 
-        _preAcquire = evaluatePreAcquire(browseOnly, destination);
+        _serverJmsSelectorSupport = connection.isSupportedServerFeature(ServerPropertyNames.FEATURE_QPID_JMS_SELECTOR);
+        _preAcquire = evaluatePreAcquire(browseOnly, destination, _serverJmsSelectorSupport);
 
         _capacity = evaluateCapacity(destination);
-        _serverJmsSelectorSupport = connection.isSupportedServerFeature(ServerPropertyNames.FEATURE_QPID_JMS_SELECTOR);
-
 
         if (destination.isAddressResolved() && AMQDestination.TOPIC_TYPE == destination.getAddressType()) 
         {            
@@ -92,8 +102,8 @@
             
             if (!namedQueue)
             {
-                _destination = destination.copyDestination();
-                _destination.setQueueName(null);
+                setDestination(destination.copyDestination());
+                getDestination().setQueueName(null);
             }
         }
     }
@@ -181,14 +191,14 @@
     {
         super.preDeliver(jmsMsg);
 
-        if (_acknowledgeMode == org.apache.qpid.jms.Session.NO_ACKNOWLEDGE)
+        if (getAcknowledgeMode() == org.apache.qpid.jms.Session.NO_ACKNOWLEDGE)
         {
             //For 0-10 we need to ensure that all messages are indicated processed in some way to
             //ensure their AMQP command-id is marked completed, and so we must send a completion
             //even for no-ack messages even though there isnt actually an 'acknowledgement' occurring.
             //Add message to the unacked message list to ensure we dont lose record of it before
             //sending a completion of some sort.
-            _session.addUnacknowledgedMessage(jmsMsg.getDeliveryTag());
+            getSession().addUnacknowledgedMessage(jmsMsg.getDeliveryTag());
         }
     }
 
@@ -196,7 +206,7 @@
             AMQMessageDelegateFactory delegateFactory, UnprocessedMessage_0_10 msg) throws Exception
     {
         AMQMessageDelegate_0_10.updateExchangeTypeMapping(msg.getMessageTransfer().getHeader(), ((AMQSession_0_10)getSession()).getQpidSession());
-        return _messageFactory.createMessage(msg.getMessageTransfer());
+        return getMessageFactory().createMessage(msg.getMessageTransfer());
     }
 
     /**
@@ -211,9 +221,9 @@
         boolean messageOk = true;
         try
         {
-            if (_messageSelectorFilter != null && !_serverJmsSelectorSupport)
+            if (!_serverJmsSelectorSupport && getMessageSelectorFilter() != null)
             {
-                messageOk = _messageSelectorFilter.matches(message);
+                messageOk = getMessageSelectorFilter().matches(message);
             }
         }
         catch (Exception e)
@@ -274,7 +284,7 @@
     {
         _0_10session.messageAcknowledge
             (Range.newInstance((int) message.getDeliveryTag()),
-             _acknowledgeMode != org.apache.qpid.jms.Session.NO_ACKNOWLEDGE);
+             getAcknowledgeMode() != org.apache.qpid.jms.Session.NO_ACKNOWLEDGE);
 
         final AMQException amqe = _0_10session.getCurrentException();
         if (amqe != null)
@@ -338,20 +348,20 @@
             {
                 messageFlow();
             }
-            if (messageListener != null && !_synchronousQueue.isEmpty())
+            if (messageListener != null && !getSynchronousQueue().isEmpty())
             {
-                Iterator messages=_synchronousQueue.iterator();
+                Iterator messages= getSynchronousQueue().iterator();
                 while (messages.hasNext())
                 {
                     AbstractJMSMessage message=(AbstractJMSMessage) messages.next();
                     messages.remove();
-                    _session.rejectMessage(message, true);
+                    getSession().rejectMessage(message, true);
                 }
             }
         }
         catch(TransportException e)
         {
-            throw _session.toJMSException("Exception while setting message listener:"+ e.getMessage(), e);
+            throw getSession().toJMSException("Exception while setting message listener:" + e.getMessage(), e);
         }
     }
 
@@ -378,7 +388,7 @@
         {
             _syncReceive.set(true);
         }
-        if (_0_10session.isStarted() && _capacity == 0 && _synchronousQueue.isEmpty())
+        if (_0_10session.isStarted() && _capacity == 0 && getSynchronousQueue().isEmpty())
         {
             messageFlow();
         }
@@ -415,19 +425,19 @@
     {
         super.postDeliver(msg);
 
-        switch (_acknowledgeMode)
+        switch (getAcknowledgeMode())
         {
             case Session.SESSION_TRANSACTED:
                 _0_10session.sendTxCompletionsIfNecessary();
                 break;
             case Session.NO_ACKNOWLEDGE:
-                if (!_session.isInRecovery())
+                if (!getSession().isInRecovery())
                 {
-                  _session.acknowledgeMessage(msg.getDeliveryTag(), false);
+                  getSession().acknowledgeMessage(msg.getDeliveryTag(), false);
                 }
                 break;
             case Session.AUTO_ACKNOWLEDGE:
-                if (!_session.isInRecovery() && _session.getAMQConnection().getSyncAck())
+                if (!getSession().isInRecovery() && getSession().getAMQConnection().getSyncAck())
                 {
                     ((AMQSession_0_10) getSession()).getQpidSession().sync();
                 }
@@ -443,10 +453,10 @@
 
     @Override public void rollbackPendingMessages()
     {
-        if (_synchronousQueue.size() > 0)
+        if (getSynchronousQueue().size() > 0)
         {
             RangeSet ranges = RangeSetFactory.createRangeSet();
-            Iterator iterator = _synchronousQueue.iterator();
+            Iterator iterator = getSynchronousQueue().iterator();
             while (iterator.hasNext())
             {
 
@@ -486,7 +496,7 @@
         }
         else
         {
-            return _exclusive;
+            return super.isExclusive();
         }
     }
     
@@ -514,7 +524,7 @@
         return _preAcquire;
     }
 
-    private boolean evaluatePreAcquire(boolean browseOnly, AMQDestination destination)
+    private boolean evaluatePreAcquire(boolean browseOnly, AMQDestination destination, boolean serverJmsSelectorSupport)
     {
         boolean preAcquire;
         if (browseOnly)
@@ -524,7 +534,7 @@
         else
         {
             boolean isQueue = (destination instanceof AMQQueue || getDestination().getAddressType() == AMQDestination.QUEUE_TYPE);
-            if (isQueue && getMessageSelectorFilter() != null)
+            if (!serverJmsSelectorSupport && isQueue && getMessageSelectorFilter() != null)
             {
                 preAcquire = false;
             }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_8.java b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_8.java
index b2f4fce..b00f9dd 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_8.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_8.java
@@ -20,24 +20,31 @@
  */
 package org.apache.qpid.client;
 
-import javax.jms.JMSException;
-import javax.jms.Message;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.failover.FailoverException;
-import org.apache.qpid.client.message.*;
-import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.common.AMQPFilterTypes;
-import org.apache.qpid.configuration.ClientProperties;
-import org.apache.qpid.framing.*;
-import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.url.BindingURL;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.failover.FailoverException;
+import org.apache.qpid.client.message.AMQMessageDelegateFactory;
+import org.apache.qpid.client.message.AbstractJMSMessage;
+import org.apache.qpid.client.message.MessageFactoryRegistry;
+import org.apache.qpid.client.message.UnprocessedMessage_0_8;
+import org.apache.qpid.client.protocol.AMQProtocolHandler;
+import org.apache.qpid.common.AMQPFilterTypes;
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.framing.AMQFrame;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicCancelBody;
+import org.apache.qpid.framing.BasicCancelOkBody;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.jms.ConnectionURL;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+
 public class BasicMessageConsumer_0_8 extends BasicMessageConsumer<UnprocessedMessage_0_8>
 {
-    protected final Logger _logger = LoggerFactory.getLogger(getClass());
+    private final Logger _logger = LoggerFactory.getLogger(getClass());
     private AMQSession_0_8.DestinationCache<AMQTopic> _topicDestinationCache;
     private AMQSession_0_8.DestinationCache<AMQQueue> _queueDestinationCache;
 
@@ -88,11 +95,11 @@
 
     void sendCancel() throws AMQException, FailoverException
     {
-        BasicCancelBody body = getSession().getMethodRegistry().createBasicCancelBody(new AMQShortString(String.valueOf(_consumerTag)), false);
+        BasicCancelBody body = getSession().getMethodRegistry().createBasicCancelBody(new AMQShortString(String.valueOf(getConsumerTag())), false);
 
-        final AMQFrame cancelFrame = body.generateFrame(_channelId);
+        final AMQFrame cancelFrame = body.generateFrame(getChannelId());
 
-        _protocolHandler.syncWrite(cancelFrame, BasicCancelOkBody.class);
+        getProtocolHandler().syncWrite(cancelFrame, BasicCancelOkBody.class);
 
         if (_logger.isDebugEnabled())
         {
@@ -103,9 +110,9 @@
     public AbstractJMSMessage createJMSMessageFromUnprocessedMessage(AMQMessageDelegateFactory delegateFactory, UnprocessedMessage_0_8 messageFrame)throws Exception
     {
 
-        return _messageFactory.createMessage(messageFrame.getDeliveryTag(),
-                                             messageFrame.isRedelivered(), messageFrame.getExchange(),
-                                             messageFrame.getRoutingKey(), messageFrame.getContentHeader(), messageFrame.getBodies(),
+        return getMessageFactory().createMessage(messageFrame.getDeliveryTag(),
+                messageFrame.isRedelivered(), messageFrame.getExchange(),
+                messageFrame.getRoutingKey(), messageFrame.getContentHeader(), messageFrame.getBodies(),
                 _queueDestinationCache, _topicDestinationCache);
 
     }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
index bf4de78..9b3b2ce 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
@@ -22,7 +22,6 @@
 
 import java.io.UnsupportedEncodingException;
 import java.util.UUID;
-
 import javax.jms.BytesMessage;
 import javax.jms.DeliveryMode;
 import javax.jms.Destination;
@@ -33,12 +32,11 @@
 import javax.jms.ObjectMessage;
 import javax.jms.StreamMessage;
 import javax.jms.TextMessage;
-
+import javax.jms.Topic;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.message.AbstractJMSMessage;
 import org.apache.qpid.client.message.MessageConverter;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.framing.ContentBody;
 import org.apache.qpid.transport.TransportException;
 import org.apache.qpid.util.UUIDGen;
 import org.apache.qpid.util.UUIDs;
@@ -49,14 +47,11 @@
 {
     enum PublishMode { ASYNC_PUBLISH_ALL, SYNC_PUBLISH_PERSISTENT, SYNC_PUBLISH_ALL };
 
-    protected final Logger _logger = LoggerFactory.getLogger(getClass());
+    private final Logger _logger ;
 
     private AMQConnection _connection;
 
-    /**
-     * If true, messages will not get a timestamp.
-     */
-    protected boolean _disableTimestamps;
+    private boolean _disableTimestamps;
 
     /**
      * Priority of messages created by this producer.
@@ -73,10 +68,7 @@
      */
     private int _deliveryMode = DeliveryMode.PERSISTENT;
 
-    /**
-     * The Destination used for this consumer, if specified upon creation.
-     */
-    protected AMQDestination _destination;
+    private AMQDestination _destination;
 
     /**
      * Default encoding used for messages produced by this producer.
@@ -88,14 +80,14 @@
      */
     private String _mimeType;
 
-    protected AMQProtocolHandler _protocolHandler;
+    private AMQProtocolHandler _protocolHandler;
 
     /**
      * True if this producer was created from a transacted session
      */
     private boolean _transacted;
 
-    protected int _channelId;
+    private int _channelId;
 
     /**
      * This is an id generated by the session and is used to tie individual producers to the session. This means we
@@ -105,29 +97,49 @@
      */
     private long _producerId;
 
-    /**
-     * The session used to create this producer
-     */
-    protected AMQSession _session;
+    private AMQSession _session;
 
     private final boolean _immediate;
 
-    private final boolean _mandatory;
+    private final Boolean _mandatory;
 
     private boolean _disableMessageId;
 
     private UUIDGen _messageIdGenerator = UUIDs.newGenerator();
 
-    protected String _userID;  // ref user id used in the connection.
+    private String _userID;  // ref user id used in the connection.
 
-    private static final ContentBody[] NO_CONTENT_BODIES = new ContentBody[0];
 
-    protected PublishMode publishMode = PublishMode.ASYNC_PUBLISH_ALL;
+    /**
+     * The default value for immediate flag used this producer is false. That is, a consumer does
+     * not need to be attached to a queue.
+     */
+    private final boolean _defaultImmediateValue = Boolean.parseBoolean(System.getProperty("qpid.default_immediate", "false"));
 
-    protected BasicMessageProducer(AMQConnection connection, AMQDestination destination, boolean transacted, int channelId,
-                                   AMQSession session, AMQProtocolHandler protocolHandler, long producerId, boolean immediate, boolean mandatory) throws AMQException
+    /**
+     * The default value for mandatory flag used by this producer is true. That is, server will not
+     * silently drop messages where no queue is connected to the exchange for the message.
+     */
+    private final boolean _defaultMandatoryValue = Boolean.parseBoolean(System.getProperty("qpid.default_mandatory", "true"));
+
+    /**
+     * The default value for mandatory flag used by this producer when publishing to a Topic is false. That is, server
+     * will silently drop messages where no queue is connected to the exchange for the message.
+     */
+    private final boolean _defaultMandatoryTopicValue =
+            Boolean.parseBoolean(System.getProperty("qpid.default_mandatory_topic",
+                    System.getProperties().containsKey("qpid.default_mandatory")
+                            ? System.getProperty("qpid.default_mandatory")
+                            : "false"));
+
+    private PublishMode publishMode = PublishMode.ASYNC_PUBLISH_ALL;
+
+    protected BasicMessageProducer(Logger logger,AMQConnection connection, AMQDestination destination, boolean transacted, int channelId,
+                                   AMQSession session, AMQProtocolHandler protocolHandler, long producerId,
+                                   Boolean immediate, Boolean mandatory) throws AMQException
     {
-        _connection = connection;
+    	_logger = logger;
+    	_connection = connection;
         _destination = destination;
         _transacted = transacted;
         _protocolHandler = protocolHandler;
@@ -139,8 +151,14 @@
             declareDestination(destination);
         }
 
-        _immediate = immediate;
-        _mandatory = mandatory;
+        _immediate = immediate == null ? _defaultImmediateValue : immediate;
+        _mandatory = mandatory == null
+                ? destination == null ? null
+                                      : destination instanceof Topic
+                                            ? _defaultMandatoryTopicValue
+                                            : _defaultMandatoryValue
+                : mandatory;
+
         _userID = connection.getUsername();
         setPublishMode();
     }
@@ -161,7 +179,10 @@
             publishMode = PublishMode.SYNC_PUBLISH_ALL;
         }
 
-        _logger.info("MessageProducer " + toString() + " using publish mode : " + publishMode);
+        if (_logger.isDebugEnabled())
+        {
+        	_logger.debug("MessageProducer " + toString() + " using publish mode : " + publishMode);
+        }
     }
 
     void resubscribe() throws AMQException
@@ -256,6 +277,14 @@
         return _timeToLive;
     }
 
+    protected AMQDestination getAMQDestination()
+    {
+        return _destination;
+    }
+
+    /**
+     * The Destination used for this consumer, if specified upon creation.
+     */
     public Destination getDestination() throws JMSException
     {
         checkNotClosed();
@@ -265,7 +294,7 @@
 
     public void close() throws JMSException
     {
-        _closed.set(true);
+        setClosed();
         _session.deregisterProducer(_producerId);
     }
 
@@ -319,7 +348,12 @@
         synchronized (_connection.getFailoverMutex())
         {
             validateDestination(destination);
-            sendImpl((AMQDestination) destination, message, _deliveryMode, _messagePriority, _timeToLive, _mandatory,
+            sendImpl((AMQDestination) destination, message, _deliveryMode, _messagePriority, _timeToLive,
+                    _mandatory == null
+                            ? destination instanceof Topic
+                                ? _defaultMandatoryTopicValue
+                                : _defaultMandatoryValue
+                            : _mandatory,
                      _immediate);
         }
     }
@@ -332,7 +366,13 @@
         synchronized (_connection.getFailoverMutex())
         {
             validateDestination(destination);
-            sendImpl((AMQDestination) destination, message, deliveryMode, priority, timeToLive, _mandatory, _immediate);
+            sendImpl((AMQDestination) destination, message, deliveryMode, priority, timeToLive,
+                    _mandatory == null
+                            ? destination instanceof Topic
+                                ? _defaultMandatoryTopicValue
+                                : _defaultMandatoryValue
+                            : _mandatory,
+                    _immediate);
         }
     }
 
@@ -480,7 +520,10 @@
             _logger.debug("Updating original message");
             origMessage.setJMSPriority(message.getJMSPriority());
             origMessage.setJMSTimestamp(message.getJMSTimestamp());
-            _logger.debug("Setting JMSExpiration:" + message.getJMSExpiration());
+            if (_logger.isDebugEnabled())
+            {
+            	_logger.debug("Setting JMSExpiration:" + message.getJMSExpiration());
+            }
             origMessage.setJMSExpiration(message.getJMSExpiration());
             origMessage.setJMSMessageID(message.getJMSMessageID());
         }
@@ -564,6 +607,9 @@
 
     }
 
+    /**
+     * The session used to create this producer
+     */
     public AMQSession getSession()
     {
         return _session;
@@ -580,4 +626,73 @@
             throw getSession().toJMSException("Exception whilst checking destination binding:" + e.getMessage(), e);
         }
     }
+
+    /**
+     * If true, messages will not get a timestamp.
+     */
+    protected boolean isDisableTimestamps()
+    {
+        return _disableTimestamps;
+    }
+
+    protected void setDisableTimestamps(boolean disableTimestamps)
+    {
+        _disableTimestamps = disableTimestamps;
+    }
+
+    protected void setDestination(AMQDestination destination)
+    {
+        _destination = destination;
+    }
+
+    protected AMQProtocolHandler getProtocolHandler()
+    {
+        return _protocolHandler;
+    }
+
+    protected void setProtocolHandler(AMQProtocolHandler protocolHandler)
+    {
+        _protocolHandler = protocolHandler;
+    }
+
+    protected int getChannelId()
+    {
+        return _channelId;
+    }
+
+    protected void setChannelId(int channelId)
+    {
+        _channelId = channelId;
+    }
+
+    protected void setSession(AMQSession session)
+    {
+        _session = session;
+    }
+
+    protected String getUserID()
+    {
+        return _userID;
+    }
+
+    protected void setUserID(String userID)
+    {
+        _userID = userID;
+    }
+
+    protected PublishMode getPublishMode()
+    {
+        return publishMode;
+    }
+
+    protected void setPublishMode(PublishMode publishMode)
+    {
+        this.publishMode = publishMode;
+    }
+
+    Logger getLogger()
+    {
+        return _logger;
+    }
+
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java
index 16afa51..a3a1e9c 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java
@@ -17,18 +17,8 @@
  */
 package org.apache.qpid.client;
 
-import static org.apache.qpid.transport.Option.NONE;
-import static org.apache.qpid.transport.Option.SYNC;
-import static org.apache.qpid.transport.Option.UNRELIABLE;
-
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQDestination.AddressOption;
@@ -48,8 +38,18 @@
 import org.apache.qpid.transport.Option;
 import org.apache.qpid.transport.TransportException;
 import org.apache.qpid.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import static org.apache.qpid.transport.Option.NONE;
+import static org.apache.qpid.transport.Option.SYNC;
+import static org.apache.qpid.transport.Option.UNRELIABLE;
+
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
 
 /**
  * This is a 0_10 message producer.
@@ -61,11 +61,11 @@
 
     BasicMessageProducer_0_10(AMQConnection connection, AMQDestination destination, boolean transacted, int channelId,
                               AMQSession session, AMQProtocolHandler protocolHandler, long producerId,
-                              boolean immediate, boolean mandatory) throws AMQException
+                              Boolean immediate, Boolean mandatory) throws AMQException
     {
-        super(connection, destination, transacted, channelId, session, protocolHandler, producerId, immediate, mandatory);
+        super(_logger, connection, destination, transacted, channelId, session, protocolHandler, producerId, immediate, mandatory);
         
-        userIDBytes = Strings.toUTF8(_userID);
+        userIDBytes = Strings.toUTF8(getUserID());
     }
 
     void declareDestination(AMQDestination destination) throws AMQException
@@ -86,7 +86,7 @@
         {       
             try
             {
-                getSession().handleAddressBasedDestination(destination,false,false);
+                getSession().handleAddressBasedDestination(destination,false,false,false);
             }
             catch(Exception e)
             {
@@ -125,7 +125,7 @@
         }
 
         long currentTime = 0;
-        if (timeToLive > 0 || !_disableTimestamps)
+        if (timeToLive > 0 || !isDisableTimestamps())
         {
             currentTime = System.currentTimeMillis();
         }        
@@ -136,7 +136,7 @@
             message.setJMSExpiration(currentTime + timeToLive);
         }
         
-        if (!_disableTimestamps)
+        if (!isDisableTimestamps())
         {
             
             deliveryProp.setTimestamp(currentTime);            
@@ -213,8 +213,8 @@
             // if true, we need to sync the delivery of this message
             boolean sync = false;
 
-            sync = ( (publishMode == PublishMode.SYNC_PUBLISH_ALL) ||
-                     (publishMode == PublishMode.SYNC_PUBLISH_PERSISTENT && 
+            sync = ( (getPublishMode() == PublishMode.SYNC_PUBLISH_ALL) ||
+                     (getPublishMode() == PublishMode.SYNC_PUBLISH_PERSISTENT &&
                          deliveryMode == DeliveryMode.PERSISTENT)
                    );  
             
@@ -248,14 +248,14 @@
     @Override
     public boolean isBound(AMQDestination destination) throws JMSException
     {
-        return _session.isQueueBound(destination);
+        return getSession().isQueueBound(destination);
     }
     
     @Override
     public void close() throws JMSException
     {
         super.close();
-        AMQDestination dest = _destination;
+        AMQDestination dest = getAMQDestination();
         if (dest != null && dest.getDestSyntax() == AMQDestination.DestSyntax.ADDR)
         {
             if (dest.getDelete() == AddressOption.ALWAYS ||
@@ -264,7 +264,7 @@
                 try
                 {
                     ((AMQSession_0_10) getSession()).getQpidSession().queueDelete(
-                        _destination.getQueueName());
+                        getAMQDestination().getQueueName());
                 }
                 catch(TransportException e)
                 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java
index b2f998c..21ff6c8 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java
@@ -20,18 +20,9 @@
  */
 package org.apache.qpid.client;
 
-import java.util.UUID;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Topic;
-import javax.jms.Queue;
-
-import java.nio.ByteBuffer;
-
 import org.apache.qpid.AMQException;
-import org.apache.qpid.client.message.AbstractJMSMessage;
 import org.apache.qpid.client.message.AMQMessageDelegate_0_8;
+import org.apache.qpid.client.message.AbstractJMSMessage;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
 import org.apache.qpid.framing.AMQFrame;
 import org.apache.qpid.framing.BasicContentHeaderProperties;
@@ -42,13 +33,24 @@
 import org.apache.qpid.framing.ExchangeDeclareBody;
 import org.apache.qpid.framing.MethodRegistry;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import java.nio.ByteBuffer;
+import java.util.UUID;
+
 public class BasicMessageProducer_0_8 extends BasicMessageProducer
 {
+	private static final Logger _logger = LoggerFactory.getLogger(BasicMessageProducer_0_8.class);
 
     BasicMessageProducer_0_8(AMQConnection connection, AMQDestination destination, boolean transacted, int channelId,
-            AMQSession session, AMQProtocolHandler protocolHandler, long producerId, boolean immediate, boolean mandatory) throws AMQException
+            AMQSession session, AMQProtocolHandler protocolHandler, long producerId, Boolean immediate, Boolean mandatory) throws AMQException
     {
-        super(connection, destination,transacted,channelId,session, protocolHandler, producerId, immediate, mandatory);
+        super(_logger,connection, destination,transacted,channelId,session, protocolHandler, producerId, immediate, mandatory);
     }
 
     void declareDestination(AMQDestination destination)
@@ -56,7 +58,7 @@
 
         final MethodRegistry methodRegistry = getSession().getMethodRegistry();
         ExchangeDeclareBody body =
-                methodRegistry.createExchangeDeclareBody(_session.getTicket(),
+                methodRegistry.createExchangeDeclareBody(getSession().getTicket(),
                                                          destination.getExchangeName(),
                                                          destination.getExchangeClass(),
                                                          destination.getExchangeName().toString().startsWith("amq."),
@@ -68,29 +70,29 @@
         // Declare the exchange
         // Note that the durable and internal arguments are ignored since passive is set to false
 
-        AMQFrame declare = body.generateFrame(_channelId);
+        AMQFrame declare = body.generateFrame(getChannelId());
 
-        _protocolHandler.writeFrame(declare);
+        getProtocolHandler().writeFrame(declare);
     }
 
     void sendMessage(AMQDestination destination, Message origMessage, AbstractJMSMessage message,
                      UUID messageId, int deliveryMode,int priority, long timeToLive, boolean mandatory,
                      boolean immediate) throws JMSException
     {
-        BasicPublishBody body = getSession().getMethodRegistry().createBasicPublishBody(_session.getTicket(),
+        BasicPublishBody body = getSession().getMethodRegistry().createBasicPublishBody(getSession().getTicket(),
                                                                                         destination.getExchangeName(),
                                                                                         destination.getRoutingKey(),
                                                                                         mandatory,
                                                                                         immediate);
 
-        AMQFrame publishFrame = body.generateFrame(_channelId);
+        AMQFrame publishFrame = body.generateFrame(getChannelId());
 
         message.prepareForSending();
         ByteBuffer payload = message.getData();
         AMQMessageDelegate_0_8 delegate = (AMQMessageDelegate_0_8) message.getDelegate();
         BasicContentHeaderProperties contentHeaderProperties = delegate.getContentHeaderProperties();
 
-        contentHeaderProperties.setUserId(_userID);
+        contentHeaderProperties.setUserId(getUserID());
 
         //Set the JMS_QPID_DESTTYPE for 0-8/9 messages
         int type;
@@ -110,7 +112,7 @@
         //Set JMS_QPID_DESTTYPE
         delegate.getContentHeaderProperties().getHeaders().setInteger(CustomJMSXProperty.JMS_QPID_DESTTYPE.getShortStringName(), type);
 
-        if (!_disableTimestamps)
+        if (!isDisableTimestamps())
         {
             final long currentTime = System.currentTimeMillis();
             contentHeaderProperties.setTimestamp(currentTime);
@@ -134,12 +136,12 @@
 
         if (payload != null)
         {
-            createContentBodies(payload, frames, 2, _channelId);
+            createContentBodies(payload, frames, 2, getChannelId());
         }
 
-        if ((contentBodyFrameCount != 0) && _logger.isDebugEnabled())
+        if ((contentBodyFrameCount != 0) && getLogger().isDebugEnabled())
         {
-            _logger.debug("Sending content body frames to " + destination);
+            getLogger().debug("Sending content body frames to " + destination);
         }
 
 
@@ -147,11 +149,11 @@
         int classIfForBasic = getSession().getMethodRegistry().createBasicQosOkBody().getClazz();
 
         AMQFrame contentHeaderFrame =
-            ContentHeaderBody.createAMQFrame(_channelId,
+            ContentHeaderBody.createAMQFrame(getChannelId(),
                                              classIfForBasic, 0, contentHeaderProperties, size);
-        if (_logger.isDebugEnabled())
+        if (getLogger().isDebugEnabled())
         {
-            _logger.debug("Sending content header frame to " + destination);
+            getLogger().debug("Sending content header frame to " + destination);
         }
 
         frames[0] = publishFrame;
@@ -160,7 +162,7 @@
 
         try
         {
-            _session.checkFlowControl();
+            getSession().checkFlowControl();
         }
         catch (InterruptedException e)
         {
@@ -170,7 +172,7 @@
             throw jmse;
         }
 
-        _protocolHandler.writeFrame(compositeFrame);
+        getProtocolHandler().writeFrame(compositeFrame);
     }
 
     /**
@@ -194,7 +196,7 @@
         else
         {
 
-            final long framePayloadMax = _session.getAMQConnection().getMaximumFrameSize() - 1;
+            final long framePayloadMax = getSession().getAMQConnection().getMaximumFrameSize() - 1;
             long remaining = payload.remaining();
             for (int i = offset; i < frames.length; i++)
             {
@@ -224,7 +226,7 @@
         else
         {
             int dataLength = payload.remaining();
-            final long framePayloadMax = _session.getAMQConnection().getMaximumFrameSize() - 1;
+            final long framePayloadMax = getSession().getAMQConnection().getMaximumFrameSize() - 1;
             int lastFrame = ((dataLength % framePayloadMax) > 0) ? 1 : 0;
             frameCount = (int) (dataLength / framePayloadMax) + lastFrame;
         }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/Closeable.java b/qpid/java/client/src/main/java/org/apache/qpid/client/Closeable.java
index e6771e1..ba26bfc 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/Closeable.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/Closeable.java
@@ -22,7 +22,6 @@
 
 import javax.jms.IllegalStateException;
 import javax.jms.JMSException;
-
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
@@ -49,14 +48,14 @@
      * We use an atomic boolean so that we do not have to synchronized access to this flag. Synchronizing access to this
      * flag would mean have a synchronized block in every method.
      */
-    protected final AtomicBoolean _closed = new AtomicBoolean(false);
+    private final AtomicBoolean _closed = new AtomicBoolean(false);
 
     /**
      * Are we in the process of closing. We have this distinction so we can
      * still signal we are in the process of closing so other objects can tell
      * the difference and tidy up.
      */
-    protected final AtomicBoolean _closing = new AtomicBoolean(false);
+    private final AtomicBoolean _closing = new AtomicBoolean(false);
 
     /**
      * Checks if this is closed, and raises a JMSException if it is.
@@ -91,6 +90,15 @@
         return _closing.get();
     }
 
+    protected boolean setClosed()
+    {
+        return _closed.getAndSet(true);
+    }
+
+    protected void setClosing(boolean closing)
+    {
+        _closing.set(closing);
+    }
 
     /**
      * Closes this object.
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java b/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java
index e81e754..b2d1072 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.client;
 
+import org.apache.qpid.framing.AMQShortString;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
 
-import org.apache.qpid.framing.AMQShortString;
-
 public enum CustomJMSXProperty
 {
     JMS_AMQP_NULL,
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/DispatcherCallback.java b/qpid/java/client/src/main/java/org/apache/qpid/client/DispatcherCallback.java
deleted file mode 100644
index 81a5500..0000000
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/DispatcherCallback.java
+++ /dev/null
@@ -1,36 +0,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.    
- *
- * 
- */
-package org.apache.qpid.client;
-
-import java.util.Queue;
-
-public abstract class DispatcherCallback
-{
-    BasicMessageConsumer _consumer;
-
-    public DispatcherCallback(BasicMessageConsumer mc)
-    {
-        _consumer = mc;
-    }
-
-    abstract public void whilePaused(Queue<MessageConsumerPair> reprocessQueue);
-
-}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/MessageConsumerPair.java b/qpid/java/client/src/main/java/org/apache/qpid/client/MessageConsumerPair.java
index 585d6db..134159a 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/MessageConsumerPair.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/MessageConsumerPair.java
@@ -22,8 +22,8 @@
 
 public class MessageConsumerPair
 {
-    BasicMessageConsumer _consumer;
-    Object _item;
+    private BasicMessageConsumer _consumer;
+    private Object _item;
 
     public MessageConsumerPair(BasicMessageConsumer consumer, Object item)
     {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java b/qpid/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java
index 5cf767ac..03574ce 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java
@@ -20,12 +20,11 @@
  */
 package org.apache.qpid.client;
 
-import java.util.Enumeration;
+import org.apache.qpid.common.QpidProperties;
 
 import javax.jms.ConnectionMetaData;
 import javax.jms.JMSException;
-
-import org.apache.qpid.common.QpidProperties;
+import java.util.Enumeration;
 
 public class QpidConnectionMetaData implements ConnectionMetaData
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/QueueReceiverAdaptor.java b/qpid/java/client/src/main/java/org/apache/qpid/client/QueueReceiverAdaptor.java
index 7059588..b778ee2 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/QueueReceiverAdaptor.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/QueueReceiverAdaptor.java
@@ -33,8 +33,8 @@
  */
 public class QueueReceiverAdaptor implements QueueReceiver {
 
-    protected MessageConsumer _consumer;
-    protected Queue _queue;
+    private MessageConsumer _consumer;
+    private Queue _queue;
 
     protected QueueReceiverAdaptor(Queue queue, MessageConsumer consumer)
     {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java b/qpid/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java
index 295c6a4..0b797df 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java
@@ -202,7 +202,7 @@
        {
            if (_delegate.getSession().isStrictAMQP())
            {
-               _delegate._logger.warn("AMQP does not support destination validation before publish, ");
+               _delegate.getLogger().warn("AMQP does not support destination validation before publish, ");
                destination.setCheckedForQueueBinding(true);
            }
            else
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/TemporaryDestination.java b/qpid/java/client/src/main/java/org/apache/qpid/client/TemporaryDestination.java
index ca137f5..6da3825 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/TemporaryDestination.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/TemporaryDestination.java
@@ -21,11 +21,11 @@
 
 package org.apache.qpid.client;
 
+import org.apache.qpid.framing.AMQShortString;
+
 import javax.jms.Destination;
 import javax.jms.JMSException;
 
-import org.apache.qpid.framing.AMQShortString;
-
 /**
  * Provides support for convenience interface implemented by both AMQTemporaryTopic and AMQTemporaryQueue
  * so that operations related to their "temporary-ness" can be abstracted out.
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/XAConnectionImpl.java b/qpid/java/client/src/main/java/org/apache/qpid/client/XAConnectionImpl.java
index 509aa25..d951433 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/XAConnectionImpl.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/XAConnectionImpl.java
@@ -17,10 +17,16 @@
  */
 package org.apache.qpid.client;
 
-import org.apache.qpid.jms.ConnectionURL;
 import org.apache.qpid.AMQException;
+import org.apache.qpid.jms.ConnectionURL;
 
-import javax.jms.*;
+import javax.jms.JMSException;
+import javax.jms.XAConnection;
+import javax.jms.XAQueueConnection;
+import javax.jms.XAQueueSession;
+import javax.jms.XASession;
+import javax.jms.XATopicConnection;
+import javax.jms.XATopicSession;
 
 /**
  * This class implements the javax.njms.XAConnection interface
@@ -47,7 +53,7 @@
     public synchronized XASession createXASession() throws JMSException
     {
         checkNotClosed();
-        return _delegate.createXASession();
+        return getDelegate().createXASession();
     }
 
     //-- Interface  XAQueueConnection
@@ -80,6 +86,6 @@
     public XASession createXASession(int ackMode) throws JMSException
     {
         checkNotClosed();
-        return _delegate.createXASession(ackMode);
+        return getDelegate().createXASession(ackMode);
     }
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/XAResourceImpl.java b/qpid/java/client/src/main/java/org/apache/qpid/client/XAResourceImpl.java
index 5b94b34..af9048f 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/XAResourceImpl.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/XAResourceImpl.java
@@ -17,9 +17,8 @@
  */
 package org.apache.qpid.client;
 
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.dtx.XidImpl;
 import org.apache.qpid.transport.DtxXaStatus;
@@ -29,8 +28,10 @@
 import org.apache.qpid.transport.RecoverResult;
 import org.apache.qpid.transport.SessionException;
 import org.apache.qpid.transport.XaResult;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
 
 /**
  * This is an implementation of javax.njms.XAResource.
@@ -307,13 +308,16 @@
             _xaSession.createSession();
             convertExecutionErrorToXAErr( e.getException().getErrorCode());
         }
-        Xid[] result = new Xid[res.getInDoubt().size()];
-        int i = 0;
-        for (Object obj : res.getInDoubt())
+        Xid[] result =  new Xid[res.getInDoubt() != null ? res.getInDoubt().size() : 0];
+        if(result.length != 0)
         {
-            org.apache.qpid.transport.Xid xid = (org.apache.qpid.transport.Xid) obj;
-            result[i] = new XidImpl(xid.getBranchId(), (int) xid.getFormat(), xid.getGlobalId());
-            i++;
+            int i = 0;
+            for (Object obj : res.getInDoubt())
+            {
+                org.apache.qpid.transport.Xid xid = (org.apache.qpid.transport.Xid) obj;
+                result[i] = new XidImpl(xid.getBranchId(), (int) xid.getFormat(), xid.getGlobalId());
+                i++;
+            }
         }
         return result;
     }
@@ -435,6 +439,16 @@
         }
     }
 
+    /**
+     * Is this resource currently enlisted in a transaction?
+     * 
+     * @return true if the resource is associated with a transaction, false otherwise.
+     */
+    public boolean isEnlisted()
+    {
+        return (_xid != null) ;
+    }
+    
     //------------------------------------------------------------------------
     // Private methods
     //------------------------------------------------------------------------
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/XASessionImpl.java b/qpid/java/client/src/main/java/org/apache/qpid/client/XASessionImpl.java
index aaabf61..6d5bf9a 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/XASessionImpl.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/XASessionImpl.java
@@ -18,8 +18,16 @@
 package org.apache.qpid.client;
 
 import org.apache.qpid.client.message.MessageFactoryRegistry;
+import org.apache.qpid.transport.RangeSet;
 
-import javax.jms.*;
+import javax.jms.JMSException;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TopicSession;
+import javax.jms.TransactionInProgressException;
+import javax.jms.XAQueueSession;
+import javax.jms.XASession;
+import javax.jms.XATopicSession;
 import javax.transaction.xa.XAResource;
 
 /**
@@ -79,7 +87,7 @@
      */
     public void createSession()
     {
-        _qpidDtxSession = _qpidConnection.createSession(0);
+        _qpidDtxSession = getQpidConnection().createSession(0);
         _qpidDtxSession.setSessionListener(this);
         _qpidDtxSession.dtxSelect();
     }
@@ -171,4 +179,17 @@
     {
         return (TopicSession) getSession();
     }
+
+    @Override
+    protected void acknowledgeImpl()
+    {
+        if (_xaResource.isEnlisted())
+        {
+            acknowledgeMessage(Long.MAX_VALUE, true) ;
+        }
+        else
+        {
+            super.acknowledgeImpl() ;
+        }
+    }
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java
index f74dbba..4099da1 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.client.failover;
 
-import org.apache.qpid.AMQDisconnectedException;
-import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.client.state.AMQStateManager;
-import org.apache.qpid.client.state.AMQState;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.AMQDisconnectedException;
+import org.apache.qpid.client.protocol.AMQProtocolHandler;
+import org.apache.qpid.client.state.AMQState;
+import org.apache.qpid.client.state.AMQStateManager;
+
 import java.util.concurrent.CountDownLatch;
 
 /**
@@ -231,14 +231,7 @@
                 {
                     _logger.info("Failover process failed - exception being propagated by protocol handler");
                     _amqProtocolHandler.setFailoverState(FailoverState.FAILED);
-                    /*try
-                    {*/
                     _amqProtocolHandler.exception(e);
-                    /*}
-                    catch (Exception ex)
-                    {
-                        _logger.error("Error notifying protocol session of error: " + ex, ex);
-                    }*/
                 }
             }
         }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverNoopSupport.java b/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverNoopSupport.java
index 51cc949..a69e808 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverNoopSupport.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverNoopSupport.java
@@ -38,10 +38,10 @@
 public class FailoverNoopSupport<T, E extends Exception> implements FailoverSupport<T, E>
 {
     /** The protected operation that is to be retried in the event of fail-over. */
-    FailoverProtectedOperation<T, E> operation;
+    private FailoverProtectedOperation<T, E> operation;
 
     /** The connection on which the fail-over protected operation is to be performed. */
-    AMQConnection connection;
+    private AMQConnection connection;
 
     /**
      * Creates an automatic retrying fail-over handler for the specified operation.
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverRetrySupport.java b/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverRetrySupport.java
index 28d19ce..d3d33d3 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverRetrySupport.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverRetrySupport.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.client.failover;
 
-import org.apache.qpid.client.AMQConnection;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.client.AMQConnection;
+
 /**
  * FailoverRetrySupport is a continuation that wraps another continuation, delaying its execution until it is notified
  * that a blocking condition has been met, and executing the continuation within a mutex. If the continuation fails, due
@@ -73,10 +73,10 @@
     private static final Logger _log = LoggerFactory.getLogger(FailoverRetrySupport.class);
 
     /** The protected operation that is to be retried in the event of fail-over. */
-    FailoverProtectedOperation<T, E> operation;
+    private FailoverProtectedOperation<T, E> operation;
 
     /** The connection on which the fail-over protected operation is to be performed. */
-    AMQConnection connection;
+    private AMQConnection connection;
 
     /**
      * Creates an automatic retrying fail-over handler for the specified operation.
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/filter/JMSSelectorFilter.java b/qpid/java/client/src/main/java/org/apache/qpid/client/filter/JMSSelectorFilter.java
index 14cce0a..bab518b 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/filter/JMSSelectorFilter.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/filter/JMSSelectorFilter.java
@@ -55,6 +55,10 @@
         {
             _matcher = new SelectorParser().parse(selector);
         }
+        catch (ParseException e)
+        {
+            throw new AMQInternalException("Unable to parse selector \""+selector+"\"", e);
+        }
         catch (SelectorParsingException e)
         {
             throw new AMQInternalException("Unable to parse selector \""+selector+"\"", e);
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/AccessRequestOkMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/AccessRequestOkMethodHandler.java
index af47673..3a3ddae 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/AccessRequestOkMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/AccessRequestOkMethodHandler.java
@@ -24,10 +24,10 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.qpid.framing.*;
-import org.apache.qpid.client.state.StateAwareMethodListener;
-import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.AMQException;
+import org.apache.qpid.client.protocol.AMQProtocolSession;
+import org.apache.qpid.client.state.StateAwareMethodListener;
+import org.apache.qpid.framing.AccessRequestOkBody;
 
 public class AccessRequestOkMethodHandler implements StateAwareMethodListener<AccessRequestOkBody>
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicCancelOkMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicCancelOkMethodHandler.java
index 5cb9412..9b5eea3 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicCancelOkMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicCancelOkMethodHandler.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.client.state.StateAwareMethodListener;
 import org.apache.qpid.framing.BasicCancelOkBody;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class BasicCancelOkMethodHandler implements StateAwareMethodListener<BasicCancelOkBody>
 {
     private static final Logger _logger = LoggerFactory.getLogger(BasicCancelOkMethodHandler.class);
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicDeliverMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicDeliverMethodHandler.java
index 33ca584..3f57e18 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicDeliverMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicDeliverMethodHandler.java
@@ -20,13 +20,14 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.message.UnprocessedMessage_0_8;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.client.state.StateAwareMethodListener;
 import org.apache.qpid.framing.BasicDeliverBody;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class BasicDeliverMethodHandler implements StateAwareMethodListener<BasicDeliverBody>
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicReturnMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicReturnMethodHandler.java
index 3bbc920..a09d298 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicReturnMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/BasicReturnMethodHandler.java
@@ -20,15 +20,15 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.message.ReturnMessage;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.client.state.StateAwareMethodListener;
 import org.apache.qpid.framing.BasicReturnBody;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class BasicReturnMethodHandler implements StateAwareMethodListener<BasicReturnBody>
 {
     private static final Logger _logger = LoggerFactory.getLogger(BasicReturnMethodHandler.class);
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java
index b9d4d6f..85328d7 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java
@@ -20,6 +20,9 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQChannelClosedException;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQInvalidRoutingKeyException;
@@ -32,8 +35,6 @@
 import org.apache.qpid.framing.ChannelCloseBody;
 import org.apache.qpid.framing.ChannelCloseOkBody;
 import org.apache.qpid.protocol.AMQConstant;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class ChannelCloseMethodHandler implements StateAwareMethodListener<ChannelCloseBody>
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseOkMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseOkMethodHandler.java
index 7293677..058484c 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseOkMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseOkMethodHandler.java
@@ -20,13 +20,14 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.client.state.StateAwareMethodListener;
 import org.apache.qpid.framing.ChannelCloseOkBody;
 import org.apache.qpid.protocol.AMQConstant;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class ChannelCloseOkMethodHandler implements StateAwareMethodListener<ChannelCloseOkBody>
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelFlowMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelFlowMethodHandler.java
index 2153b9c..919c5f6 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelFlowMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelFlowMethodHandler.java
@@ -1,12 +1,13 @@
 package org.apache.qpid.client.handler;
 
-import org.apache.qpid.framing.ChannelFlowBody;
-import org.apache.qpid.client.state.StateAwareMethodListener;
-import org.apache.qpid.client.protocol.AMQProtocolSession;
-import org.apache.qpid.AMQException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.protocol.AMQProtocolSession;
+import org.apache.qpid.client.state.StateAwareMethodListener;
+import org.apache.qpid.framing.ChannelFlowBody;
+
 /*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelFlowOkMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelFlowOkMethodHandler.java
index 6f66a97..c15404e 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelFlowOkMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ChannelFlowOkMethodHandler.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.client.state.StateAwareMethodListener;
 import org.apache.qpid.framing.ChannelFlowOkBody;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class ChannelFlowOkMethodHandler implements StateAwareMethodListener<ChannelFlowOkBody>
 {
     private static final Logger _logger = LoggerFactory.getLogger(ChannelFlowOkMethodHandler.class);
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl.java
index ec98783..e1a0e18 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl.java
@@ -20,17 +20,18 @@
  */
 package org.apache.qpid.client.handler;
 
-import java.util.Map;
-import java.util.HashMap;
-
-import org.apache.qpid.framing.*;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.state.AMQStateManager;
-import org.apache.qpid.client.state.AMQMethodNotImplementedException;
-import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.protocol.AMQProtocolSession;
+import org.apache.qpid.client.state.AMQMethodNotImplementedException;
+import org.apache.qpid.client.state.AMQStateManager;
+import org.apache.qpid.framing.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
 public class ClientMethodDispatcherImpl implements MethodDispatcher
 {
 
@@ -94,16 +95,16 @@
 
     public static ClientMethodDispatcherImpl newMethodDispatcher(ProtocolVersion version, AMQProtocolSession session)
     {
-        if (_logger.isInfoEnabled())
+        if (_logger.isDebugEnabled())
         {
-            _logger.info("New Method Dispatcher:" + session);
+            _logger.debug("New Method Dispatcher:" + session);
         }
         
         DispatcherFactory factory = _dispatcherFactories.get(version);
         return factory.createMethodDispatcher(session);
     }
 
-    AMQProtocolSession _session;
+    private AMQProtocolSession _session;
 
     public ClientMethodDispatcherImpl(AMQProtocolSession session)
     {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_0_9.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_0_9.java
index d3e9fba..f4fc3a4 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_0_9.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_0_9.java
@@ -20,14 +20,12 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.protocol.AMQProtocolSession;
+import org.apache.qpid.client.state.AMQMethodNotImplementedException;
 import org.apache.qpid.framing.*;
 import org.apache.qpid.framing.amqp_0_9.MethodDispatcher_0_9;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.state.AMQStateManager;
-import org.apache.qpid.client.state.AMQMethodNotImplementedException;
-import org.apache.qpid.client.protocol.AMQProtocolSession;
-
 public class ClientMethodDispatcherImpl_0_9 extends ClientMethodDispatcherImpl implements MethodDispatcher_0_9
 {
     public ClientMethodDispatcherImpl_0_9(AMQProtocolSession session)
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_0_91.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_0_91.java
index f15340a..5f33561 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_0_91.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_0_91.java
@@ -20,14 +20,12 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.protocol.AMQProtocolSession;
+import org.apache.qpid.client.state.AMQMethodNotImplementedException;
 import org.apache.qpid.framing.*;
 import org.apache.qpid.framing.amqp_0_91.MethodDispatcher_0_91;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.state.AMQStateManager;
-import org.apache.qpid.client.state.AMQMethodNotImplementedException;
-import org.apache.qpid.client.protocol.AMQProtocolSession;
-
 public class ClientMethodDispatcherImpl_0_91 extends ClientMethodDispatcherImpl implements MethodDispatcher_0_91
 {
     public ClientMethodDispatcherImpl_0_91(AMQProtocolSession session)
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_8_0.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_8_0.java
index 19f7588..28ad603 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_8_0.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl_8_0.java
@@ -20,11 +20,19 @@
  */
  package org.apache.qpid.client.handler;
 
-import org.apache.qpid.framing.*;
-import org.apache.qpid.framing.amqp_8_0.MethodDispatcher_8_0;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
+import org.apache.qpid.framing.BasicRecoverOkBody;
+import org.apache.qpid.framing.ChannelAlertBody;
+import org.apache.qpid.framing.TestContentBody;
+import org.apache.qpid.framing.TestContentOkBody;
+import org.apache.qpid.framing.TestIntegerBody;
+import org.apache.qpid.framing.TestIntegerOkBody;
+import org.apache.qpid.framing.TestStringBody;
+import org.apache.qpid.framing.TestStringOkBody;
+import org.apache.qpid.framing.TestTableBody;
+import org.apache.qpid.framing.TestTableOkBody;
+import org.apache.qpid.framing.amqp_8_0.MethodDispatcher_8_0;
 
 public class ClientMethodDispatcherImpl_8_0 extends ClientMethodDispatcherImpl implements MethodDispatcher_8_0
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java
index b392604..2cf7b08 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java
@@ -20,21 +20,20 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQConnectionClosedException;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.client.AMQAuthenticationException;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
-import org.apache.qpid.client.state.AMQState;
 import org.apache.qpid.client.state.StateAwareMethodListener;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.ConnectionCloseBody;
 import org.apache.qpid.framing.ConnectionCloseOkBody;
 import org.apache.qpid.protocol.AMQConstant;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class ConnectionCloseMethodHandler implements StateAwareMethodListener<ConnectionCloseBody>
 {
     private static final Logger _logger = LoggerFactory.getLogger(ConnectionCloseMethodHandler.class);
@@ -55,9 +54,6 @@
     {
         _logger.info("ConnectionClose frame received");
 
-        // does it matter
-        // stateManager.changeState(AMQState.CONNECTION_CLOSING);
-
         AMQConstant errorCode = AMQConstant.getConstant(method.getReplyCode());
         AMQShortString reason = method.getReplyText();
 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionOpenOkMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionOpenOkMethodHandler.java
index e40cafd..1b197de 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionOpenOkMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionOpenOkMethodHandler.java
@@ -20,11 +20,10 @@
  */
 package org.apache.qpid.client.handler;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.ConnectionOpenOkBody;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.client.state.AMQState;
 import org.apache.qpid.client.state.StateAwareMethodListener;
+import org.apache.qpid.framing.ConnectionOpenOkBody;
 
 public class ConnectionOpenOkMethodHandler implements StateAwareMethodListener<ConnectionOpenOkBody>
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionRedirectMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionRedirectMethodHandler.java
index 472c471..0ccb9b7 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionRedirectMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionRedirectMethodHandler.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.client.state.StateAwareMethodListener;
 import org.apache.qpid.framing.ConnectionRedirectBody;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class ConnectionRedirectMethodHandler implements StateAwareMethodListener<ConnectionRedirectBody>
 {
     private static final Logger _logger = LoggerFactory.getLogger(ConnectionRedirectMethodHandler.class);
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionSecureMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionSecureMethodHandler.java
index 9a9bee7..8afb6ff 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionSecureMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionSecureMethodHandler.java
@@ -20,15 +20,15 @@
  */
 package org.apache.qpid.client.handler;
 
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.client.state.StateAwareMethodListener;
 import org.apache.qpid.framing.ConnectionSecureBody;
 import org.apache.qpid.framing.ConnectionSecureOkBody;
 
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslException;
+
 public class ConnectionSecureMethodHandler implements StateAwareMethodListener<ConnectionSecureBody>
 {
     private static final ConnectionSecureMethodHandler _instance = new ConnectionSecureMethodHandler();
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
index 939bd18..66c4821 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
@@ -20,12 +20,8 @@
  */
 package org.apache.qpid.client.handler;
 
-import java.io.UnsupportedEncodingException;
-import java.util.StringTokenizer;
-
-import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
@@ -33,16 +29,21 @@
 import org.apache.qpid.client.security.CallbackHandlerRegistry;
 import org.apache.qpid.client.state.AMQState;
 import org.apache.qpid.client.state.StateAwareMethodListener;
-import org.apache.qpid.common.ClientProperties;
 import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.configuration.ClientProperties;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.ConnectionStartBody;
 import org.apache.qpid.framing.ConnectionStartOkBody;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.framing.FieldTableFactory;
 import org.apache.qpid.framing.ProtocolVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.qpid.properties.ConnectionStartProperties;
+
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslException;
+import java.io.UnsupportedEncodingException;
+import java.util.StringTokenizer;
 
 public class ConnectionStartMethodHandler implements StateAwareMethodListener<ConnectionStartBody>
 {
@@ -148,14 +149,18 @@
                 session.getStateManager().changeState(AMQState.CONNECTION_NOT_TUNED);
                 FieldTable clientProperties = FieldTableFactory.newFieldTable();
 
-                clientProperties.setString(new AMQShortString(ClientProperties.instance.toString()),
-                    session.getClientID());
-                clientProperties.setString(new AMQShortString(ClientProperties.product.toString()),
-                    QpidProperties.getProductName());
-                clientProperties.setString(new AMQShortString(ClientProperties.version.toString()),
-                    QpidProperties.getReleaseVersion());
-                clientProperties.setString(new AMQShortString(ClientProperties.platform.toString()), getFullSystemInfo());
-
+                clientProperties.setString(ConnectionStartProperties.CLIENT_ID_0_8,
+                        session.getClientID());
+                clientProperties.setString(ConnectionStartProperties.PRODUCT,
+                        QpidProperties.getProductName());
+                clientProperties.setString(ConnectionStartProperties.VERSION_0_8,
+                        QpidProperties.getReleaseVersion());
+                clientProperties.setString(ConnectionStartProperties.PLATFORM,
+                        ConnectionStartProperties.getPlatformInfo());
+                clientProperties.setString(ConnectionStartProperties.PROCESS,
+                        System.getProperty(ClientProperties.PROCESS_NAME, "Qpid Java Client"));
+                clientProperties.setInteger(ConnectionStartProperties.PID,
+                        ConnectionStartProperties.getPID());
 
                 ConnectionStartOkBody connectionStartOkBody = session.getMethodRegistry().createConnectionStartOkBody(clientProperties,new AMQShortString(mechanism),saslResponse,new AMQShortString(locales));
                 // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
@@ -178,20 +183,6 @@
         }
     }
 
-    private String getFullSystemInfo()
-    {
-        StringBuffer fullSystemInfo = new StringBuffer();
-        fullSystemInfo.append(System.getProperty("java.runtime.name"));
-        fullSystemInfo.append(", " + System.getProperty("java.runtime.version"));
-        fullSystemInfo.append(", " + System.getProperty("java.vendor"));
-        fullSystemInfo.append(", " + System.getProperty("os.arch"));
-        fullSystemInfo.append(", " + System.getProperty("os.name"));
-        fullSystemInfo.append(", " + System.getProperty("os.version"));
-        fullSystemInfo.append(", " + System.getProperty("sun.os.patch.level"));
-
-        return fullSystemInfo.toString();
-    }
-
     private String chooseMechanism(byte[] availableMechanisms) throws UnsupportedEncodingException
     {
         final String mechanisms = new String(availableMechanisms, "utf8");
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java
index d1b2caf..f777186 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java
@@ -20,15 +20,18 @@
  */
 package org.apache.qpid.client.handler;
 
-import org.apache.qpid.AMQException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.client.ConnectionTuneParameters;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.client.state.AMQState;
 import org.apache.qpid.client.state.StateAwareMethodListener;
-import org.apache.qpid.framing.*;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.ConnectionOpenBody;
+import org.apache.qpid.framing.ConnectionTuneBody;
+import org.apache.qpid.framing.ConnectionTuneOkBody;
+import org.apache.qpid.framing.MethodRegistry;
 
 public class ConnectionTuneMethodHandler implements StateAwareMethodListener<ConnectionTuneBody>
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ExchangeBoundOkMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ExchangeBoundOkMethodHandler.java
index 690d782..b60127c 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ExchangeBoundOkMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ExchangeBoundOkMethodHandler.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.client.state.StateAwareMethodListener;
 import org.apache.qpid.framing.ExchangeBoundOkBody;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * @author Apache Software Foundation
  */
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/QueueDeleteOkMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/QueueDeleteOkMethodHandler.java
index 01d82c9..3c76a8a 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/QueueDeleteOkMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/QueueDeleteOkMethodHandler.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
 import org.apache.qpid.client.state.StateAwareMethodListener;
 import org.apache.qpid.framing.QueueDeleteOkBody;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * @author Apache Software Foundation
  */
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate.java
index a9434ed..d01c4ac 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate.java
@@ -25,7 +25,6 @@
 
 import javax.jms.Destination;
 import javax.jms.JMSException;
-
 import java.util.Enumeration;
 import java.util.UUID;
 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java
index 179ebd6..a0c3914 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java
@@ -21,22 +21,8 @@
 
 package org.apache.qpid.client.message;
 
-import java.lang.ref.SoftReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageFormatException;
-import javax.jms.MessageNotWriteableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQPInvalidClassException;
@@ -54,8 +40,22 @@
 import org.apache.qpid.transport.MessageProperties;
 import org.apache.qpid.transport.ReplyTo;
 import org.apache.qpid.transport.TransportException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
+import javax.jms.MessageNotWriteableException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
 
 /**
  * This extends AbstractAMQMessageDelegate which contains common code between
@@ -65,7 +65,22 @@
 public class AMQMessageDelegate_0_10 extends AbstractAMQMessageDelegate
 {
     private static final Logger _logger = LoggerFactory.getLogger(AMQMessageDelegate_0_10.class);
-    private static final Map<ReplyTo, SoftReference<Destination>> _destinationCache = Collections.synchronizedMap(new HashMap<ReplyTo, SoftReference<Destination>>());
+
+    private static final float DESTINATION_CACHE_LOAD_FACTOR = 0.75f;
+    private static final int DESTINATION_CACHE_SIZE = 500;
+    private static final int DESTINATION_CACHE_CAPACITY = (int) (DESTINATION_CACHE_SIZE / DESTINATION_CACHE_LOAD_FACTOR);
+
+    private static final Map<ReplyTo, Destination> _destinationCache =
+            Collections.synchronizedMap(new LinkedHashMap<ReplyTo,Destination>(DESTINATION_CACHE_CAPACITY,
+                                                                              DESTINATION_CACHE_LOAD_FACTOR,
+                                                                              true)
+    {
+        @Override
+        protected boolean removeEldestEntry(Map.Entry<ReplyTo, Destination> eldest)
+        {
+            return size() >= DESTINATION_CACHE_SIZE;
+        }
+    });
 
     public static final String JMS_TYPE = "x-jms-type";
 
@@ -241,12 +256,8 @@
         }
         else
         {
-            Destination dest = null;
-            SoftReference<Destination> ref = _destinationCache.get(replyTo);
-            if (ref != null)
-            {
-	            dest = ref.get();
-            }
+            Destination dest = _destinationCache.get(replyTo);
+
             if (dest == null)
             {
                 String exchange = replyTo.getExchange();
@@ -254,14 +265,13 @@
 
                 if (AMQDestination.getDefaultDestSyntax() == AMQDestination.DestSyntax.BURL)
                 {
-            
                     dest = generateDestination(new AMQShortString(exchange), new AMQShortString(routingKey));
                 }
                 else
                 {
                     dest = convertToAddressBasedDestination(exchange,routingKey,null);
                 }
-                _destinationCache.put(replyTo, new SoftReference<Destination>(dest));
+                _destinationCache.put(replyTo, dest);
             }
 
             return dest;
@@ -271,6 +281,7 @@
     private Destination convertToAddressBasedDestination(String exchange, String routingKey, String subject)
     {
         String addr;
+        boolean isQueue = true;
         if ("".equals(exchange)) // type Queue
         {
             subject = (subject == null) ? "" : "/" + subject;
@@ -279,11 +290,24 @@
         else
         {
             addr = exchange + "/" + routingKey;
+            isQueue = false;
         }
         
         try
         {
-            return AMQDestination.createDestination("ADDR:" + addr);
+            AMQDestination dest = (AMQDestination)AMQDestination.createDestination("ADDR:" + addr);
+            if (isQueue)
+            {
+                dest.setQueueName(new AMQShortString(routingKey));
+                dest.setRoutingKey(new AMQShortString(routingKey));
+                dest.setExchangeName(new AMQShortString(""));
+            }
+            else
+            {
+                dest.setRoutingKey(new AMQShortString(routingKey));
+                dest.setExchangeName(new AMQShortString(exchange));
+            }
+            return dest;
         }
         catch(Exception e)
         {
@@ -341,13 +365,11 @@
                jmse.setLinkedException(e);
                throw jmse;
            }
-
         }
-        
-        final ReplyTo replyTo = new ReplyTo(amqd.getExchangeName().toString(), amqd.getRoutingKey().toString());
-        _destinationCache.put(replyTo, new SoftReference<Destination>(destination));
-        _messageProps.setReplyTo(replyTo);
 
+        final ReplyTo replyTo = new ReplyTo(amqd.getExchangeName().toString(), amqd.getRoutingKey().toString());
+        _destinationCache.put(replyTo, destination);
+        _messageProps.setReplyTo(replyTo);
     }
 
     public Destination getJMSDestination() throws JMSException
@@ -560,6 +582,10 @@
         {
             return ((Short)o).shortValue();
         }
+        else if(o instanceof String)
+        {
+            return Short.valueOf((String) o);
+        }
         else
         {
             try
@@ -587,6 +613,10 @@
         {
             return ((Integer)o).intValue();
         }
+        else if(o instanceof String)
+        {
+            return Integer.valueOf((String) o);
+        }
         else
         {
             try
@@ -613,6 +643,10 @@
         {
             return ((Long)o).longValue();
         }
+        else if(o instanceof String)
+        {
+            return Long.valueOf((String) o);
+        }
         else
         {
             try
@@ -933,7 +967,7 @@
 //          apply when a property is used in a message selector expression. For
 //          example, suppose you set a property as a string value, as in the
 //          following:
-//              myMessage.setStringProperty("NumberOfOrders", "2");
+//              myMessage.setStringProperty("NumberOfOrders", "2")
 //          The following expression in a message selector would evaluate to false,
 //          because a string cannot be used in an arithmetic expression:
 //          "NumberOfOrders > 1"
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_8.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_8.java
index ab7061c..fe9f9f4 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_8.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_8.java
@@ -21,27 +21,47 @@
 
 package org.apache.qpid.client.message;
 
-import java.net.URISyntaxException;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageNotWriteableException;
-
-import org.apache.qpid.client.*;
-import org.apache.qpid.collections.ReferenceMap;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.AMQSession_0_8;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.client.CustomJMSXProperty;
+import org.apache.qpid.client.JMSAMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.BasicContentHeaderProperties;
 import org.apache.qpid.framing.ContentHeaderProperties;
 import org.apache.qpid.url.AMQBindingURL;
 import org.apache.qpid.url.BindingURL;
 
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageNotWriteableException;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
+
+
 public class AMQMessageDelegate_0_8 extends AbstractAMQMessageDelegate
 {
-    private static final Map _destinationCache = Collections.synchronizedMap(new ReferenceMap());
+    private static final float DESTINATION_CACHE_LOAD_FACTOR = 0.75f;
+    private static final int DESTINATION_CACHE_SIZE = 500;
+    private static final int DESTINATION_CACHE_CAPACITY = (int) (DESTINATION_CACHE_SIZE / DESTINATION_CACHE_LOAD_FACTOR);
+
+    private static final Map<String, Destination> _destinationCache =
+            Collections.synchronizedMap(new LinkedHashMap<String,Destination>(DESTINATION_CACHE_CAPACITY,
+                                                                              DESTINATION_CACHE_LOAD_FACTOR,
+                                                                              true)
+    {
+        @Override
+        protected boolean removeEldestEntry(Map.Entry<String, Destination> eldest)
+        {
+            return size() >= DESTINATION_CACHE_SIZE;
+        }
+    });
 
     public static final String JMS_TYPE = "x-jms-type";
 
@@ -229,7 +249,7 @@
         }
         else
         {
-            Destination dest = (Destination) _destinationCache.get(replyToEncoding);
+            Destination dest = _destinationCache.get(replyToEncoding);
             if (dest == null)
             {
                 try
@@ -266,7 +286,7 @@
         final AMQDestination amqd = (AMQDestination) destination;
 
         final AMQShortString encodedDestination = amqd.getEncodedName();
-        _destinationCache.put(encodedDestination, destination);
+        _destinationCache.put(encodedDestination.asString(), destination);
         getContentHeaderProperties().setReplyTo(encodedDestination);
     }
 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessage.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessage.java
index be71c8c..11d99f5 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessage.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessage.java
@@ -21,18 +21,17 @@
  */
 
 
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.nio.ByteBuffer;
-
-import javax.jms.JMSException;
-import javax.jms.MessageFormatException;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.transport.codec.BBDecoder;
 import org.apache.qpid.transport.codec.BBEncoder;
 
+import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
 public class AMQPEncodedMapMessage extends JMSMapMessage
 {
     public static final String MIME_TYPE = "amqp/map";
@@ -68,7 +67,7 @@
                 || (value instanceof Double) || (value instanceof String) || (value instanceof byte[])
                 || (value instanceof List) || (value instanceof Map) || (value instanceof UUID) || (value == null))
         {
-            _map.put(propName, value);
+            getMap().put(propName, value);
         }
         else
         {
@@ -82,7 +81,7 @@
     public ByteBuffer getData()
     {
         BBEncoder encoder = new BBEncoder(1024);
-        encoder.writeMap(_map);
+        encoder.writeMap(getMap());
         return encoder.segment();
     }
     
@@ -94,22 +93,18 @@
             data.rewind();
             BBDecoder decoder = new BBDecoder();
             decoder.init(data);
-            _map = decoder.readMap();
+            setMap(decoder.readMap());
         }
         else
         {
-            _map.clear();
+            getMap().clear();
         }
     }
 
     // for testing
     public Map<String,Object> getMap()
     {
-        return _map;
+        return super.getMap();
     }
-    
-    void setMap(Map<String,Object> map)
-    {
-        _map = map;
-    }
+
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessageFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessageFactory.java
index 2c38f15..f997862 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessageFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessageFactory.java
@@ -21,12 +21,11 @@
  */
 
 
-import javax.jms.JMSException;
-
-import java.nio.ByteBuffer;
-
 import org.apache.qpid.AMQException;
 
+import javax.jms.JMSException;
+import java.nio.ByteBuffer;
+
 public class AMQPEncodedMapMessageFactory extends AbstractJMSMessageFactory
 {
 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractAMQMessageDelegate.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractAMQMessageDelegate.java
index 1b6c0c7..1395f39 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractAMQMessageDelegate.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractAMQMessageDelegate.java
@@ -20,12 +20,6 @@
  */
 package org.apache.qpid.client.message;
 
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.jms.JMSException;
-import javax.jms.Session;
-
 import org.apache.qpid.client.AMQAnyDestination;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQQueue;
@@ -34,6 +28,11 @@
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
 
+import javax.jms.JMSException;
+import javax.jms.Session;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 /**
  * This abstract class provides exchange lookup functionality that is shared
  * between all MessageDelegates. Update facilities are provided so that the 0-10
@@ -122,18 +121,18 @@
             exchangeInfo = new ExchangeInfo(exchange.asString(),"",AMQDestination.UNKNOWN_TYPE);
         }
         
-        if ("topic".equals(exchangeInfo.exchangeType))
+        if ("topic".equals(exchangeInfo.getExchangeType()))
         {
             dest = new AMQTopic(exchange, routingKey, null);
         }
-        else if ("direct".equals(exchangeInfo.exchangeType))
+        else if ("direct".equals(exchangeInfo.getExchangeType()))
         {
             dest = new AMQQueue(exchange, routingKey, routingKey); 
         }
         else
         {
             dest = new AMQAnyDestination(exchange,
-                                         new AMQShortString(exchangeInfo.exchangeType),
+                                         new AMQShortString(exchangeInfo.getExchangeType()),
                                          routingKey,
                                          false,
                                          false,
@@ -224,9 +223,9 @@
 
 class ExchangeInfo
 {
-    String exchangeName;
-    String exchangeType;
-    int destType = AMQDestination.QUEUE_TYPE;
+    private String exchangeName;
+    private String exchangeType;
+    private int destType = AMQDestination.QUEUE_TYPE;
     
     public ExchangeInfo(String exchangeName, String exchangeType,
                         int destType)
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesTypedMessage.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesTypedMessage.java
index ddeb62f..9c7bd0b 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesTypedMessage.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesTypedMessage.java
@@ -21,26 +21,20 @@
 
 package org.apache.qpid.client.message;
 
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
-import java.nio.ByteBuffer;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.transport.util.Functions;
 
 import javax.jms.JMSException;
 import javax.jms.MessageNotReadableException;
 import javax.jms.MessageNotWriteableException;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.transport.util.Functions;
+import java.nio.ByteBuffer;
 
 /**
  * @author Apache Software Foundation
  */
 public abstract class AbstractBytesTypedMessage extends AbstractJMSMessage
 {
-    protected boolean _readableMessage = false;
+    private boolean _readableMessage = false;
 
     AbstractBytesTypedMessage(AMQMessageDelegateFactory delegateFactory, boolean fromReceivedMessage)
     {
@@ -81,6 +75,11 @@
         _readableMessage = false;
     }
 
+    protected void setReadable(boolean readable)
+    {
+        _readableMessage = readable;
+    }
+
 
     public String toBodyString() throws JMSException
     {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
index f713554..d1e4344 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
@@ -20,16 +20,15 @@
  */
 package org.apache.qpid.client.message;
 
-import java.nio.ByteBuffer;
-import java.util.Enumeration;
-import java.util.UUID;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQSession;
 
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.MessageNotWriteableException;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQSession;
+import java.nio.ByteBuffer;
+import java.util.Enumeration;
+import java.util.UUID;
 
 public abstract class AbstractJMSMessage implements org.apache.qpid.jms.Message
 {
@@ -37,7 +36,7 @@
 
     /** If the acknowledge mode is CLIENT_ACKNOWLEDGE the session is required */
 
-    protected AMQMessageDelegate _delegate;
+    private AMQMessageDelegate _delegate;
     private boolean _redelivered;
     private boolean _receivedFromServer;
 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java
index 16b71db..6085676 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java
@@ -20,27 +20,25 @@
  */
 package org.apache.qpid.client.message;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQSession_0_8;
 import org.apache.qpid.client.AMQTopic;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
 import org.apache.qpid.framing.ContentBody;
 import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
-import org.apache.qpid.transport.MessageProperties;
 import org.apache.qpid.transport.DeliveryProperties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.qpid.transport.MessageProperties;
 
 import javax.jms.JMSException;
-
+import java.nio.ByteBuffer;
 import java.util.Iterator;
 import java.util.List;
 
-import java.nio.ByteBuffer;
-
 public abstract class AbstractJMSMessageFactory implements MessageFactory
 {
     private static final Logger _logger = LoggerFactory.getLogger(AbstractJMSMessageFactory.class);
@@ -59,25 +57,25 @@
         {
             if (debug)
             {
-                _logger.debug("Non-fragmented message body (bodySize=" + contentHeader.bodySize + ")");
+                _logger.debug("Non-fragmented message body (bodySize=" + contentHeader.getBodySize() + ")");
             }
 
-            data = ByteBuffer.wrap(((ContentBody) bodies.get(0))._payload);
+            data = ByteBuffer.wrap(((ContentBody) bodies.get(0)).getPayload());
         }
         else if (bodies != null)
         {
             if (debug)
             {
                 _logger.debug("Fragmented message body (" + bodies
-                        .size() + " frames, bodySize=" + contentHeader.bodySize + ")");
+                        .size() + " frames, bodySize=" + contentHeader.getBodySize() + ")");
             }
 
-            data = ByteBuffer.allocate((int) contentHeader.bodySize); // XXX: Is cast a problem?
+            data = ByteBuffer.allocate((int) contentHeader.getBodySize()); // XXX: Is cast a problem?
             final Iterator it = bodies.iterator();
             while (it.hasNext())
             {
                 ContentBody cb = (ContentBody) it.next();
-                final ByteBuffer payload = ByteBuffer.wrap(cb._payload);
+                final ByteBuffer payload = ByteBuffer.wrap(cb.getPayload());
                 if(payload.isDirect() || payload.isReadOnly())
                 {
                     data.put(payload);
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/FieldTableSupport.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/FieldTableSupport.java
index 49ae8c1..31a0440 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/FieldTableSupport.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/FieldTableSupport.java
@@ -20,35 +20,39 @@
  * 
  */
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public class FieldTableSupport
 {
-  public static FieldTable convertToFieldTable(Map<String,?> props)
-  {
-      FieldTable ft = new FieldTable();
-      if (props != null)
-      {
-          for (String key : props.keySet())
-          {
-              ft.setObject(key, props.get(key));
-          }
-      }
-      return ft;
-  }
+    private FieldTableSupport()
+    {
+    }
 
-  public static Map<String,Object> convertToMap(FieldTable ft)
-  {
-     Map<String,Object> map = new HashMap<String,Object>();
-     for (AMQShortString key: ft.keySet() )
-     {
-         map.put(key.asString(), ft.getObject(key));
-     }
+    public static FieldTable convertToFieldTable(Map<String,?> props)
+    {
+        FieldTable ft = new FieldTable();
+        if (props != null)
+        {
+            for (String key : props.keySet())
+            {
+                ft.setObject(key, props.get(key));
+            }
+        }
+        return ft;
+    }
 
-     return map;
-  }
+    public static Map<String,Object> convertToMap(FieldTable ft)
+    {
+        Map<String,Object> map = new HashMap<String,Object>();
+        for (AMQShortString key: ft.keySet() )
+        {
+            map.put(key.asString(), ft.getObject(key));
+        }
+
+        return map;
+    }
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java
index e252bdb..b0320d0 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java
@@ -20,21 +20,13 @@
  */
 package org.apache.qpid.client.message;
 
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
+import org.apache.qpid.AMQException;
 
 import javax.jms.BytesMessage;
 import javax.jms.JMSException;
 import javax.jms.MessageEOFException;
 import javax.jms.MessageFormatException;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
+import java.nio.ByteBuffer;
 
 public class JMSBytesMessage extends AbstractBytesTypedMessage implements BytesMessage
 {
@@ -60,7 +52,7 @@
 
     public void reset()
     {
-        _readableMessage = true;
+        setReadable(true);
 
         if(_typedBytesContentReader != null)
         {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessageFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessageFactory.java
index 89561b8..c8c01f1 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessageFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessageFactory.java
@@ -20,12 +20,9 @@
  */
 package org.apache.qpid.client.message;
 
-import javax.jms.JMSException;
-
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
 
+import javax.jms.JMSException;
 import java.nio.ByteBuffer;
 
 public class JMSBytesMessageFactory extends AbstractJMSMessageFactory
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java
index 52c0eb2..122a5c4 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java
@@ -20,19 +20,18 @@
  */
 package org.apache.qpid.client.message;
 
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Enumeration;
-
-import javax.jms.JMSException;
-import javax.jms.MessageFormatException;
-
-import java.nio.ByteBuffer;
 import org.apache.qpid.AMQPInvalidClassException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
 
+import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.Enumeration;
+
 
 public final class JMSHeaderAdapter
 {
@@ -60,7 +59,7 @@
             {
                 Object str = getHeaders().getObject(string);
 
-                if (str == null || !(str instanceof String))
+                if (!(str instanceof String))
                 {
                     throw new MessageFormatException("getBoolean can't use " + string + " item.");
                 }
@@ -89,7 +88,7 @@
             {
                 Object str = getHeaders().getObject(string);
 
-                if (str == null || !(str instanceof String))
+                if (!(str instanceof String))
                 {
                     throw new MessageFormatException("getBoolean can't use " + string + " item.");
                 }
@@ -160,7 +159,7 @@
             {
                 Object str = getHeaders().getObject(string);
 
-                if (str == null || !(str instanceof String))
+                if (!(str instanceof String))
                 {
                     throw new MessageFormatException("getByte can't use " + string + " item.");
                 }
@@ -228,7 +227,7 @@
             {
                 Object str = getHeaders().getObject(string);
 
-                if (str == null || !(str instanceof String))
+                if (!(str instanceof String))
                 {
                     throw new MessageFormatException("getFloat can't use " + string + " item.");
                 }
@@ -285,7 +284,7 @@
                         s = String.valueOf(o);
                     }
                 }
-            }//else return s // null;
+            }
         }
 
         return s;
@@ -527,7 +526,7 @@
 //          apply when a property is used in a message selector expression. For
 //          example, suppose you set a property as a string value, as in the
 //          following:
-//              myMessage.setStringProperty("NumberOfOrders", "2");
+//              myMessage.setStringProperty("NumberOfOrders", "2")
 //          The following expression in a message selector would evaluate to false,
 //          because a string cannot be used in an arithmetic expression:
 //          "NumberOfOrders > 1"
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
index fad24a9..e18ed80 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
@@ -20,17 +20,14 @@
  */
 package org.apache.qpid.client.message;
 
-import org.apache.qpid.AMQException;
-
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.AMQException;
+
 import javax.jms.JMSException;
 import javax.jms.MessageFormatException;
-
 import java.nio.ByteBuffer;
-import java.nio.charset.CharacterCodingException;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -42,7 +39,7 @@
 
     public static final String MIME_TYPE = "jms/map-message";
 
-    protected Map<String, Object> _map = new HashMap<String, Object>();
+    private Map<String, Object> _map = new HashMap<String, Object>();
 
     public JMSMapMessage(AMQMessageDelegateFactory delegateFactory) throws JMSException
     {
@@ -486,4 +483,13 @@
         return writer.getData();
     }
 
+    protected Map<String, Object> getMap()
+    {
+        return _map;
+    }
+
+    protected void setMap(Map<String, Object> map)
+    {
+        _map = map;
+    }
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java
index 89408a5..72bc8d5 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.client.message;
 
-import javax.jms.JMSException;
-
-import java.nio.ByteBuffer;
 import org.apache.qpid.AMQException;
 
+import javax.jms.JMSException;
+import java.nio.ByteBuffer;
+
 public class JMSMapMessageFactory extends AbstractJMSMessageFactory
 {
     public AbstractJMSMessage createMessage(AMQMessageDelegateFactory delegateFactory) throws JMSException
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java
index 7f733b9..509fc9f 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java
@@ -20,16 +20,18 @@
  */
 package org.apache.qpid.client.message;
 
-import java.io.*;
-import java.nio.ByteBuffer;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.util.ClassLoadingAwareObjectInputStream;
+import org.apache.qpid.util.ByteBufferInputStream;
 
 import javax.jms.JMSException;
 import javax.jms.MessageFormatException;
 import javax.jms.ObjectMessage;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.util.ClassLoadingAwareObjectInputStream;
-import org.apache.qpid.util.ByteBufferInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.nio.ByteBuffer;
 
 public class JMSObjectMessage extends AbstractJMSMessage implements ObjectMessage
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessageFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessageFactory.java
index 4660c91..a172781 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessageFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessageFactory.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.client.message;
 
-import javax.jms.JMSException;
-
-import java.nio.ByteBuffer;
 import org.apache.qpid.AMQException;
 
+import javax.jms.JMSException;
+import java.nio.ByteBuffer;
+
 public class JMSObjectMessageFactory extends AbstractJMSMessageFactory
 {
     protected AbstractJMSMessage createMessage(AMQMessageDelegate delegate, ByteBuffer data) throws AMQException
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessage.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessage.java
index 5c93f6b..b958d89 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessage.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessage.java
@@ -20,15 +20,12 @@
  */
 package org.apache.qpid.client.message;
 
+import org.apache.qpid.AMQException;
+
 import javax.jms.JMSException;
 import javax.jms.StreamMessage;
-
 import java.nio.ByteBuffer;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
-
 /**
  * @author Apache Software Foundation
  */
@@ -57,7 +54,7 @@
 
     public void reset()
     {
-        _readableMessage = true;
+        setReadable(true);
 
         if(_typedBytesContentReader != null)
         {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessageFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessageFactory.java
index 359f515..56fa8e5 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessageFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessageFactory.java
@@ -20,12 +20,11 @@
  */
 package org.apache.qpid.client.message;
 
-import javax.jms.JMSException;
-
-import java.nio.ByteBuffer;
-
 import org.apache.qpid.AMQException;
 
+import javax.jms.JMSException;
+import java.nio.ByteBuffer;
+
 public class JMSStreamMessageFactory extends AbstractJMSMessageFactory
 {
     protected AbstractJMSMessage createMessage(AMQMessageDelegate delegate, ByteBuffer data) throws AMQException
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java
index acf3a0c..097a3bb 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java
@@ -20,8 +20,11 @@
  */
 package org.apache.qpid.client.message;
 
-import java.io.DataInputStream;
-import java.io.UnsupportedEncodingException;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.CustomJMSXProperty;
+
+import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
 import java.nio.charset.CharacterCodingException;
@@ -29,16 +32,6 @@
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
 
-import javax.jms.JMSException;
-import javax.jms.MessageFormatException;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.CustomJMSXProperty;
-import org.apache.qpid.framing.AMQFrameDecodingException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
-import org.apache.qpid.util.Strings;
-
 public class JMSTextMessage extends AbstractJMSMessage implements javax.jms.TextMessage
 {
     private static final String MIME_TYPE = "text/plain";
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessageFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessageFactory.java
index d1af32c..0b28e6c 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessageFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessageFactory.java
@@ -20,12 +20,10 @@
  */
 package org.apache.qpid.client.message;
 
-import javax.jms.JMSException;
-
-import java.nio.ByteBuffer;
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
+
+import javax.jms.JMSException;
+import java.nio.ByteBuffer;
 
 public class JMSTextMessageFactory extends AbstractJMSMessageFactory
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageConverter.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageConverter.java
index e606ef1..5abd02f 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageConverter.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageConverter.java
@@ -22,10 +22,17 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.client.AMQSession;
 
-import javax.jms.*;
-
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageEOFException;
+import javax.jms.ObjectMessage;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
 import java.util.Enumeration;
 
 public class MessageConverter
@@ -34,7 +41,7 @@
     /**
      * Log4J logger
      */
-    protected final Logger _logger = LoggerFactory.getLogger(getClass());
+    private final Logger _logger = LoggerFactory.getLogger(getClass());
 
     /**
      * AbstractJMSMessage which will hold the converted message
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactory.java
index 93c2872..70c6aa4 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactory.java
@@ -20,10 +20,6 @@
  */
 package org.apache.qpid.client.message;
 
-import java.util.List;
-
-import javax.jms.JMSException;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQSession_0_8;
@@ -33,6 +29,9 @@
 import org.apache.qpid.transport.DeliveryProperties;
 import org.apache.qpid.transport.MessageProperties;
 
+import javax.jms.JMSException;
+import java.util.List;
+
 
 public interface MessageFactory
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java
index 15ad3ed..fa39b4c 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java
@@ -20,12 +20,8 @@
  */
 package org.apache.qpid.client.message;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.nio.ByteBuffer;
-
-import javax.jms.JMSException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQQueue;
@@ -34,19 +30,21 @@
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.BasicContentHeaderProperties;
 import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.transport.Struct;
+import org.apache.qpid.transport.DeliveryProperties;
 import org.apache.qpid.transport.MessageProperties;
 import org.apache.qpid.transport.MessageTransfer;
-import org.apache.qpid.transport.DeliveryProperties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.JMSException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 public class MessageFactoryRegistry
 {
     /**
      * This class logger
      */
-    protected final Logger _logger = LoggerFactory.getLogger(getClass());
+    private final Logger _logger = LoggerFactory.getLogger(getClass());
 
     private final Map<String, MessageFactory> _mimeStringToFactoryMap = new HashMap<String, MessageFactory>();
     private final Map<AMQShortString, MessageFactory> _mimeShortStringToFactoryMap =
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/QpidMessageProperties.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/QpidMessageProperties.java
index b30afaf..663dfd3 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/QpidMessageProperties.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/QpidMessageProperties.java
@@ -25,6 +25,9 @@
  */
 public class QpidMessageProperties 
 {
+    private QpidMessageProperties()
+    {
+    }
 
     public static final String QPID_SUBJECT = "qpid.subject";
     
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/TypedBytesContentReader.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/TypedBytesContentReader.java
index 1ae25eb..b00ac7e 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/TypedBytesContentReader.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/TypedBytesContentReader.java
@@ -455,7 +455,7 @@
             ByteBuffer dup = _data.duplicate();
             int pos = _data.position();
             byte b;
-            while((b = _data.get()) != 0);
+            while((b = _data.get()) != 0) {};
             dup.limit(_data.position()-1);
             return _charsetDecoder.decode(dup).toString();
 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnprocessedMessage.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnprocessedMessage.java
index e2cb36a..bb0e3b4 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnprocessedMessage.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnprocessedMessage.java
@@ -21,7 +21,6 @@
 package org.apache.qpid.client.message;
 
 import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.BasicMessageConsumer;
 
 
 /**
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnprocessedMessage_0_8.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnprocessedMessage_0_8.java
index ce87a11..5ed98dc 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnprocessedMessage_0_8.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnprocessedMessage_0_8.java
@@ -20,15 +20,15 @@
  */
 package org.apache.qpid.client.message;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.BasicDeliverBody;
 import org.apache.qpid.framing.ContentBody;
 import org.apache.qpid.framing.ContentHeaderBody;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
 /**
  * This class contains everything needed to process a JMS message. It assembles the deliver body, the content header and
  * the content body/ies.
@@ -44,7 +44,7 @@
     private AMQShortString _exchange;
     private AMQShortString _routingKey;
     private final long _deliveryId;
-    protected boolean _redelivered;
+    private boolean _redelivered;
 
     private BasicDeliverBody _deliverBody;
     private ContentHeaderBody _contentHeader;
@@ -87,13 +87,13 @@
     public void receiveBody(ContentBody body)
     {
 
-        if (body._payload != null)
+        if (body.getPayload() != null)
         {
-            final long payloadSize = body._payload.length;
+            final long payloadSize = body.getPayload().length;
 
             if (_bodies == null)
             {
-                if (payloadSize == getContentHeader().bodySize)
+                if (payloadSize == getContentHeader().getBodySize())
                 {
                     _bodies = Collections.singletonList(body);
                 }
@@ -124,7 +124,7 @@
 
     public boolean isAllBodyDataReceived()
     {
-        return _bytesReceived == getContentHeader().bodySize;
+        return _bytesReceived == getContentHeader().getBodySize();
     }
 
     public BasicDeliverBody getDeliverBody()
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java b/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java
index 368ec60..318fe32 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java
@@ -20,22 +20,21 @@
  */
 package org.apache.qpid.client.messaging.address;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQDestination.Binding;
 import org.apache.qpid.client.messaging.address.Link.Reliability;
 import org.apache.qpid.client.messaging.address.Link.Subscription;
 import org.apache.qpid.client.messaging.address.Node.ExchangeNode;
 import org.apache.qpid.client.messaging.address.Node.QueueNode;
-import org.apache.qpid.client.messaging.address.Node.UnknownNodeType;
 import org.apache.qpid.configuration.Accessor;
 import org.apache.qpid.configuration.Accessor.MapAccessor;
 import org.apache.qpid.messaging.Address;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
 /**
  * Utility class for extracting information from the address class
  */
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/Link.java b/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/Link.java
index c73d800..41f6725 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/Link.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/Link.java
@@ -29,16 +29,16 @@
     
     public enum Reliability { UNRELIABLE, AT_MOST_ONCE, AT_LEAST_ONCE, EXACTLY_ONCE }
     
-    protected String name;
-    protected String _filter;
-    protected FilterType _filterType = FilterType.SUBJECT;
-    protected boolean _isNoLocal;
-    protected boolean _isDurable;
-    protected int _consumerCapacity = 0;
-    protected int _producerCapacity = 0;
-    protected Node node;
-    protected Subscription subscription;
-    protected Reliability reliability = Reliability.AT_LEAST_ONCE;
+    private String name;
+    private String _filter;
+    private FilterType _filterType = FilterType.SUBJECT;
+    private boolean _isNoLocal;
+    private boolean _isDurable;
+    private int _consumerCapacity = 0;
+    private int _producerCapacity = 0;
+    private Node node;
+    private Subscription subscription;
+    private Reliability reliability = Reliability.AT_LEAST_ONCE;
     
     public Reliability getReliability()
     {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/Node.java b/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/Node.java
index c98b194..0da0327 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/Node.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/Node.java
@@ -21,25 +21,28 @@
 
 package org.apache.qpid.client.messaging.address;
 
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQDestination.Binding;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
-import javax.naming.OperationNotSupportedException;
-
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQDestination.Binding;
-
 public abstract class Node
 { 
-    protected int _nodeType = AMQDestination.UNKNOWN_TYPE;
-    protected boolean _isDurable;
-    protected boolean _isAutoDelete;
-    protected String _alternateExchange;
-    protected List<Binding> _bindings = new ArrayList<Binding>();
-    protected Map<String,Object> _declareArgs = Collections.emptyMap();
-    
+    private int _nodeType = AMQDestination.UNKNOWN_TYPE;
+    private boolean _isDurable;
+    private boolean _isAutoDelete;
+    private String _alternateExchange;
+    private List<Binding> _bindings = new ArrayList<Binding>();
+    private Map<String,Object> _declareArgs = Collections.emptyMap();
+
+    protected Node(int nodeType)
+    {
+        _nodeType = nodeType;
+    }
+
     public int getType()
     {
         return _nodeType;
@@ -101,12 +104,12 @@
     
     public static class QueueNode extends Node 
     {
-       protected boolean _isExclusive;      
-       protected QpidQueueOptions _queueOptions = new QpidQueueOptions();
+       private boolean _isExclusive;
+       private QpidQueueOptions _queueOptions = new QpidQueueOptions();
        
        public QueueNode()
        {
-           _nodeType = AMQDestination.QUEUE_TYPE;
+           super(AMQDestination.QUEUE_TYPE);
        }
        
        public boolean isExclusive()
@@ -122,12 +125,12 @@
     
     public static class ExchangeNode extends Node 
     {
-       protected QpidExchangeOptions _exchangeOptions = new QpidExchangeOptions();
-       protected String _exchangeType;
+       private QpidExchangeOptions _exchangeOptions = new QpidExchangeOptions();
+       private String _exchangeType;
        
        public ExchangeNode()
        {
-           _nodeType = AMQDestination.TOPIC_TYPE;
+           super(AMQDestination.TOPIC_TYPE);
        }
        
        public String getExchangeType()
@@ -144,5 +147,9 @@
     
     public static class UnknownNodeType extends Node 
     {
+        public UnknownNodeType()
+        {
+            super(AMQDestination.UNKNOWN_TYPE);
+        }
     }
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
index 8911d4e..d380402 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
@@ -20,18 +20,9 @@
  */
 package org.apache.qpid.client.protocol;
 
-import java.io.DataOutput;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.SocketAddress;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import org.apache.qpid.util.BytesDataOutput;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQConnectionClosedException;
 import org.apache.qpid.AMQDisconnectedException;
@@ -66,8 +57,16 @@
 import org.apache.qpid.thread.Threading;
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.network.NetworkConnection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * AMQProtocolHandler is the client side protocol handler for AMQP, it handles all protocol events received from the
@@ -300,7 +299,6 @@
     {
         if (_failoverState == FailoverState.NOT_STARTED)
         {
-            // if (!(cause instanceof AMQUndeliveredException) && (!(cause instanceof AMQAuthenticationException)))
             if ((cause instanceof AMQConnectionClosedException) || cause instanceof IOException)
             {
                 _logger.info("Exception caught therefore going to attempt failover: " + cause, cause);
@@ -314,7 +312,7 @@
             }
 
             // FIXME Need to correctly handle other exceptions. Things like ...
-            // if (cause instanceof AMQChannelClosedException)
+            // AMQChannelClosedException
             // which will cause the JMSSession to end due to a channel close and so that Session needs
             // to be removed from the map so we can correctly still call close without an exception when trying to close
             // the server closed session.  See also CloseChannelMethodHandler as the sessionClose is never called on exception
@@ -865,160 +863,6 @@
         return _suggestedProtocolVersion;
     }
 
-    private static class BytesDataOutput implements DataOutput
-        {
-            int _pos = 0;
-            byte[] _buf;
-
-            public BytesDataOutput(byte[] buf)
-            {
-                _buf = buf;
-            }
-
-            public void setBuffer(byte[] buf)
-            {
-                _buf = buf;
-                _pos = 0;
-            }
-
-            public void reset()
-            {
-                _pos = 0;
-            }
-
-            public int length()
-            {
-                return _pos;
-            }
-
-            public void write(int b)
-            {
-                _buf[_pos++] = (byte) b;
-            }
-
-            public void write(byte[] b)
-            {
-                System.arraycopy(b, 0, _buf, _pos, b.length);
-                _pos+=b.length;
-            }
-
-
-            public void write(byte[] b, int off, int len)
-            {
-                System.arraycopy(b, off, _buf, _pos, len);
-                _pos+=len;
-
-            }
-
-            public void writeBoolean(boolean v)
-            {
-                _buf[_pos++] = v ? (byte) 1 : (byte) 0;
-            }
-
-            public void writeByte(int v)
-            {
-                _buf[_pos++] = (byte) v;
-            }
-
-            public void writeShort(int v)
-            {
-                _buf[_pos++] = (byte) (v >>> 8);
-                _buf[_pos++] = (byte) v;
-            }
-
-            public void writeChar(int v)
-            {
-                _buf[_pos++] = (byte) (v >>> 8);
-                _buf[_pos++] = (byte) v;
-            }
-
-            public void writeInt(int v)
-            {
-                _buf[_pos++] = (byte) (v >>> 24);
-                _buf[_pos++] = (byte) (v >>> 16);
-                _buf[_pos++] = (byte) (v >>> 8);
-                _buf[_pos++] = (byte) v;
-            }
-
-            public void writeLong(long v)
-            {
-                _buf[_pos++] = (byte) (v >>> 56);
-                _buf[_pos++] = (byte) (v >>> 48);
-                _buf[_pos++] = (byte) (v >>> 40);
-                _buf[_pos++] = (byte) (v >>> 32);
-                _buf[_pos++] = (byte) (v >>> 24);
-                _buf[_pos++] = (byte) (v >>> 16);
-                _buf[_pos++] = (byte) (v >>> 8);
-                _buf[_pos++] = (byte)v;
-            }
-
-            public void writeFloat(float v)
-            {
-                writeInt(Float.floatToIntBits(v));
-            }
-
-            public void writeDouble(double v)
-            {
-                writeLong(Double.doubleToLongBits(v));
-            }
-
-            public void writeBytes(String s)
-            {
-                int len = s.length();
-                for (int i = 0 ; i < len ; i++)
-                {
-                    _buf[_pos++] = ((byte)s.charAt(i));
-                }
-            }
-
-            public void writeChars(String s)
-            {
-                int len = s.length();
-                for (int i = 0 ; i < len ; i++)
-                {
-                    int v = s.charAt(i);
-                    _buf[_pos++] = (byte) (v >>> 8);
-                    _buf[_pos++] = (byte) v;
-                }
-            }
-
-            public void writeUTF(String s)
-            {
-                int strlen = s.length();
-
-                int pos = _pos;
-                _pos+=2;
-
-
-                for (int i = 0; i < strlen; i++)
-                {
-                    int c = s.charAt(i);
-                    if ((c >= 0x0001) && (c <= 0x007F))
-                    {
-                        c = s.charAt(i);
-                        _buf[_pos++] = (byte) c;
-
-                    }
-                    else if (c > 0x07FF)
-                    {
-                        _buf[_pos++]  = (byte) (0xE0 | ((c >> 12) & 0x0F));
-                        _buf[_pos++]  = (byte) (0x80 | ((c >>  6) & 0x3F));
-                        _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
-                    }
-                    else
-                    {
-                        _buf[_pos++] = (byte) (0xC0 | ((c >>  6) & 0x1F));
-                        _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
-                    }
-                }
-
-                int len = _pos - (pos + 2);
-
-                _buf[pos++] = (byte) (len >>> 8);
-                _buf[pos] = (byte) len;
-            }
-
-        }
 
 
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java
index b7253e6..af57fd9 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java
@@ -20,11 +20,8 @@
  */
 package org.apache.qpid.client.protocol;
 
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.jms.JMSException;
-import javax.security.sasl.SaslClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQConnection;
@@ -48,8 +45,11 @@
 import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.TransportException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.JMSException;
+import javax.security.sasl.SaslClient;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 /**
  * Wrapper for protocol session that provides type-safe access to session attributes. <p/> The underlying protocol
@@ -73,16 +73,11 @@
 
     protected static final String SASL_CLIENT = "SASLClient";
 
-    /**
-     * The handler from which this session was created and which is used to handle protocol events. We send failover
-     * events to the handler.
-     */
-    protected final AMQProtocolHandler _protocolHandler;
+    private final AMQProtocolHandler _protocolHandler;
 
-    /** Maps from the channel id to the AMQSession that it represents. */
-    protected ConcurrentMap<Integer, AMQSession> _channelId2SessionMap = new ConcurrentHashMap<Integer, AMQSession>();
+    private ConcurrentMap<Integer, AMQSession> _channelId2SessionMap = new ConcurrentHashMap<Integer, AMQSession>();
 
-    protected ConcurrentMap _closingChannels = new ConcurrentHashMap();
+    private ConcurrentMap _closingChannels = new ConcurrentHashMap();
 
     /**
      * Maps from a channel id to an unprocessed message. This is used to tie together the JmsDeliverBody (which arrives
@@ -91,20 +86,17 @@
     private final ConcurrentMap<Integer, UnprocessedMessage> _channelId2UnprocessedMsgMap = new ConcurrentHashMap<Integer, UnprocessedMessage>();
     private final UnprocessedMessage[] _channelId2UnprocessedMsgArray = new UnprocessedMessage[16];
 
-    /** Counter to ensure unique queue names */
-    protected int _queueId = 1;
-    protected final Object _queueIdLock = new Object();
+    private int _queueId = 1;
+    private final Object _queueIdLock = new Object();
 
     private ProtocolVersion _protocolVersion;
-//    private VersionSpecificRegistry _registry =
-//        MainRegistry.getVersionSpecificRegistry(ProtocolVersion.getLatestSupportedVersion());
 
     private MethodRegistry _methodRegistry =
             MethodRegistry.getMethodRegistry(ProtocolVersion.getLatestSupportedVersion());
 
     private MethodDispatcher _methodDispatcher;
 
-    protected final AMQConnection _connection;
+    private final AMQConnection _connection;
 
     private ConnectionTuneParameters _connectionTuneParameters;
 
@@ -116,7 +108,10 @@
     {
         _protocolHandler = protocolHandler;
         _protocolVersion = connection.getProtocolVersion();
-        _logger.info("Using ProtocolVersion for Session:" + _protocolVersion);
+        if (_logger.isDebugEnabled())
+        {
+        	_logger.debug("Using ProtocolVersion for Session:" + _protocolVersion);
+        }
         _methodDispatcher = ClientMethodDispatcherImpl.newMethodDispatcher(ProtocolVersion.getLatestSupportedVersion(),
                                                                            this);
         _connection = connection;
@@ -223,7 +218,7 @@
         }
 
         msg.setContentHeader(contentHeader);
-        if (contentHeader.bodySize == 0)
+        if (contentHeader.getBodySize() == 0)
         {
             deliverMessageToAMQSession(channelId, msg);
         }
@@ -310,7 +305,10 @@
      */
     public void closeSession(AMQSession session)
     {
-        _logger.debug("closeSession called on protocol session for session " + session.getChannelId());
+        if (_logger.isDebugEnabled())
+        {
+        	_logger.debug("closeSession called on protocol session for session " + session.getChannelId());
+        }
         final int channelId = session.getChannelId();
         if (channelId <= 0)
         {
@@ -401,7 +399,10 @@
 
     public void setProtocolVersion(final ProtocolVersion pv)
     {
-        _logger.info("Setting ProtocolVersion to :" + pv);
+        if (_logger.isDebugEnabled())
+        {
+        	_logger.debug("Setting ProtocolVersion to :" + pv);
+        }
         _protocolVersion = pv;
         _methodRegistry = MethodRegistry.getMethodRegistry(pv);
         _methodDispatcher = ClientMethodDispatcherImpl.newMethodDispatcher(pv, this);
@@ -470,4 +471,55 @@
     {
         return "AMQProtocolSession[" + _connection + ']';
     }
+
+    /**
+     * The handler from which this session was created and which is used to handle protocol events. We send failover
+     * events to the handler.
+     */
+    protected AMQProtocolHandler getProtocolHandler()
+    {
+        return _protocolHandler;
+    }
+
+    /** Maps from the channel id to the AMQSession that it represents. */
+    protected ConcurrentMap<Integer, AMQSession> getChannelId2SessionMap()
+    {
+        return _channelId2SessionMap;
+    }
+
+    protected void setChannelId2SessionMap(ConcurrentMap<Integer, AMQSession> channelId2SessionMap)
+    {
+        _channelId2SessionMap = channelId2SessionMap;
+    }
+
+    protected ConcurrentMap getClosingChannels()
+    {
+        return _closingChannels;
+    }
+
+    protected void setClosingChannels(ConcurrentMap closingChannels)
+    {
+        _closingChannels = closingChannels;
+    }
+
+    /** Counter to ensure unique queue names */
+    protected int getQueueId()
+    {
+        return _queueId;
+    }
+
+    protected void setQueueId(int queueId)
+    {
+        _queueId = queueId;
+    }
+
+    protected Object getQueueIdLock()
+    {
+        return _queueIdLock;
+    }
+
+    protected AMQConnection getConnection()
+    {
+        return _connection;
+    }
 }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/BlockingMethodFrameListener.java b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/BlockingMethodFrameListener.java
index 2bc609e..b865c51 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/BlockingMethodFrameListener.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/BlockingMethodFrameListener.java
@@ -20,12 +20,7 @@
  */
 package org.apache.qpid.client.protocol;
 
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-
 import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQTimeoutException;
 import org.apache.qpid.client.failover.FailoverException;
 import org.apache.qpid.client.util.BlockingWaiter;
 import org.apache.qpid.framing.AMQMethodBody;
@@ -68,7 +63,7 @@
 {
 
     /** Holds the channel id for the channel upon which this listener is waiting for a response. */
-    protected int _channelId;
+    private int _channelId;
 
     /**
      * Creates a new method listener, that filters incoming method to just those that match the specified channel id.
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/HeartbeatDiagnostics.java b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/HeartbeatDiagnostics.java
index d44faea..d387a8b 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/HeartbeatDiagnostics.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/HeartbeatDiagnostics.java
@@ -24,6 +24,10 @@
 {
     private static final Diagnostics _impl = init();
 
+    private HeartbeatDiagnostics()
+    {
+    }
+
     private static Diagnostics init()
     {
         return Boolean.getBoolean("amqj.heartbeat.diagnostics") ? new On() : new Off();
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/security/AMQCallbackHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/security/AMQCallbackHandler.java
index 67dd1a5..068e105 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/security/AMQCallbackHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/security/AMQCallbackHandler.java
@@ -20,10 +20,10 @@
  */
 package org.apache.qpid.client.security;
 
-import javax.security.auth.callback.CallbackHandler;
-
 import org.apache.qpid.jms.ConnectionURL;
 
+import javax.security.auth.callback.CallbackHandler;
+
 public interface AMQCallbackHandler extends CallbackHandler
 {
     void initialise(ConnectionURL connectionURL);    
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java b/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java
index 14bae68..6b2448e 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.java
@@ -20,6 +20,11 @@
  */
 package org.apache.qpid.client.security;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.util.FileUtils;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Collection;
@@ -33,10 +38,6 @@
 import java.util.StringTokenizer;
 import java.util.TreeMap;
 
-import org.apache.qpid.util.FileUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * CallbackHandlerRegistry is a registry for call back handlers for user authentication and interaction during user
  * authentication. It is capable of reading its configuration from a properties file containing call back handler
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.java b/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.java
index 2b4261b..9198903 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.client.security;
 
-import org.apache.qpid.util.FileUtils;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.security.sasl.SaslClientFactory;
+import org.apache.qpid.util.FileUtils;
 
+import javax.security.sasl.SaslClientFactory;
 import java.io.IOException;
 import java.io.InputStream;
 import java.security.Security;
@@ -63,6 +62,10 @@
     /** The default name of the SASL properties file resource. */
     public static final String DEFAULT_RESOURCE_NAME = "org/apache/qpid/client/security/DynamicSaslRegistrar.properties";
 
+    private DynamicSaslRegistrar()
+    {
+    }
+
     /** Reads the properties file, and creates a dynamic security provider to register the SASL implementations with. */
     public static void registerSaslProviders()
     {
@@ -122,47 +125,6 @@
     }
 
     /**
-     * Either attempts to open the specified filename as an input stream, or uses the default SASL configuration
-     * resource.
-     *
-     * @param filename The name of the file to get the SASL properties from, null to use the default.
-     *
-     * @return An input stream to read the dynamic SASL configuration from, or null if one could not be opened.
-     */
-    /*private static InputStream openPropertiesInputStream(String filename)
-    {
-        InputStream is = null;
-
-        // Flag to indicate whether the default resource should be used. By default this is true, so that the default
-        // is used when opening the file fails.
-        boolean useDefault = true;
-
-        // Try to open the file if one was specified.
-        if (filename != null)
-        {
-            try
-            {
-                is = new BufferedInputStream(new FileInputStream(new File(filename)));
-
-                // Clear the default flag because the file was succesfully opened.
-                useDefault = false;
-            }
-            catch (FileNotFoundException e)
-            {
-                _logger.error("Unable to read from file " + filename + ": " + e, e);
-            }
-        }
-
-        // Load the default resource if a file was not specified, or if opening the file failed.
-        if (useDefault)
-        {
-            is = CallbackHandlerRegistry.class.getResourceAsStream(DEFAULT_RESOURCE_NAME);
-        }
-
-        return is;
-    }*/
-
-    /**
      * Parses the specified properties as a mapping from IANA registered SASL mechanism names to implementing client
      * factories. If the client factories cannot be instantiated or do not implement SaslClientFactory then the
      * properties refering to them are ignored.
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/security/JCAProvider.java b/qpid/java/client/src/main/java/org/apache/qpid/client/security/JCAProvider.java
index 828d26e..4a91f80 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/security/JCAProvider.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/security/JCAProvider.java
@@ -24,9 +24,7 @@
 import org.slf4j.LoggerFactory;
 
 import javax.security.sasl.SaslClientFactory;
-
 import java.security.Provider;
-import java.security.Security;
 import java.util.Map;
 
 /**
@@ -53,7 +51,6 @@
         super("AMQSASLProvider-Client", 1.0, "A JCA provider that registers all "
             + "AMQ SASL providers that want to be registered");
         register(providerMap);
-//        Security.addProvider(this);
     }
 
     /**
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandler.java
index 6ec83f0..fe24d48 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandler.java
@@ -20,17 +20,16 @@
  */
 package org.apache.qpid.client.security;
 
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
+import org.apache.qpid.jms.ConnectionURL;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.NameCallback;
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.callback.UnsupportedCallbackException;
-
-import org.apache.qpid.jms.ConnectionURL;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 
 public class UsernameHashedPasswordCallbackHandler implements AMQCallbackHandler
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandler.java
index ad08872..99b5f24 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandler.java
@@ -20,14 +20,13 @@
  */
 package org.apache.qpid.client.security;
 
-import java.io.IOException;
+import org.apache.qpid.jms.ConnectionURL;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.NameCallback;
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.callback.UnsupportedCallbackException;
-
-import org.apache.qpid.jms.ConnectionURL;
+import java.io.IOException;
 
 public class UsernamePasswordCallbackHandler implements AMQCallbackHandler
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java b/qpid/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java
index f8a25c6..5f9a240 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java
@@ -20,6 +20,9 @@
  */
 package org.apache.qpid.client.security.amqplain;
 
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.FieldTableFactory;
+
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.NameCallback;
@@ -27,9 +30,6 @@
 import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslException;
 
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.framing.FieldTableFactory;
-
 /**
  * Implements the "AMQPlain" authentication protocol that uses FieldTables to send username and pwd.
  *
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClientFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClientFactory.java
index 30cc786..f1d7da2 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClientFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClientFactory.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.client.security.amqplain;
 
-import java.util.Map;
-
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslClientFactory;
 import javax.security.sasl.SaslException;
+import java.util.Map;
 
 public class AmqPlainSaslClientFactory implements SaslClientFactory
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/security/anonymous/AnonymousSaslClientFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/security/anonymous/AnonymousSaslClientFactory.java
index de698f8..283ba5f 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/security/anonymous/AnonymousSaslClientFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/security/anonymous/AnonymousSaslClientFactory.java
@@ -20,14 +20,12 @@
  */
 package org.apache.qpid.client.security.anonymous;
 
-import java.util.Arrays;
-import java.util.Map;
-
-import javax.security.sasl.Sasl;
+import javax.security.auth.callback.CallbackHandler;
 import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslClientFactory;
 import javax.security.sasl.SaslException;
-import javax.security.auth.callback.CallbackHandler;
+import java.util.Arrays;
+import java.util.Map;
 
 public class AnonymousSaslClientFactory implements SaslClientFactory
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/security/crammd5hashed/CRAMMD5HashedSaslClientFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/security/crammd5hashed/CRAMMD5HashedSaslClientFactory.java
index 22bb1ac..cb989f7 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/security/crammd5hashed/CRAMMD5HashedSaslClientFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/security/crammd5hashed/CRAMMD5HashedSaslClientFactory.java
@@ -20,15 +20,12 @@
  */
 package org.apache.qpid.client.security.crammd5hashed;
 
-import org.apache.qpid.client.security.amqplain.AmqPlainSaslClient;
-
-import javax.security.sasl.SaslClientFactory;
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
-import javax.security.sasl.Sasl;
 import javax.security.auth.callback.CallbackHandler;
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslClientFactory;
+import javax.security.sasl.SaslException;
 import java.util.Map;
-import java.security.Security;
 
 public class CRAMMD5HashedSaslClientFactory implements SaslClientFactory
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQMethodNotImplementedException.java b/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQMethodNotImplementedException.java
index 2c99b9a..f7d8b2b 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQMethodNotImplementedException.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQMethodNotImplementedException.java
@@ -20,8 +20,8 @@
  */
 package org.apache.qpid.client.state;
 
-import org.apache.qpid.framing.AMQMethodBody;
 import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQMethodBody;
 
 public class AMQMethodNotImplementedException extends AMQException
 {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java b/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java
index 0d6fc72..7d028e0 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java
@@ -20,16 +20,17 @@
  */
 package org.apache.qpid.client.state;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.protocol.AMQProtocolSession;
-import org.apache.qpid.framing.*;
-import org.apache.qpid.protocol.AMQMethodEvent;
-import org.apache.qpid.protocol.AMQMethodListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Set;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.protocol.AMQProtocolSession;
+import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.protocol.AMQMethodEvent;
+import org.apache.qpid.protocol.AMQMethodListener;
+
 import java.util.List;
+import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
@@ -62,7 +63,7 @@
 
     private static final long MAXIMUM_STATE_WAIT_TIME = Long.parseLong(System.getProperty("amqj.MaximumStateWait", "30000"));
 
-    protected final List<StateWaiter> _waiters = new CopyOnWriteArrayList<StateWaiter>();
+    private final List<StateWaiter> _waiters = new CopyOnWriteArrayList<StateWaiter>();
     private Exception _lastException;
 
     public AMQStateManager()
@@ -110,7 +111,6 @@
     {
         B method = evt.getMethod();
 
-        //    StateAwareMethodListener handler = findStateTransitionHandler(_currentState, evt.getMethod());
         method.execute(_protocolSession.getMethodDispatcher(), evt.getChannelId());
         return true;
     }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/state/StateAwareMethodListener.java b/qpid/java/client/src/main/java/org/apache/qpid/client/state/StateAwareMethodListener.java
index 17d04f4..6b038e0 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/state/StateAwareMethodListener.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/state/StateAwareMethodListener.java
@@ -21,9 +21,8 @@
 package org.apache.qpid.client.state;
 
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQMethodBody;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
-import org.apache.qpid.protocol.AMQMethodEvent;
+import org.apache.qpid.framing.AMQMethodBody;
 
 /**
  * A frame listener that is informed of the protocl state when invoked and has
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/state/StateWaiter.java b/qpid/java/client/src/main/java/org/apache/qpid/client/state/StateWaiter.java
index 732480e..c8903d2 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/state/StateWaiter.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/state/StateWaiter.java
@@ -20,11 +20,12 @@
  */
 package org.apache.qpid.client.state;
 
-import org.apache.qpid.client.util.BlockingWaiter;
-import org.apache.qpid.client.failover.FailoverException;
-import org.apache.qpid.AMQException;
-import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.failover.FailoverException;
+import org.apache.qpid.client.util.BlockingWaiter;
 
 import java.util.Set;
 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQNoTransportForProtocolException.java b/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQNoTransportForProtocolException.java
deleted file mode 100644
index 6e47e2c..0000000
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQNoTransportForProtocolException.java
+++ /dev/null
@@ -1,59 +0,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.
- *
- */
-package org.apache.qpid.client.transport;
-
-import org.apache.qpid.jms.BrokerDetails;
-
-/**
- * AMQNoTransportForProtocolException represents a connection failure where there is no transport medium to connect
- * to the broker available.  This may be the case if their is a error in the connection url, or an unsupported transport
- * type is specified.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Represent absence of a transport medium.
- * </table>
- *
- * @todo Error code never used. This is not an AMQException.
- */
-public class AMQNoTransportForProtocolException extends AMQTransportConnectionException
-{
-    BrokerDetails _details;
-
-    public AMQNoTransportForProtocolException(BrokerDetails details, String message, Throwable cause)
-    {
-        super(null, message, cause);
-
-        _details = details;
-    }
-
-    public String toString()
-    {
-        if (_details != null)
-        {
-            return super.toString() + _details.toString();
-        }
-        else
-        {
-            return super.toString();
-        }
-    }
-}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQTransportConnectionException.java b/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQTransportConnectionException.java
deleted file mode 100644
index 6bef621..0000000
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQTransportConnectionException.java
+++ /dev/null
@@ -1,43 +0,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.
- *
- */
-package org.apache.qpid.client.transport;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.protocol.AMQConstant;
-
-/**
- * AMQTransportConnectionException indicates a failure to establish a connection through the transporting medium, to
- * an AMQP broker.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Represent failure to connect through the transport medium.
- * </table>
- *
- * @todo Error code never used. This is not an AMQException.
- */
-public class AMQTransportConnectionException extends AMQException
-{
-    public AMQTransportConnectionException(AMQConstant errorCode, String message, Throwable cause)
-    {
-        super(errorCode, message, cause);
-    }
-}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java b/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java
index 1b483f6..3c9a6e1 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ClientConnectionDelegate.java
@@ -20,13 +20,11 @@
  */
 package org.apache.qpid.client.transport;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
+import org.ietf.jgss.GSSContext;
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.GSSManager;
+import org.ietf.jgss.GSSName;
+import org.ietf.jgss.Oid;
 
 import org.apache.qpid.client.security.AMQCallbackHandler;
 import org.apache.qpid.client.security.CallbackHandlerRegistry;
@@ -38,11 +36,13 @@
 import org.apache.qpid.transport.ConnectionSettings;
 import org.apache.qpid.transport.util.Logger;
 import org.apache.qpid.util.Strings;
-import org.ietf.jgss.GSSContext;
-import org.ietf.jgss.GSSException;
-import org.ietf.jgss.GSSManager;
-import org.ietf.jgss.GSSName;
-import org.ietf.jgss.Oid;
+
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  *
@@ -85,7 +85,7 @@
     protected SaslClient createSaslClient(List<Object> brokerMechs) throws ConnectionException, SaslException
     {
         final String brokerMechanisms = Strings.join(" ", brokerMechs);
-        final String restrictionList = _conSettings.getSaslMechs();
+        final String restrictionList = getConnectionSettings().getSaslMechs();
         final String selectedMech = CallbackHandlerRegistry.getInstance().selectMechanism(brokerMechanisms, restrictionList);
         if (selectedMech == null)
         {
@@ -96,14 +96,14 @@
         }
 
         Map<String,Object> saslProps = new HashMap<String,Object>();
-        if (_conSettings.isUseSASLEncryption())
+        if (getConnectionSettings().isUseSASLEncryption())
         {
             saslProps.put(Sasl.QOP, "auth-conf");
         }
 
         final AMQCallbackHandler handler = CallbackHandlerRegistry.getInstance().createCallbackHandler(selectedMech);
         handler.initialise(_connectionURL);
-        final SaslClient sc = Sasl.createSaslClient(new String[] {selectedMech}, null, _conSettings.getSaslProtocol(), _conSettings.getSaslServerName(), saslProps, handler);
+        final SaslClient sc = Sasl.createSaslClient(new String[] {selectedMech}, null, getConnectionSettings().getSaslProtocol(), getConnectionSettings().getSaslServerName(), saslProps, handler);
 
         return sc;
     }
@@ -137,7 +137,7 @@
     private String getKerberosUser()
     {
         LOGGER.debug("Obtaining userID from kerberos");
-        String service = _conSettings.getSaslProtocol() + "@" + _conSettings.getSaslServerName();
+        String service = getConnectionSettings().getSaslProtocol() + "@" + getConnectionSettings().getSaslServerName();
         GSSManager manager = GSSManager.getInstance();
 
         try
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ITransportConnection.java b/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ITransportConnection.java
deleted file mode 100644
index 7a24d6e..0000000
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/ITransportConnection.java
+++ /dev/null
@@ -1,32 +0,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.
- *
- */
-package org.apache.qpid.client.transport;
-
-import java.io.IOException;
-
-import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.jms.BrokerDetails;
-
-public interface ITransportConnection
-{
-    void connect(AMQProtocolHandler protocolHandler, BrokerDetails brokerDetail)
-            throws IOException;
-}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java b/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java
index 0316756..f303d15 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java
@@ -21,10 +21,6 @@
  */
 
 
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.StringTokenizer;
-
 import org.apache.qpid.client.AMQBrokerDetails;
 import org.apache.qpid.client.AMQConnectionFactory;
 import org.apache.qpid.client.AMQConnectionURL;
@@ -32,6 +28,10 @@
 import org.apache.qpid.url.URLHelper;
 import org.apache.qpid.url.URLSyntaxException;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.StringTokenizer;
+
 public class URLParser
 {
     private AMQConnectionURL _url;
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java
index 605e9ee..d81868f 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java
@@ -17,13 +17,13 @@
  */
 package org.apache.qpid.client.url;
 
+import org.apache.qpid.client.AMQBrokerDetails;
+import org.apache.qpid.jms.BrokerDetails;
+
 import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.qpid.client.AMQBrokerDetails;
-import org.apache.qpid.jms.BrokerDetails;
-
 /**
  * The format Qpid URL is based on the AMQP one.
  * The grammar is as follows:
@@ -57,7 +57,6 @@
     private static final char PROPERTY_SEPARATOR_CHAR = ';';
     private static final char ADDRESS_SEPERATOR_CHAR = ',';
 
-    //private static final char CLIENT_ID_TRANSPORT_SEPARATOR_CHAR = ':';
     private static final char TRANSPORT_HOST_SEPARATOR_CHAR = ':';
     private static final char HOST_PORT_SEPARATOR_CHAR = ':';
     private static final char AT_CHAR = '@';
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/util/BlockingWaiter.java b/qpid/java/client/src/main/java/org/apache/qpid/client/util/BlockingWaiter.java
index bec4164..80d1715 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/util/BlockingWaiter.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/util/BlockingWaiter.java
@@ -20,16 +20,17 @@
  */
 package org.apache.qpid.client.util;
 
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQTimeoutException;
 import org.apache.qpid.client.failover.FailoverException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
 
 /**
  * BlockingWaiter is a 'rendezvous' which delegates handling of
@@ -84,7 +85,7 @@
     private volatile Exception _error;
 
     /** Holds the incomming Object. */
-    protected Object _doneObject = null;
+    private Object _doneObject = null;
     private AtomicBoolean _waiting = new AtomicBoolean(false);
     private boolean _closed = false;
 
@@ -183,11 +184,7 @@
                     {
                         _logger.error(e.getMessage(), e);
                         // IGNORE    -- //fixme this isn't ideal as being interrupted isn't equivellant to sucess
-                        // if (!_ready && timeout != -1)
-                        // {
-                        // _error = new AMQException("Server did not respond timely");
-                        // _ready = true;
-                        // }
+
                     }
                 }
             }
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/util/FlowControllingBlockingQueue.java b/qpid/java/client/src/main/java/org/apache/qpid/client/util/FlowControllingBlockingQueue.java
index ee7fc53..c8d1214 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/util/FlowControllingBlockingQueue.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/util/FlowControllingBlockingQueue.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.client.util;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.util.Iterator;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * A blocking queue that emits events above a user specified threshold allowing the caller to take action (e.g. flow
  * control) to try to prevent the queue growing (much) further. The underlying queue itself is not bounded therefore the
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/collections/KeyValue.java b/qpid/java/client/src/main/java/org/apache/qpid/collections/KeyValue.java
deleted file mode 100644
index e890aba..0000000
--- a/qpid/java/client/src/main/java/org/apache/qpid/collections/KeyValue.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *  Copyright 2003-2004 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.qpid.collections;
-
-/**
- * Defines a simple key value pair.
- * <p>
- * A Map Entry has considerable additional semantics over and above a simple
- * key-value pair. This interface defines the minimum key value, with just the
- * two get methods.
- *
- * @since Commons Collections 3.0
- * @version $Revision$ $Date$
- * 
- * @author Stephen Colebourne
- */
-public interface KeyValue {
-
-    /**
-     * Gets the key from the pair.
-     *
-     * @return the key 
-     */
-    Object getKey();
-
-    /**
-     * Gets the value from the pair.
-     *
-     * @return the value
-     */
-    Object getValue();
-
-}
\ No newline at end of file
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/collections/ReferenceMap.java b/qpid/java/client/src/main/java/org/apache/qpid/collections/ReferenceMap.java
deleted file mode 100644
index 1516c56..0000000
--- a/qpid/java/client/src/main/java/org/apache/qpid/collections/ReferenceMap.java
+++ /dev/null
@@ -1,957 +0,0 @@
-/*
- *  Copyright 2001-2004 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.qpid.collections;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.ref.Reference;
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.SoftReference;
-import java.lang.ref.WeakReference;
-import java.util.AbstractCollection;
-import java.util.AbstractMap;
-import java.util.AbstractSet;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import org.apache.qpid.collections.keyvalue.DefaultMapEntry;
-
-/**
- *  Hash-based {@link Map} implementation that allows
- *  mappings to be removed by the garbage collector.<p>
- *
- *  When you construct a <code>ReferenceMap</code>, you can 
- *  specify what kind of references are used to store the
- *  map's keys and values.  If non-hard references are 
- *  used, then the garbage collector can remove mappings
- *  if a key or value becomes unreachable, or if the 
- *  JVM's memory is running low.  For information on how
- *  the different reference types behave, see
- *  {@link Reference}.<p>
- *
- *  Different types of references can be specified for keys
- *  and values.  The keys can be configured to be weak but
- *  the values hard, in which case this class will behave
- *  like a <a href="http://java.sun.com/j2se/1.4/docs/api/java/util/WeakHashMap.html">
- *  <code>WeakHashMap</code></a>.  However, you
- *  can also specify hard keys and weak values, or any other
- *  combination.  The default constructor uses hard keys
- *  and soft values, providing a memory-sensitive cache.<p>
- *
- *  The algorithms used are basically the same as those
- *  in {@link java.util.HashMap}.  In particular, you 
- *  can specify a load factor and capacity to suit your
- *  needs.  All optional {@link Map} operations are 
- *  supported.<p>
- *
- *  However, this {@link Map} implementation does <I>not</I>
- *  allow null elements.  Attempting to add a null key or
- *  or a null value to the map will raise a 
- *  <code>NullPointerException</code>.<p>
- *
- *  As usual, this implementation is not synchronized.  You
- *  can use {@link java.util.Collections#synchronizedMap} to 
- *  provide synchronized access to a <code>ReferenceMap</code>.
- *
- * @see java.lang.ref.Reference
- * 
- * @deprecated Moved to map subpackage. Due to be removed in v4.0.
- * @since Commons Collections 2.1
- * @version $Revision$ $Date$
- * 
- * @author Paul Jack
- */
-public class ReferenceMap extends AbstractMap {
-
-    /**
-     *  For serialization.
-     */
-    private static final long serialVersionUID = -3370601314380922368L;
-
-
-    /**
-     *  Constant indicating that hard references should be used.
-     */
-    final public static int HARD = 0;
-
-
-    /**
-     *  Constant indicating that soft references should be used.
-     */
-    final public static int SOFT = 1;
-
-
-    /**
-     *  Constant indicating that weak references should be used.
-     */
-    final public static int WEAK = 2;
-
-
-    // --- serialized instance variables:
-
-
-    /**
-     *  The reference type for keys.  Must be HARD, SOFT, WEAK.
-     *  Note: I originally marked this field as final, but then this class
-     *   didn't compile under JDK1.2.2.
-     *  @serial
-     */
-    private int keyType;
-
-
-    /**
-     *  The reference type for values.  Must be HARD, SOFT, WEAK.
-     *  Note: I originally marked this field as final, but then this class
-     *   didn't compile under JDK1.2.2.
-     *  @serial
-     */
-    private int valueType;
-
-
-    /**
-     *  The threshold variable is calculated by multiplying
-     *  table.length and loadFactor.  
-     *  Note: I originally marked this field as final, but then this class
-     *   didn't compile under JDK1.2.2.
-     *  @serial
-     */
-    private float loadFactor;
-    
-    /**
-     * Should the value be automatically purged when the associated key has been collected?
-     */
-    private boolean purgeValues = false;
-
-
-    // -- Non-serialized instance variables
-
-    /**
-     *  ReferenceQueue used to eliminate stale mappings.
-     *  See purge.
-     */
-    private transient ReferenceQueue queue = new ReferenceQueue();
-
-
-    /**
-     *  The hash table.  Its length is always a power of two.  
-     */
-    private transient Entry[] table;
-
-
-    /**
-     *  Number of mappings in this map.
-     */
-    private transient int size;
-
-
-    /**
-     *  When size reaches threshold, the map is resized.  
-     *  See resize().
-     */
-    private transient int threshold;
-
-
-    /**
-     *  Number of times this map has been modified.
-     */
-    private transient volatile int modCount;
-
-
-    /**
-     *  Cached key set.  May be null if key set is never accessed.
-     */
-    private transient Set keySet;
-
-
-    /**
-     *  Cached entry set.  May be null if entry set is never accessed.
-     */
-    private transient Set entrySet;
-
-
-    /**
-     *  Cached values.  May be null if values() is never accessed.
-     */
-    private transient Collection values;
-
-
-    /**
-     *  Constructs a new <code>ReferenceMap</code> that will
-     *  use hard references to keys and soft references to values.
-     */
-    public ReferenceMap() {
-        this(HARD, SOFT);
-    }
-
-    /**
-     *  Constructs a new <code>ReferenceMap</code> that will
-     *  use the specified types of references.
-     *
-     *  @param keyType  the type of reference to use for keys;
-     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
-     *  @param valueType  the type of reference to use for values;
-     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
-     *  @param purgeValues should the value be automatically purged when the 
-     *   key is garbage collected 
-     */
-    public ReferenceMap(int keyType, int valueType, boolean purgeValues) {
-        this(keyType, valueType);
-        this.purgeValues = purgeValues;
-    }
-
-    /**
-     *  Constructs a new <code>ReferenceMap</code> that will
-     *  use the specified types of references.
-     *
-     *  @param keyType  the type of reference to use for keys;
-     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
-     *  @param valueType  the type of reference to use for values;
-     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
-     */
-    public ReferenceMap(int keyType, int valueType) {
-        this(keyType, valueType, 16, 0.75f);
-    }
-
-    /**
-     *  Constructs a new <code>ReferenceMap</code> with the
-     *  specified reference types, load factor and initial
-     *  capacity.
-     *
-     *  @param keyType  the type of reference to use for keys;
-     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
-     *  @param valueType  the type of reference to use for values;
-     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
-     *  @param capacity  the initial capacity for the map
-     *  @param loadFactor  the load factor for the map
-     *  @param purgeValues should the value be automatically purged when the 
-     *   key is garbage collected 
-     */
-    public ReferenceMap(
-                        int keyType, 
-                        int valueType, 
-                        int capacity, 
-                        float loadFactor, 
-                        boolean purgeValues) {
-        this(keyType, valueType, capacity, loadFactor);
-        this.purgeValues = purgeValues;
-    }
-
-    /**
-     *  Constructs a new <code>ReferenceMap</code> with the
-     *  specified reference types, load factor and initial
-     *  capacity.
-     *
-     *  @param keyType  the type of reference to use for keys;
-     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
-     *  @param valueType  the type of reference to use for values;
-     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
-     *  @param capacity  the initial capacity for the map
-     *  @param loadFactor  the load factor for the map
-     */
-    public ReferenceMap(int keyType, int valueType, int capacity, float loadFactor) {
-        super();
-
-        verify("keyType", keyType);
-        verify("valueType", valueType);
-
-        if (capacity <= 0) {
-            throw new IllegalArgumentException("capacity must be positive");
-        }
-        if ((loadFactor <= 0.0f) || (loadFactor >= 1.0f)) {
-            throw new IllegalArgumentException("Load factor must be greater than 0 and less than 1.");
-        }
-
-        this.keyType = keyType;
-        this.valueType = valueType;
-
-        int v = 1;
-        while (v < capacity) v *= 2;
-
-        this.table = new Entry[v];
-        this.loadFactor = loadFactor;
-        this.threshold = (int)(v * loadFactor);
-    }
-
-
-    // used by constructor
-    private static void verify(String name, int type) {
-        if ((type < HARD) || (type > WEAK)) {
-            throw new IllegalArgumentException(name + 
-               " must be HARD, SOFT, WEAK.");
-        }
-    }
-
-
-    /**
-     *  Writes this object to the given output stream.
-     *
-     *  @param out  the output stream to write to
-     *  @throws IOException  if the stream raises it
-     */
-    private void writeObject(ObjectOutputStream out) throws IOException {
-        out.defaultWriteObject();
-        out.writeInt(table.length);
-
-        // Have to use null-terminated list because size might shrink
-        // during iteration
-
-        for (Iterator iter = entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Map.Entry)iter.next();
-            out.writeObject(entry.getKey());
-            out.writeObject(entry.getValue());
-        }
-        out.writeObject(null);
-    }
-
-
-    /**
-     *  Reads the contents of this object from the given input stream.
-     *
-     *  @param inp  the input stream to read from
-     *  @throws IOException  if the stream raises it
-     *  @throws ClassNotFoundException  if the stream raises it
-     */
-    private void readObject(ObjectInputStream inp) throws IOException, ClassNotFoundException {
-        inp.defaultReadObject();
-        table = new Entry[inp.readInt()];
-        threshold = (int)(table.length * loadFactor);
-        queue = new ReferenceQueue();
-        Object key = inp.readObject();
-        while (key != null) {
-            Object value = inp.readObject();
-            put(key, value);
-            key = inp.readObject();
-        }
-    }
-
-
-    /**
-     *  Constructs a reference of the given type to the given 
-     *  referent.  The reference is registered with the queue
-     *  for later purging.
-     *
-     *  @param type  HARD, SOFT or WEAK
-     *  @param referent  the object to refer to
-     *  @param hash  the hash code of the <I>key</I> of the mapping;
-     *    this number might be different from referent.hashCode() if
-     *    the referent represents a value and not a key
-     */
-    private Object toReference(int type, Object referent, int hash) {
-        switch (type) {
-            case HARD: return referent;
-            case SOFT: return new SoftRef(hash, referent, queue);
-            case WEAK: return new WeakRef(hash, referent, queue);
-            default: throw new Error();
-        }
-    }
-
-
-    /**
-     *  Returns the entry associated with the given key.
-     *
-     *  @param key  the key of the entry to look up
-     *  @return  the entry associated with that key, or null
-     *    if the key is not in this map
-     */
-    private Entry getEntry(Object key) {
-        if (key == null) return null;
-        int hash = key.hashCode();
-        int index = indexFor(hash);
-        for (Entry entry = table[index]; entry != null; entry = entry.next) {
-            if ((entry.hash == hash) && key.equals(entry.getKey())) {
-                return entry;
-            }
-        }
-        return null;
-    }
-
-
-    /**
-     *  Converts the given hash code into an index into the
-     *  hash table.
-     */
-    private int indexFor(int hash) {
-        // mix the bits to avoid bucket collisions...
-        hash += ~(hash << 15);
-        hash ^= (hash >>> 10);
-        hash += (hash << 3);
-        hash ^= (hash >>> 6);
-        hash += ~(hash << 11);
-        hash ^= (hash >>> 16);
-        return hash & (table.length - 1);
-    }
-
-
-
-    /**
-     *  Resizes this hash table by doubling its capacity.
-     *  This is an expensive operation, as entries must
-     *  be copied from the old smaller table to the new 
-     *  bigger table.
-     */
-    private void resize() {
-        Entry[] old = table;
-        table = new Entry[old.length * 2];
-
-        for (int i = 0; i < old.length; i++) {
-            Entry next = old[i];
-            while (next != null) {
-                Entry entry = next;
-                next = next.next;
-                int index = indexFor(entry.hash);
-                entry.next = table[index];
-                table[index] = entry;
-            }
-            old[i] = null;
-        }
-        threshold = (int)(table.length * loadFactor);
-    }
-
-
-
-    /**
-     * Purges stale mappings from this map.
-     * <p>
-     * Ordinarily, stale mappings are only removed during
-     * a write operation, although this method is called for both
-     * read and write operations to maintain a consistent state.
-     * <p>
-     * Note that this method is not synchronized!  Special
-     * care must be taken if, for instance, you want stale
-     * mappings to be removed on a periodic basis by some
-     * background thread.
-     */
-    private void purge() {
-        Reference ref = queue.poll();
-        while (ref != null) {
-            purge(ref);
-            ref = queue.poll();
-        }
-    }
-
-
-    private void purge(Reference ref) {
-        // The hashCode of the reference is the hashCode of the
-        // mapping key, even if the reference refers to the 
-        // mapping value...
-        int hash = ref.hashCode();
-        int index = indexFor(hash);
-        Entry previous = null;
-        Entry entry = table[index];
-        while (entry != null) {
-            if (entry.purge(ref)) {
-                if (previous == null) table[index] = entry.next;
-                else previous.next = entry.next;
-                this.size--;
-                return;
-            }
-            previous = entry;
-            entry = entry.next;
-        }
-
-    }
-
-
-    /**
-     *  Returns the size of this map.
-     *
-     *  @return  the size of this map
-     */
-    public int size() {
-        purge();
-        return size;
-    }
-
-
-    /**
-     *  Returns <code>true</code> if this map is empty.
-     *
-     *  @return <code>true</code> if this map is empty
-     */
-    public boolean isEmpty() {
-        purge();
-        return size == 0;
-    }
-
-
-    /**
-     *  Returns <code>true</code> if this map contains the given key.
-     *
-     *  @return true if the given key is in this map
-     */
-    public boolean containsKey(Object key) {
-        purge();
-        Entry entry = getEntry(key);
-        if (entry == null) return false;
-        return entry.getValue() != null;
-    }
-
-
-    /**
-     *  Returns the value associated with the given key, if any.
-     *
-     *  @return the value associated with the given key, or <code>null</code>
-     *   if the key maps to no value
-     */
-    public Object get(Object key) {
-        purge();
-        Entry entry = getEntry(key);
-        if (entry == null) return null;
-        return entry.getValue();
-    }
-
-
-    /**
-     *  Associates the given key with the given value.<p>
-     *  Neither the key nor the value may be null.
-     *
-     *  @param key  the key of the mapping
-     *  @param value  the value of the mapping
-     *  @return  the last value associated with that key, or 
-     *   null if no value was associated with the key
-     *  @throws NullPointerException if either the key or value
-     *   is null
-     */
-    public Object put(Object key, Object value) {
-        if (key == null) throw new NullPointerException("null keys not allowed");
-        if (value == null) throw new NullPointerException("null values not allowed");
-
-        purge();
-        if (size + 1 > threshold) resize();
-
-        int hash = key.hashCode();
-        int index = indexFor(hash);
-        Entry entry = table[index];
-        while (entry != null) {
-            if ((hash == entry.hash) && key.equals(entry.getKey())) {
-                Object result = entry.getValue();
-                entry.setValue(value);
-                return result;
-            }
-            entry = entry.next;
-        }
-        this.size++; 
-        modCount++;
-        key = toReference(keyType, key, hash);
-        value = toReference(valueType, value, hash);
-        table[index] = new Entry(key, hash, value, table[index]);
-        return null;
-    }
-
-
-    /**
-     *  Removes the key and its associated value from this map.
-     *
-     *  @param key  the key to remove
-     *  @return the value associated with that key, or null if
-     *   the key was not in the map
-     */
-    public Object remove(Object key) {
-        if (key == null) return null;
-        purge();
-        int hash = key.hashCode();
-        int index = indexFor(hash);
-        Entry previous = null;
-        Entry entry = table[index];
-        while (entry != null) {
-            if ((hash == entry.hash) && key.equals(entry.getKey())) {
-                if (previous == null) table[index] = entry.next;
-                else previous.next = entry.next;
-                this.size--;
-                modCount++;
-                return entry.getValue();
-            }
-            previous = entry;
-            entry = entry.next;
-        }
-        return null;
-    }
-
-
-    /**
-     *  Clears this map.
-     */
-    public void clear() {
-        Arrays.fill(table, null);
-        size = 0;
-        while (queue.poll() != null); // drain the queue
-    }
-
-
-    /**
-     *  Returns a set view of this map's entries.
-     *
-     *  @return a set view of this map's entries
-     */
-    public Set entrySet() {
-        if (entrySet != null) {
-            return entrySet;
-        } 
-        entrySet = new AbstractSet() {
-            public int size() {
-                return ReferenceMap.this.size();
-            }
-
-            public void clear() {
-                ReferenceMap.this.clear();
-            }
-
-            public boolean contains(Object o) {
-                if (o == null) return false;
-                if (!(o instanceof Map.Entry)) return false;
-                Map.Entry e = (Map.Entry)o;
-                Entry e2 = getEntry(e.getKey());
-                return (e2 != null) && e.equals(e2);
-            }
-
-            public boolean remove(Object o) {
-                boolean r = contains(o);
-                if (r) {
-                    Map.Entry e = (Map.Entry)o;
-                    ReferenceMap.this.remove(e.getKey());
-                }
-                return r;
-            }
-
-            public Iterator iterator() {
-                return new EntryIterator();
-            }
-
-            public Object[] toArray() {
-                return toArray(new Object[0]);
-            }
-
-            public Object[] toArray(Object[] arr) {
-                ArrayList list = new ArrayList();
-                Iterator iterator = iterator();
-                while (iterator.hasNext()) {
-                    Entry e = (Entry)iterator.next();
-                    list.add(new DefaultMapEntry(e.getKey(), e.getValue()));
-                }
-                return list.toArray(arr);
-            }
-        };
-        return entrySet;
-    }
-
-
-    /**
-     *  Returns a set view of this map's keys.
-     *
-     *  @return a set view of this map's keys
-     */
-    public Set keySet() {
-        if (keySet != null) return keySet;
-        keySet = new AbstractSet() {
-            public int size() {
-                return ReferenceMap.this.size();
-            }
-
-            public Iterator iterator() {
-                return new KeyIterator();
-            }
-
-            public boolean contains(Object o) {
-                return containsKey(o);
-            }
-
-
-            public boolean remove(Object o) {
-                Object r = ReferenceMap.this.remove(o);
-                return r != null;
-            }
-
-            public void clear() {
-                ReferenceMap.this.clear();
-            }
-
-            public Object[] toArray() {
-                return toArray(new Object[0]);
-            }
-
-            public Object[] toArray(Object[] array) {
-                Collection c = new ArrayList(size());
-                for (Iterator it = iterator(); it.hasNext(); ) {
-                    c.add(it.next());
-                }
-                return c.toArray(array);
-            }
-        };
-        return keySet;
-    }
-
-
-    /**
-     *  Returns a collection view of this map's values.
-     *
-     *  @return a collection view of this map's values.
-     */
-    public Collection values() {
-        if (values != null) return values;
-        values = new AbstractCollection()  {
-            public int size() {
-                return ReferenceMap.this.size();
-            }
-
-            public void clear() {
-                ReferenceMap.this.clear();
-            }
-
-            public Iterator iterator() {
-                return new ValueIterator();
-            }
-
-            public Object[] toArray() {
-                return toArray(new Object[0]);
-            }
-
-            public Object[] toArray(Object[] array) {
-                Collection c = new ArrayList(size());
-                for (Iterator it = iterator(); it.hasNext(); ) {
-                    c.add(it.next());
-                }
-                return c.toArray(array);
-            }
-        };
-        return values;
-    }
-
-
-    // If getKey() or getValue() returns null, it means
-    // the mapping is stale and should be removed.
-    private class Entry implements Map.Entry, KeyValue {
-
-        Object key;
-        Object value;
-        int hash;
-        Entry next;
-
-
-        public Entry(Object key, int hash, Object value, Entry next) {
-            this.key = key;
-            this.hash = hash;
-            this.value = value;
-            this.next = next;
-        }
-
-
-        public Object getKey() {
-            return (keyType > HARD) ? ((Reference)key).get() : key;
-        }
-
-
-        public Object getValue() {
-            return (valueType > HARD) ? ((Reference)value).get() : value;
-        }
-
-
-        public Object setValue(Object object) {
-            Object old = getValue();
-            if (valueType > HARD) ((Reference)value).clear();
-            value = toReference(valueType, object, hash);
-            return old;
-        }
-
-
-        public boolean equals(Object o) {
-            if (o == null) return false;
-            if (o == this) return true;
-            if (!(o instanceof Map.Entry)) return false;
-            
-            Map.Entry entry = (Map.Entry)o;
-            Object key = entry.getKey();
-            Object value = entry.getValue();
-            if ((key == null) || (value == null)) return false;
-            return key.equals(getKey()) && value.equals(getValue());
-        }
-
-
-        public int hashCode() {
-            Object v = getValue();
-            return hash ^ ((v == null) ? 0 : v.hashCode());
-        }
-
-
-        public String toString() {
-            return getKey() + "=" + getValue();
-        }
-
-
-        boolean purge(Reference ref) {
-            boolean r = (keyType > HARD) && (key == ref);
-            r = r || ((valueType > HARD) && (value == ref));
-            if (r) {
-                if (keyType > HARD) ((Reference)key).clear();
-                if (valueType > HARD) {
-                    ((Reference)value).clear();
-                } else if (purgeValues) {
-                    value = null;
-                }
-            }
-            return r;
-        }
-    }
-
-
-    private class EntryIterator implements Iterator {
-        // These fields keep track of where we are in the table.
-        int index;
-        Entry entry;
-        Entry previous;
-
-        // These Object fields provide hard references to the
-        // current and next entry; this assures that if hasNext()
-        // returns true, next() will actually return a valid element.
-        Object nextKey, nextValue;
-        Object currentKey, currentValue;
-
-        int expectedModCount;
-
-
-        public EntryIterator() {
-            index = (size() != 0 ? table.length : 0);
-            // have to do this here!  size() invocation above
-            // may have altered the modCount.
-            expectedModCount = modCount;
-        }
-
-
-        public boolean hasNext() {
-            checkMod();
-            while (nextNull()) {
-                Entry e = entry;
-                int i = index;
-                while ((e == null) && (i > 0)) {
-                    i--;
-                    e = table[i];
-                }
-                entry = e;
-                index = i;
-                if (e == null) {
-                    currentKey = null;
-                    currentValue = null;
-                    return false;
-                }
-                nextKey = e.getKey();
-                nextValue = e.getValue();
-                if (nextNull()) entry = entry.next;
-            }
-            return true;
-        }
-
-
-        private void checkMod() {
-            if (modCount != expectedModCount) {
-                throw new ConcurrentModificationException();
-            }
-        }
-
-
-        private boolean nextNull() {
-            return (nextKey == null) || (nextValue == null);
-        }
-
-        protected Entry nextEntry() {    
-            checkMod();
-            if (nextNull() && !hasNext()) throw new NoSuchElementException();
-            previous = entry;
-            entry = entry.next;
-            currentKey = nextKey;
-            currentValue = nextValue;
-            nextKey = null;
-            nextValue = null;
-            return previous;
-        }
-
-
-        public Object next() {
-            return nextEntry();
-        }
-
-
-        public void remove() {
-            checkMod();
-            if (previous == null) throw new IllegalStateException();
-            ReferenceMap.this.remove(currentKey);
-            previous = null;
-            currentKey = null;
-            currentValue = null;
-            expectedModCount = modCount;
-        }
-
-    }
-
-
-    private class ValueIterator extends EntryIterator {
-        public Object next() {
-            return nextEntry().getValue();
-        }
-    }
-
-
-    private class KeyIterator extends EntryIterator {
-        public Object next() {
-            return nextEntry().getKey();
-        }
-    }
-
-
-
-    // These two classes store the hashCode of the key of
-    // of the mapping, so that after they're dequeued a quick
-    // lookup of the bucket in the table can occur.
-
-
-    private static class SoftRef extends SoftReference {
-        private int hash;
-
-
-        public SoftRef(int hash, Object r, ReferenceQueue q) {
-            super(r, q);
-            this.hash = hash;
-        }
-
-
-        public int hashCode() {
-            return hash;
-        }
-    }
-
-
-    private static class WeakRef extends WeakReference {
-        private int hash;
-
-
-        public WeakRef(int hash, Object r, ReferenceQueue q) {
-            super(r, q);
-            this.hash = hash;
-        }
-
-
-        public int hashCode() {
-            return hash;
-        }
-    }
-
-
-}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/collections/keyvalue/AbstractKeyValue.java b/qpid/java/client/src/main/java/org/apache/qpid/collections/keyvalue/AbstractKeyValue.java
deleted file mode 100644
index a7ca67a..0000000
--- a/qpid/java/client/src/main/java/org/apache/qpid/collections/keyvalue/AbstractKeyValue.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- *  Copyright 2003-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.qpid.collections.keyvalue;
-
-import org.apache.qpid.collections.KeyValue;
-
-
-/**
- * Abstract pair class to assist with creating <code>KeyValue</code>
- * and {@link java.util.Map.Entry Map.Entry} implementations.
- *
- * @since Commons Collections 3.0
- * @version $Revision$ $Date$
- * 
- * @author James Strachan
- * @author Michael A. Smith
- * @author Neil O'Toole
- * @author Stephen Colebourne
- */
-public abstract class AbstractKeyValue implements KeyValue {
-
-    /** The key */
-    protected Object key;
-    /** The value */
-    protected Object value;
-
-    /**
-     * Constructs a new pair with the specified key and given value.
-     *
-     * @param key  the key for the entry, may be null
-     * @param value  the value for the entry, may be null
-     */
-    protected AbstractKeyValue(Object key, Object value) {
-        super();
-        this.key = key;
-        this.value = value;
-    }
-
-    /**
-     * Gets the key from the pair.
-     *
-     * @return the key 
-     */
-    public Object getKey() {
-        return key;
-    }
-
-    /**
-     * Gets the value from the pair.
-     *
-     * @return the value
-     */
-    public Object getValue() {
-        return value;
-    }
-
-    /**
-     * Gets a debugging String view of the pair.
-     * 
-     * @return a String view of the entry
-     */
-    public String toString() {
-        return new StringBuffer()
-            .append(getKey())
-            .append('=')
-            .append(getValue())
-            .toString();
-    }
-
-}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/collections/keyvalue/AbstractMapEntry.java b/qpid/java/client/src/main/java/org/apache/qpid/collections/keyvalue/AbstractMapEntry.java
deleted file mode 100644
index f4717a1..0000000
--- a/qpid/java/client/src/main/java/org/apache/qpid/collections/keyvalue/AbstractMapEntry.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- *  Copyright 2003-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.qpid.collections.keyvalue;
-
-import java.util.Map;
-
-import org.apache.qpid.collections.keyvalue.AbstractKeyValue;
-
-/**
- * Abstract Pair class to assist with creating correct
- * {@link java.util.Map.Entry Map.Entry} implementations.
- *
- * @since Commons Collections 3.0
- * @version $Revision$ $Date$
- * 
- * @author James Strachan
- * @author Michael A. Smith
- * @author Neil O'Toole
- * @author Stephen Colebourne
- */
-public abstract class AbstractMapEntry extends AbstractKeyValue implements Map.Entry {
-
-    /**
-     * Constructs a new entry with the given key and given value.
-     *
-     * @param key  the key for the entry, may be null
-     * @param value  the value for the entry, may be null
-     */
-    protected AbstractMapEntry(Object key, Object value) {
-        super(key, value);
-    }
-
-    // Map.Entry interface
-    //-------------------------------------------------------------------------
-    /** 
-     * Sets the value stored in this <code>Map.Entry</code>.
-     * <p>
-     * This <code>Map.Entry</code> is not connected to a Map, so only the
-     * local data is changed.
-     *
-     * @param value  the new value
-     * @return the previous value
-     */
-    public Object setValue(Object value) {
-        Object answer = this.value;
-        this.value = value;
-        return answer;
-    }
-
-    /**
-     * Compares this <code>Map.Entry</code> with another <code>Map.Entry</code>.
-     * <p>
-     * Implemented per API documentation of {@link java.util.Map.Entry#equals(Object)}
-     * 
-     * @param obj  the object to compare to
-     * @return true if equal key and value
-     */
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (obj instanceof Map.Entry == false) {
-            return false;
-        }
-        Map.Entry other = (Map.Entry) obj;
-        return
-            (getKey() == null ? other.getKey() == null : getKey().equals(other.getKey())) &&
-            (getValue() == null ? other.getValue() == null : getValue().equals(other.getValue()));
-    }
-
-    /**
-     * Gets a hashCode compatible with the equals method.
-     * <p>
-     * Implemented per API documentation of {@link java.util.Map.Entry#hashCode()}
-     * 
-     * @return a suitable hash code
-     */
-    public int hashCode() {
-        return (getKey() == null ? 0 : getKey().hashCode()) ^
-               (getValue() == null ? 0 : getValue().hashCode()); 
-    }
-
-}
\ No newline at end of file
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/collections/keyvalue/DefaultMapEntry.java b/qpid/java/client/src/main/java/org/apache/qpid/collections/keyvalue/DefaultMapEntry.java
deleted file mode 100644
index f0f04a3..0000000
--- a/qpid/java/client/src/main/java/org/apache/qpid/collections/keyvalue/DefaultMapEntry.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *  Copyright 2001-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.qpid.collections.keyvalue;
-
-import java.util.Map;
-
-import org.apache.qpid.collections.KeyValue;
-import org.apache.qpid.collections.keyvalue.AbstractMapEntry;
-
-/**
- * A restricted implementation of {@link java.util.Map.Entry} that prevents
- * the <code>Map.Entry</code> contract from being broken.
- *
- * @since Commons Collections 3.0
- * @version $Revision$ $Date$
- * 
- * @author James Strachan
- * @author Michael A. Smith
- * @author Neil O'Toole
- * @author Stephen Colebourne
- */
-public final class DefaultMapEntry extends AbstractMapEntry {
-
-    /**
-     * Constructs a new entry with the specified key and given value.
-     *
-     * @param key  the key for the entry, may be null
-     * @param value  the value for the entry, may be null
-     */
-    public DefaultMapEntry(final Object key, final Object value) {
-        super(key, value);
-    }
-
-    /**
-     * Constructs a new entry from the specified <code>KeyValue</code>.
-     *
-     * @param pair  the pair to copy, must not be null
-     * @throws NullPointerException if the entry is null
-     */
-    public DefaultMapEntry(final KeyValue pair) {
-        super(pair.getKey(), pair.getValue());
-    }
-
-    /**
-     * Constructs a new entry from the specified <code>Map.Entry</code>.
-     *
-     * @param entry  the entry to copy, must not be null
-     * @throws NullPointerException if the entry is null
-     */
-    public DefaultMapEntry(final Map.Entry entry) {
-        super(entry.getKey(), entry.getValue());
-    }
-
-}
\ No newline at end of file
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java
index 0c2f4ce..71d7ffd 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java
@@ -20,10 +20,10 @@
  */
 package org.apache.qpid.jms;
 
-import java.util.Map;
-
 import org.apache.qpid.transport.ConnectionSettings;
 
+import java.util.Map;
+
 public interface BrokerDetails
 {
 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
index 24d9360..8fd6ff6 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
@@ -21,7 +21,6 @@
 package org.apache.qpid.jms;
 
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.ProtocolVersion;
 
 import java.util.List;
 
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
index 56abf03..f4d2ecc 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
@@ -20,15 +20,15 @@
  */
 package org.apache.qpid.jms;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.jms.failover.FailoverExchangeMethod;
 import org.apache.qpid.jms.failover.FailoverMethod;
 import org.apache.qpid.jms.failover.FailoverRoundRobinServers;
 import org.apache.qpid.jms.failover.FailoverSingleServer;
 import org.apache.qpid.jms.failover.NoFailover;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class FailoverPolicy
 {
     private static final Logger _logger = LoggerFactory.getLogger(FailoverPolicy.class);
@@ -74,12 +74,6 @@
         {
             String failoverMethod = connectionDetails.getFailoverMethod();
 
-            /*
-                        if (failoverMethod.equals(FailoverMethod.RANDOM))
-                        {
-                            //todo write a random connection Failover
-                        }
-             */
             if (failoverMethod.equals(FailoverMethod.SINGLE_BROKER))
             {
                 method = new FailoverSingleServer(connectionDetails);
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/MessageProducer.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/MessageProducer.java
index 4ad917f..bec8b09 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/MessageProducer.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/MessageProducer.java
@@ -20,11 +20,10 @@
  */
 package org.apache.qpid.jms;
 
-import java.io.UnsupportedEncodingException;
-
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
+import java.io.UnsupportedEncodingException;
 
 /**
  */
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/Session.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/Session.java
index 5287381..b4bf2d1 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/Session.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/Session.java
@@ -26,9 +26,11 @@
 import javax.jms.JMSException;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
+import javax.jms.QueueSession;
+import javax.jms.TopicSession;
 
 
-public interface Session extends javax.jms.Session
+public interface Session extends TopicSession, QueueSession
 {
     /**
      * Indicates that no client acknowledgements are required. Broker assumes that once it has delivered
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverExchangeMethod.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverExchangeMethod.java
index cb3ab71..a5eda29 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverExchangeMethod.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverExchangeMethod.java
@@ -20,15 +20,8 @@
  */
 package org.apache.qpid.jms.failover;
 
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.Session;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQAnyDestination;
 import org.apache.qpid.client.AMQBrokerDetails;
@@ -36,8 +29,15 @@
 import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.jms.Connection;
 import org.apache.qpid.jms.ConnectionURL;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Session;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * When using the Failover exchange a single broker is supplied in the URL.
@@ -127,9 +127,7 @@
             for (String brokerEntry:list)
             {                
                 String[] urls = brokerEntry.substring(5) .split(",");
-                // Iterate until you find the correct transport
-                // Need to reconsider the logic when the C++ broker supports
-                // SSL URLs.
+
                 for (String url:urls)
                 {
                     String[] tokens = url.split(":");
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java
index 41ba497..84c1794 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java
@@ -20,11 +20,12 @@
  */
 package org.apache.qpid.jms.failover;
 
-import org.apache.qpid.jms.BrokerDetails;
-import org.apache.qpid.jms.ConnectionURL;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.jms.ConnectionURL;
+
 public class FailoverRoundRobinServers implements FailoverMethod
 {
     private static final Logger _logger = LoggerFactory.getLogger(FailoverRoundRobinServers.class);
@@ -49,8 +50,7 @@
     /** The current number of cycles performed. */
     private int _currentCycleRetries = 0;
 
-    /** Array of BrokerDetail used to make connections. */
-    protected ConnectionURL _connectionDetails;
+    private ConnectionURL _connectionDetails;
 
     public FailoverRoundRobinServers(ConnectionURL connectionDetails)
     {
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
index d033a49..1ef71ec 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
@@ -20,11 +20,12 @@
  */
 package org.apache.qpid.jms.failover;
 
-import org.apache.qpid.jms.BrokerDetails;
-import org.apache.qpid.jms.ConnectionURL;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.jms.ConnectionURL;
+
 public class FailoverSingleServer implements FailoverMethod
 {
     private static final Logger _logger = LoggerFactory.getLogger(FailoverSingleServer.class);
@@ -36,10 +37,10 @@
     private BrokerDetails _brokerDetail;
 
     /** The number of times to retry connecting to the sever */
-    protected int _retries;
+    private int _retries;
 
     /** The current number of attempts made to the server */
-    protected int _currentRetries = 0;
+    private int _currentRetries = 0;
 
 
     public FailoverSingleServer(ConnectionURL connectionDetails)
@@ -64,6 +65,11 @@
         _currentRetries = 0;
     }
 
+    protected void setCurrentRetries(int currentRetries)
+    {
+        _currentRetries = currentRetries;
+    }
+
     public boolean failoverAllowed()
     {
         return _currentRetries < _retries;
@@ -150,6 +156,11 @@
         _retries = retries;
     }
 
+    public int getRetries()
+    {
+        return _retries;
+    }
+
     public String methodName()
     {
         return "Single Server";
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java
index 1231324..82cb0f9 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java
@@ -44,7 +44,7 @@
     public void attainedConnection()
     {
         _connected=true;
-        _currentRetries = _retries;
+        setCurrentRetries(getRetries());
     }
 
     @Override
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java
index b480f56..bc3f898 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java
@@ -20,24 +20,8 @@
  */
 package org.apache.qpid.jndi;
 
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.Queue;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.ConfigurationException;
-import javax.naming.spi.InitialContextFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQConnectionFactory;
 import org.apache.qpid.client.AMQDestination;
@@ -46,16 +30,30 @@
 import org.apache.qpid.client.AMQTopic;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.url.AMQBindingURL;
 import org.apache.qpid.url.BindingURL;
 import org.apache.qpid.url.URLSyntaxException;
 import org.apache.qpid.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.naming.ConfigurationException;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
 
 public class PropertiesFileInitialContextFactory implements InitialContextFactory
 {
-    protected final Logger _logger = LoggerFactory.getLogger(PropertiesFileInitialContextFactory.class);
+    private final Logger _logger = LoggerFactory.getLogger(PropertiesFileInitialContextFactory.class);
 
     private String CONNECTION_FACTORY_PREFIX = "connectionfactory.";
     private String DESTINATION_PREFIX = "destination.";
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jndi/ReadOnlyContext.java b/qpid/java/client/src/main/java/org/apache/qpid/jndi/ReadOnlyContext.java
index 1719ea1..76ec5f9 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/jndi/ReadOnlyContext.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/jndi/ReadOnlyContext.java
@@ -20,13 +20,6 @@
  */
 package org.apache.qpid.jndi;
 
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-
 import javax.naming.Binding;
 import javax.naming.CompositeName;
 import javax.naming.Context;
@@ -41,6 +34,12 @@
 import javax.naming.OperationNotSupportedException;
 import javax.naming.Reference;
 import javax.naming.spi.NamingManager;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
 
 /**
  * Based on class from ActiveMQ.
@@ -66,9 +65,9 @@
     private static final long serialVersionUID = -5754338187296859149L;
     protected static final NameParser nameParser = new NameParserImpl();
 
-    protected final Hashtable environment; // environment for this context
-    protected final Map bindings; // bindings at my level
-    protected final Map treeBindings; // all bindings under me
+    private final Hashtable environment; // environment for this context
+    private final Map bindings; // bindings at my level
+    private final Map treeBindings; // all bindings under me
 
     private boolean frozen = false;
     private String nameInNamespace = "";
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/naming/ReadOnlyContext.java b/qpid/java/client/src/main/java/org/apache/qpid/naming/ReadOnlyContext.java
deleted file mode 100644
index 59ec4cf..0000000
--- a/qpid/java/client/src/main/java/org/apache/qpid/naming/ReadOnlyContext.java
+++ /dev/null
@@ -1,509 +0,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.
- */
-package org.apache.qpid.naming;
-
-import org.apache.qpid.jndi.NameParserImpl;
-
-import javax.naming.*;
-import javax.naming.spi.NamingManager;
-import java.io.Serializable;
-import java.util.*;
-
-/**
- * Based on class from ActiveMQ.
- * A read-only Context
- * <p/>
- * This version assumes it and all its subcontext are read-only and any attempt
- * to modify (e.g. through bind) will result in an OperationNotSupportedException.
- * Each Context in the tree builds a cache of the entries in all sub-contexts
- * to optimise the performance of lookup.
- * </p>
- * <p>This implementation is intended to optimise the performance of lookup(String)
- * to about the level of a HashMap get. It has been observed that the scheme
- * resolution phase performed by the JVM takes considerably longer, so for
- * optimum performance lookups should be coded like:</p>
- * <code>
- * Context componentContext = (Context)new InitialContext().lookup("java:comp");
- * String envEntry = (String) componentContext.lookup("env/myEntry");
- * String envEntry2 = (String) componentContext.lookup("env/myEntry2");
- * </code>
- */
-public class ReadOnlyContext implements Context, Serializable
-{
-    private static final long serialVersionUID = -5754338187296859149L;
-    protected static final NameParser nameParser = new NameParserImpl();
-
-    protected final Hashtable environment; // environment for this context
-    protected final Map bindings; // bindings at my level
-    protected final Map treeBindings; // all bindings under me
-
-    private boolean frozen = false;
-    private String nameInNamespace = "";
-    public static final String SEPARATOR = "/";
-
-    public ReadOnlyContext()
-    {
-        environment = new Hashtable();
-        bindings = new HashMap();
-        treeBindings = new HashMap();
-    }
-
-    public ReadOnlyContext(Hashtable env)
-    {
-        if (env == null)
-        {
-            this.environment = new Hashtable();
-        }
-        else
-        {
-            this.environment = new Hashtable(env);
-        }
-
-        this.bindings = Collections.EMPTY_MAP;
-        this.treeBindings = Collections.EMPTY_MAP;
-    }
-
-    public ReadOnlyContext(Hashtable environment, Map bindings)
-    {
-        if (environment == null)
-        {
-            this.environment = new Hashtable();
-        }
-        else
-        {
-            this.environment = new Hashtable(environment);
-        }
-
-        this.bindings = bindings;
-        treeBindings = new HashMap();
-        frozen = true;
-    }
-
-    public ReadOnlyContext(Hashtable environment, Map bindings, String nameInNamespace)
-    {
-        this(environment, bindings);
-        this.nameInNamespace = nameInNamespace;
-    }
-
-    protected ReadOnlyContext(ReadOnlyContext clone, Hashtable env)
-    {
-        this.bindings = clone.bindings;
-        this.treeBindings = clone.treeBindings;
-        this.environment = new Hashtable(env);
-    }
-
-    protected ReadOnlyContext(ReadOnlyContext clone, Hashtable env, String nameInNamespace)
-    {
-        this(clone, env);
-        this.nameInNamespace = nameInNamespace;
-    }
-
-    public void freeze()
-    {
-        frozen = true;
-    }
-
-    boolean isFrozen()
-    {
-        return frozen;
-    }
-
-    /**
-     * internalBind is intended for use only during setup or possibly by suitably synchronized superclasses.
-     * It binds every possible lookup into a map in each context.  To do this, each context
-     * strips off one name segment and if necessary creates a new context for it. Then it asks that context
-     * to bind the remaining name.  It returns a map containing all the bindings from the next context, plus
-     * the context it just created (if it in fact created it). (the names are suitably extended by the segment
-     * originally lopped off).
-     *
-     * @param name
-     * @param value
-     * @return
-     * @throws javax.naming.NamingException
-     */
-    protected Map internalBind(String name, Object value) throws NamingException
-    {
-        assert (name != null) && (name.length() > 0);
-        assert !frozen;
-
-        Map newBindings = new HashMap();
-        int pos = name.indexOf('/');
-        if (pos == -1)
-        {
-            if (treeBindings.put(name, value) != null)
-            {
-                throw new NamingException("Something already bound at " + name);
-            }
-
-            bindings.put(name, value);
-            newBindings.put(name, value);
-        }
-        else
-        {
-            String segment = name.substring(0, pos);
-            assert segment != null;
-            assert !segment.equals("");
-            Object o = treeBindings.get(segment);
-            if (o == null)
-            {
-                o = newContext();
-                treeBindings.put(segment, o);
-                bindings.put(segment, o);
-                newBindings.put(segment, o);
-            }
-            else if (!(o instanceof ReadOnlyContext))
-            {
-                throw new NamingException("Something already bound where a subcontext should go");
-            }
-
-            ReadOnlyContext readOnlyContext = (ReadOnlyContext) o;
-            String remainder = name.substring(pos + 1);
-            Map subBindings = readOnlyContext.internalBind(remainder, value);
-            for (Iterator iterator = subBindings.entrySet().iterator(); iterator.hasNext();)
-            {
-                Map.Entry entry = (Map.Entry) iterator.next();
-                String subName = segment + "/" + (String) entry.getKey();
-                Object bound = entry.getValue();
-                treeBindings.put(subName, bound);
-                newBindings.put(subName, bound);
-            }
-        }
-
-        return newBindings;
-    }
-
-    protected ReadOnlyContext newContext()
-    {
-        return new ReadOnlyContext();
-    }
-
-    public Object addToEnvironment(String propName, Object propVal) throws NamingException
-    {
-        return environment.put(propName, propVal);
-    }
-
-    public Hashtable getEnvironment() throws NamingException
-    {
-        return (Hashtable) environment.clone();
-    }
-
-    public Object removeFromEnvironment(String propName) throws NamingException
-    {
-        return environment.remove(propName);
-    }
-
-    public Object lookup(String name) throws NamingException
-    {
-        if (name.length() == 0)
-        {
-            return this;
-        }
-
-        Object result = treeBindings.get(name);
-        if (result == null)
-        {
-            result = bindings.get(name);
-        }
-
-        if (result == null)
-        {
-            int pos = name.indexOf(':');
-            if (pos > 0)
-            {
-                String scheme = name.substring(0, pos);
-                Context ctx = NamingManager.getURLContext(scheme, environment);
-                if (ctx == null)
-                {
-                    throw new NamingException("scheme " + scheme + " not recognized");
-                }
-
-                return ctx.lookup(name);
-            }
-            else
-            {
-                // Split out the first name of the path
-                // and look for it in the bindings map.
-                CompositeName path = new CompositeName(name);
-
-                if (path.size() == 0)
-                {
-                    return this;
-                }
-                else
-                {
-                    String first = path.get(0);
-                    Object obj = bindings.get(first);
-                    if (obj == null)
-                    {
-                        throw new NameNotFoundException(name);
-                    }
-                    else if ((obj instanceof Context) && (path.size() > 1))
-                    {
-                        Context subContext = (Context) obj;
-                        obj = subContext.lookup(path.getSuffix(1));
-                    }
-
-                    return obj;
-                }
-            }
-        }
-
-        if (result instanceof LinkRef)
-        {
-            LinkRef ref = (LinkRef) result;
-            result = lookup(ref.getLinkName());
-        }
-
-        if (result instanceof Reference)
-        {
-            try
-            {
-                result = NamingManager.getObjectInstance(result, null, null, this.environment);
-            }
-            catch (NamingException e)
-            {
-                throw e;
-            }
-            catch (Exception e)
-            {
-                throw (NamingException) new NamingException("could not look up : " + name).initCause(e);
-            }
-        }
-
-        if (result instanceof ReadOnlyContext)
-        {
-            String prefix = getNameInNamespace();
-            if (prefix.length() > 0)
-            {
-                prefix = prefix + SEPARATOR;
-            }
-
-            result = new ReadOnlyContext((ReadOnlyContext) result, environment, prefix + name);
-        }
-
-        return result;
-    }
-
-    public Object lookup(Name name) throws NamingException
-    {
-        return lookup(name.toString());
-    }
-
-    public Object lookupLink(String name) throws NamingException
-    {
-        return lookup(name);
-    }
-
-    public Name composeName(Name name, Name prefix) throws NamingException
-    {
-        Name result = (Name) prefix.clone();
-        result.addAll(name);
-
-        return result;
-    }
-
-    public String composeName(String name, String prefix) throws NamingException
-    {
-        CompositeName result = new CompositeName(prefix);
-        result.addAll(new CompositeName(name));
-
-        return result.toString();
-    }
-
-    public NamingEnumeration list(String name) throws NamingException
-    {
-        Object o = lookup(name);
-        if (o == this)
-        {
-            return new ReadOnlyContext.ListEnumeration();
-        }
-        else if (o instanceof Context)
-        {
-            return ((Context) o).list("");
-        }
-        else
-        {
-            throw new NotContextException();
-        }
-    }
-
-    public NamingEnumeration listBindings(String name) throws NamingException
-    {
-        Object o = lookup(name);
-        if (o == this)
-        {
-            return new ReadOnlyContext.ListBindingEnumeration();
-        }
-        else if (o instanceof Context)
-        {
-            return ((Context) o).listBindings("");
-        }
-        else
-        {
-            throw new NotContextException();
-        }
-    }
-
-    public Object lookupLink(Name name) throws NamingException
-    {
-        return lookupLink(name.toString());
-    }
-
-    public NamingEnumeration list(Name name) throws NamingException
-    {
-        return list(name.toString());
-    }
-
-    public NamingEnumeration listBindings(Name name) throws NamingException
-    {
-        return listBindings(name.toString());
-    }
-
-    public void bind(Name name, Object obj) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    public void bind(String name, Object obj) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    public void close() throws NamingException
-    {
-        // ignore
-    }
-
-    public Context createSubcontext(Name name) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    public Context createSubcontext(String name) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    public void destroySubcontext(Name name) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    public void destroySubcontext(String name) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    public String getNameInNamespace() throws NamingException
-    {
-        return nameInNamespace;
-    }
-
-    public NameParser getNameParser(Name name) throws NamingException
-    {
-        return nameParser;
-    }
-
-    public NameParser getNameParser(String name) throws NamingException
-    {
-        return nameParser;
-    }
-
-    public void rebind(Name name, Object obj) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    public void rebind(String name, Object obj) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    public void rename(Name oldName, Name newName) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    public void rename(String oldName, String newName) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    public void unbind(Name name) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    public void unbind(String name) throws NamingException
-    {
-        throw new OperationNotSupportedException();
-    }
-
-    private abstract class LocalNamingEnumeration implements NamingEnumeration
-    {
-        private Iterator i = bindings.entrySet().iterator();
-
-        public boolean hasMore() throws NamingException
-        {
-            return i.hasNext();
-        }
-
-        public boolean hasMoreElements()
-        {
-            return i.hasNext();
-        }
-
-        protected Map.Entry getNext()
-        {
-            return (Map.Entry) i.next();
-        }
-
-        public void close() throws NamingException
-        { }
-    }
-
-    private class ListEnumeration extends ReadOnlyContext.LocalNamingEnumeration
-    {
-        public Object next() throws NamingException
-        {
-            return nextElement();
-        }
-
-        public Object nextElement()
-        {
-            Map.Entry entry = getNext();
-
-            return new NameClassPair((String) entry.getKey(), entry.getValue().getClass().getName());
-        }
-    }
-
-    private class ListBindingEnumeration extends ReadOnlyContext.LocalNamingEnumeration
-    {
-        public Object next() throws NamingException
-        {
-            return nextElement();
-        }
-
-        public Object nextElement()
-        {
-            Map.Entry entry = getNext();
-
-            return new Binding((String) entry.getKey(), entry.getValue());
-        }
-    }
-}
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/naming/jndi.properties b/qpid/java/client/src/main/java/org/apache/qpid/naming/jndi.properties
deleted file mode 100644
index 830de5f..0000000
--- a/qpid/java/client/src/main/java/org/apache/qpid/naming/jndi.properties
+++ /dev/null
@@ -1,40 +0,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.
-#
-java.naming.factory.initial = org.apache.qpid.naming.PropertiesFileInitialConextFactory
-
-# use the following property to configure the default connector
-#java.naming.provider.url - ignored.
-
-# register some connection factories
-# connectionfactory.[jndiname] = [ConnectionURL]
-# qpid:username=foo;password=password;client_id=id;virtualhost=path@tpc:localhost:1556
-connectionfactory.local = qpid:tcp:localhost'
-
-# 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
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/nclient/MessagePartListener.java b/qpid/java/client/src/main/java/org/apache/qpid/nclient/MessagePartListener.java
index 6f07dcb..b90f430 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/nclient/MessagePartListener.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/nclient/MessagePartListener.java
@@ -17,9 +17,6 @@
  */
 package org.apache.qpid.nclient;
 
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.transport.Header;
 import org.apache.qpid.transport.MessageTransfer;
 
 /**
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/nclient/util/ByteBufferMessage.java b/qpid/java/client/src/main/java/org/apache/qpid/nclient/util/ByteBufferMessage.java
index 14bfb4f..7134f0a 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/nclient/util/ByteBufferMessage.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/nclient/util/ByteBufferMessage.java
@@ -21,14 +21,17 @@
  */
 
 
+import org.apache.qpid.api.Message;
+import org.apache.qpid.transport.DeliveryProperties;
+import org.apache.qpid.transport.Header;
+import org.apache.qpid.transport.MessageProperties;
+
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.util.*;
-
-import org.apache.qpid.transport.DeliveryProperties;
-import org.apache.qpid.transport.MessageProperties;
-import org.apache.qpid.transport.Header;
-import org.apache.qpid.api.Message;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
 
 /**
  * <p>A Simple implementation of the message interface
@@ -42,7 +45,7 @@
  */
 public class ByteBufferMessage implements Message
 {
-    private List<ByteBuffer> _data;// = new ArrayList<ByteBuffer>();
+    private List<ByteBuffer> _data;
     private ByteBuffer _readBuffer;
     private int _dataSize;
     private DeliveryProperties _currentDeliveryProps;
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/nclient/util/MessagePartListenerAdapter.java b/qpid/java/client/src/main/java/org/apache/qpid/nclient/util/MessagePartListenerAdapter.java
index 2f1eda6..9a2e9de 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/nclient/util/MessagePartListenerAdapter.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/nclient/util/MessagePartListenerAdapter.java
@@ -21,12 +21,13 @@
  */
 
 
+import org.apache.qpid.nclient.MessagePartListener;
+import org.apache.qpid.transport.Header;
+import org.apache.qpid.transport.MessageTransfer;
+
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
-import org.apache.qpid.transport.*;
-import org.apache.qpid.nclient.MessagePartListener;
-
 /**
  * This is a simple message assembler.
  * Will call onMessage method of the adaptee
@@ -37,8 +38,8 @@
  */
 public class MessagePartListenerAdapter implements MessagePartListener
 {
-	MessageListener _adaptee;
-    ByteBufferMessage _currentMsg;
+	private MessageListener _adaptee;
+    private ByteBufferMessage _currentMsg;
 
 	public MessagePartListenerAdapter(MessageListener listener)
 	{
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java
index 3a565f0..d186a44 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java
@@ -20,15 +20,14 @@
  */
 package org.apache.qpid.client;
 
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-
 import junit.framework.TestCase;
 
 import org.apache.qpid.AMQInvalidArgumentException;
 
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import java.util.concurrent.atomic.AtomicReference;
+
 public class AMQConnectionUnitTest extends TestCase
 {
 
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/AMQQueueTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/AMQQueueTest.java
index 7789f87..bc48ee8 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/client/AMQQueueTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/AMQQueueTest.java
@@ -20,17 +20,17 @@
  */
 package org.apache.qpid.client;
 
-import org.apache.qpid.framing.AMQShortString;
-
 import junit.framework.TestCase;
 
+import org.apache.qpid.framing.AMQShortString;
+
 public class AMQQueueTest extends TestCase
 {
-    AMQShortString exchange = new AMQShortString("test.exchange");
-    AMQShortString routingkey = new AMQShortString("test-route");
-    AMQShortString qname = new AMQShortString("test-queue");
-    AMQShortString[] oneBinding = new AMQShortString[]{new AMQShortString("bindingA")};
-    AMQShortString[] bindings = new AMQShortString[]{new AMQShortString("bindingB"), 
+    private AMQShortString exchange = new AMQShortString("test.exchange");
+    private AMQShortString routingkey = new AMQShortString("test-route");
+    private AMQShortString qname = new AMQShortString("test-queue");
+    private AMQShortString[] oneBinding = new AMQShortString[]{new AMQShortString("bindingA")};
+    private AMQShortString[] bindings = new AMQShortString[]{new AMQShortString("bindingB"),
                                                      new AMQShortString("bindingC")};
 
     public void testToURLNoBindings()
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java b/qpid/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java
index 1889577..028e2d5 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java
@@ -18,53 +18,18 @@
  */
 package org.apache.qpid.client;
 
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.transport.*;
+import org.apache.qpid.transport.Connection.SessionFactory;
+import org.apache.qpid.transport.Connection.State;
 
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
 import javax.jms.MessageProducer;
-
-import junit.framework.TestCase;
-
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.transport.Binary;
-import org.apache.qpid.transport.Connection;
-import org.apache.qpid.transport.Connection.SessionFactory;
-import org.apache.qpid.transport.Connection.State;
-import org.apache.qpid.transport.ExchangeBound;
-import org.apache.qpid.transport.ExchangeBoundResult;
-import org.apache.qpid.transport.ExchangeDeclare;
-import org.apache.qpid.transport.ExchangeDelete;
-import org.apache.qpid.transport.ExchangeQuery;
-import org.apache.qpid.transport.ExchangeQueryResult;
-import org.apache.qpid.transport.ExecutionErrorCode;
-import org.apache.qpid.transport.ExecutionException;
-import org.apache.qpid.transport.ExecutionResult;
-import org.apache.qpid.transport.ExecutionSync;
-import org.apache.qpid.transport.Future;
-import org.apache.qpid.transport.MessageCancel;
-import org.apache.qpid.transport.MessageFlow;
-import org.apache.qpid.transport.MessageRelease;
-import org.apache.qpid.transport.MessageSubscribe;
-import org.apache.qpid.transport.MessageTransfer;
-import org.apache.qpid.transport.Method;
-import org.apache.qpid.transport.Option;
-import org.apache.qpid.transport.ProtocolEvent;
-import org.apache.qpid.transport.QueueDelete;
-import org.apache.qpid.transport.QueueQuery;
-import org.apache.qpid.transport.QueueQueryResult;
-import org.apache.qpid.transport.Sender;
-import org.apache.qpid.transport.Session;
-import org.apache.qpid.transport.SessionAttach;
-import org.apache.qpid.transport.SessionDelegate;
-import org.apache.qpid.transport.SessionDetach;
-import org.apache.qpid.transport.SessionException;
-import org.apache.qpid.transport.SessionRequestTimeout;
-import org.apache.qpid.transport.TxCommit;
-import org.apache.qpid.transport.TxRollback;
-import org.apache.qpid.transport.TxSelect;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Tests AMQSession_0_10 methods.
@@ -73,7 +38,7 @@
  * {@link SessionException} is not thrown from methods of
  * {@link AMQSession_0_10}.
  */
-public class AMQSession_0_10Test extends TestCase
+public class AMQSession_0_10Test extends QpidTestCase
 {
 
     public void testExceptionOnCommit()
@@ -311,7 +276,7 @@
         {
             BasicMessageConsumer_0_10 consumer = session.createMessageConsumer(createDestination(), 1, 1, true, false,
                     null, null, false, true);
-            session.sendConsume(consumer, new AMQShortString("test"), null, true, null, 1);
+            session.sendConsume(consumer, new AMQShortString("test"), null, true, 1);
         }
         catch (Exception e)
         {
@@ -494,6 +459,28 @@
         assertNotNull("ExchangeDeclare event was not sent", event);
     }
 
+    public void testGetQueueDepthWithSync()
+    {
+        // slow down a flush thread
+        setTestSystemProperty("qpid.session.max_ack_delay", "10000");
+        AMQSession_0_10 session =  createAMQSession_0_10(false, javax.jms.Session.DUPS_OK_ACKNOWLEDGE);
+        try
+        {
+            session.acknowledgeMessage(-1, false);
+            session.getQueueDepth(createDestination(), true);
+        }
+        catch (Exception e)
+        {
+            fail("Unexpected exception is cought:" + e.getMessage());
+        }
+        ProtocolEvent command = findSentProtocolEventOfClass(session, MessageAccept.class, false);
+        assertNotNull("MessageAccept command was not sent", command);
+        command = findSentProtocolEventOfClass(session, ExecutionSync.class, false);
+        assertNotNull("ExecutionSync command was not sent", command);
+        command = findSentProtocolEventOfClass(session, QueueQuery.class, false);
+        assertNotNull("QueueQuery command was not sent", command);
+    }
+
     private AMQAnyDestination createDestination()
     {
         AMQAnyDestination destination = null;
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/BasicMessageConsumer_0_8_Test.java b/qpid/java/client/src/test/java/org/apache/qpid/client/BasicMessageConsumer_0_8_Test.java
index 02089cc..722cbd0 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/client/BasicMessageConsumer_0_8_Test.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/BasicMessageConsumer_0_8_Test.java
@@ -20,12 +20,12 @@
  */
 package org.apache.qpid.client;
 
-import javax.jms.Session;
+import junit.framework.TestCase;
 
 import org.apache.qpid.test.unit.message.TestAMQSession;
 import org.apache.qpid.url.AMQBindingURL;
 
-import junit.framework.TestCase;
+import javax.jms.Session;
 
 public class BasicMessageConsumer_0_8_Test extends TestCase
 {
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/DispatcherDaemonTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/DispatcherDaemonTest.java
new file mode 100644
index 0000000..b9c4bfc
--- /dev/null
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/DispatcherDaemonTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.client;
+
+import javax.jms.Session;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.url.URLSyntaxException;
+
+public class DispatcherDaemonTest extends QpidTestCase
+{
+    private AMQSession<?,?> _session;
+
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+        if (_session != null && _session.getDispatcherThread() != null)
+        {
+            _session.getDispatcherThread().interrupt();
+        }
+    }
+
+    public void testDispatcherIsRunInDaemonThreadWithNoMessageListener() throws Exception
+    {
+        _session = createSession();
+        _session.startDispatcherIfNecessary();
+        assertFalse("Dispatcher thread should be non daemon as qpid.jms.daemon.dispatcher is not set",
+                _session.getDispatcherThread().isDaemon());
+    }
+
+    public void testDispatcherIsRunInDaemonThreadWithConsumerMessageListenerAndDaemonFlagOn() throws Exception
+    {
+        setTestSystemProperty(ClientProperties.DAEMON_DISPATCHER, "true");
+        _session = createSession();
+        _session.startDispatcherIfNecessary();
+        assertTrue("Dispatcher thread should be daemon as qpid.jms.daemon.dispatcher is set to true",
+                _session.getDispatcherThread().isDaemon());
+    }
+
+    private AMQSession<?,?> createSession() throws AMQException, URLSyntaxException
+    {
+        AMQConnection amqConnection = new MockAMQConnection(
+                "amqp://guest:guest@client/test?brokerlist='tcp://localhost:1'&maxprefetch='0'");
+
+        AMQSession_0_8 session = new AMQSession_0_8(amqConnection, 1, true, Session.SESSION_TRANSACTED, 1, 1);
+        return session;
+    }
+
+}
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/MockAMQConnection.java b/qpid/java/client/src/test/java/org/apache/qpid/client/MockAMQConnection.java
index 919809e..009598d 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/client/MockAMQConnection.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/MockAMQConnection.java
@@ -51,13 +51,13 @@
     @Override
     public ProtocolVersion makeBrokerConnection(BrokerDetails brokerDetail) throws IOException
     {
-        _connected = true;
-        _protocolHandler.getStateManager().changeState(AMQState.CONNECTION_OPEN);
+        setConnected(true);
+        getProtocolHandler().getStateManager().changeState(AMQState.CONNECTION_OPEN);
         return null;
     }
 
     public AMQConnectionDelegate getDelegate()
     {
-        return _delegate;
+        return super.getDelegate();
     }
 }
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java b/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java
new file mode 100644
index 0000000..8c66a75
--- /dev/null
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java
@@ -0,0 +1,108 @@
+/*
+ *
+ * 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.client.message;
+
+import javax.jms.Destination;
+
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.transport.DeliveryProperties;
+import org.apache.qpid.transport.MessageProperties;
+import org.apache.qpid.transport.ReplyTo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class AMQMessageDelegate_0_10Test extends QpidTestCase
+{
+
+    private static final String MAX_SHORT = "maxShort";
+    private static final String MIN_SHORT = "minShort";
+    private static final String MAX_INT = "maxInt";
+    private static final String MIN_INT = "minInt";
+    private static final String MAX_LONG = "maxLong";
+    private static final String MIN_LONG = "minLong";
+
+    /**
+     * Tests that when two messages arrive with the same ReplyTo exchange and routingKey values,
+     * the cache returns the same Destination object from getJMSReplyTo instead of a new one.
+     */
+    public void testDestinationCache() throws Exception
+    {
+        //create a message delegate and retrieve the replyTo Destination
+        AMQMessageDelegate_0_10 delegate1 = generateMessageDelegateWithReplyTo();
+        Destination dest1 = delegate1.getJMSReplyTo();
+
+        //create a new message delegate with the same details, and retrieve the replyTo Destination
+        AMQMessageDelegate_0_10 delegate2 = generateMessageDelegateWithReplyTo();
+        Destination dest2 = delegate2.getJMSReplyTo();
+
+        //verify that the destination cache means these are the same Destination object
+        assertSame("Should have received the same Destination objects", dest1, dest2);
+    }
+
+
+    private AMQMessageDelegate_0_10 generateMessageDelegateWithReplyTo()
+    {
+        MessageProperties mesProps = new MessageProperties();
+        ReplyTo reply = new ReplyTo("amq.direct", "myReplyQueue");
+        mesProps.setReplyTo(reply);
+
+        DeliveryProperties delProps = new DeliveryProperties();
+        delProps.setExchange("amq.direct");
+        delProps.setRoutingKey("myRequestQueue");
+
+        AMQMessageDelegate_0_10 delegate = new AMQMessageDelegate_0_10(mesProps,delProps,1L);
+        return delegate;
+    }
+
+    public void testMessageProperties() throws Exception
+    {
+        MessageProperties msgProps = new MessageProperties();
+
+        Map<String, Object> appHeaders = new HashMap<String, Object>();
+        appHeaders.put(MAX_SHORT, String.valueOf(Short.MAX_VALUE));
+        appHeaders.put(MIN_SHORT, String.valueOf(Short.MIN_VALUE));
+        appHeaders.put(MAX_INT, String.valueOf(Integer.MAX_VALUE));
+        appHeaders.put(MIN_INT, String.valueOf(Integer.MIN_VALUE));
+        appHeaders.put(MAX_LONG, String.valueOf(Long.MAX_VALUE));
+        appHeaders.put(MIN_LONG, String.valueOf(Long.MIN_VALUE));
+
+        msgProps.setApplicationHeaders(appHeaders);
+
+        AMQMessageDelegate_0_10 delegate = new AMQMessageDelegate_0_10(msgProps,new DeliveryProperties(),1L);
+
+        assertEquals("Max long value not retrieved successfully", Long.MAX_VALUE, delegate.getLongProperty(MAX_LONG));
+        assertEquals("Min long value not retrieved successfully", Long.MIN_VALUE, delegate.getLongProperty(MIN_LONG));
+        assertEquals("Max int value not retrieved successfully as long", (long) Integer.MAX_VALUE, delegate.getLongProperty(MAX_INT));
+        assertEquals("Min int value not retrieved successfully as long", (long) Integer.MIN_VALUE, delegate.getLongProperty(MIN_INT));
+        assertEquals("Max short value not retrieved successfully as long", (long) Short.MAX_VALUE, delegate.getLongProperty(MAX_SHORT));
+        assertEquals("Min short value not retrieved successfully as long", (long) Short.MIN_VALUE, delegate.getLongProperty(MIN_SHORT));
+
+        assertEquals("Max int value not retrieved successfully", Integer.MAX_VALUE, delegate.getIntProperty(MAX_INT));
+        assertEquals("Min int value not retrieved successfully", Integer.MIN_VALUE, delegate.getIntProperty(MIN_INT));
+        assertEquals("Max short value not retrieved successfully as int", (int) Short.MAX_VALUE, delegate.getIntProperty(MAX_SHORT));
+        assertEquals("Min short value not retrieved successfully as int", (int) Short.MIN_VALUE, delegate.getIntProperty(MIN_SHORT));
+
+        assertEquals("Max short value not retrieved successfully", Short.MAX_VALUE, delegate.getShortProperty(MAX_SHORT));
+        assertEquals("Min short value not retrieved successfully", Short.MIN_VALUE, delegate.getShortProperty(MIN_SHORT));
+    }
+
+}
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/message/AbstractJMSMessageTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/message/AbstractJMSMessageTest.java
index f81f482..1fbd7cf 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/client/message/AbstractJMSMessageTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/message/AbstractJMSMessageTest.java
@@ -21,10 +21,10 @@
  */
 
 
-import javax.jms.JMSException;
-
 import junit.framework.TestCase;
 
+import javax.jms.JMSException;
+
 public class AbstractJMSMessageTest extends TestCase
 {
 
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java
index e159ceb..9a5ca33 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java
@@ -20,10 +20,9 @@
  */
 package org.apache.qpid.client.protocol;
 
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
 import junit.framework.TestCase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQAuthenticationException;
@@ -35,8 +34,9 @@
 import org.apache.qpid.framing.amqp_8_0.BasicRecoverOkBodyImpl;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.transport.TestNetworkConnection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * This is a test address QPID-1431 where frame listeners would fail to be notified of an incomming exception.
@@ -59,15 +59,15 @@
     private static final Logger _logger = LoggerFactory.getLogger(AMQProtocolHandlerTest.class);
 
     // The handler to test
-    AMQProtocolHandler _handler;
+    private AMQProtocolHandler _handler;
 
     // A frame to block upon whilst waiting the exception
-    AMQFrame _blockFrame;
+    private AMQFrame _blockFrame;
 
     // Latch to know when the listener receives an exception
     private CountDownLatch _handleCountDown;
     // The listener that will receive an exception
-    BlockToAccessFrameListener _listener;
+    private BlockToAccessFrameListener _listener;
 
     @Override
     public void setUp() throws Exception
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/security/CallbackHandlerRegistryTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/security/CallbackHandlerRegistryTest.java
index cc5d48f..b451ad6 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/client/security/CallbackHandlerRegistryTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/security/CallbackHandlerRegistryTest.java
@@ -20,15 +20,14 @@
  */
 package org.apache.qpid.client.security;
 
-import java.io.IOException;
-import java.util.Properties;
+import org.apache.qpid.jms.ConnectionURL;
+import org.apache.qpid.test.utils.QpidTestCase;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
-
-import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.test.utils.QpidTestCase;
+import java.io.IOException;
+import java.util.Properties;
 
 
 /**
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandlerTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandlerTest.java
index 9e23f72..290ef74 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandlerTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandlerTest.java
@@ -20,20 +20,15 @@
  */
 package org.apache.qpid.client.security;
 
-import java.security.MessageDigest;
-import java.util.Arrays;
+import junit.framework.TestCase;
+
+import org.apache.qpid.client.AMQConnectionURL;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.NameCallback;
 import javax.security.auth.callback.PasswordCallback;
-
-import junit.framework.TestCase;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.client.MockAMQConnection;
-import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.client.protocol.AMQProtocolSession;
+import java.security.MessageDigest;
+import java.util.Arrays;
 
 /**
  * Unit tests for the UsernameHashPasswordCallbackHandler.  This callback handler is
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandlerTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandlerTest.java
index 83ddfd7..70f279d 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandlerTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandlerTest.java
@@ -20,18 +20,14 @@
  */
 package org.apache.qpid.client.security;
 
+import junit.framework.TestCase;
+
+import org.apache.qpid.client.AMQConnectionURL;
+
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.NameCallback;
 import javax.security.auth.callback.PasswordCallback;
 
-import junit.framework.TestCase;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.client.MockAMQConnection;
-import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.client.protocol.AMQProtocolSession;
-
 /**
  * Unit tests for the UsernamePasswordCallbackHandler.
  *
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/util/ClassLoadingAwareObjectInputStreamTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/util/ClassLoadingAwareObjectInputStreamTest.java
index a12e4ce..91460ab 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/client/util/ClassLoadingAwareObjectInputStreamTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/client/util/ClassLoadingAwareObjectInputStreamTest.java
@@ -20,6 +20,8 @@
  */
 package org.apache.qpid.client.util;
 
+import org.apache.qpid.test.utils.QpidTestCase;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
@@ -27,12 +29,10 @@
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.qpid.test.utils.QpidTestCase;
-
 public class ClassLoadingAwareObjectInputStreamTest extends QpidTestCase
 {
-    InputStream _in;
-    ClassLoadingAwareObjectInputStream _claOIS;
+    private InputStream _in;
+    private ClassLoadingAwareObjectInputStream _claOIS;
 
     protected void setUp() throws Exception
     {
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/jms/FailoverPolicyTest.java b/qpid/java/client/src/test/java/org/apache/qpid/jms/FailoverPolicyTest.java
index 438995a..cb96232 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/jms/FailoverPolicyTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/jms/FailoverPolicyTest.java
@@ -20,13 +20,7 @@
  */
 package org.apache.qpid.jms;
 
-import javax.jms.ConnectionConsumer;
-import javax.jms.ConnectionMetaData;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.ServerSessionPool;
-import javax.jms.Topic;
+import junit.framework.TestCase;
 
 import org.apache.qpid.client.AMQConnectionURL;
 import org.apache.qpid.jms.failover.FailoverExchangeMethod;
@@ -35,7 +29,13 @@
 import org.apache.qpid.jms.failover.FailoverSingleServer;
 import org.apache.qpid.jms.failover.NoFailover;
 
-import junit.framework.TestCase;
+import javax.jms.ConnectionConsumer;
+import javax.jms.ConnectionMetaData;
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.ServerSessionPool;
+import javax.jms.Topic;
 
 /**
  * Tests the ability of FailoverPolicy to instantiate the correct FailoverMethod.
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
index ddbc698..b408ad8 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
@@ -20,12 +20,6 @@
  */
 package org.apache.qpid.test.unit.basic;
 
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import javax.jms.JMSException;
-
 import junit.framework.TestCase;
 
 import org.apache.qpid.client.message.JMSTextMessage;
@@ -33,6 +27,11 @@
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.framing.FieldTableFactory;
 
+import javax.jms.JMSException;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
 public class FieldTableKeyEnumeratorTest extends TestCase
 {
     public void testTrue()
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTablePropertyTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTablePropertyTest.java
index 60ed688..e27c684 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTablePropertyTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTablePropertyTest.java
@@ -20,15 +20,14 @@
  */
 package org.apache.qpid.test.unit.basic;
 
-import java.util.Enumeration;
-
-import javax.jms.JMSException;
-
 import junit.framework.TestCase;
 
 import org.apache.qpid.client.message.JMSTextMessage;
 import org.apache.qpid.client.message.TestMessageHelper;
 
+import javax.jms.JMSException;
+import java.util.Enumeration;
+
 public class FieldTablePropertyTest extends TestCase
 {
     public void testPropertyNames()
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java
index d560c41..0bdd306 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java
@@ -20,6 +20,9 @@
  */
 package org.apache.qpid.test.unit.client.channelclose;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQChannelClosedException;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQInvalidArgumentException;
@@ -32,9 +35,6 @@
 import org.apache.qpid.framing.ChannelCloseBody;
 import org.apache.qpid.protocol.AMQConstant;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class ChannelCloseMethodHandlerNoCloseOk implements StateAwareMethodListener<ChannelCloseBody>
 {
     private static final Logger _logger = LoggerFactory.getLogger(ChannelCloseMethodHandlerNoCloseOk.class);
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/NoCloseOKStateManager.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/NoCloseOKStateManager.java
index c7eb745..3498045 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/NoCloseOKStateManager.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/NoCloseOKStateManager.java
@@ -20,37 +20,8 @@
  */
 package org.apache.qpid.test.unit.client.channelclose;
 
-import org.apache.qpid.client.state.AMQStateManager;
-import org.apache.qpid.client.state.AMQState;
-import org.apache.qpid.client.handler.ConnectionStartMethodHandler;
-import org.apache.qpid.client.handler.ConnectionCloseMethodHandler;
-import org.apache.qpid.client.handler.ConnectionTuneMethodHandler;
-import org.apache.qpid.client.handler.ConnectionSecureMethodHandler;
-import org.apache.qpid.client.handler.ConnectionOpenOkMethodHandler;
-import org.apache.qpid.client.handler.ChannelCloseOkMethodHandler;
-import org.apache.qpid.client.handler.BasicDeliverMethodHandler;
-import org.apache.qpid.client.handler.BasicReturnMethodHandler;
-import org.apache.qpid.client.handler.BasicCancelOkMethodHandler;
-import org.apache.qpid.client.handler.ChannelFlowOkMethodHandler;
-import org.apache.qpid.client.handler.QueueDeleteOkMethodHandler;
-import org.apache.qpid.client.handler.ExchangeBoundOkMethodHandler;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
-import org.apache.qpid.framing.ConnectionStartBody;
-import org.apache.qpid.framing.ConnectionCloseBody;
-import org.apache.qpid.framing.ConnectionTuneBody;
-import org.apache.qpid.framing.ConnectionSecureBody;
-import org.apache.qpid.framing.ConnectionOpenOkBody;
-import org.apache.qpid.framing.ChannelCloseBody;
-import org.apache.qpid.framing.ChannelCloseOkBody;
-import org.apache.qpid.framing.BasicDeliverBody;
-import org.apache.qpid.framing.BasicReturnBody;
-import org.apache.qpid.framing.BasicCancelOkBody;
-import org.apache.qpid.framing.ChannelFlowOkBody;
-import org.apache.qpid.framing.QueueDeleteOkBody;
-import org.apache.qpid.framing.ExchangeBoundOkBody;
-
-import java.util.Map;
-import java.util.HashMap;
+import org.apache.qpid.client.state.AMQStateManager;
 
 public class NoCloseOKStateManager extends AMQStateManager
 {
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
index 2c32e4c..9addb0e 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
@@ -21,14 +21,14 @@
 package org.apache.qpid.test.unit.client.destinationurl;
 
 import junit.framework.TestCase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.RejectBehaviour;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.url.AMQBindingURL;
 import org.apache.qpid.url.BindingURL;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.net.URISyntaxException;
 
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java
index 65013e7..1ab3ad0 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java
@@ -20,17 +20,16 @@
  */
 package org.apache.qpid.test.unit.client.message;
 
-import java.util.HashMap;
+import junit.framework.TestCase;
+
+import org.apache.qpid.client.message.JMSBytesMessage;
+import org.apache.qpid.client.message.TestMessageHelper;
 
 import javax.jms.MessageEOFException;
 import javax.jms.MessageFormatException;
 import javax.jms.MessageNotReadableException;
 import javax.jms.MessageNotWriteableException;
-
-import junit.framework.TestCase;
-
-import org.apache.qpid.client.message.JMSBytesMessage;
-import org.apache.qpid.client.message.TestMessageHelper;
+import java.util.HashMap;
 
 public class BytesMessageTest extends TestCase
 {
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java
index 3e04c36..f75c660 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java
@@ -20,15 +20,15 @@
  */
 package org.apache.qpid.test.unit.client.message;
 
-import javax.jms.JMSException;
-import javax.jms.MessageFormatException;
-
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
 import org.apache.qpid.client.message.JMSMapMessage;
 import org.apache.qpid.client.message.TestMessageHelper;
 
+import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
+
 
 public class MapMessageTest extends TestCase
 {
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageUnitTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageUnitTest.java
index e37970e..a2c5bf6 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageUnitTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageUnitTest.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.test.unit.client.message;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-
 import org.apache.qpid.client.message.JMSObjectMessage;
 import org.apache.qpid.client.message.TestMessageHelper;
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+
 public class ObjectMessageUnitTest extends QpidTestCase
 {
     private JMSObjectMessage _om;
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/StreamMessageTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/StreamMessageTest.java
index 085dd81..648e4b0 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/StreamMessageTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/StreamMessageTest.java
@@ -20,7 +20,10 @@
  */
 package org.apache.qpid.test.unit.client.message;
 
-import java.util.HashMap;
+import junit.framework.TestCase;
+
+import org.apache.qpid.client.message.JMSStreamMessage;
+import org.apache.qpid.client.message.TestMessageHelper;
 
 import javax.jms.JMSException;
 import javax.jms.MessageEOFException;
@@ -28,11 +31,7 @@
 import javax.jms.MessageNotReadableException;
 import javax.jms.MessageNotWriteableException;
 import javax.jms.StreamMessage;
-
-import junit.framework.TestCase;
-
-import org.apache.qpid.client.message.JMSStreamMessage;
-import org.apache.qpid.client.message.TestMessageHelper;
+import java.util.HashMap;
 
 /**
  * @author Apache Software Foundation
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java
index 30f3b0b..a80b3d1 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java
@@ -20,8 +20,6 @@
  */
 package org.apache.qpid.test.unit.client.message;
 
-import javax.jms.JMSException;
-
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
@@ -29,6 +27,8 @@
 import org.apache.qpid.client.message.JMSTextMessage;
 import org.apache.qpid.client.message.TestMessageHelper;
 
+import javax.jms.JMSException;
+
 public class TextMessageTest extends TestCase
 {
     public void testTextOnConstruction() throws Exception
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDIPropertyFileTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDIPropertyFileTest.java
index 2052312..576ab4f 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDIPropertyFileTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/jndi/JNDIPropertyFileTest.java
@@ -20,22 +20,21 @@
  */
 package org.apache.qpid.test.unit.jndi;
 
-import java.util.Properties;
+import junit.framework.TestCase;
+
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.framing.AMQShortString;
 
 import javax.jms.Queue;
 import javax.jms.Topic;
 import javax.naming.ConfigurationException;
 import javax.naming.Context;
 import javax.naming.InitialContext;
-
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.framing.AMQShortString;
-
-import junit.framework.TestCase;
+import java.util.Properties;
 
 public class JNDIPropertyFileTest extends TestCase
 {
-    Context ctx;
+    private Context ctx;
     
     public JNDIPropertyFileTest() throws Exception
     {
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/MessageConverterTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/MessageConverterTest.java
index cd18b51..04122a6 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/MessageConverterTest.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/MessageConverterTest.java
@@ -20,20 +20,24 @@
  */
 package org.apache.qpid.test.unit.message;
 
-import javax.jms.*;
-
 import junit.framework.TestCase;
 
-import org.apache.qpid.client.*;
-import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.client.failover.FailoverException;
-import org.apache.qpid.client.message.*;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.MockAMQConnection;
+import org.apache.qpid.client.message.AMQMessageDelegateFactory;
+import org.apache.qpid.client.message.AbstractJMSMessage;
+import org.apache.qpid.client.message.JMSMapMessage;
+import org.apache.qpid.client.message.JMSTextMessage;
+import org.apache.qpid.client.message.MessageConverter;
 import org.apache.qpid.exchange.ExchangeDefaults;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.AMQException;
 
-import java.util.Map;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.TextMessage;
 
 
 public class MessageConverterTest extends TestCase
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/NonQpidMessage.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/NonQpidMessage.java
index b1cf23b..d93ba23 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/NonQpidMessage.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/NonQpidMessage.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.test.unit.message;
 
-import java.util.Enumeration;
-import java.util.Hashtable;
-
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageFormatException;
+import java.util.Enumeration;
+import java.util.Hashtable;
 
 public class NonQpidMessage implements Message
 {
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java
index 4c3e9c2..f199961 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java
+++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java
@@ -20,22 +20,24 @@
  */
 package org.apache.qpid.test.unit.message;
 
-import java.util.Map;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQSession_0_8;
+import org.apache.qpid.client.BasicMessageConsumer_0_8;
+import org.apache.qpid.client.BasicMessageProducer_0_8;
+import org.apache.qpid.client.failover.FailoverException;
+import org.apache.qpid.client.message.AMQMessageDelegateFactory;
+import org.apache.qpid.client.protocol.AMQProtocolHandler;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
 
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.TemporaryQueue;
 import javax.jms.Topic;
 import javax.jms.TopicSubscriber;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.*;
-import org.apache.qpid.client.failover.FailoverException;
-import org.apache.qpid.client.message.AMQMessageDelegateFactory;
-import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.filter.MessageFilter;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
+import java.util.Map;
 
 public class TestAMQSession extends AMQSession_0_8
 {
@@ -122,7 +124,7 @@
         return false;
     }
 
-    public void sendConsume(BasicMessageConsumer_0_8 consumer, AMQShortString queueName, AMQProtocolHandler protocolHandler, boolean nowait, MessageFilter messageSelector, int tag) throws AMQException, FailoverException
+    public void sendConsume(BasicMessageConsumer_0_8 consumer, AMQShortString queueName, AMQProtocolHandler protocolHandler, boolean nowait, int tag) throws AMQException, FailoverException
     {
 
     }
@@ -143,7 +145,7 @@
     }
 
     public void sendQueueDeclare(AMQDestination amqd, AMQProtocolHandler protocolHandler,
-                                 boolean nowait) throws AMQException, FailoverException
+                                 boolean nowait, boolean passive) throws AMQException, FailoverException
     {
 
     }
diff --git a/qpid/java/common/Composite.tpl b/qpid/java/common/Composite.tpl
index 2cbd683..2b2f8fd 100644
--- a/qpid/java/common/Composite.tpl
+++ b/qpid/java/common/Composite.tpl
@@ -21,22 +21,12 @@
  */
 
 
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
 import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
-import java.util.UUID;
 
 import org.apache.qpid.transport.codec.Decoder;
-import org.apache.qpid.transport.codec.Encodable;
 import org.apache.qpid.transport.codec.Encoder;
 
-import org.apache.qpid.transport.network.Frame;
-
-import org.apache.qpid.util.Strings;
-
-
 ${
 from genutil import *
 
@@ -77,6 +67,13 @@
 }
 
 typecode = code(type)
+
+if segments:
+  out("import java.nio.ByteBuffer;\n")
+  out("import org.apache.qpid.util.Strings;\n")
+
+if track != "-1":
+  out("import org.apache.qpid.transport.network.Frame;\n")
 }
 
 public final class $name extends $base {
@@ -190,7 +187,7 @@
 if not f.empty:
   out("        this.$(f.name) = $(f.default);")
 }
-        this.dirty = true;
+        setDirty(true);
         return this;
     }
 """)
@@ -214,13 +211,17 @@
 if pack > 0:
   if f.empty:
     out("        if (value)\\n")
+    out("        {\\n")
     out("            packing_flags |= $(f.flag_mask(pack));\\n")
+    out("        }\\n")
     out("        else\\n")
-    out("            packing_flags &= ~$(f.flag_mask(pack));")
+    out("        {\\n")
+    out("            packing_flags &= ~$(f.flag_mask(pack));\\n")
+    out("        }\\n")
   else:
     out("        packing_flags |= $(f.flag_mask(pack));")
 }
-        this.dirty = true;
+        setDirty(true);
         return this;
     }
 
@@ -304,6 +305,7 @@
     continue
   if pack > 0:
     out("        if ((packing_flags & $(f.flag_mask(pack))) != 0)\n    ")
+    out("    {\n    ")
   pre = ""
   post = ""
   if f.type_node.name == "struct":
@@ -311,6 +313,8 @@
   elif f.type_node.name == "domain":
     post = ".getValue()"
   out("        enc.write$(f.coder)($(pre)this.$(f.name)$(post));\n")
+  if pack > 0:
+    out("        }\n")
 }
     }
 
@@ -325,6 +329,7 @@
     continue
   if pack > 0:
     out("        if ((packing_flags & $(f.flag_mask(pack))) != 0)\n    ")
+    out("    {\n    ")
   pre = ""
   post = ""
   arg = ""
@@ -335,6 +340,8 @@
     pre = "%s.get(" % cname(f.type_node)
     post = ")"
   out("        this.$(f.name) = $(pre)dec.read$(f.coder)($(arg))$(post);\n")
+  if pack > 0:
+    out("        }\n")
 }
     }
 
@@ -346,10 +353,31 @@
 for f in fields:
   if pack > 0:
     out("        if ((packing_flags & $(f.flag_mask(pack))) != 0)\n    ")
+    out("    {\n    ")
   out('        result.put("$(f.name)", $(f.get)());\n')
+  if pack > 0:
+    out("        }\n")
 }
 
         return result;
     }
 
+${
+if name == "ReplyTo":
+  out("    public boolean equals(final Object obj){\n")
+  out("        if (this == obj){\n")
+  out("            return true;\n")
+  out("        }\n\n")
+  out("        if(!(obj instanceof ReplyTo)){\n")
+  out("            return false;\n")
+  out("        }\n\n")
+  out("        final ReplyTo reply = (ReplyTo) obj;\n")
+  out("        return (routingKey == null ? reply.getRoutingKey() == null : routingKey.equals(reply.getRoutingKey()))\n")
+  out("            && (exchange == null ? reply.getExchange() == null : exchange.equals(reply.getExchange()));\n")
+  out("    }\n\n")
+  out("    public int hashCode(){\n")
+  out("        int result = routingKey == null ? 1 : routingKey.hashCode();\n")
+  out("        return 31 * result + (exchange == null ? 5 : exchange.hashCode());\n")
+  out("    }")
+}
 }
diff --git a/qpid/java/common/Invoker.tpl b/qpid/java/common/Invoker.tpl
index 2eed43a..2087710 100644
--- a/qpid/java/common/Invoker.tpl
+++ b/qpid/java/common/Invoker.tpl
@@ -21,10 +21,7 @@
  */
 
 
-import java.nio.ByteBuffer;
-import java.util.List;
 import java.util.Map;
-import java.util.UUID;
 
 public abstract class $(invoker) {
 ${
diff --git a/qpid/java/common/Type.tpl b/qpid/java/common/Type.tpl
index 7f9cfee..4635c4e 100644
--- a/qpid/java/common/Type.tpl
+++ b/qpid/java/common/Type.tpl
@@ -56,9 +56,9 @@
   out("    $name((byte) $code, $width, $fixed)")
 };
 
-    public byte code;
-    public int width;
-    public boolean fixed;
+    private final byte code;
+    private final int width;
+    private final boolean fixed;
 
     Type(byte code, int width, boolean fixed)
     {
@@ -67,6 +67,21 @@
         this.fixed = fixed;
     }
 
+    public byte getCode()
+    {
+        return code;
+    }
+
+    public int getWidth()
+    {
+        return width;
+    }
+
+    public boolean isFixed()
+    {
+        return fixed;
+    }
+
     public static Type get(byte code)
     {
         switch (code)
diff --git a/qpid/java/common/bin/qpid-run b/qpid/java/common/bin/qpid-run
index ef4363e..1e37334 100755
--- a/qpid/java/common/bin/qpid-run
+++ b/qpid/java/common/bin/qpid-run
@@ -110,7 +110,7 @@
 log $INFO System Properties set to ${SYSTEM_PROPS[@]}
 log $INFO QPID_OPTS set to $QPID_OPTS
 
-program=$(basename $0)
+program=$(basename "$0")
 sourced=${BASH_SOURCE[0]}
 if [[ -z ${sourced:-''} ]]; then
   sourced=$(which qpid-run) || ${QPID_HOME}/bin/qpid-run
diff --git a/qpid/java/common/build.xml b/qpid/java/common/build.xml
index f2f85fc..fe96f384 100644
--- a/qpid/java/common/build.xml
+++ b/qpid/java/common/build.xml
@@ -32,6 +32,7 @@
   <property name="xml.spec.list" value='"${xml.spec.dir}/amqp.0-8.xml" "${xml.spec.dir}/amqp.0-9.xml" "${xml.spec.dir}/amqp0-9-1.stripped.xml"' />
   <property name="gentools.timestamp" location="${framing.generated.dir}/gentools.timestamp" />
   <property name="jython.timestamp" location="${framing.generated.dir}/jython.timestamp" />
+  <property name="selector.output.dir" value="${module.precompiled}/org/apache/qpid/filter/selector"/>
 
   <target name="check_jython_deps">
     <uptodate property="jython.notRequired" targetfile="${jython.timestamp}">
@@ -96,7 +97,14 @@
 
   </target>
 
-  <target name="precompile" depends="gentools,jython,create-version,build-version"/>
+  <target name="jms-selector">
+    <mkdir dir="${selector.output.dir}"/>
+    <javacc target="src/main/grammar/SelectorParser.jj"
+            outputdirectory="${selector.output.dir}"
+            javacchome="${project.root}/lib"/>
+  </target>
+
+  <target name="precompile" depends="gentools,jython,create-version,build-version,jms-selector"/>
 
   <target name="bundle" depends="bundle-tasks"/>
 </project>
diff --git a/qpid/java/common/genutil.py b/qpid/java/common/genutil.py
index 57a461e..7996cca 100644
--- a/qpid/java/common/genutil.py
+++ b/qpid/java/common/genutil.py
@@ -109,7 +109,7 @@
   "uint32": "long",
   "uint64": "long",
   "datetime": "long",
-  "uuid": "UUID",
+  "uuid": "java.util.UUID",
   "sequence-no": "int",
   "sequence-set": "RangeSet", # XXX
   "byte-ranges": "RangeSet", # XXX
@@ -120,7 +120,7 @@
   "vbin32": "byte[]",
   "struct32": "Struct",
   "map": "Map<String,Object>",
-  "array": "List<Object>"
+  "array": "java.util.List<Object>"
   }
 
 def cname(nd, field="@name"):
@@ -232,7 +232,7 @@
       params.append("%s %s" % (f.type, f.name))
   if type["segments"]:
     params.append("Header header")
-    params.append("ByteBuffer body")
+    params.append("java.nio.ByteBuffer body")
   if options or type.name in ("control", "command"):
     params.append("Option ... _options")
   return params
diff --git a/qpid/java/client/src/main/grammar/SelectorParser.jj b/qpid/java/common/src/main/grammar/SelectorParser.jj
similarity index 92%
rename from qpid/java/client/src/main/grammar/SelectorParser.jj
rename to qpid/java/common/src/main/grammar/SelectorParser.jj
index c811128..ec3a271 100644
--- a/qpid/java/client/src/main/grammar/SelectorParser.jj
+++ b/qpid/java/common/src/main/grammar/SelectorParser.jj
@@ -1,609 +1,612 @@
-/*
- *
- * 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.
- *
- */
-
- //
- // Original File from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
- //
-
-// ----------------------------------------------------------------------------
-// OPTIONS
-// ----------------------------------------------------------------------------
-options {
-  STATIC = false;
-  UNICODE_INPUT = true;
-
-  // some performance optimizations
-  OPTIMIZE_TOKEN_MANAGER = true;
-  ERROR_REPORTING = false;
-}
-
-// ----------------------------------------------------------------------------
-// PARSER
-// ----------------------------------------------------------------------------
-
-PARSER_BEGIN(SelectorParser)
-/*
- *
- * 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.filter.selector;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-
-import org.apache.qpid.AMQInternalException;
-import org.apache.qpid.filter.ArithmeticExpression;
-import org.apache.qpid.filter.BooleanExpression;
-import org.apache.qpid.filter.ComparisonExpression;
-import org.apache.qpid.filter.ConstantExpression;
-import org.apache.qpid.filter.Expression;
-import org.apache.qpid.filter.LogicExpression;
-import org.apache.qpid.filter.PropertyExpression;
-import org.apache.qpid.filter.UnaryExpression;
-
-/**
- * JMS Selector Parser generated by JavaCC
- *
- * Do not edit this .java file directly - it is autogenerated from SelectorParser.jj
- */
-public class SelectorParser {
-
-    public SelectorParser() {
-        this(new StringReader(""));
-    }
-
-    public BooleanExpression parse(String sql) throws AMQInternalException {
-        this.ReInit(new StringReader(sql));
-
-        try {
-            return this.JmsSelector();
-        }
-        catch (Throwable e) {
-	        throw new AMQInternalException(sql,e);
-        }
-
-    }
-
-    private BooleanExpression asBooleanExpression(Expression value) throws ParseException  {
-        if (value instanceof BooleanExpression) {
-            return (BooleanExpression) value;
-        }
-        if (value instanceof PropertyExpression) {
-            return UnaryExpression.createBooleanCast( value );
-        }
-        throw new ParseException("Expression will not result in a boolean value: " + value);
-    }
-
-
-}
-
-PARSER_END(SelectorParser)
-
-// ----------------------------------------------------------------------------
-// Tokens
-// ----------------------------------------------------------------------------
-
-/* White Space */
-SPECIAL_TOKEN :
-{
-  " " | "\t" | "\n" | "\r" | "\f"
-}
-
-/* Comments */
-SKIP:
-{
-  <LINE_COMMENT: "--" (~["\n","\r"])* ("\n"|"\r"|"\r\n") >
-}
-
-SKIP:
-{
-  <BLOCK_COMMENT: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
-}
-
-/* Reserved Words */
-TOKEN [IGNORE_CASE] :
-{
-    <  NOT     : "NOT">
-  | <  AND     : "AND">
-  | <  OR      : "OR">
-  | <  BETWEEN : "BETWEEN">
-  | <  LIKE    : "LIKE">
-  | <  ESCAPE  : "ESCAPE">
-  | <  IN      : "IN">
-  | <  IS      : "IS">
-  | <  TRUE    : "TRUE" >
-  | <  FALSE   : "FALSE" >
-  | <  NULL    : "NULL" >  
-}
-
-/* Literals */
-TOKEN [IGNORE_CASE] :
-{
-
-    < DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* (["l","L"])? >
-  | < HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
-  | < OCTAL_LITERAL: "0" (["0"-"7"])* >
-  | < FLOATING_POINT_LITERAL:
-          (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? // matches: 5.5 or 5. or 5.5E10 or 5.E10
-        | "." (["0"-"9"])+ (<EXPONENT>)?              // matches: .5 or .5E10
-        | (["0"-"9"])+ <EXPONENT>                     // matches: 5E10
-    >
-  | < #EXPONENT: "E" (["+","-"])? (["0"-"9"])+ >
-  | < STRING_LITERAL: "'" ( ("''") | ~["'"] )*  "'" >
-}
-
-TOKEN [IGNORE_CASE] :
-{
-    < ID : ["a"-"z", "_", "$"] (["a"-"z","0"-"9","_", "$"])* >
-    | < QUOTED_ID : "\"" ( ("\"\"") | ~["\""] )*  "\""  >
-
-}
-
-// ----------------------------------------------------------------------------
-// Grammer
-// ----------------------------------------------------------------------------
-BooleanExpression JmsSelector() :
-{
-    Expression left=null;
-}
-{
-    (
-        left = orExpression()
-    )
-    {
-        return asBooleanExpression(left);
-    }
-
-}
-
-Expression orExpression() :
-{
-    Expression left;
-    Expression right;
-}
-{
-    (
-        left = andExpression()
-        (
-            <OR> right = andExpression()
-            {
-                left = LogicExpression.createOR(asBooleanExpression(left), asBooleanExpression(right));
-            }
-        )*
-    )
-    {
-        return left;
-    }
-
-}
-
-
-Expression andExpression() :
-{
-    Expression left;
-    Expression right;
-}
-{
-    (
-        left = equalityExpression()
-        (
-            <AND> right = equalityExpression()
-            {
-                left = LogicExpression.createAND(asBooleanExpression(left), asBooleanExpression(right));
-            }
-        )*
-    )
-    {
-        return left;
-    }
-}
-
-Expression equalityExpression() :
-{
-    Expression left;
-    Expression right;
-}
-{
-    (
-        left = comparisonExpression()
-        (
-
-            "=" right = comparisonExpression()
-            {
-                left = ComparisonExpression.createEqual(left, right);
-            }
-            |
-            "<>" right = comparisonExpression()
-            {
-                left = ComparisonExpression.createNotEqual(left, right);
-            }
-            |
-            LOOKAHEAD(2)
-            <IS> <NULL>
-            {
-                left = ComparisonExpression.createIsNull(left);
-            }
-            |
-            <IS> <NOT> <NULL>
-            {
-                left = ComparisonExpression.createIsNotNull(left);
-            }
-        )*
-    )
-    {
-        return left;
-    }
-}
-
-Expression comparisonExpression() :
-{
-    Expression left;
-    Expression right;
-    Expression low;
-    Expression high;
-    String t, u;
-	boolean not;
-	ArrayList list;
-}
-{
-    (
-        left = addExpression()
-        (
-
-                ">" right = addExpression()
-                {
-                    left = ComparisonExpression.createGreaterThan(left, right);
-                }
-            |
-                ">=" right = addExpression()
-                {
-                    left = ComparisonExpression.createGreaterThanEqual(left, right);
-                }
-            |
-                "<" right = addExpression()
-                {
-                    left = ComparisonExpression.createLessThan(left, right);
-                }
-            |
-                "<=" right = addExpression()
-                {
-                    left = ComparisonExpression.createLessThanEqual(left, right);
-                }
-           |
-				{
-					u=null;
-				}
-		        <LIKE> t = stringLitteral()
-		        	[ <ESCAPE> u = stringLitteral() ]
-		        {
-                    left = ComparisonExpression.createLike(left, t, u);
-		        }
-           |
-	        	LOOKAHEAD(2)
-				{
-					u=null;
-				}
-		        <NOT> <LIKE> t = stringLitteral() [ <ESCAPE> u = stringLitteral() ]
-		        {
-                    left = ComparisonExpression.createNotLike(left, t, u);
-		        }
-            |
-		        <BETWEEN> low = addExpression() <AND> high = addExpression()
-		        {
-					left = ComparisonExpression.createBetween(left, low, high);
-		        }
-	        |
-	        	LOOKAHEAD(2)
-		        <NOT> <BETWEEN> low = addExpression() <AND> high = addExpression()
-		        {
-					left = ComparisonExpression.createNotBetween(left, low, high);
-		        }
-            |
-				<IN>
-		        "("
-		            t = stringLitteral()
-		            {
-			            list = new ArrayList();
-			            list.add( t );
-		            }
-			        (
-			        	","
-			            t = stringLitteral()
-			            {
-				            list.add( t );
-			            }
-
-			        )*
-		        ")"
-		        {
-		           left = ComparisonExpression.createInFilter(left, list);
-		        }
-            |
-	        	LOOKAHEAD(2)
-	            <NOT> <IN>
-		        "("
-		            t = stringLitteral()
-		            {
-			            list = new ArrayList();
-			            list.add( t );
-		            }
-			        (
-			        	","
-			            t = stringLitteral()
-			            {
-				            list.add( t );
-			            }
-
-			        )*
-		        ")"
-		        {
-		           left = ComparisonExpression.createNotInFilter(left, list);
-		        }
-
-        )*
-    )
-    {
-        return left;
-    }
-}
-
-Expression addExpression() :
-{
-    Expression left;
-    Expression right;
-}
-{
-    left = multExpr()
-    (
-	    LOOKAHEAD( ("+"|"-") multExpr())
-	    (
-	        "+" right = multExpr()
-	        {
-	            left = ArithmeticExpression.createPlus(left, right);
-	        }
-	        |
-	        "-" right = multExpr()
-	        {
-	            left = ArithmeticExpression.createMinus(left, right);
-	        }
-        )
-
-    )*
-    {
-        return left;
-    }
-}
-
-Expression multExpr() :
-{
-    Expression left;
-    Expression right;
-}
-{
-    left = unaryExpr()
-    (
-        "*" right = unaryExpr()
-        {
-	        left = ArithmeticExpression.createMultiply(left, right);
-        }
-        |
-        "/" right = unaryExpr()
-        {
-	        left = ArithmeticExpression.createDivide(left, right);
-        }
-        |
-        "%" right = unaryExpr()
-        {
-	        left = ArithmeticExpression.createMod(left, right);
-        }
-
-    )*
-    {
-        return left;
-    }
-}
-
-
-Expression unaryExpr() :
-{
-    String s=null;
-    Expression left=null;
-}
-{
-	(
-		LOOKAHEAD( "+" unaryExpr() )
-	    "+" left=unaryExpr()
-	    |
-	    "-" left=unaryExpr()
-	    {
-	        left = UnaryExpression.createNegate(left);
-	    }
-	    |
-	    <NOT> left=unaryExpr()
-	    {
-		    left = UnaryExpression.createNOT( asBooleanExpression(left) );
-	    }
-	    |	   
-	    left = primaryExpr()
-    )
-    {
-        return left;
-    }
-
-}
-
-Expression primaryExpr() :
-{
-    Expression left=null;
-}
-{
-    (
-        left = literal()
-        |
-        left = variable()
-        |
-        "(" left = orExpression() ")"
-    )
-    {
-        return left;
-    }
-}
-
-
-
-ConstantExpression literal() :
-{
-    Token t;
-    String s;
-    ConstantExpression left=null;
-}
-{
-    (
-        (
-            s = stringLitteral()
-            {
-                left = new ConstantExpression(s);
-            }
-        )
-        |
-        (
-            t = <DECIMAL_LITERAL>
-            {
-            	left = ConstantExpression.createFromDecimal(t.image);
-            }
-        )
-        |
-        (
-            t = <HEX_LITERAL>
-            {
-            	left = ConstantExpression.createFromHex(t.image);
-            }
-        )
-        |
-        (
-            t = <OCTAL_LITERAL>
-            {
-            	left = ConstantExpression.createFromOctal(t.image);
-            }
-        )
-        |
-        (
-            t = <FLOATING_POINT_LITERAL>
-            {
-            	left = ConstantExpression.createFloat(t.image);
-            }
-        )
-        |
-        (
-            <TRUE>
-            {
-                left = ConstantExpression.TRUE;
-            }
-        )
-        |
-        (
-            <FALSE>
-            {
-                left = ConstantExpression.FALSE;
-            }
-        )
-        |
-        (
-            <NULL>
-            {
-                left = ConstantExpression.NULL;
-            }
-        )
-    )
-    {
-        return left;
-    }
-}
-
-String stringLitteral() :
-{
-    Token t;
-    StringBuffer rc = new StringBuffer();
-    boolean first=true;
-}
-{
-    t = <STRING_LITERAL>
-    {
-    	// Decode the sting value.
-    	String image = t.image;
-    	for( int i=1; i < image.length()-1; i++ ) {
-    		char c = image.charAt(i);
-    		if( c == '\'' )
-    			i++;
-   			rc.append(c);
-    	}
-	    return rc.toString();
-    }
-}
-
-PropertyExpression variable() :
-{
-    Token t;
-    StringBuffer rc = new StringBuffer();
-    PropertyExpression left=null;
-}
-{
-    (
-        t = <ID>
-        {
-            left = new PropertyExpression(t.image);
-        }
-        |
-        t = <QUOTED_ID>
-        {
-            // Decode the sting value.
-            String image = t.image;
-            for( int i=1; i < image.length()-1; i++ ) {
-                char c = image.charAt(i);
-                if( c == '"' )
-                    i++;
-                rc.append(c);
-            }
-            return new PropertyExpression(rc.toString());
-        }
-
-    )
-    {
-        return left;
-    }
-}
+/*

+ *

+ * 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.

+ *

+ */

+

+ //

+ // Original File from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>

+ //

+

+// ----------------------------------------------------------------------------

+// OPTIONS

+// ----------------------------------------------------------------------------

+options {

+  STATIC = false;

+  UNICODE_INPUT = true;

+

+  // some performance optimizations

+  ERROR_REPORTING = false;

+}

+

+// ----------------------------------------------------------------------------

+// PARSER

+// ----------------------------------------------------------------------------

+

+PARSER_BEGIN(SelectorParser)

+/*

+ *

+ * 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.filter.selector;

+

+import java.io.StringReader;

+import java.util.ArrayList;

+

+import org.apache.qpid.filter.ArithmeticExpression;

+import org.apache.qpid.filter.BooleanExpression;

+import org.apache.qpid.filter.ComparisonExpression;

+import org.apache.qpid.filter.ConstantExpression;

+import org.apache.qpid.filter.Expression;

+import org.apache.qpid.filter.LogicExpression;

+import org.apache.qpid.filter.PropertyExpression;

+import org.apache.qpid.filter.UnaryExpression;

+

+/**

+ * JMS Selector Parser generated by JavaCC

+ *

+ * Do not edit this .java file directly - it is autogenerated from SelectorParser.jj

+ */

+public class SelectorParser

+{

+

+    public SelectorParser()

+    {

+        this(new StringReader(""));

+    }

+

+    public BooleanExpression parse(String sql) throws ParseException

+    {

+        this.ReInit(new StringReader(sql));

+

+        return this.JmsSelector();

+

+    }

+

+    private BooleanExpression asBooleanExpression(Expression value) throws ParseException

+    {

+        if (value instanceof BooleanExpression)

+        {

+            return (BooleanExpression) value;

+        }

+        if (value instanceof PropertyExpression)

+        {

+            return UnaryExpression.createBooleanCast( value );

+        }

+        throw new ParseException("Expression will not result in a boolean value: " + value);

+    }

+

+

+}

+

+PARSER_END(SelectorParser)

+

+// ----------------------------------------------------------------------------

+// Tokens

+// ----------------------------------------------------------------------------

+

+/* White Space */

+SPECIAL_TOKEN :

+{

+  " " | "\t" | "\n" | "\r" | "\f"

+}

+

+/* Comments */

+SKIP:

+{

+  <LINE_COMMENT: "--" (~["\n","\r"])* ("\n"|"\r"|"\r\n") >

+}

+

+SKIP:

+{

+  <BLOCK_COMMENT: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">

+}

+

+/* Reserved Words */

+TOKEN [IGNORE_CASE] :

+{

+    <  NOT     : "NOT">

+  | <  AND     : "AND">

+  | <  OR      : "OR">

+  | <  BETWEEN : "BETWEEN">

+  | <  LIKE    : "LIKE">

+  | <  ESCAPE  : "ESCAPE">

+  | <  IN      : "IN">

+  | <  IS      : "IS">

+  | <  TRUE    : "TRUE" >

+  | <  FALSE   : "FALSE" >

+  | <  NULL    : "NULL" >

+}

+

+/* Literals */

+TOKEN [IGNORE_CASE] :

+{

+

+    < DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* (["l","L"])? >

+  | < HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >

+  | < OCTAL_LITERAL: "0" (["0"-"7"])* >

+  | < FLOATING_POINT_LITERAL:

+          (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? // matches: 5.5 or 5. or 5.5E10 or 5.E10

+        | "." (["0"-"9"])+ (<EXPONENT>)?              // matches: .5 or .5E10

+        | (["0"-"9"])+ <EXPONENT>                     // matches: 5E10

+    >

+  | < #EXPONENT: "E" (["+","-"])? (["0"-"9"])+ >

+  | < STRING_LITERAL: "'" ( ("''") | ~["'"] )*  "'" >

+}

+

+TOKEN [IGNORE_CASE] :

+{

+    < ID : ["a"-"z", "_", "$"] (["a"-"z","0"-"9","_", "$"])* >

+    | < QUOTED_ID : "\"" ( ("\"\"") | ~["\""] )*  "\""  >

+}

+

+// ----------------------------------------------------------------------------

+// Grammer

+// ----------------------------------------------------------------------------

+BooleanExpression JmsSelector() :

+{

+    Expression left=null;

+}

+{

+    (

+        left = orExpression()

+    )

+    {

+        return asBooleanExpression(left);

+    }

+

+}

+

+Expression orExpression() :

+{

+    Expression left;

+    Expression right;

+}

+{

+    (

+        left = andExpression()

+        (

+            <OR> right = andExpression()

+            {

+                left = LogicExpression.createOR(asBooleanExpression(left), asBooleanExpression(right));

+            }

+        )*

+    )

+    {

+        return left;

+    }

+

+}

+

+

+Expression andExpression() :

+{

+    Expression left;

+    Expression right;

+}

+{

+    (

+        left = equalityExpression()

+        (

+            <AND> right = equalityExpression()

+            {

+                left = LogicExpression.createAND(asBooleanExpression(left), asBooleanExpression(right));

+            }

+        )*

+    )

+    {

+        return left;

+    }

+}

+

+Expression equalityExpression() :

+{

+    Expression left;

+    Expression right;

+}

+{

+    (

+        left = comparisonExpression()

+        (

+

+            "=" right = comparisonExpression()

+            {

+                left = ComparisonExpression.createEqual(left, right);

+            }

+            |

+            "<>" right = comparisonExpression()

+            {

+                left = ComparisonExpression.createNotEqual(left, right);

+            }

+            |

+            LOOKAHEAD(2)

+            <IS> <NULL>

+            {

+                left = ComparisonExpression.createIsNull(left);

+            }

+            |

+            <IS> <NOT> <NULL>

+            {

+                left = ComparisonExpression.createIsNotNull(left);

+            }

+        )*

+    )

+    {

+        return left;

+    }

+}

+

+Expression comparisonExpression() :

+{

+    Expression left;

+    Expression right;

+    Expression low;

+    Expression high;

+    String t, u;

+	boolean not;

+	ArrayList list;

+}

+{

+    (

+        left = addExpression()

+        (

+

+                ">" right = addExpression()

+                {

+                    left = ComparisonExpression.createGreaterThan(left, right);

+                }

+            |

+                ">=" right = addExpression()

+                {

+                    left = ComparisonExpression.createGreaterThanEqual(left, right);

+                }

+            |

+                "<" right = addExpression()

+                {

+                    left = ComparisonExpression.createLessThan(left, right);

+                }

+            |

+                "<=" right = addExpression()

+                {

+                    left = ComparisonExpression.createLessThanEqual(left, right);

+                }

+           |

+				{

+					u=null;

+				}

+		        <LIKE> t = stringLiteral()

+		        	[ <ESCAPE> u = stringLiteral() ]

+		        {

+                    left = ComparisonExpression.createLike(left, t, u);

+		        }

+           |

+	        	LOOKAHEAD(2)

+				{

+					u=null;

+				}

+		        <NOT> <LIKE> t = stringLiteral() [ <ESCAPE> u = stringLiteral() ]

+		        {

+                    left = ComparisonExpression.createNotLike(left, t, u);

+		        }

+            |

+		        <BETWEEN> low = addExpression() <AND> high = addExpression()

+		        {

+					left = ComparisonExpression.createBetween(left, low, high);

+		        }

+	        |

+	        	LOOKAHEAD(2)

+		        <NOT> <BETWEEN> low = addExpression() <AND> high = addExpression()

+		        {

+					left = ComparisonExpression.createNotBetween(left, low, high);

+		        }

+            |

+				<IN>

+		        "("

+		            t = stringLiteral()

+		            {

+			            list = new ArrayList();

+			            list.add( t );

+		            }

+			        (

+			        	","

+			            t = stringLiteral()

+			            {

+				            list.add( t );

+			            }

+

+			        )*

+		        ")"

+		        {

+		           left = ComparisonExpression.createInFilter(left, list);

+		        }

+            |

+	        	LOOKAHEAD(2)

+	            <NOT> <IN>

+		        "("

+		            t = stringLiteral()

+		            {

+			            list = new ArrayList();

+			            list.add( t );

+		            }

+			        (

+			        	","

+			            t = stringLiteral()

+			            {

+				            list.add( t );

+			            }

+

+			        )*

+		        ")"

+		        {

+		           left = ComparisonExpression.createNotInFilter(left, list);

+		        }

+

+        )*

+    )

+    {

+        return left;

+    }

+}

+

+Expression addExpression() :

+{

+    Expression left;

+    Expression right;

+}

+{

+    left = multExpr()

+    (

+	    LOOKAHEAD( ("+"|"-") multExpr())

+	    (

+	        "+" right = multExpr()

+	        {

+	            left = ArithmeticExpression.createPlus(left, right);

+	        }

+	        |

+	        "-" right = multExpr()

+	        {

+	            left = ArithmeticExpression.createMinus(left, right);

+	        }

+        )

+

+    )*

+    {

+        return left;

+    }

+}

+

+Expression multExpr() :

+{

+    Expression left;

+    Expression right;

+}

+{

+    left = unaryExpr()

+    (

+        "*" right = unaryExpr()

+        {

+	        left = ArithmeticExpression.createMultiply(left, right);

+        }

+        |

+        "/" right = unaryExpr()

+        {

+	        left = ArithmeticExpression.createDivide(left, right);

+        }

+        |

+        "%" right = unaryExpr()

+        {

+	        left = ArithmeticExpression.createMod(left, right);

+        }

+

+    )*

+    {

+        return left;

+    }

+}

+

+

+Expression unaryExpr() :

+{

+    String s=null;

+    Expression left=null;

+}

+{

+	(

+		LOOKAHEAD( "+" unaryExpr() )

+	    "+" left=unaryExpr()

+	    |

+	    "-" left=unaryExpr()

+	    {

+	        left = UnaryExpression.createNegate(left);

+	    }

+	    |

+	    <NOT> left=unaryExpr()

+	    {

+		    left = UnaryExpression.createNOT( asBooleanExpression(left) );

+	    }

+	    |

+	    left = primaryExpr()

+    )

+    {

+        return left;

+    }

+

+}

+

+Expression primaryExpr() :

+{

+    Expression left=null;

+}

+{

+    (

+        left = literal()

+        |

+        left = variable()

+        |

+        "(" left = orExpression() ")"

+    )

+    {

+        return left;

+    }

+}

+

+

+

+ConstantExpression literal() :

+{

+    Token t;

+    String s;

+    ConstantExpression left=null;

+}

+{

+    (

+        (

+            s = stringLiteral()

+            {

+                left = new ConstantExpression(s);

+            }

+        )

+        |

+        (

+            t = <DECIMAL_LITERAL>

+            {

+            	left = ConstantExpression.createFromDecimal(t.image);

+            }

+        )

+        |

+        (

+            t = <HEX_LITERAL>

+            {

+            	left = ConstantExpression.createFromHex(t.image);

+            }

+        )

+        |

+        (

+            t = <OCTAL_LITERAL>

+            {

+            	left = ConstantExpression.createFromOctal(t.image);

+            }

+        )

+        |

+        (

+            t = <FLOATING_POINT_LITERAL>

+            {

+            	left = ConstantExpression.createFloat(t.image);

+            }

+        )

+        |

+        (

+            <TRUE>

+            {

+                left = ConstantExpression.TRUE;

+            }

+        )

+        |

+        (

+            <FALSE>

+            {

+                left = ConstantExpression.FALSE;

+            }

+        )

+        |

+        (

+            <NULL>

+            {

+                left = ConstantExpression.NULL;

+            }

+        )

+    )

+    {

+        return left;

+    }

+}

+

+String stringLiteral() :

+{

+    Token t;

+    StringBuffer rc = new StringBuffer();

+    boolean first=true;

+}

+{

+    t = <STRING_LITERAL>

+    {

+    	// Decode the sting value.

+    	String image = t.image;

+    	for( int i=1; i < image.length()-1; i++ ) {

+            char c = image.charAt(i);

+            if( c == (char) 0x27 )//single quote

+            {

+                i++;

+            }

+            rc.append(c);

+    	}

+	    return rc.toString();

+    }

+}

+

+PropertyExpression variable() :

+{

+    Token t;

+    StringBuffer rc = new StringBuffer();

+    PropertyExpression left=null;

+}

+{

+    (

+        t = <ID>

+        {

+            left = new PropertyExpression(t.image);

+        }

+        |

+        t = <QUOTED_ID>

+        {

+            // Decode the sting value.

+            String image = t.image;

+            for( int i=1; i < image.length()-1; i++ ) {

+                char c = image.charAt(i);

+                if( c == '"' )

+                {

+                    i++;

+                }

+                rc.append(c);

+            }

+            return new PropertyExpression(rc.toString());

+        }

+

+

+    )

+    {

+        return left;

+    }

+}

diff --git a/qpid/java/common/src/main/java/common.bnd b/qpid/java/common/src/main/java/common.bnd
index 64e80c9..9149986 100755
--- a/qpid/java/common/src/main/java/common.bnd
+++ b/qpid/java/common/src/main/java/common.bnd
@@ -17,7 +17,7 @@
 # under the License.

 #

 

-ver: 0.15.0

+ver: 0.17.0

 

 Bundle-SymbolicName: qpid-common

 Bundle-Version: ${ver}

diff --git a/qpid/java/common/src/main/java/org/apache/configuration/PropertyNameResolver.java b/qpid/java/common/src/main/java/org/apache/configuration/PropertyNameResolver.java
deleted file mode 100644
index 73ee747..0000000
--- a/qpid/java/common/src/main/java/org/apache/configuration/PropertyNameResolver.java
+++ /dev/null
@@ -1,129 +0,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.
-*
-*/
-
-package org.apache.configuration;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class PropertyNameResolver
-{
-    public static interface Accessor
-    {
-        Object get(String name);
-    }
-
-    private static Map<Class<?>,Accessor> accessors = new HashMap<Class<?>,Accessor>();
-    protected Map<String,QpidProperty> properties;
-
-    private static class BooleanAccessor implements Accessor
-    {
-        public Boolean get(String name)
-        {
-            return Boolean.getBoolean(name);
-        }
-    }
-
-    private static class IntegerAccessor implements Accessor
-    {
-        public Integer get(String name)
-        {
-            return Integer.getInteger(name);
-        }
-    }
-    
-    private static class LongAccessor implements Accessor
-    {
-        public Long get(String name)
-        {
-            return Long.getLong(name);
-        }
-    }
-    
-    private static class StringAccessor implements Accessor
-    {
-        public String get(String name)
-        {
-            return System.getProperty(name);
-        }
-    }
-
-    static
-    {
-        accessors.put(Boolean.class, new BooleanAccessor());
-        accessors.put(Integer.class, new IntegerAccessor());
-        accessors.put(String.class, new StringAccessor());
-        accessors.put(Long.class, new LongAccessor());
-    }
-    
-   public Integer getIntegerValue(String propName)
-   {
-       return properties.get(propName).get(Integer.class);
-   }
-
-   public Long getLongValue(String propName)
-   {
-       return properties.get(propName).get(Long.class);
-   }
-   
-   public String getStringValue(String propName)
-   {
-       return properties.get(propName).get(String.class);
-   }
-
-   public Boolean getBooleanValue(String propName)
-   {
-       return properties.get(propName).get(Boolean.class);
-   }
-
-   public <T> T get(String propName,Class<T> klass)
-   {
-       return properties.get(propName).get(klass);
-   }
-   
-   static class QpidProperty
-   {
-       private Object defValue;
-       private String[] names;
-
-       QpidProperty(Object defValue, String ... names)
-       {
-           this.defValue = defValue;
-           this.names = names;
-       }
-
-       <T> T get(Class<T> klass)
-       {
-           Accessor acc = accessors.get(klass);
-           for (String name : names)
-           {
-               Object obj = acc.get(name);
-               if (obj != null)
-               {
-                   return klass.cast(obj);
-               }
-           }
-
-           return klass.cast(defValue);
-       }
-   }
-
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQChannelException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQChannelException.java
index 2f6290b..44cd603 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/AMQChannelException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/AMQChannelException.java
@@ -20,7 +20,9 @@
  */
 package org.apache.qpid;
 
-import org.apache.qpid.framing.*;
+import org.apache.qpid.framing.AMQFrame;
+import org.apache.qpid.framing.MethodRegistry;
+import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.protocol.AMQConstant;
 
 /**
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionException.java
index ca9c9f9..c7a0816 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionException.java
@@ -21,7 +21,9 @@
 
 package org.apache.qpid;
 
-import org.apache.qpid.framing.*;
+import org.apache.qpid.framing.AMQFrame;
+import org.apache.qpid.framing.MethodRegistry;
+import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.protocol.AMQConstant;
 
 /**
@@ -45,7 +47,7 @@
     /** AMQP version for which exception ocurred, minor code. */
     private final byte minor;
 
-    boolean _closeConnetion;
+    private boolean _closeConnetion;
 
     public AMQConnectionException(AMQConstant errorCode, String msg, int classId, int methodId, byte major, byte minor,
         Throwable cause)
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionFailureException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionFailureException.java
index f2503e5..d9a9ee0 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionFailureException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionFailureException.java
@@ -20,10 +20,10 @@
  */
 package org.apache.qpid;
 
-import java.util.Collection;
-
 import org.apache.qpid.protocol.AMQConstant;
 
+import java.util.Collection;
+
 /**
  * AMQConnectionFailureException indicates that a connection to a broker could not be formed.
  *
@@ -36,7 +36,7 @@
  */
 public class AMQConnectionFailureException extends AMQException
 {
-    Collection<Exception> _exceptions;
+    private Collection<Exception> _exceptions;
     
 	public AMQConnectionFailureException(String message, Throwable cause)
 	{
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQStoreException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQStoreException.java
index 8389fe5..45aa36a 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/AMQStoreException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/AMQStoreException.java
@@ -20,10 +20,8 @@
  */
 package org.apache.qpid;
 
-import java.sql.SQLException;
-
 /**
- * StoreException is a specific type of internal error relating to errors in the message store, such as {@link SQLException}.
+ * StoreException is a specific type of internal error relating to errors in the message store, such as {@link java.sql.SQLException}.
  */
 public class AMQStoreException extends AMQInternalException
 {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQUnresolvedAddressException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQUnresolvedAddressException.java
index eee3e6a..82ffe58 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/AMQUnresolvedAddressException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/AMQUnresolvedAddressException.java
@@ -35,7 +35,7 @@
  */
 public class AMQUnresolvedAddressException extends AMQException
 {
-    String _broker;
+    private String _broker;
 
     public AMQUnresolvedAddressException(String message, String broker, Throwable cause)
     {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/ConsoleOutput.java b/qpid/java/common/src/main/java/org/apache/qpid/ConsoleOutput.java
deleted file mode 100644
index 00ad5cf..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/ConsoleOutput.java
+++ /dev/null
@@ -1,62 +0,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.
- *
- */
-package org.apache.qpid;
-
-import static org.apache.qpid.transport.util.Functions.str;
-
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.transport.Sender;
-
-
-/**
- * ConsoleOutput
- *
- * @author Rafael H. Schloming
- */
-
-public class ConsoleOutput implements Sender<ByteBuffer>
-{
-
-    public void send(ByteBuffer buf)
-    {
-        System.out.println(str(buf));
-    }
-
-    public void flush()
-    {
-        // pass
-    }
-
-    public void close()
-    {
-        System.out.println("CLOSED");
-    }
-
-    public void setIdleTimeout(int i)
-    {
-        // TODO Auto-generated method stub
-        
-    }
-    
-    
-
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/QpidConfig.java b/qpid/java/common/src/main/java/org/apache/qpid/QpidConfig.java
deleted file mode 100644
index b4cad44..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/QpidConfig.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package org.apache.qpid;
-/*
- * 
- * 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.
- * 
- */
-
-
-/**
- * API to configure the Security parameters of the client.
- * The user can choose to pick the config from any source 
- * and set it using this class.
- *
- */
-public class QpidConfig
-{
-    private static QpidConfig _instance = new QpidConfig();
-    
-    private SecurityMechanism[] securityMechanisms = 
-        new SecurityMechanism[]{new SecurityMechanism("PLAIN","org.apache.qpid.security.UsernamePasswordCallbackHandler"),
-                                new SecurityMechanism("CRAM_MD5","org.apache.qpid.security.UsernamePasswordCallbackHandler")};
-
-    private SaslClientFactory[] saslClientFactories =
-        new SaslClientFactory[]{new SaslClientFactory("AMQPLAIN","org.apache.qpid.security.amqplain.AmqPlainSaslClientFactory")};       
-    
-   private  QpidConfig(){}
-    
-   public static QpidConfig get()
-   {
-       return _instance;
-   }
-    
-   public void setSecurityMechanisms(SecurityMechanism... securityMechanisms)
-   {
-       this.securityMechanisms = securityMechanisms;
-   }   
-   
-   public SecurityMechanism[] getSecurityMechanisms()
-   {
-       return securityMechanisms;
-   }
-       
-   public void setSaslClientFactories(SaslClientFactory... saslClientFactories)
-   {
-       this.saslClientFactories = saslClientFactories;
-   }   
-   
-   public SaslClientFactory[] getSaslClientFactories()
-   {
-       return saslClientFactories;
-   }
-   
-   public static class SecurityMechanism
-   {
-        String type;
-        String handler;
-        
-        SecurityMechanism(String type,String handler)
-        {
-            this.type = type;
-            this.handler = handler;
-        }
-
-        public String getHandler()
-        {
-            return handler;
-        }
-
-        public String getType()
-        {
-            return type;
-        }
-   }
-   
-   public static class SaslClientFactory
-   {
-        String type;
-        String factoryClass;
-        
-        SaslClientFactory(String type,String factoryClass)
-        {
-            this.type = type;
-            this.factoryClass = factoryClass;
-        }
-
-        public String getFactoryClass()
-        {
-            return factoryClass;
-        }
-
-        public String getType()
-        {
-            return type;
-        }
-   }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/SerialException.java b/qpid/java/common/src/main/java/org/apache/qpid/SerialException.java
deleted file mode 100644
index c59a6af..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/SerialException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.qpid;
-/*
- * 
- * 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.
- * 
- */
-
-
-/**
- * This exception is used by the serial class (imp RFC 1982)
- *
- */
-public class SerialException extends ArithmeticException
-{
-    /**
-     * Constructs an <code>SerialException</code> with the specified
-     * detail message.
-     *
-     * @param message The exception message.
-     */
-    public SerialException(String message)
-    {
-        super(message);
-   }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/api/Message.java b/qpid/java/common/src/main/java/org/apache/qpid/api/Message.java
index df6f279..49c7be1 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/api/Message.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/api/Message.java
@@ -1,11 +1,11 @@
 package org.apache.qpid.api;
 
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import org.apache.qpid.transport.MessageProperties;
 import org.apache.qpid.transport.DeliveryProperties;
 import org.apache.qpid.transport.Header;
+import org.apache.qpid.transport.MessageProperties;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java
index 1d19653..ffdb7e6 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java
@@ -20,13 +20,27 @@
  */
 package org.apache.qpid.codec;
 
-import java.io.*;
-import java.nio.ByteBuffer;
-import java.util.*;
-
-import org.apache.qpid.framing.*;
+import org.apache.qpid.framing.AMQDataBlock;
+import org.apache.qpid.framing.AMQDataBlockDecoder;
+import org.apache.qpid.framing.AMQFrameDecodingException;
+import org.apache.qpid.framing.AMQMethodBodyFactory;
+import org.apache.qpid.framing.AMQProtocolVersionException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.ByteArrayDataInput;
+import org.apache.qpid.framing.EncodingUtils;
+import org.apache.qpid.framing.ProtocolInitiation;
 import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
 
+import java.io.ByteArrayInputStream;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
 /**
  * AMQDecoder delegates the decoding of AMQP either to a data block decoder, or in the case of new connections, to a
  * protocol initiation decoder. It is a cumulative decoder, which means that it can accumulate data to decode in the
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java b/qpid/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java
index 9ed915c..57cd2a1 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java
@@ -34,11 +34,13 @@
 {
     JMS_SELECTOR("x-filter-jms-selector"),
     NO_CONSUME("x-filter-no-consume"),
-    AUTO_CLOSE("x-filter-auto-close");
+    AUTO_CLOSE("x-filter-auto-close"),
+    NO_LOCAL("x-qpid-no-local");
 
     /** The identifying string for the filter type. */
     private final AMQShortString _value;
 
+
     /**
      * Creates a new filter type from its identifying string.
      *
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/common/ClientProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/common/ClientProperties.java
deleted file mode 100644
index 7371c12..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/common/ClientProperties.java
+++ /dev/null
@@ -1,52 +0,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.
- *
- *
- */
-package org.apache.qpid.common;
-
-import org.apache.qpid.framing.AMQShortString;
-
-/**
- * Specifies the available client property types that different clients can use to identify themselves with.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Specify the available client property types.
- * </table>
- */
-public enum ClientProperties
-{
-    instance("instance"),
-    product("product"),
-    version("version"),
-    platform("platform");
-
-    private final AMQShortString _amqShortString;
-
-    private ClientProperties(String name)
-    {
-        _amqShortString = new AMQShortString(name);
-    }
-
-
-    public AMQShortString toAMQShortString()
-    {
-        return _amqShortString;
-    }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/common/ServerPropertyNames.java b/qpid/java/common/src/main/java/org/apache/qpid/common/ServerPropertyNames.java
index aa262bd..dd94f82 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/common/ServerPropertyNames.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/common/ServerPropertyNames.java
@@ -26,6 +26,10 @@
  */
 public final class ServerPropertyNames
 {
+    private ServerPropertyNames()
+    {
+    }
+
     /**
      * Server property: federation tag UUID
      */
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/Accessor.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/Accessor.java
index dc5b69d..517fd18 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/Accessor.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/configuration/Accessor.java
@@ -1,4 +1,3 @@
-package org.apache.qpid.configuration;
 /*
  * 
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,12 +18,11 @@
  * under the License.
  * 
  */
-
+package org.apache.qpid.configuration;
 
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -41,7 +39,7 @@
     {
         public Boolean getBoolean(String name)
         {
-            return Boolean.getBoolean(name);
+            return System.getProperty(name) == null ? null : Boolean.getBoolean(name);
         }
         
         public Integer getInt(String name)
@@ -62,13 +60,18 @@
     
     static class MapAccessor implements Accessor
     {
-        protected Map<Object,Object> source;
+        private Map<Object,Object> source;
         
         public MapAccessor(Map<Object,Object> map)
         {
             source = map;
         }
-        
+
+        protected void setSource(Map<Object, Object> source)
+        {
+            this.source = source;
+        }
+
         public Boolean getBoolean(String name)
         {
             if (source != null && source.containsKey(name))
@@ -161,8 +164,10 @@
             {
                 inStream.close();
             }
-            source = props;
+            setSource(props);
         }
+
+
     }
     
     static class CombinedAccessor implements Accessor
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
index a36e7c2..3227bb6 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
@@ -95,6 +95,7 @@
      * synchronous operations.
      */
     public static final String QPID_SYNC_OP_TIMEOUT = "qpid.sync_op_timeout";
+    @Deprecated
     public static final String AMQJ_DEFAULT_SYNCWRITE_TIMEOUT = "amqj.default_syncwrite_timeout";
 
     /**
@@ -106,6 +107,7 @@
      * System properties to change the default value used for TCP_NODELAY
      */
     public static final String QPID_TCP_NODELAY_PROP_NAME = "qpid.tcp_nodelay";
+    @Deprecated
     public static final String AMQJ_TCP_NODELAY_PROP_NAME = "amqj.tcp_nodelay";
 
     /**
@@ -116,16 +118,54 @@
      */
     public static final String REJECT_BEHAVIOUR_PROP_NAME = "qpid.reject.behaviour";
 
-    /*
-    public static final QpidProperty<Boolean>  IGNORE_SET_CLIENTID_PROP_NAME =
-        QpidProperty.booleanProperty(false,"qpid.ignore_set_client_id","ignore_setclientID");
+    private ClientProperties()
+    {
+    }
 
-    public static final QpidProperty<Boolean> SYNC_PERSISTENT_PROP_NAME =
-        QpidProperty.booleanProperty(false,"qpid.sync_persistence","sync_persistence");
+    /**
+     * System property used to set the key manager factory algorithm.
+     *
+     * Historically, Qpid referred to this as {@value #QPID_SSL_KEY_STORE_CERT_TYPE_PROP_NAME}.
+     */
+    public static final String QPID_SSL_KEY_MANAGER_FACTORY_ALGORITHM_PROP_NAME = "qpid.ssl.KeyManagerFactory.algorithm";
+    @Deprecated
+    public static final String QPID_SSL_KEY_STORE_CERT_TYPE_PROP_NAME = "qpid.ssl.keyStoreCertType";
 
+    /**
+     * System property used to set the trust manager factory algorithm.
+     *
+     * Historically, Qpid referred to this as {@value #QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME}.
+     */
+    public static final String QPID_SSL_TRUST_MANAGER_FACTORY_ALGORITHM_PROP_NAME = "qpid.ssl.TrustManagerFactory.algorithm";
+    @Deprecated
+    public static final String QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME = "qpid.ssl.trustStoreCertType";
 
-    public static final QpidProperty<Integer> MAX_PREFETCH_PROP_NAME =
-        QpidProperty.intProperty(500,"qpid.max_prefetch","max_prefetch"); */
+    /**
+     * System property to enable allow dispatcher thread to be run as a daemon thread
+     */
+    public static final String DAEMON_DISPATCHER = "qpid.jms.daemon.dispatcher";
 
+    /**
+     * Used to name the process utilising the Qpid client, to override the default
+     * value is used in the ConnectionStartOk reply to the broker.
+     */
+    public static final String PROCESS_NAME = "qpid.client_process";
 
+    /**
+     * System property used to set the socket receive buffer size.
+     *
+     * Historically, Qpid referred to this as {@value #LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME}.
+     */
+    public static final String RECEIVE_BUFFER_SIZE_PROP_NAME  = "qpid.receive_buffer_size";
+    @Deprecated
+    public static final String LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME  = "amqj.receiveBufferSize";
+
+    /**
+     * System property used to set the socket send buffer size.
+     *
+     * Historically, Qpid referred to this as {@value #LEGACY_SEND_BUFFER_SIZE_PROP_NAME}.
+     */
+    public static final String SEND_BUFFER_SIZE_PROP_NAME  = "qpid.send_buffer_size";
+    @Deprecated
+    public static final String LEGACY_SEND_BUFFER_SIZE_PROP_NAME  = "amqj.sendBufferSize";
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java
index 73a3363..b8181e3 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java
@@ -21,7 +21,6 @@
 package org.apache.qpid.configuration;
 
 import org.apache.qpid.AMQException;
-import org.apache.qpid.protocol.AMQConstant;
 
 /**
  * Indicates a failure to parse a property expansion. See {@link PropertyUtils} for the code that does property
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyUtils.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyUtils.java
index 6e2b25f..81702ee 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyUtils.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyUtils.java
@@ -40,6 +40,10 @@
  */
 public class PropertyUtils
 {
+    private PropertyUtils()
+    {
+    }
+
     /**
      * Given a string that contains substrings of the form <code>${xxx}</code>, looks up the valuea of 'xxx' as a
      * system properties and substitutes tham back into the original string, to provide a property value expanded
@@ -66,13 +70,13 @@
         parsePropertyString(value, fragments, propertyRefs);
 
         StringBuffer sb = new StringBuffer();
-        Iterator j = propertyRefs.iterator();
+        Iterator<String> j = propertyRefs.iterator();
 
         for (String fragment : fragments)
         {
             if (fragment == null)
             {
-                String propertyName = (String) j.next();
+                String propertyName = j.next();
 
                 // try to get it from the project or keys
                 // Backward compatibility
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/QpidProperty.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/QpidProperty.java
index 9c0aaae..e098949 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/QpidProperty.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/configuration/QpidProperty.java
@@ -20,11 +20,11 @@
 
 import org.apache.qpid.configuration.Accessor.SystemPropertyAccessor;
 
-abstract class QpidProperty<T>
+public abstract class QpidProperty<T>
 {
     private T defValue;
     private String[] names;
-    protected Accessor accessor;
+    private Accessor accessor;
 
     QpidProperty(T defValue, String... names)
     {
@@ -38,7 +38,7 @@
         this.names = names;
     }
 
-    T get()
+    public T get()
     {
         for (String name : names)
         {
@@ -101,7 +101,12 @@
     {
         return new QpidStringProperty(accessor,defaultValue, names);
     }
-    
+
+    protected Accessor getAccessor()
+    {
+        return accessor;
+    }
+
     static class QpidBooleanProperty extends QpidProperty<Boolean>
     {
         QpidBooleanProperty(Boolean defValue, String... names)
@@ -117,7 +122,7 @@
         @Override
         protected Boolean getByName(String name)
         {
-            return accessor.getBoolean(name);
+            return getAccessor().getBoolean(name);
         }
     }
 
@@ -136,7 +141,7 @@
         @Override
         protected Integer getByName(String name)
         {
-            return accessor.getInt(name);
+            return getAccessor().getInt(name);
         }
     }
 
@@ -155,7 +160,7 @@
         @Override
         protected Long getByName(String name)
         {
-            return accessor.getLong(name);
+            return getAccessor().getLong(name);
         }
     }
 
@@ -174,7 +179,7 @@
         @Override
         protected String getByName(String name)
         {
-            return accessor.getString(name);
+            return getAccessor().getString(name);
         }
     }
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/dtx/XidImpl.java b/qpid/java/common/src/main/java/org/apache/qpid/dtx/XidImpl.java
index 69457ca..3590254 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/dtx/XidImpl.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/dtx/XidImpl.java
@@ -19,11 +19,13 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQInvalidArgumentException;
 
 import javax.transaction.xa.Xid;
-
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
 import java.util.Arrays;
 
 /**
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java b/qpid/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java
index 1989ade..975ec4d 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java
@@ -36,6 +36,10 @@
  */
 public class ExchangeDefaults
 {
+    private ExchangeDefaults()
+    {
+    }
+
     /** The default direct exchange, which is a special internal exchange that cannot be explicitly bound to. */
     public static final AMQShortString DEFAULT_EXCHANGE_NAME = new AMQShortString("<<default>>");
 
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/ArithmeticExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/ArithmeticExpression.java
similarity index 87%
rename from qpid/java/broker/src/main/java/org/apache/qpid/server/filter/ArithmeticExpression.java
rename to qpid/java/common/src/main/java/org/apache/qpid/filter/ArithmeticExpression.java
index 221d23e..47d970c 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/ArithmeticExpression.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/filter/ArithmeticExpression.java
@@ -15,14 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.qpid.server.filter;
+package org.apache.qpid.filter;
 //
 // Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
 //
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.queue.Filterable;
-
 /**
  * An expression which performs an operation on two expression values
  */
@@ -60,7 +57,7 @@
                         return plus((Number) lvalue, asNumber(rvalue));
                     }
 
-                    throw new RuntimeException("Cannot call plus operation on: " + lvalue + " and: " + rvalue);
+                    throw new SelectorParsingException("Cannot call plus operation on: " + lvalue + " and: " + rvalue);
                 }
 
                 public String getExpressionSymbol()
@@ -81,7 +78,7 @@
                         return minus((Number) lvalue, asNumber(rvalue));
                     }
 
-                    throw new RuntimeException("Cannot call minus operation on: " + lvalue + " and: " + rvalue);
+                    throw new SelectorParsingException("Cannot call minus operation on: " + lvalue + " and: " + rvalue);
                 }
 
                 public String getExpressionSymbol()
@@ -103,7 +100,7 @@
                         return multiply((Number) lvalue, asNumber(rvalue));
                     }
 
-                    throw new RuntimeException("Cannot call multiply operation on: " + lvalue + " and: " + rvalue);
+                    throw new SelectorParsingException("Cannot call multiply operation on: " + lvalue + " and: " + rvalue);
                 }
 
                 public String getExpressionSymbol()
@@ -125,7 +122,7 @@
                         return divide((Number) lvalue, asNumber(rvalue));
                     }
 
-                    throw new RuntimeException("Cannot call divide operation on: " + lvalue + " and: " + rvalue);
+                    throw new SelectorParsingException("Cannot call divide operation on: " + lvalue + " and: " + rvalue);
                 }
 
                 public String getExpressionSymbol()
@@ -147,7 +144,7 @@
                         return mod((Number) lvalue, asNumber(rvalue));
                     }
 
-                    throw new RuntimeException("Cannot call mod operation on: " + lvalue + " and: " + rvalue);
+                    throw new SelectorParsingException("Cannot call mod operation on: " + lvalue + " and: " + rvalue);
                 }
 
                 public String getExpressionSymbol()
@@ -244,19 +241,19 @@
         }
         else
         {
-            throw new RuntimeException("Cannot convert value: " + value + " into a number");
+            throw new SelectorParsingException("Cannot convert value: " + value + " into a number");
         }
     }
 
-    public Object evaluate(Filterable message)
+    public Object evaluate(FilterableMessage message)
     {
-        Object lvalue = left.evaluate(message);
+        Object lvalue = getLeft().evaluate(message);
         if (lvalue == null)
         {
             return null;
         }
 
-        Object rvalue = right.evaluate(message);
+        Object rvalue = getRight().evaluate(message);
         if (rvalue == null)
         {
             return null;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/BinaryExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/BinaryExpression.java
similarity index 85%
rename from qpid/java/broker/src/main/java/org/apache/qpid/server/filter/BinaryExpression.java
rename to qpid/java/common/src/main/java/org/apache/qpid/filter/BinaryExpression.java
index 024257b..6467bbb 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/BinaryExpression.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/filter/BinaryExpression.java
@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.qpid.server.filter;
+package org.apache.qpid.filter;
 //
 // Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
 //
@@ -25,8 +25,8 @@
  */
 public abstract class BinaryExpression implements Expression
 {
-    protected Expression left;
-    protected Expression right;
+    private final Expression left;
+    private final Expression right;
 
     public BinaryExpression(Expression left, Expression right)
     {
@@ -87,20 +87,4 @@
      */
     public abstract String getExpressionSymbol();
 
-    /**
-     * @param expression
-     */
-    public void setRight(Expression expression)
-    {
-        right = expression;
-    }
-
-    /**
-     * @param expression
-     */
-    public void setLeft(Expression expression)
-    {
-        left = expression;
-    }
-
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/BooleanExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/BooleanExpression.java
similarity index 89%
rename from qpid/java/broker/src/main/java/org/apache/qpid/server/filter/BooleanExpression.java
rename to qpid/java/common/src/main/java/org/apache/qpid/filter/BooleanExpression.java
index 06e8664..13e1604 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/BooleanExpression.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/filter/BooleanExpression.java
@@ -15,13 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.qpid.server.filter;
+package org.apache.qpid.filter;
 //
 // Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
 //
 
-import org.apache.qpid.server.queue.Filterable;
-
 /**
  * A BooleanExpression is an expression that always
  * produces a Boolean result.
@@ -33,6 +31,6 @@
      * @param message
      * @return true if the expression evaluates to Boolean.TRUE.
      */
-    public boolean matches(Filterable message);
+    public boolean matches(FilterableMessage message);
 
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/ComparisonExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/ComparisonExpression.java
similarity index 91%
rename from qpid/java/broker/src/main/java/org/apache/qpid/server/filter/ComparisonExpression.java
rename to qpid/java/common/src/main/java/org/apache/qpid/filter/ComparisonExpression.java
index aad9d41..2cfb97d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/ComparisonExpression.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/filter/ComparisonExpression.java
@@ -18,7 +18,7 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.filter;
+package org.apache.qpid.filter;
 //
 // Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
 //
@@ -27,8 +27,6 @@
 import java.util.List;
 import java.util.regex.Pattern;
 
-import org.apache.qpid.server.queue.Filterable;
-
 /**
  * A filter performing a comparison of two objects
  */
@@ -74,7 +72,7 @@
     static class LikeExpression extends UnaryExpression implements BooleanExpression
     {
 
-        Pattern likePattern;
+        private Pattern likePattern;
 
         /**
          * @param right
@@ -136,7 +134,7 @@
         /**
          *  org.apache.activemq.filter.Expression#evaluate(MessageEvaluationContext)
          */
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
 
             Object rv = this.getRight().evaluate(message);
@@ -150,13 +148,12 @@
             {
                 return
                     Boolean.FALSE;
-                    // throw new RuntimeException("LIKE can only operate on String identifiers.  LIKE attemped on: '" + rv.getClass());
             }
 
             return likePattern.matcher((String) rv).matches() ? Boolean.TRUE : Boolean.FALSE;
         }
 
-        public boolean matches(Filterable message)
+        public boolean matches(FilterableMessage message)
         {
             Object object = evaluate(message);
 
@@ -168,8 +165,8 @@
     {
         if ((escape != null) && (escape.length() != 1))
         {
-            throw new RuntimeException(
-                "The ESCAPE string litteral is invalid.  It can only be one character.  Litteral used: " + escape);
+            throw new SelectorParsingException(
+                "The ESCAPE string literal is invalid.  It can only be one character.  Litteral used: " + escape);
         }
 
         int c = -1;
@@ -191,7 +188,7 @@
 
         if (!(left instanceof PropertyExpression))
         {
-            throw new RuntimeException("Expected a property for In expression, got: " + left);
+            throw new SelectorParsingException("Expected a property for In expression, got: " + left);
         }
 
         return UnaryExpression.createInExpression((PropertyExpression) left, elements, false);
@@ -203,7 +200,7 @@
 
         if (!(left instanceof PropertyExpression))
         {
-            throw new RuntimeException("Expected a property for In expression, got: " + left);
+            throw new SelectorParsingException("Expected a property for In expression, got: " + left);
         }
 
         return UnaryExpression.createInExpression((PropertyExpression) left, elements, true);
@@ -334,18 +331,18 @@
             }
 
             // Else it's boolean or a String..
-            throw new RuntimeException("Value '" + expr + "' cannot be compared.");
+            throw new SelectorParsingException("Value '" + expr + "' cannot be compared.");
         }
 
         if (expr instanceof BooleanExpression)
         {
-            throw new RuntimeException("Value '" + expr + "' cannot be compared.");
+            throw new SelectorParsingException("Value '" + expr + "' cannot be compared.");
         }
     }
 
     /**
      * Validates that the expression can be used in == or <> expression.
-     * Cannot not be NULL TRUE or FALSE litterals.
+     * Cannot not be NULL TRUE or FALSE literals.
      *
      * @param expr
      */
@@ -356,7 +353,7 @@
             Object value = ((ConstantExpression) expr).getValue();
             if (value == null)
             {
-                throw new RuntimeException("'" + expr + "' cannot be compared.");
+                throw new SelectorParsingException("'" + expr + "' cannot be compared.");
             }
         }
     }
@@ -372,7 +369,7 @@
         {
             if ((left instanceof BooleanExpression) && !(right instanceof BooleanExpression))
             {
-                throw new RuntimeException("'" + left + "' cannot be compared with '" + right + "'");
+                throw new SelectorParsingException("'" + left + "' cannot be compared with '" + right + "'");
             }
         }
     }
@@ -386,15 +383,15 @@
         super(left, right);
     }
 
-    public Object evaluate(Filterable message)
+    public Object evaluate(FilterableMessage message)
     {
-        Comparable lv = (Comparable) left.evaluate(message);
+        Comparable lv = (Comparable) getLeft().evaluate(message);
         if (lv == null)
         {
             return null;
         }
 
-        Comparable rv = (Comparable) right.evaluate(message);
+        Comparable rv = (Comparable) getRight().evaluate(message);
         if (rv == null)
         {
             return null;
@@ -548,7 +545,7 @@
 
     protected abstract boolean asBoolean(int answer);
 
-    public boolean matches(Filterable message)
+    public boolean matches(FilterableMessage message)
     {
         Object object = evaluate(message);
 
@@ -562,10 +559,10 @@
             super(left, right);
         }
 
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
-            Object lv = left.evaluate(message);
-            Object rv = right.evaluate(message);
+            Object lv = getLeft().evaluate(message);
+            Object rv = getRight().evaluate(message);
 
             // Iff one of the values is null
             if ((lv == null) ^ (rv == null))
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/ConstantExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/ConstantExpression.java
similarity index 96%
rename from qpid/java/broker/src/main/java/org/apache/qpid/server/filter/ConstantExpression.java
rename to qpid/java/common/src/main/java/org/apache/qpid/filter/ConstantExpression.java
index 5cc9ca8..20c9f14 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/ConstantExpression.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/filter/ConstantExpression.java
@@ -18,15 +18,13 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.filter;
+package org.apache.qpid.filter;
 //
 // Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
 //
 
 import java.math.BigDecimal;
 
-import org.apache.qpid.server.queue.Filterable;
-
 /**
  * Represents a constant expression
  */
@@ -40,7 +38,7 @@
             super(value);
         }
 
-        public boolean matches(Filterable message)
+        public boolean matches(FilterableMessage message)
         {
             Object object = evaluate(message);
 
@@ -119,7 +117,7 @@
         this.value = value;
     }
 
-    public Object evaluate(Filterable message)
+    public Object evaluate(FilterableMessage message)
     {
         return value;
     }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/Expression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/Expression.java
similarity index 88%
rename from qpid/java/broker/src/main/java/org/apache/qpid/server/filter/Expression.java
rename to qpid/java/common/src/main/java/org/apache/qpid/filter/Expression.java
index 97e9915..1030c7b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/Expression.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/filter/Expression.java
@@ -15,13 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.qpid.server.filter;
+package org.apache.qpid.filter;
 //
 // Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
 //
 
-import org.apache.qpid.server.queue.Filterable;
-
 /**
  * Represents an expression
  */
@@ -31,6 +29,6 @@
     /**
      * @return the value of this expression
      */
-    public Object evaluate(Filterable message);
+    public Object evaluate(FilterableMessage message);
 
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/Expression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/FilterableMessage.java
similarity index 66%
copy from qpid/java/broker/src/main/java/org/apache/qpid/server/filter/Expression.java
copy to qpid/java/common/src/main/java/org/apache/qpid/filter/FilterableMessage.java
index 97e9915..b5b00ae 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/Expression.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/filter/FilterableMessage.java
@@ -1,36 +1,41 @@
+package org.apache.qpid.filter;
+
 /**
- *
  * 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
- *
+ * <p/>
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p/>
  * 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.server.filter;
-//
-// Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
-//
-
-import org.apache.qpid.server.queue.Filterable;
-
-/**
- * Represents an expression
- */
-public interface Expression
+public interface FilterableMessage
 {
 
-    /**
-     * @return the value of this expression
-     */
-    public Object evaluate(Filterable message);
+    boolean isPersistent();
 
+    boolean isRedelivered();
+
+    Object getHeader(String name);
+
+    String getReplyTo();
+
+    String getType();
+
+    byte getPriority();
+
+    String getMessageId();
+
+    long getTimestamp();
+
+    String getCorrelationId();
+
+    long getExpiration();
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/LogicExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/LogicExpression.java
similarity index 83%
rename from qpid/java/broker/src/main/java/org/apache/qpid/server/filter/LogicExpression.java
rename to qpid/java/common/src/main/java/org/apache/qpid/filter/LogicExpression.java
index fdba184..f8ec19d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/LogicExpression.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/filter/LogicExpression.java
@@ -15,13 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.qpid.server.filter;
+package org.apache.qpid.filter;
 //
 // Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
 //
 
-import org.apache.qpid.server.queue.Filterable;
-
 /**
  * A filter performing a comparison of two objects
  */
@@ -47,9 +45,9 @@
         super(left, right);
     }
 
-    public abstract Object evaluate(Filterable message);
+    public abstract Object evaluate(FilterableMessage message);
 
-    public boolean matches(Filterable message)
+    public boolean matches(FilterableMessage message)
     {
         Object object = evaluate(message);
 
@@ -63,17 +61,17 @@
             super(lvalue, rvalue);
         }
 
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
 
-            Boolean lv = (Boolean) left.evaluate(message);
+            Boolean lv = (Boolean) getLeft().evaluate(message);
             // Can we do an OR shortcut??
             if ((lv != null) && lv.booleanValue())
             {
                 return Boolean.TRUE;
             }
 
-            Boolean rv = (Boolean) right.evaluate(message);
+            Boolean rv = (Boolean) getRight().evaluate(message);
 
             return (rv == null) ? null : rv;
         }
@@ -91,10 +89,10 @@
             super(lvalue, rvalue);
         }
 
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
 
-            Boolean lv = (Boolean) left.evaluate(message);
+            Boolean lv = (Boolean) getLeft().evaluate(message);
 
             // Can we do an AND shortcut??
             if (lv == null)
@@ -107,7 +105,7 @@
                 return Boolean.FALSE;
             }
 
-            Boolean rv = (Boolean) right.evaluate(message);
+            Boolean rv = (Boolean) getRight().evaluate(message);
 
             return (rv == null) ? null : rv;
         }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/PropertyExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/PropertyExpression.java
similarity index 77%
rename from qpid/java/broker/src/main/java/org/apache/qpid/server/filter/PropertyExpression.java
rename to qpid/java/common/src/main/java/org/apache/qpid/filter/PropertyExpression.java
index 9848f90..4fb9c0e 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/PropertyExpression.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/filter/PropertyExpression.java
@@ -18,19 +18,17 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.filter;
+package org.apache.qpid.filter;
 //
 // Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
 //
 
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.util.HashMap;
 
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.CommonContentHeaderProperties;
-import org.apache.qpid.server.queue.Filterable;
-
 /**
  * Represents a property  expression
  */
@@ -41,14 +39,14 @@
 
     private static final int DEFAULT_PRIORITY = 4;
 
-    private static final Logger _logger = org.apache.log4j.Logger.getLogger(PropertyExpression.class);
+    private static final Logger _logger = LoggerFactory.getLogger(PropertyExpression.class);
 
     private static final HashMap<String, Expression> JMS_PROPERTY_EXPRESSIONS = new HashMap<String, Expression>();
 
     {
         JMS_PROPERTY_EXPRESSIONS.put("JMSDestination", new Expression()
                                      {
-                                         public Object evaluate(Filterable message)
+                                         public Object evaluate(FilterableMessage message)
                                          {
                                              //TODO
                                              return null;
@@ -74,7 +72,7 @@
 
         JMS_PROPERTY_EXPRESSIONS.put("JMSRedelivered", new Expression()
                                      {
-                                         public Object evaluate(Filterable message)
+                                         public Object evaluate(FilterableMessage message)
                                          {
                                              return message.isRedelivered();
                                          }
@@ -95,10 +93,10 @@
 
         
 
-        jmsPropertyExpression = (Expression) JMS_PROPERTY_EXPRESSIONS.get(name);
+        jmsPropertyExpression = JMS_PROPERTY_EXPRESSIONS.get(name);
     }
 
-    public Object evaluate(Filterable message)
+    public Object evaluate(FilterableMessage message)
     {
 
         if (jmsPropertyExpression != null)
@@ -107,7 +105,7 @@
         }
         else
         {
-            return message.getMessageHeader().getHeader(name);
+            return message.getHeader(name);
         }
     }
 
@@ -149,9 +147,9 @@
 
     private static class ReplyToExpression implements Expression
     {
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
-            String replyTo = message.getMessageHeader().getReplyTo();
+            String replyTo = message.getReplyTo();
             return replyTo;
         }
 
@@ -159,10 +157,10 @@
 
     private static class TypeExpression implements Expression
     {
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
 
-                String type = message.getMessageHeader().getType();
+                String type = message.getType();
                 return type;
 
         }
@@ -170,7 +168,7 @@
 
     private static class DeliveryModeExpression implements Expression
     {
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
                 JMSDeliveryMode mode = message.isPersistent() ? JMSDeliveryMode.PERSISTENT :
                                                                 JMSDeliveryMode.NON_PERSISTENT;
@@ -185,19 +183,19 @@
 
     private static class PriorityExpression implements Expression
     {
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
-            byte priority = message.getMessageHeader().getPriority();
+            byte priority = message.getPriority();
             return (int) priority;
         }
     }
 
     private static class MessageIDExpression implements Expression
     {
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
 
-            String messageId = message.getMessageHeader().getMessageId();
+            String messageId = message.getMessageId();
 
             return messageId;
 
@@ -206,19 +204,19 @@
 
     private static class TimestampExpression implements Expression
     {
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
-            long timestamp = message.getMessageHeader().getTimestamp();
+            long timestamp = message.getTimestamp();
             return timestamp;
         }
     }
 
     private static class CorrelationIdExpression implements Expression
     {
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
 
-            String correlationId = message.getMessageHeader().getCorrelationId();
+            String correlationId = message.getCorrelationId();
 
             return correlationId;
         }
@@ -226,9 +224,9 @@
 
     private static class ExpirationExpression implements Expression
     {
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
-            long expiration = message.getMessageHeader().getExpiration();
+            long expiration = message.getExpiration();
             return expiration;
 
         }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/Expression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/SelectorParsingException.java
similarity index 66%
copy from qpid/java/broker/src/main/java/org/apache/qpid/server/filter/Expression.java
copy to qpid/java/common/src/main/java/org/apache/qpid/filter/SelectorParsingException.java
index 97e9915..f08b3df 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/Expression.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/filter/SelectorParsingException.java
@@ -1,36 +1,36 @@
+package org.apache.qpid.filter;
+
 /**
- *
  * 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
- *
+ * <p/>
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p/>
  * 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.server.filter;
-//
-// Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
-//
-
-import org.apache.qpid.server.queue.Filterable;
-
-/**
- * Represents an expression
- */
-public interface Expression
+public class SelectorParsingException extends RuntimeException
 {
+    public SelectorParsingException(String s)
+    {
+        super(s);
+    }
 
-    /**
-     * @return the value of this expression
-     */
-    public Object evaluate(Filterable message);
+    public SelectorParsingException(String message, Throwable cause)
+    {
+        super(message, cause);
+    }
+
+    public SelectorParsingException(Throwable cause)
+    {
+        super(cause);
+    }
 
 }
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/UnaryExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/UnaryExpression.java
similarity index 81%
rename from qpid/java/broker/src/main/java/org/apache/qpid/server/filter/UnaryExpression.java
rename to qpid/java/common/src/main/java/org/apache/qpid/filter/UnaryExpression.java
index 557af95..b80b898 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/UnaryExpression.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/filter/UnaryExpression.java
@@ -18,7 +18,7 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.filter;
+package org.apache.qpid.filter;
 //
 // Based on like named file from r450141 of the Apache ActiveMQ project <http://www.activemq.org/site/home.html>
 //
@@ -26,12 +26,8 @@
 import java.math.BigDecimal;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.queue.Filterable;
-
 /**
  * An expression which performs an operation on two expression values
  */
@@ -39,7 +35,7 @@
 {
 
     private static final BigDecimal BD_LONG_MIN_VALUE = BigDecimal.valueOf(Long.MIN_VALUE);
-    protected Expression right;
+    private Expression right;
 
     public static Expression createNegate(Expression left)
     {
@@ -76,31 +72,20 @@
             super(left);
         }
 
-        public boolean matches(Filterable message)
+        public boolean matches(FilterableMessage message)
         {
             Object object = evaluate(message);
 
             return (object != null) && (object == Boolean.TRUE);
         }
     }
-    ;
 
-    public static<E extends Exception> BooleanExpression createNOT(BooleanExpression left)
+    public static BooleanExpression createNOT(BooleanExpression left)
     {
         return new NotExpression(left);
     }
 
-    public static BooleanExpression createXPath(final String xpath)
-    {
-        return new XPathExpression(xpath);
-    }
-
-    public static BooleanExpression createXQuery(final String xpath)
-    {
-        return new XQueryExpression(xpath);
-    }
-
-    public static<E extends Exception> BooleanExpression createBooleanCast(Expression left)
+    public static BooleanExpression createBooleanCast(Expression left)
     {
         return new BooleanCastExpression(left);
     }
@@ -142,7 +127,7 @@
         }
         else
         {
-            throw new RuntimeException("Don't know how to negate: " + left);
+            throw new SelectorParsingException("Don't know how to negate: " + left);
         }
     }
 
@@ -156,11 +141,6 @@
         return right;
     }
 
-    public void setRight(Expression expression)
-    {
-        right = expression;
-    }
-
     /**
      * @see java.lang.Object#toString()
      */
@@ -193,7 +173,7 @@
      * Returns the symbol that represents this binary expression.  For example, addition is
      * represented by "+"
      *
-     * @return
+     * @return symbol
      */
     public abstract String getExpressionSymbol();
 
@@ -204,9 +184,9 @@
             super(left);
         }
 
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
-            Object rvalue = right.evaluate(message);
+            Object rvalue = getRight().evaluate(message);
             if (rvalue == null)
             {
                 return null;
@@ -238,10 +218,10 @@
             _not = not;
         }
 
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
 
-            Object rvalue = right.evaluate(message);
+            Object rvalue = getRight().evaluate(message);
             if (rvalue == null)
             {
                 return null;
@@ -265,16 +245,14 @@
 
         public String toString()
         {
-            StringBuffer answer = new StringBuffer();
-            answer.append(right);
+            StringBuilder answer = new StringBuilder(String.valueOf(getRight()));
             answer.append(" ");
             answer.append(getExpressionSymbol());
             answer.append(" ( ");
 
             int count = 0;
-            for (Iterator i = _inList.iterator(); i.hasNext();)
+            for (Object o : _inList)
             {
-                Object o = (Object) i.next();
                 if (count != 0)
                 {
                     answer.append(", ");
@@ -309,15 +287,15 @@
             super(left);
         }
 
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
-            Boolean lvalue = (Boolean) right.evaluate(message);
+            Boolean lvalue = (Boolean) getRight().evaluate(message);
             if (lvalue == null)
             {
                 return null;
             }
 
-            return lvalue.booleanValue() ? Boolean.FALSE : Boolean.TRUE;
+            return lvalue ? Boolean.FALSE : Boolean.TRUE;
         }
 
         public String getExpressionSymbol()
@@ -333,9 +311,9 @@
             super(left);
         }
 
-        public Object evaluate(Filterable message)
+        public Object evaluate(FilterableMessage message)
         {
-            Object rvalue = right.evaluate(message);
+            Object rvalue = getRight().evaluate(message);
             if (rvalue == null)
             {
                 return null;
@@ -346,12 +324,12 @@
                 return Boolean.FALSE;
             }
 
-            return ((Boolean) rvalue).booleanValue() ? Boolean.TRUE : Boolean.FALSE;
+            return ((Boolean) rvalue) ? Boolean.TRUE : Boolean.FALSE;
         }
 
         public String toString()
         {
-            return right.toString();
+            return getRight().toString();
         }
 
         public String getExpressionSymbol()
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java
index 363d9f1..cb0c78e 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java
@@ -20,12 +20,11 @@
  */
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
 import org.apache.qpid.AMQException;
+import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
+
+import java.io.DataOutput;
+import java.io.IOException;
 
 public interface AMQBody
 {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlock.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlock.java
index e77e594..fd42084 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlock.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlock.java
@@ -20,9 +20,7 @@
  */
 package org.apache.qpid.framing;
 
-import java.io.DataInputStream;
 import java.io.DataOutput;
-import java.io.DataOutputStream;
 import java.io.IOException;
 
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java
index b6f2fb1..9d5e654 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.framing;
 
-import org.apache.qpid.codec.MarkableDataInput;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.DataInputStream;
+import org.apache.qpid.codec.MarkableDataInput;
+
 import java.io.IOException;
 
 public class AMQDataBlockDecoder
@@ -39,7 +39,7 @@
         _bodiesSupported[HeartbeatBody.TYPE] = new HeartbeatBodyFactory();
     }
 
-    Logger _logger = LoggerFactory.getLogger(AMQDataBlockDecoder.class);
+    private Logger _logger = LoggerFactory.getLogger(AMQDataBlockDecoder.class);
 
     public AMQDataBlockDecoder()
     { }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java
index 9b5699e..238f28e 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java
@@ -22,8 +22,8 @@
 
 import org.apache.qpid.codec.MarkableDataInput;
 
-import java.io.*;
 import java.io.DataOutput;
+import java.io.IOException;
 
 public class AMQFrame extends AMQDataBlock implements EncodableAMQDataBlock
 {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java
index 2170ebf..966a036 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java
@@ -26,7 +26,6 @@
 import org.apache.qpid.protocol.AMQConstant;
 
 import java.io.DataOutput;
-import java.io.DataOutputStream;
 import java.io.IOException;
 
 public interface AMQMethodBody extends AMQBody
@@ -53,10 +52,6 @@
 
     public void writePayload(DataOutput buffer) throws IOException;
 
-    //public abstract void populateMethodBodyFromBuffer(ByteBuffer buffer) throws AMQFrameDecodingException;
-
-    //public void populateFromBuffer(ByteBuffer buffer, long size) throws AMQFrameDecodingException;
-
     public AMQFrame generateFrame(int channelId);
 
     public String toString();
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java
index ec6d662..7fe293b 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java
@@ -20,14 +20,12 @@
  */
 package org.apache.qpid.framing;
 
-import org.apache.qpid.codec.MarkableDataInput;
-import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.DataInput;
-import java.io.DataInputStream;
+import org.apache.qpid.codec.MarkableDataInput;
+import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
+
 import java.io.IOException;
 
 public class AMQMethodBodyFactory implements BodyFactory
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
index 4ff7827..85870e6 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
@@ -25,11 +25,14 @@
 import org.slf4j.LoggerFactory;
 
 import java.io.DataInput;
-import java.io.DataInputStream;
 import java.io.DataOutput;
 import java.io.IOException;
-import java.util.*;
 import java.lang.ref.WeakReference;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
 
 /**
  * A short string is a representation of an AMQ Short String
@@ -318,7 +321,6 @@
     {
 
         final int size = length();
-        //buffer.setAutoExpand(true);
         buffer.writeByte(size);
         buffer.write(_data, _offset, size);
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
index a07fd78..94a7d12 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
@@ -27,6 +27,10 @@
 {
     public static final Map<Byte, AMQType> _reverseTypeMap = new HashMap<Byte, AMQType>();
 
+    private AMQTypeMap()
+    {
+    }
+
     static
     {
         for(AMQType type : AMQType.values())
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java
index f64164c..c4dc86b 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java
@@ -20,10 +20,12 @@
  */
 package org.apache.qpid.framing;
 
-import java.io.*;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.Map;
-import java.math.BigDecimal;
 
 /**
  * AMQTypedValue combines together a native Java Object value, and an {@link AMQType}, as a fully typed AMQP parameter
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
index 2739f7d..eb52815 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
@@ -20,14 +20,13 @@
  */
 package org.apache.qpid.framing;
 
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
 public class BasicContentHeaderProperties implements CommonContentHeaderProperties
 {
     //persistent & non-persistent constants, values as per JMS DeliveryMode
@@ -89,7 +88,7 @@
 
     public int getPropertyListSize()
     {
-        if(_encodedForm != null && (_headers == null || _headers.isClean()))
+        if(useEncodedForm())
         {
             return _encodedForm.length;
         }
@@ -190,7 +189,7 @@
 
     public void writePropertyListPayload(DataOutput buffer) throws IOException
     {
-        if(_encodedForm != null && (_headers == null || !_headers.isClean()))
+        if(useEncodedForm())
         {
             buffer.write(_encodedForm);
         }
@@ -295,85 +294,83 @@
 
     private void decode(ByteArrayDataInput buffer) throws IOException, AMQFrameDecodingException
     {
-        // ByteBuffer buffer = ByteBuffer.wrap(_encodedForm);
+        int headersOffset = 0;
 
-            int headersOffset = 0;
+        if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0)
+        {
+            _contentType = buffer.readAMQShortString();
+            headersOffset += EncodingUtils.encodedShortStringLength(_contentType);
+        }
 
-            if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0)
-            {
-                _contentType = buffer.readAMQShortString();
-                headersOffset += EncodingUtils.encodedShortStringLength(_contentType);
-            }
+        if ((_propertyFlags & ENCODING_MASK) != 0)
+        {
+            _encoding = buffer.readAMQShortString();
+            headersOffset += EncodingUtils.encodedShortStringLength(_encoding);
+        }
 
-            if ((_propertyFlags & ENCODING_MASK) != 0)
-            {
-                _encoding = buffer.readAMQShortString();
-                headersOffset += EncodingUtils.encodedShortStringLength(_encoding);
-            }
+        if ((_propertyFlags & HEADERS_MASK) != 0)
+        {
+            long length = EncodingUtils.readUnsignedInteger(buffer);
 
-            if ((_propertyFlags & HEADERS_MASK) != 0)
-            {
-                long length = EncodingUtils.readUnsignedInteger(buffer);
+            _headers = new FieldTable(_encodedForm, headersOffset+4, (int)length);
 
-                _headers = new FieldTable(_encodedForm, headersOffset+4, (int)length);
+            buffer.skipBytes((int)length);
+        }
 
-                buffer.skipBytes((int)length);
-            }
+        if ((_propertyFlags & DELIVERY_MODE_MASK) != 0)
+        {
+            _deliveryMode = buffer.readByte();
+        }
 
-            if ((_propertyFlags & DELIVERY_MODE_MASK) != 0)
-            {
-                _deliveryMode = buffer.readByte();
-            }
+        if ((_propertyFlags & PRIORITY_MASK) != 0)
+        {
+            _priority = buffer.readByte();
+        }
 
-            if ((_propertyFlags & PRIORITY_MASK) != 0)
-            {
-                _priority = buffer.readByte();
-            }
+        if ((_propertyFlags & CORRELATION_ID_MASK) != 0)
+        {
+            _correlationId = buffer.readAMQShortString();
+        }
 
-            if ((_propertyFlags & CORRELATION_ID_MASK) != 0)
-            {
-                _correlationId = buffer.readAMQShortString();
-            }
+        if ((_propertyFlags & REPLY_TO_MASK) != 0)
+        {
+            _replyTo = buffer.readAMQShortString();
+        }
 
-            if ((_propertyFlags & REPLY_TO_MASK) != 0)
-            {
-                _replyTo = buffer.readAMQShortString();
-            }
+        if ((_propertyFlags & EXPIRATION_MASK) != 0)
+        {
+            _expiration = EncodingUtils.readLongAsShortString(buffer);
+        }
 
-            if ((_propertyFlags & EXPIRATION_MASK) != 0)
-            {
-                _expiration = EncodingUtils.readLongAsShortString(buffer);
-            }
+        if ((_propertyFlags & MESSAGE_ID_MASK) != 0)
+        {
+            _messageId = buffer.readAMQShortString();
+        }
 
-            if ((_propertyFlags & MESSAGE_ID_MASK) != 0)
-            {
-                _messageId = buffer.readAMQShortString();
-            }
+        if ((_propertyFlags & TIMESTAMP_MASK) != 0)
+        {
+            _timestamp = EncodingUtils.readTimestamp(buffer);
+        }
 
-            if ((_propertyFlags & TIMESTAMP_MASK) != 0)
-            {
-                _timestamp = EncodingUtils.readTimestamp(buffer);
-            }
+        if ((_propertyFlags & TYPE_MASK) != 0)
+        {
+            _type = buffer.readAMQShortString();
+        }
 
-            if ((_propertyFlags & TYPE_MASK) != 0)
-            {
-                _type = buffer.readAMQShortString();
-            }
+        if ((_propertyFlags & USER_ID_MASK) != 0)
+        {
+            _userId = buffer.readAMQShortString();
+        }
 
-            if ((_propertyFlags & USER_ID_MASK) != 0)
-            {
-                _userId = buffer.readAMQShortString();
-            }
+        if ((_propertyFlags & APPLICATION_ID_MASK) != 0)
+        {
+            _appId = buffer.readAMQShortString();
+        }
 
-            if ((_propertyFlags & APPLICATION_ID_MASK) != 0)
-            {
-                _appId = buffer.readAMQShortString();
-            }
-
-            if ((_propertyFlags & CLUSTER_ID_MASK) != 0)
-            {
-                _clusterId = buffer.readAMQShortString();
-            }
+        if ((_propertyFlags & CLUSTER_ID_MASK) != 0)
+        {
+            _clusterId = buffer.readAMQShortString();
+        }
 
 
     }
@@ -655,4 +652,10 @@
             + _expiration + ",JMSPriority = " + _priority + ",JMSTimestamp = " + _timestamp + ",JMSType = " + _type;
     }
 
+    private boolean useEncodedForm()
+    {
+        return _encodedForm != null && (_headers == null || _headers.isClean());
+    }
+
+
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ByteArrayDataInput.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ByteArrayDataInput.java
index 6561856..196ab42 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ByteArrayDataInput.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/ByteArrayDataInput.java
@@ -2,8 +2,6 @@
 
 import org.apache.qpid.codec.MarkableDataInput;
 
-import java.io.IOException;
-
 public class ByteArrayDataInput implements ExtendedDataInput, MarkableDataInput
 {
     private byte[] _data;
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java
index 541d104..6d6ec70 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java
@@ -20,20 +20,20 @@
  */
 package org.apache.qpid.framing;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
+
 import java.io.DataInput;
 import java.io.DataInputStream;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
-import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
-import org.apache.qpid.AMQException;
-
 public class ContentBody implements AMQBody
 {
     public static final byte TYPE = 3;
 
-    public byte[] _payload;
+    private byte[] _payload;
 
     public ContentBody()
     {
@@ -42,7 +42,7 @@
     public ContentBody(DataInput buffer, long size) throws AMQFrameDecodingException, IOException
     {
         _payload = new byte[(int)size];
-        buffer.readFully(_payload);
+        buffer.readFully(getPayload());
     }
 
 
@@ -58,12 +58,12 @@
 
     public int getSize()
     {
-        return _payload == null ? 0 : _payload.length;
+        return getPayload() == null ? 0 : getPayload().length;
     }
 
     public void writePayload(DataOutput buffer) throws IOException
     {
-        buffer.write(_payload);
+        buffer.write(getPayload());
     }
 
     public void handle(final int channelId, final AMQVersionAwareProtocolSession session)
@@ -77,7 +77,7 @@
         if (size > 0)
         {
             _payload = new byte[(int)size];
-            buffer.read(_payload);
+            buffer.read(getPayload());
         }
 
     }
@@ -86,6 +86,11 @@
     {
     }
 
+    public byte[] getPayload()
+    {
+        return _payload;
+    }
+
     private static class BufferContentBody implements AMQBody
     {
         private final int _length;
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBodyFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBodyFactory.java
index de2ffe9..10df105 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBodyFactory.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBodyFactory.java
@@ -20,12 +20,13 @@
  */
 package org.apache.qpid.framing;
 
-import java.io.IOException;
-
-import org.apache.qpid.codec.MarkableDataInput;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.codec.MarkableDataInput;
+
+import java.io.IOException;
+
 public class ContentBodyFactory implements BodyFactory
 {
     private static final Logger _log = LoggerFactory.getLogger(AMQMethodBodyFactory.class);
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java
index 8a2ad53..f6fa89a 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java
@@ -20,24 +20,23 @@
  */
 package org.apache.qpid.framing;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
+
 import java.io.DataInput;
 import java.io.DataInputStream;
 import java.io.DataOutput;
 import java.io.IOException;
 
-import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
-import org.apache.qpid.AMQException;
-
 public class ContentHeaderBody implements AMQBody
 {
     public static final byte TYPE = 2;
 
-    public int classId;
+    private int classId;
 
-    public int weight;
+    private int weight;
 
-    /** unsigned long but java can't handle that anyway when allocating byte array */
-    public long bodySize;
+    private long bodySize;
 
     /** must never be null */
     private ContentHeaderProperties properties;
@@ -76,17 +75,6 @@
         return TYPE;
     }
 
-    protected void populateFromBuffer(DataInputStream buffer, long size)
-        throws AMQFrameDecodingException, AMQProtocolVersionException, IOException
-    {
-        classId = buffer.readUnsignedShort();
-        weight = buffer.readUnsignedShort();
-        bodySize = buffer.readLong();
-        int propertyFlags = buffer.readUnsignedShort();
-        ContentHeaderPropertiesFactory factory = ContentHeaderPropertiesFactory.getInstance();
-        properties = factory.createContentHeaderProperties(classId, propertyFlags, buffer, (int)size - 14);
-    }
-
     /**
      * Helper method that is used currently by the persistence layer (by BDB at the moment).
      * @param buffer
@@ -153,4 +141,25 @@
                 ", properties=" + properties +
                 '}';
     }
+
+    public int getClassId()
+    {
+        return classId;
+    }
+
+    public int getWeight()
+    {
+        return weight;
+    }
+
+    /** unsigned long but java can't handle that anyway when allocating byte array */
+    public long getBodySize()
+    {
+        return bodySize;
+    }
+
+    public void setBodySize(long bodySize)
+    {
+        this.bodySize = bodySize;
+    }
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBodyFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBodyFactory.java
index c3e4c69..83a5211 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBodyFactory.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBodyFactory.java
@@ -20,12 +20,13 @@
  */
 package org.apache.qpid.framing;
 
-import java.io.IOException;
-
-import org.apache.qpid.codec.MarkableDataInput;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.codec.MarkableDataInput;
+
+import java.io.IOException;
+
 public class ContentHeaderBodyFactory implements BodyFactory
 {
     private static final Logger _log = LoggerFactory.getLogger(AMQMethodBodyFactory.class);
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java
index ea8358a..2e1b988 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java
@@ -21,7 +21,6 @@
 package org.apache.qpid.framing;
 
 import java.io.DataInput;
-import java.io.DataInputStream;
 import java.io.DataOutput;
 import java.io.IOException;
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java
index 48bd528..ff97c0b 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java
@@ -20,12 +20,11 @@
  */
 package org.apache.qpid.framing;
 
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.IOException;
-
 import org.apache.qpid.framing.amqp_8_0.BasicConsumeBodyImpl;
 
+import java.io.DataInput;
+import java.io.IOException;
+
 public class ContentHeaderPropertiesFactory
 {
     private static final ContentHeaderPropertiesFactory _instance = new ContentHeaderPropertiesFactory();
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
index e018407..1ecd8a1 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
@@ -20,11 +20,12 @@
  */
 package org.apache.qpid.framing;
 
-import java.io.*;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 
@@ -40,6 +41,10 @@
     public static final int SIZEOF_UNSIGNED_INT = 4;
     private static final boolean[] ALL_FALSE_ARRAY = new boolean[8];
 
+    private EncodingUtils()
+    {
+    }
+
     public static int encodedShortStringLength(String s)
     {
         if (s == null)
@@ -114,7 +119,7 @@
         {
             return len + 6 + encodedShortStringLength((short) (i / 1000000));
         }
-        else // if (i > 99999)
+        else // if i > 99999
         {
             return len + 5 + encodedShortStringLength((short) (i / 100000));
         }
@@ -259,7 +264,6 @@
 
     public static void writeLongStringBytes(DataOutput buffer, String s) throws IOException
     {
-        assert (s == null) || (s.length() <= 0xFFFE);
         if (s != null)
         {
             int len = s.length();
@@ -281,7 +285,6 @@
 
     public static void writeLongStringBytes(DataOutput buffer, char[] s) throws IOException
     {
-        assert (s == null) || (s.length <= 0xFFFE);
         if (s != null)
         {
             int len = s.length;
@@ -302,7 +305,6 @@
 
     public static void writeLongStringBytes(DataOutput buffer, byte[] bytes) throws IOException
     {
-        assert (bytes == null) || (bytes.length <= 0xFFFE);
         if (bytes != null)
         {
             writeUnsignedInteger(buffer, bytes.length);
@@ -736,8 +738,6 @@
 
     public static long readTimestamp(DataInput buffer) throws IOException
     {
-        // Discard msb from AMQ timestamp
-        // buffer.getUnsignedInt();
         return buffer.readLong();
     }
 
@@ -802,8 +802,6 @@
 
         byte[] from = new byte[size];
 
-        // Is this not the same.
-        // bb.get(from, 0, length);
         for (int i = 0; i < size; i++)
         {
             from[i] = bb.get(i);
@@ -958,7 +956,6 @@
         else
         {                                                    
             // really writing out unsigned byte
-            //buffer.put((byte) 0);
             writeUnsignedInteger(buffer, 0L);
         }
     }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
index 863e363..57f2c63 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
@@ -25,7 +25,11 @@
 
 import org.apache.qpid.AMQPInvalidClassException;
 
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.Collections;
 import java.util.Enumeration;
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java
index af0c5b8..a2d4d27 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java
@@ -21,11 +21,14 @@
 package org.apache.qpid.framing;
 
 import java.io.DataInput;
-import java.io.DataInputStream;
 import java.io.IOException;
 
 public class FieldTableFactory
 {
+    private FieldTableFactory()
+    {
+    }
+
     public static FieldTable newFieldTable()
     {
         return new FieldTable();
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java
index 95b6246..1613cd0 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.framing;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
+
 import java.io.DataInputStream;
 import java.io.DataOutput;
 import java.io.IOException;
 
-import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
-import org.apache.qpid.AMQException;
-
 public class HeartbeatBody implements AMQBody
 {
     public static final byte TYPE = 8;
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java
index 2925724..0a06f0f 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java
@@ -23,8 +23,9 @@
 import org.apache.qpid.AMQException;
 import org.apache.qpid.codec.MarkableDataInput;
 
-import java.io.*;
-
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.util.Arrays;
 
 public class ProtocolInitiation extends AMQDataBlock implements EncodableAMQDataBlock
@@ -36,14 +37,11 @@
     private static final byte CURRENT_PROTOCOL_CLASS = 1;
     private static final byte TCP_PROTOCOL_INSTANCE = 1;
 
-    public final byte[] _protocolHeader;
-    public final byte _protocolClass;
-    public final byte _protocolInstance;
-    public final byte _protocolMajor;
-    public final byte _protocolMinor;
-
-
-//    public ProtocolInitiation() {}
+    private final byte[] _protocolHeader;
+    private final byte _protocolClass;
+    private final byte _protocolInstance;
+    private final byte _protocolMajor;
+    private final byte _protocolMinor;
 
     public ProtocolInitiation(byte[] protocolHeader, byte protocolClass, byte protocolInstance, byte protocolMajor, byte protocolMinor)
     {
@@ -206,6 +204,26 @@
         return pv;
     }
 
+    public byte getProtocolClass()
+    {
+        return _protocolClass;
+    }
+
+    public byte getProtocolInstance()
+    {
+        return _protocolInstance;
+    }
+
+    public byte getProtocolMajor()
+    {
+        return _protocolMajor;
+    }
+
+    public byte getProtocolMinor()
+    {
+        return _protocolMinor;
+    }
+
     public String toString()
     {
         StringBuffer buffer = new StringBuffer(new String(_protocolHeader));
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/SmallCompositeAMQDataBlock.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/SmallCompositeAMQDataBlock.java
deleted file mode 100644
index dd854dd..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/SmallCompositeAMQDataBlock.java
+++ /dev/null
@@ -1,99 +0,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.
- *
- */
-
-package org.apache.qpid.framing;
-
-import java.io.DataOutput;
-import java.io.IOException;
-
-public class SmallCompositeAMQDataBlock extends AMQDataBlock implements EncodableAMQDataBlock
-{
-    private AMQDataBlock _firstFrame;
-
-    private AMQDataBlock _block;
-
-    public SmallCompositeAMQDataBlock(AMQDataBlock block)
-    {
-        _block = block;
-    }
-
-    /**
-     * The encoded block will be logically first before the AMQDataBlocks which are encoded
-     * into the buffer afterwards.
-     * @param encodedBlock already-encoded data
-     * @param block a block to be encoded.
-     */
-    public SmallCompositeAMQDataBlock(AMQDataBlock encodedBlock, AMQDataBlock block)
-    {
-        this(block);
-        _firstFrame = encodedBlock;
-    }
-
-    public AMQDataBlock getBlock()
-    {
-        return _block;
-    }
-
-    public AMQDataBlock getFirstFrame()
-    {
-        return _firstFrame;
-    }
-
-    public long getSize()
-    {
-        long frameSize = _block.getSize();
-
-        if (_firstFrame != null)
-        {
-
-            frameSize += _firstFrame.getSize();
-        }
-        return frameSize;
-    }
-
-    public void writePayload(DataOutput buffer) throws IOException
-    {
-        if (_firstFrame != null)
-        {
-            _firstFrame.writePayload(buffer);
-        }
-        _block.writePayload(buffer);
-
-    }
-
-    public String toString()
-    {
-        if (_block == null)
-        {
-            return "No blocks contained in composite frame";
-        }
-        else
-        {
-            StringBuilder buf = new StringBuilder(this.getClass().getName());
-            buf.append("{encodedBlock=").append(_firstFrame);
-
-            buf.append(" _block=[").append(_block.toString()).append("]");
-
-            buf.append("}");
-            return buf.toString();
-        }
-    }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java
deleted file mode 100644
index e770fdd..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java
+++ /dev/null
@@ -1,200 +0,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.
- *
- */
-package org.apache.qpid.framing;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-
-import org.apache.qpid.codec.MarkableDataInput;
-import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VersionSpecificRegistry
-{
-    private static final Logger _log = LoggerFactory.getLogger(VersionSpecificRegistry.class);
-
-    private final byte _protocolMajorVersion;
-    private final byte _protocolMinorVersion;
-
-    private static final int DEFAULT_MAX_CLASS_ID = 200;
-    private static final int DEFAULT_MAX_METHOD_ID = 50;
-
-    private AMQMethodBodyInstanceFactory[][] _registry = new AMQMethodBodyInstanceFactory[DEFAULT_MAX_CLASS_ID][];
-
-    private ProtocolVersionMethodConverter _protocolVersionConverter;
-
-    public VersionSpecificRegistry(byte major, byte minor)
-    {
-        _protocolMajorVersion = major;
-        _protocolMinorVersion = minor;
-
-        _protocolVersionConverter = loadProtocolVersionConverters(major, minor);
-    }
-
-    private static ProtocolVersionMethodConverter loadProtocolVersionConverters(byte protocolMajorVersion,
-        byte protocolMinorVersion)
-    {
-        try
-        {
-            Class<ProtocolVersionMethodConverter> versionMethodConverterClass =
-                (Class<ProtocolVersionMethodConverter>) Class.forName("org.apache.qpid.framing.MethodConverter_"
-                    + protocolMajorVersion + "_" + protocolMinorVersion);
-
-            return versionMethodConverterClass.newInstance();
-
-        }
-        catch (ClassNotFoundException e)
-        {
-            _log.warn("Could not find protocol conversion classes for " + protocolMajorVersion + "-" + protocolMinorVersion);
-            if (protocolMinorVersion != 0)
-            {
-                protocolMinorVersion--;
-
-                return loadProtocolVersionConverters(protocolMajorVersion, protocolMinorVersion);
-            }
-            else if (protocolMajorVersion != 0)
-            {
-                protocolMajorVersion--;
-
-                return loadProtocolVersionConverters(protocolMajorVersion, protocolMinorVersion);
-            }
-            else
-            {
-                return null;
-            }
-
-        }
-        catch (IllegalAccessException e)
-        {
-            throw new IllegalStateException("Unable to load protocol version converter: ", e);
-        }
-        catch (InstantiationException e)
-        {
-            throw new IllegalStateException("Unable to load protocol version converter: ", e);
-        }
-    }
-
-    public byte getProtocolMajorVersion()
-    {
-        return _protocolMajorVersion;
-    }
-
-    public byte getProtocolMinorVersion()
-    {
-        return _protocolMinorVersion;
-    }
-
-    public AMQMethodBodyInstanceFactory getMethodBody(final short classID, final short methodID)
-    {
-        try
-        {
-            return _registry[classID][methodID];
-        }
-        catch (IndexOutOfBoundsException e)
-        {
-            return null;
-        }
-        catch (NullPointerException e)
-        {
-            return null;
-        }
-    }
-
-    public void registerMethod(final short classID, final short methodID, final AMQMethodBodyInstanceFactory instanceFactory)
-    {
-        if (_registry.length <= classID)
-        {
-            AMQMethodBodyInstanceFactory[][] oldRegistry = _registry;
-            _registry = new AMQMethodBodyInstanceFactory[classID + 1][];
-            System.arraycopy(oldRegistry, 0, _registry, 0, oldRegistry.length);
-        }
-
-        if (_registry[classID] == null)
-        {
-            _registry[classID] =
-                new AMQMethodBodyInstanceFactory[(methodID > DEFAULT_MAX_METHOD_ID) ? (methodID + 1)
-                                                                                    : (DEFAULT_MAX_METHOD_ID + 1)];
-        }
-        else if (_registry[classID].length <= methodID)
-        {
-            AMQMethodBodyInstanceFactory[] oldMethods = _registry[classID];
-            _registry[classID] = new AMQMethodBodyInstanceFactory[methodID + 1];
-            System.arraycopy(oldMethods, 0, _registry[classID], 0, oldMethods.length);
-        }
-
-        _registry[classID][methodID] = instanceFactory;
-
-    }
-
-    public AMQMethodBody get(short classID, short methodID, MarkableDataInput in, long size) throws AMQFrameDecodingException, IOException
-    {
-        AMQMethodBodyInstanceFactory bodyFactory;
-        try
-        {
-            bodyFactory = _registry[classID][methodID];
-        }
-        catch (NullPointerException e)
-        {
-            throw new AMQFrameDecodingException(null, "Class " + classID + " unknown in AMQP version "
-                + _protocolMajorVersion + "-" + _protocolMinorVersion + " (while trying to decode class " + classID
-                + " method " + methodID + ".", e);
-        }
-        catch (IndexOutOfBoundsException e)
-        {
-            if (classID >= _registry.length)
-            {
-                throw new AMQFrameDecodingException(null, "Class " + classID + " unknown in AMQP version "
-                    + _protocolMajorVersion + "-" + _protocolMinorVersion + " (while trying to decode class " + classID
-                    + " method " + methodID + ".", e);
-
-            }
-            else
-            {
-                throw new AMQFrameDecodingException(null, "Method " + methodID + " unknown in AMQP version "
-                    + _protocolMajorVersion + "-" + _protocolMinorVersion + " (while trying to decode class " + classID
-                    + " method " + methodID + ".", e);
-
-            }
-        }
-
-        if (bodyFactory == null)
-        {
-            throw new AMQFrameDecodingException(null, "Method " + methodID + " unknown in AMQP version "
-                + _protocolMajorVersion + "-" + _protocolMinorVersion + " (while trying to decode class " + classID
-                + " method " + methodID + ".", null);
-        }
-
-        return bodyFactory.newInstance( in, size);
-
-    }
-
-    public ProtocolVersionMethodConverter getProtocolVersionMethodConverter()
-    {
-        return _protocolVersionConverter;
-    }
-
-    public void configure()
-    {
-        _protocolVersionConverter.configure();
-    }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfoImpl.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfoImpl.java
index e3d5da7..53c70c8 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfoImpl.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfoImpl.java
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.framing.abstraction;
 
-import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 import org.apache.qpid.framing.AMQShortString;
 
 public class MessagePublishInfoImpl implements MessagePublishInfo
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java
index 90a730d..b3eb121 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java
@@ -21,12 +21,16 @@
 
 package org.apache.qpid.framing.amqp_0_9;
 
+import org.apache.qpid.framing.AMQBody;
+import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicPublishBody;
+import org.apache.qpid.framing.ContentBody;
 import org.apache.qpid.framing.abstraction.AbstractMethodConverter;
-import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter;
 import org.apache.qpid.framing.abstraction.ContentChunk;
 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 import org.apache.qpid.framing.abstraction.MessagePublishInfoImpl;
-import org.apache.qpid.framing.*;
+import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter;
 
 
 public class MethodConverter_0_9 extends AbstractMethodConverter implements ProtocolVersionMethodConverter
@@ -115,7 +119,7 @@
 
         public byte[] getData()
         {
-            return _contentBodyChunk._payload;
+            return _contentBodyChunk.getPayload();
         }
 
         public void reduceToFit()
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_91/MethodConverter_0_91.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_91/MethodConverter_0_91.java
index 3b0cc3c..d33749d 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_91/MethodConverter_0_91.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_91/MethodConverter_0_91.java
@@ -21,12 +21,16 @@
 
 package org.apache.qpid.framing.amqp_0_91;
 
+import org.apache.qpid.framing.AMQBody;
+import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicPublishBody;
+import org.apache.qpid.framing.ContentBody;
 import org.apache.qpid.framing.abstraction.AbstractMethodConverter;
-import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter;
 import org.apache.qpid.framing.abstraction.ContentChunk;
 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 import org.apache.qpid.framing.abstraction.MessagePublishInfoImpl;
-import org.apache.qpid.framing.*;
+import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter;
 
 public class MethodConverter_0_91 extends AbstractMethodConverter implements ProtocolVersionMethodConverter
 {
@@ -114,7 +118,7 @@
 
         public byte[] getData()
         {
-            return _contentBodyChunk._payload;
+            return _contentBodyChunk.getPayload();
         }
 
         public void reduceToFit()
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java
index e6d0482..4c7772a 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java
@@ -21,12 +21,16 @@
 
 package org.apache.qpid.framing.amqp_8_0;
 
-import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter;
+import org.apache.qpid.framing.AMQBody;
+import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.BasicPublishBody;
+import org.apache.qpid.framing.ContentBody;
+import org.apache.qpid.framing.abstraction.AbstractMethodConverter;
 import org.apache.qpid.framing.abstraction.ContentChunk;
 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
-import org.apache.qpid.framing.abstraction.AbstractMethodConverter;
 import org.apache.qpid.framing.abstraction.MessagePublishInfoImpl;
-import org.apache.qpid.framing.*;
+import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter;
 
 public class MethodConverter_8_0 extends AbstractMethodConverter implements ProtocolVersionMethodConverter
 {
@@ -59,7 +63,7 @@
 
             public byte[] getData()
             {
-                return contentBodyChunk._payload;
+                return contentBodyChunk.getPayload();
             }
 
             public void reduceToFit()
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java
index d9c1214..bccae8e 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java
@@ -20,12 +20,12 @@
  */
 package org.apache.qpid.messaging;
 
-import java.util.Map;
-
 import org.apache.qpid.messaging.util.AddressParser;
 
 import static org.apache.qpid.messaging.util.PyPrint.pprint;
 
+import java.util.Map;
+
 
 /**
  * Address
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressParser.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressParser.java
index 7b31436..d1e1060 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressParser.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressParser.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.messaging.util;
 
+import org.apache.qpid.messaging.Address;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.qpid.messaging.Address;
-
 
 /**
  * AddressParser
@@ -257,6 +257,10 @@
         {
             eat(SLASH);
             subject = toks2str(eat_until(SEMI, EOF));
+            if ("None".equals(subject))
+            {
+            	subject = null;
+            }
         }
         else
         {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/JAddr.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/JAddr.java
index 93df052..c5c2cac 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/JAddr.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/JAddr.java
@@ -20,16 +20,13 @@
  */
 package org.apache.qpid.messaging.util;
 
-import java.io.InputStreamReader;
-
-import java.util.List;
-
 import org.apache.qpid.messaging.Address;
-import org.apache.qpid.messaging.util.ParseError;
-import org.apache.qpid.messaging.util.Token;
 
 import static org.apache.qpid.messaging.util.PyPrint.pprint;
 
+import java.io.InputStreamReader;
+import java.util.List;
+
 
 /**
  * JAddr
@@ -38,6 +35,9 @@
 
 public class JAddr
 {
+    private JAddr()
+    {
+    }
 
     public static final void main(String[] args) throws Exception
     {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexer.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexer.java
index 8226cc7..9638ec7 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexer.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexer.java
@@ -21,9 +21,7 @@
 package org.apache.qpid.messaging.util;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.NoSuchElementException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/PyPrint.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/PyPrint.java
index ef6c724..2681893 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/PyPrint.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/PyPrint.java
@@ -33,6 +33,9 @@
 
 public class PyPrint
 {
+    private PyPrint()
+    {
+    }
 
     public static String pprint(Object obj)
     {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java b/qpid/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java
index 3e99b24..0df9a85 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java
@@ -22,10 +22,10 @@
 
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.LinkedBlockingQueue;
 
 
 /**
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
new file mode 100644
index 0000000..15c144b
--- /dev/null
+++ b/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
@@ -0,0 +1,93 @@
+/*
+ *  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.properties;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+
+import org.apache.qpid.transport.util.Logger;
+
+/**
+ * Constants for the various properties 0-10 clients can
+ * set values for during the ConnectionStartOk reply.
+ */
+public class ConnectionStartProperties
+{
+    private static final Logger LOGGER = Logger.get(ConnectionStartProperties.class);
+
+    public static final String CLIENT_ID_0_10 = "clientName";
+    public static final String CLIENT_ID_0_8 = "instance";
+
+    public static final String VERSION_0_8 = "version";
+    public static final String VERSION_0_10 = "qpid.client_version";
+
+    public static final String PROCESS = "qpid.client_process";
+
+    public static final String PID = "qpid.client_pid";
+
+    public static final String PLATFORM = "platform";
+
+    public static final String PRODUCT ="product";
+
+    public static final String SESSION_FLOW = "qpid.session_flow";
+
+    public static int getPID()
+    {
+        RuntimeMXBean rtb = ManagementFactory.getRuntimeMXBean();
+        String processName = rtb.getName();
+        if (processName != null && processName.indexOf('@') > 0)
+        {
+            try
+            {
+                return Integer.parseInt(processName.substring(0,processName.indexOf('@')));
+            }
+            catch(Exception e)
+            {
+                LOGGER.warn("Unable to get the PID due to error",e);
+                return -1;
+            }
+        }
+        else
+        {
+            LOGGER.warn("Unable to get the PID due to unsupported format : " + processName);
+            return -1;
+        }
+    }
+
+    public static String getPlatformInfo()
+    {
+        StringBuilder fullSystemInfo = new StringBuilder(System.getProperty("java.runtime.name"));
+        fullSystemInfo.append(", ");
+        fullSystemInfo.append(System.getProperty("java.runtime.version"));
+        fullSystemInfo.append(", ");
+        fullSystemInfo.append(System.getProperty("java.vendor"));
+        fullSystemInfo.append(", ");
+        fullSystemInfo.append(System.getProperty("os.arch"));
+        fullSystemInfo.append(", ");
+        fullSystemInfo.append(System.getProperty("os.name"));
+        fullSystemInfo.append(", ");
+        fullSystemInfo.append(System.getProperty("os.version"));
+        fullSystemInfo.append(", ");
+        fullSystemInfo.append(System.getProperty("sun.os.patch.level"));
+
+        return fullSystemInfo.toString();
+    }
+}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java
index 14d1bef..2a2342c 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.protocol;
 
+import org.apache.qpid.framing.AMQShortString;
+
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.qpid.framing.AMQShortString;
-
 /**
  * Defines constants for AMQP codes and also acts as a factory for creating such constants from the raw codes. Each
  * constant also defines a short human readable description of the constant.
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodListener.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodListener.java
index 5a7679a..8cc9709 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodListener.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodListener.java
@@ -20,8 +20,8 @@
  */
 package org.apache.qpid.protocol;
 
-import org.apache.qpid.framing.AMQMethodBody;
 import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQMethodBody;
 
 /**
  * AMQMethodListener is a listener that receives notifications of AMQP methods. The methods are packaged as events in
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQVersionAwareProtocolSession.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQVersionAwareProtocolSession.java
index b58e7d0..185c01d 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQVersionAwareProtocolSession.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQVersionAwareProtocolSession.java
@@ -20,9 +20,13 @@
  */
 package org.apache.qpid.protocol;
 
-import org.apache.qpid.framing.*;
-import org.apache.qpid.transport.Sender;
 import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQMethodBody;
+import org.apache.qpid.framing.ContentBody;
+import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.HeartbeatBody;
+import org.apache.qpid.framing.MethodRegistry;
+import org.apache.qpid.transport.Sender;
 
 import java.nio.ByteBuffer;
 
@@ -47,7 +51,6 @@
      *
      * @return The method registry for a specific version of the AMQP.
      */
-//    public VersionSpecificRegistry getRegistry();
 
     MethodRegistry getMethodRegistry();
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngine.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngine.java
index fd651a2..7ca5889 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngine.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngine.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.protocol;
 
-import java.net.SocketAddress;
-import java.nio.ByteBuffer;
-
 import org.apache.qpid.transport.Receiver;
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.network.NetworkConnection;
 
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+
 /**
  * A ProtocolEngine is a Receiver for java.nio.ByteBuffers. It takes the data passed to it in the received
  * decodes it and then process the result.
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngineFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngineFactory.java
index 7378edf..885a6a9 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngineFactory.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngineFactory.java
@@ -20,9 +20,7 @@
  */
 package org.apache.qpid.protocol;
 
-import org.apache.qpid.transport.network.NetworkConnection;
-
-public interface ProtocolEngineFactory  
+public interface ProtocolEngineFactory
 { 
  
   // Returns a new instance of a ProtocolEngine 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/ssl/SSLContextFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/ssl/SSLContextFactory.java
index 01f1340..c9ff180 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/ssl/SSLContextFactory.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/ssl/SSLContextFactory.java
@@ -20,18 +20,17 @@
  */
 package org.apache.qpid.ssl;
 
-import java.io.IOException;
-import java.security.GeneralSecurityException;
-import java.security.KeyStore;
+import org.apache.qpid.transport.network.security.ssl.QpidClientX509KeyManager;
+import org.apache.qpid.transport.network.security.ssl.SSLUtil;
 
 import javax.net.ssl.KeyManager;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
-
-import org.apache.qpid.transport.network.security.ssl.QpidClientX509KeyManager;
-import org.apache.qpid.transport.network.security.ssl.SSLUtil;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
 
 /**
  * Factory used to create SSLContexts. SSL needs to be configured
@@ -42,7 +41,6 @@
 {
     public static final String JAVA_KEY_STORE_CODE = "JKS";
     public static final String TRANSPORT_LAYER_SECURITY_CODE = "TLS";
-    public static final String KEY_STORE_CERTIFICATE_TYPE = "SunX509";
 
     private SSLContextFactory()
     {
@@ -50,28 +48,28 @@
     }
 
     public static SSLContext buildServerContext(final String keyStorePath,
-            final String keyStorePassword, final String keyStoreCertType)
+            final String keyStorePassword, final String keyManagerFactoryAlgorithm)
             throws GeneralSecurityException, IOException
     {
         return buildContext(null, null, null, keyStorePath, keyStorePassword,
-                keyStoreCertType, null);
+                keyManagerFactoryAlgorithm, null);
     }
 
     public static SSLContext buildClientContext(final String trustStorePath,
-            final String trustStorePassword, final String trustStoreCertType,
+            final String trustStorePassword, final String trustManagerFactoryAlgorithm,
             final String keyStorePath, final String keyStorePassword,
-            final String keyStoreCertType, final String certAlias)
+            final String keyManagerFactoryAlgorithm, final String certAlias)
             throws GeneralSecurityException, IOException
     {
         return buildContext(trustStorePath, trustStorePassword,
-                trustStoreCertType, keyStorePath, keyStorePassword,
-                keyStoreCertType, certAlias);
+                trustManagerFactoryAlgorithm, keyStorePath, keyStorePassword,
+                keyManagerFactoryAlgorithm, certAlias);
     }
     
     private static SSLContext buildContext(final String trustStorePath,
-            final String trustStorePassword, final String trustStoreCertType,
+            final String trustStorePassword, final String trustManagerFactoryAlgorithm,
             final String keyStorePath, final String keyStorePassword,
-            final String keyStoreCertType, final String certAlias)
+            final String keyManagerFactoryAlgorithm, final String certAlias)
             throws GeneralSecurityException, IOException
     {
         // Initialize the SSLContext to work with our key managers.
@@ -86,7 +84,7 @@
             final KeyStore ts = SSLUtil.getInitializedKeyStore(trustStorePath,
                     trustStorePassword);
             final TrustManagerFactory tmf = TrustManagerFactory
-                    .getInstance(trustStoreCertType);
+                    .getInstance(trustManagerFactoryAlgorithm);
             tmf.init(ts);
 
             trustManagers = tmf.getTrustManagers();
@@ -102,7 +100,7 @@
             {
                 keyManagers = new KeyManager[] { new QpidClientX509KeyManager(
                         certAlias, keyStorePath, keyStorePassword,
-                        keyStoreCertType) };
+                        keyManagerFactoryAlgorithm) };
             }
             else
             {
@@ -112,7 +110,7 @@
                 char[] keyStoreCharPassword = keyStorePassword == null ? null : keyStorePassword.toCharArray();
                 // Set up key manager factory to use our key store
                 final KeyManagerFactory kmf = KeyManagerFactory
-                        .getInstance(keyStoreCertType);
+                        .getInstance(keyManagerFactoryAlgorithm);
                 kmf.init(ks, keyStoreCharPassword);
                 keyManagers = kmf.getKeyManagers();
             }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/thread/LoggingUncaughtExceptionHandler.java b/qpid/java/common/src/main/java/org/apache/qpid/thread/LoggingUncaughtExceptionHandler.java
index 192675e..58d8045 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/thread/LoggingUncaughtExceptionHandler.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/thread/LoggingUncaughtExceptionHandler.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.thread;
 
-import java.lang.Thread.UncaughtExceptionHandler;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.lang.Thread.UncaughtExceptionHandler;
+
 /**
  *
  * An {@link UncaughtExceptionHandler} that writes the exception to the application log via
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/thread/QpidThreadExecutor.java b/qpid/java/common/src/main/java/org/apache/qpid/thread/QpidThreadExecutor.java
index 30010a2..06f5e6b 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/thread/QpidThreadExecutor.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/thread/QpidThreadExecutor.java
@@ -21,8 +21,6 @@
 
 package org.apache.qpid.thread;
 
-import org.apache.qpid.thread.Threading;
-
 import java.util.concurrent.Executor;
 
 public class QpidThreadExecutor implements Executor
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/thread/Threading.java b/qpid/java/common/src/main/java/org/apache/qpid/thread/Threading.java
index 603e8a7..265b336 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/thread/Threading.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/thread/Threading.java
@@ -24,7 +24,11 @@
 public final class Threading
 {
     private static ThreadFactory threadFactory;
-    
+
+    private Threading()
+    {
+    }
+
     static {
         try
         {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Binary.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Binary.java
index 491a7ac..e3e6f81 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Binary.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Binary.java
@@ -20,9 +20,9 @@
  */
 package org.apache.qpid.transport;
 
-import java.nio.ByteBuffer;
+import static org.apache.qpid.transport.util.Functions.str;
 
-import static org.apache.qpid.transport.util.Functions.*;
+import java.nio.ByteBuffer;
 
 
 /**
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
index 9bdad6b..c75adab 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
@@ -20,20 +20,20 @@
  */
 package org.apache.qpid.transport;
 
+import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.properties.ConnectionStartProperties;
+import org.apache.qpid.transport.util.Logger;
+
 import static org.apache.qpid.transport.Connection.State.OPEN;
 import static org.apache.qpid.transport.Connection.State.RESUMING;
 
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
-
-import org.apache.qpid.transport.util.Logger;
-
 
 /**
  * ClientDelegate
@@ -46,11 +46,11 @@
 
 
 
-    protected final ConnectionSettings _conSettings;
+    private final ConnectionSettings _connectionSettings;
 
     public ClientDelegate(ConnectionSettings settings)
     {
-        this._conSettings = settings;
+        _connectionSettings = settings;
     }
 
     public void init(Connection conn, ProtocolHeader hdr)
@@ -66,15 +66,17 @@
     {
         Map<String,Object> clientProperties = new HashMap<String,Object>();
 
-        if(this._conSettings.getClientProperties() != null)
+        if(_connectionSettings.getClientProperties() != null)
         {
-            clientProperties.putAll(_conSettings.getClientProperties());
+            clientProperties.putAll(_connectionSettings.getClientProperties());
         }
 
-        clientProperties.put("qpid.session_flow", 1);
-        clientProperties.put("qpid.client_pid",getPID());
-        clientProperties.put("qpid.client_process",
-                System.getProperty("qpid.client_process","Qpid Java Client"));
+        clientProperties.put(ConnectionStartProperties.SESSION_FLOW, 1);
+        clientProperties.put(ConnectionStartProperties.PID, ConnectionStartProperties.getPID());
+        clientProperties.put(ConnectionStartProperties.PROCESS, System.getProperty(ClientProperties.PROCESS_NAME, "Qpid Java Client"));
+        clientProperties.put(ConnectionStartProperties.VERSION_0_10, QpidProperties.getReleaseVersion());
+        clientProperties.put(ConnectionStartProperties.PRODUCT, QpidProperties.getProductName());
+        clientProperties.put(ConnectionStartProperties.PLATFORM, ConnectionStartProperties.getPlatformInfo());
 
         List<Object> brokerMechs = start.getMechanisms();
         if (brokerMechs == null || brokerMechs.isEmpty())
@@ -131,7 +133,7 @@
     @Override
     public void connectionTune(Connection conn, ConnectionTune tune)
     {
-        int hb_interval = calculateHeartbeatInterval(_conSettings.getHeartbeatInterval(),
+        int hb_interval = calculateHeartbeatInterval(_connectionSettings.getHeartbeatInterval(),
                                                      tune.getHeartbeatMin(),
                                                      tune.getHeartbeatMax()
                                                      );
@@ -146,7 +148,7 @@
         //(or that forced by protocol limitations [0xFFFF])
         conn.setChannelMax(channelMax == 0 ? Connection.MAX_CHANNEL_MAX : channelMax);
 
-        conn.connectionOpen(_conSettings.getVhost(), null, Option.INSIST);
+        conn.connectionOpen(_connectionSettings.getVhost(), null, Option.INSIST);
     }
 
     @Override
@@ -197,31 +199,8 @@
         }
     }
 
-    private int getPID()
+    public ConnectionSettings getConnectionSettings()
     {
-        RuntimeMXBean rtb = ManagementFactory.getRuntimeMXBean();
-        String processName = rtb.getName();
-        if (processName != null && processName.indexOf('@')>0)
-        {
-            try
-            {
-                return Integer.parseInt(processName.substring(0,processName.indexOf('@')));
-            }
-            catch(Exception e)
-            {
-                log.warn("Unable to get the client PID due to error",e);
-                return -1;
-            }
-        }
-        else
-        {
-            log.warn("Unable to get the client PID due to unsupported format : " + processName);
-            return -1;
-        }
-
+        return _connectionSettings;
     }
-
-
-
-
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
index dee5f69..b0f1a1b 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
@@ -20,25 +20,6 @@
  */
 package org.apache.qpid.transport;
 
-import static org.apache.qpid.transport.Connection.State.CLOSED;
-import static org.apache.qpid.transport.Connection.State.CLOSING;
-import static org.apache.qpid.transport.Connection.State.NEW;
-import static org.apache.qpid.transport.Connection.State.OPEN;
-import static org.apache.qpid.transport.Connection.State.OPENING;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslServer;
-
 import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.transport.network.Assembler;
 import org.apache.qpid.transport.network.Disassembler;
@@ -52,6 +33,24 @@
 import org.apache.qpid.transport.util.Waiter;
 import org.apache.qpid.util.Strings;
 
+import static org.apache.qpid.transport.Connection.State.CLOSED;
+import static org.apache.qpid.transport.Connection.State.CLOSING;
+import static org.apache.qpid.transport.Connection.State.NEW;
+import static org.apache.qpid.transport.Connection.State.OPEN;
+import static org.apache.qpid.transport.Connection.State.OPENING;
+
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslServer;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+
 
 /**
  * Connection
@@ -125,7 +124,6 @@
     private String userID;
     private ConnectionSettings conSettings;
     private SecurityLayer securityLayer;
-    private String _clientId;
 
     private final AtomicBoolean connectionLost = new AtomicBoolean(false);
 
@@ -161,16 +159,6 @@
         }
     }
 
-    public String getClientId()
-    {
-        return _clientId;
-    }
-
-    public void setClientId(String id)
-    {
-        _clientId = id;
-    }
-
     void setLocale(String locale)
     {
         this.locale = locale;
@@ -201,23 +189,12 @@
         return saslClient;
     }
 
-    public void connect(String host, int port, String vhost, String username, String password)
+    public void connect(String host, int port, String vhost, String username, String password, boolean ssl, String saslMechs)
     {
-        connect(host, port, vhost, username, password, false);
+        connect(host, port, vhost, username, password, ssl, saslMechs, null);
     }
 
-    public void connect(String host, int port, String vhost, String username, String password, boolean ssl)
-    {
-        connect(host, port, vhost, username, password, ssl,"PLAIN");
-    }
-
-    public void connect(String host, int port, String vhost, String username, String password, boolean ssl,String saslMechs)
-    {
-        connect(host, port, vhost, username, password, ssl,saslMechs, Collections.EMPTY_MAP);
-    }
-
-
-    public void connect(String host, int port, String vhost, String username, String password, boolean ssl,String saslMechs,Map<String,Object> clientProps)
+    public void connect(String host, int port, String vhost, String username, String password, boolean ssl, String saslMechs, Map<String,Object> clientProps)
     {
         ConnectionSettings settings = new ConnectionSettings();
         settings.setHost(host);
@@ -535,7 +512,7 @@
         exception(new ConnectionException(t));
     }
 
-    void closeCode(ConnectionClose close)
+    public void closeCode(ConnectionClose close)
     {
         synchronized (lock)
         {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java
index 3933016..fdd35d4 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java
@@ -22,7 +22,7 @@
 
 import org.apache.qpid.transport.util.Logger;
 
-import static org.apache.qpid.transport.Connection.State.*;
+import static org.apache.qpid.transport.Connection.State.CLOSE_RCVD;
 
 
 /**
@@ -71,12 +71,17 @@
 
     @Override public void connectionClose(Connection conn, ConnectionClose close)
     {
-        conn.connectionCloseOk();
-        conn.getSender().close();
+        sendConnectionCloseOkAndCloseSender(conn);
         conn.closeCode(close);
         conn.setState(CLOSE_RCVD);
     }
 
+    protected void sendConnectionCloseOkAndCloseSender(Connection conn)
+    {
+        conn.connectionCloseOk();
+        conn.getSender().close();
+    }
+
     @Override public void connectionCloseOk(Connection conn, ConnectionCloseOk ok)
     {
         conn.getSender().close();
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java
index 2ee507e..084428d 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java
@@ -20,9 +20,24 @@
  */
 package org.apache.qpid.transport;
 
+import static org.apache.qpid.configuration.ClientProperties.AMQJ_TCP_NODELAY_PROP_NAME;
+import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_KEY_MANAGER_FACTORY_ALGORITHM_PROP_NAME;
+import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_KEY_STORE_CERT_TYPE_PROP_NAME;
+import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_TRUST_MANAGER_FACTORY_ALGORITHM_PROP_NAME;
+import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME;
+import static org.apache.qpid.configuration.ClientProperties.QPID_TCP_NODELAY_PROP_NAME;
+import static org.apache.qpid.configuration.ClientProperties.RECEIVE_BUFFER_SIZE_PROP_NAME;
+import static org.apache.qpid.configuration.ClientProperties.SEND_BUFFER_SIZE_PROP_NAME;
+import static org.apache.qpid.configuration.ClientProperties.LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME;
+import static org.apache.qpid.configuration.ClientProperties.LEGACY_SEND_BUFFER_SIZE_PROP_NAME;
+
 import java.util.Map;
 
-import org.apache.qpid.configuration.ClientProperties;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.apache.qpid.configuration.QpidProperty;
+
 
 /**
  * A ConnectionSettings object can only be associated with
@@ -34,37 +49,36 @@
 {
     public static final String WILDCARD_ADDRESS = "*";
 
-    String protocol = "tcp";
-    String host = "localhost";
-    String vhost;
-    String username = "guest";
-    String password = "guest";
-    int port = 5672;
-    boolean tcpNodelay = Boolean.valueOf(System.getProperty(ClientProperties.QPID_TCP_NODELAY_PROP_NAME,
-                                         System.getProperty(ClientProperties.AMQJ_TCP_NODELAY_PROP_NAME, "true")));
-    int maxChannelCount = 32767;
-    int maxFrameSize = 65535;
-    int heartbeatInterval;
-    int readBufferSize = 65535;
-    int writeBufferSize = 65535;
-    long transportTimeout = 60000;
-    
+    private String protocol = "tcp";
+    private String host = "localhost";
+    private String vhost;
+    private String username = "guest";
+    private String password = "guest";
+    private int port = 5672;
+    private boolean tcpNodelay = QpidProperty.booleanProperty(Boolean.TRUE, QPID_TCP_NODELAY_PROP_NAME, AMQJ_TCP_NODELAY_PROP_NAME).get();
+    private int maxChannelCount = 32767;
+    private int maxFrameSize = 65535;
+    private int heartbeatInterval;
+    private int readBufferSize = QpidProperty.intProperty(65535, RECEIVE_BUFFER_SIZE_PROP_NAME, LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME).get();
+    private int writeBufferSize = QpidProperty.intProperty(65535, SEND_BUFFER_SIZE_PROP_NAME, LEGACY_SEND_BUFFER_SIZE_PROP_NAME).get();;
+    private long transportTimeout = 60000;
+
     // SSL props
-    boolean useSSL;
-    String keyStorePath = System.getProperty("javax.net.ssl.keyStore");
-    String keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword");
-    String keyStoreCertType = System.getProperty("qpid.ssl.keyStoreCertType","SunX509");;
-    String trustStoreCertType = System.getProperty("qpid.ssl.trustStoreCertType","SunX509");;
-    String trustStorePath = System.getProperty("javax.net.ssl.trustStore");;
-    String trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword");;
-    String certAlias;
-    boolean verifyHostname;
+    private boolean useSSL;
+    private String keyStorePath = System.getProperty("javax.net.ssl.keyStore");
+    private String keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword");
+    private String keyManagerFactoryAlgorithm = QpidProperty.stringProperty(KeyManagerFactory.getDefaultAlgorithm(), QPID_SSL_KEY_MANAGER_FACTORY_ALGORITHM_PROP_NAME, QPID_SSL_KEY_STORE_CERT_TYPE_PROP_NAME).get();
+    private String trustManagerFactoryAlgorithm = QpidProperty.stringProperty(TrustManagerFactory.getDefaultAlgorithm(), QPID_SSL_TRUST_MANAGER_FACTORY_ALGORITHM_PROP_NAME, QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME).get();
+    private String trustStorePath = System.getProperty("javax.net.ssl.trustStore");;
+    private String trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword");;
+    private String certAlias;
+    private boolean verifyHostname;
     
     // SASL props
-    String saslMechs = System.getProperty("qpid.sasl_mechs", null);
-    String saslProtocol = System.getProperty("qpid.sasl_protocol", "AMQP");
-    String saslServerName = System.getProperty("qpid.sasl_server_name", "localhost");
-    boolean useSASLEncryption;
+    private String saslMechs = System.getProperty("qpid.sasl_mechs", null);
+    private String saslProtocol = System.getProperty("qpid.sasl_protocol", "AMQP");
+    private String saslServerName = System.getProperty("qpid.sasl_server_name", "localhost");
+    private boolean useSASLEncryption;
    
     private Map<String, Object> _clientProperties;
     
@@ -288,24 +302,24 @@
         this.verifyHostname = verifyHostname;
     }
     
-    public String getKeyStoreCertType()
+    public String getKeyManagerFactoryAlgorithm()
     {
-        return keyStoreCertType;
+        return keyManagerFactoryAlgorithm;
     }
 
-    public void setKeyStoreCertType(String keyStoreCertType)
+    public void setKeyManagerFactoryAlgorithm(String keyManagerFactoryAlgorithm)
     {
-        this.keyStoreCertType = keyStoreCertType;
+        this.keyManagerFactoryAlgorithm = keyManagerFactoryAlgorithm;
     }
 
-    public String getTrustStoreCertType()
+    public String getTrustManagerFactoryAlgorithm()
     {
-        return trustStoreCertType;
+        return trustManagerFactoryAlgorithm;
     }
 
-    public void setTrustStoreCertType(String trustStoreCertType)
+    public void setTrustManagerFactoryAlgorithm(String trustManagerFactoryAlgorithm)
     {
-        this.trustStoreCertType = trustStoreCertType;
+        this.trustManagerFactoryAlgorithm = trustManagerFactoryAlgorithm;
     }
 
     public int getReadBufferSize()
@@ -337,5 +351,4 @@
     {
         this.transportTimeout = transportTimeout;
     }
-
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Header.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Header.java
index 543856c..7ac75f9 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Header.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Header.java
@@ -20,7 +20,7 @@
  */
 package org.apache.qpid.transport;
 
-import java.util.*;
+import java.util.List;
 
 
 /**
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Method.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Method.java
index abf9682..b3af99e 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Method.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Method.java
@@ -22,9 +22,9 @@
 
 import org.apache.qpid.transport.network.Frame;
 
-import java.nio.ByteBuffer;
+import static org.apache.qpid.transport.util.Functions.str;
 
-import static org.apache.qpid.transport.util.Functions.*;
+import java.nio.ByteBuffer;
 
 /**
  * Method
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java
index 8d3f7a7..472beb6 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java
@@ -20,6 +20,8 @@
  */
 package org.apache.qpid.transport;
 
+import java.net.InetSocketAddress;
+
 /**
  * This interface provides a means for NetworkDrivers to configure TCP options such as incoming and outgoing
  * buffer sizes and set particular options on the socket. NetworkDrivers should honour the values returned
@@ -43,4 +45,6 @@
     String getTransport();
 
     Integer getConnectorProcessors();
+
+    InetSocketAddress getAddress();
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolHeader.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolHeader.java
index e5b93e4..3959dc8 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolHeader.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolHeader.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.transport;
 
-import java.nio.ByteBuffer;
-
+import org.apache.qpid.transport.network.Frame;
 import org.apache.qpid.transport.network.NetworkDelegate;
 import org.apache.qpid.transport.network.NetworkEvent;
-import org.apache.qpid.transport.network.Frame;
+
+import java.nio.ByteBuffer;
 
 
 /**
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Range.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Range.java
index c47171d..413ec8e 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Range.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Range.java
@@ -20,13 +20,16 @@
  */
 package org.apache.qpid.transport;
 
+import static org.apache.qpid.util.Serial.gt;
+import static org.apache.qpid.util.Serial.le;
+import static org.apache.qpid.util.Serial.max;
+import static org.apache.qpid.util.Serial.min;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
-import static org.apache.qpid.util.Serial.*;
-
 
 /**
  * Range
@@ -119,6 +122,11 @@
         throw new UnsupportedOperationException();
     }
 
+    public void subtract(RangeSet rangeSet)
+    {
+        throw new UnsupportedOperationException();
+    }
+
     public RangeSet copy()
     {
         RangeSet rangeSet = RangeSetFactory.createRangeSet();
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSet.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSet.java
index 34ebd02..19990a4 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSet.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSet.java
@@ -20,9 +20,7 @@
  */
 package org.apache.qpid.transport;
 
-import java.util.*;
-
-import static org.apache.qpid.util.Serial.*;
+import java.util.Iterator;
 
 /**
  * RangeSet
@@ -51,6 +49,8 @@
 
     void add(int value);
 
+    void subtract(final RangeSet other);
+
     void clear();
 
     RangeSet copy();
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetFactory.java
index 0f19d7e..0f049ab 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetFactory.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetFactory.java
@@ -22,6 +22,10 @@
 
 public class RangeSetFactory
 {
+    private RangeSetFactory()
+    {
+    }
+
     public static RangeSet createRangeSet()
     {
         return new RangeSetImpl();
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetImpl.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetImpl.java
index f2540af..adf18e2 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetImpl.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetImpl.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.transport;
 
+import static org.apache.qpid.util.Serial.lt;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
 
-import static org.apache.qpid.util.Serial.lt;
-
 public class RangeSetImpl implements RangeSet
 {
 
@@ -150,6 +150,68 @@
         ranges.clear();
     }
 
+    public void subtract(final RangeSet other)
+    {
+        final Iterator<Range> otherIter = other.iterator() ;
+        if (otherIter.hasNext())
+        {
+            Range otherRange = otherIter.next();
+            final ListIterator<Range> iter = ranges.listIterator() ;
+            if (iter.hasNext())
+            {
+                Range range = iter.next();
+                do
+                {
+                    if (otherRange.getUpper() < range.getLower())
+                    {
+                        otherRange = nextRange(otherIter) ;
+                    }
+                    else if (range.getUpper() < otherRange.getLower())
+                    {
+                        range = nextRange(iter) ;
+                    }
+                    else
+                    {
+                        final boolean first = range.getLower() < otherRange.getLower() ;
+                        final boolean second = otherRange.getUpper() < range.getUpper() ;
+
+                        if (first)
+                        {
+                            iter.set(Range.newInstance(range.getLower(), otherRange.getLower()-1)) ;
+                            if (second)
+                            {
+                                iter.add(Range.newInstance(otherRange.getUpper()+1, range.getUpper())) ;
+                                iter.previous() ;
+                                range = iter.next() ;
+                            }
+                            else
+                            {
+                                range = nextRange(iter) ;
+                            }
+                        }
+                        else if (second)
+                        {
+                            range = Range.newInstance(otherRange.getUpper()+1, range.getUpper()) ;
+                            iter.set(range) ;
+                            otherRange = nextRange(otherIter) ;
+                        }
+                        else
+                        {
+                            iter.remove() ;
+                            range = nextRange(iter) ;
+                        }
+                    }
+                }
+                while ((otherRange != null) && (range != null)) ;
+            }
+        }
+    }
+
+    private Range nextRange(final Iterator<Range> iter)
+    {
+        return (iter.hasNext() ? iter.next() : null) ;
+    }
+
     public RangeSet copy()
     {
         return new org.apache.qpid.transport.RangeSetImpl(this);
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
index 07d21c9..ec409d1 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
@@ -20,18 +20,17 @@
  */
 package org.apache.qpid.transport;
 
-import static org.apache.qpid.transport.Connection.State.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import static org.apache.qpid.transport.Connection.State.OPEN;
 
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 
 /**
  * ServerDelegate
@@ -70,9 +69,6 @@
         conn.setLocale(ok.getLocale());
         String mechanism = ok.getMechanism();
 
-        String clientName = (String) ok.getClientProperties().get("clientName");
-        conn.setClientId(clientName);
-
         if (mechanism == null || mechanism.length() == 0)
         {
             tuneAuthorizedConnection(conn);
@@ -195,17 +191,11 @@
     @Override
     public void sessionAttach(Connection conn, SessionAttach atc)
     {
-        sessionAttachImpl(conn, atc);
-    }
-
-    protected Session sessionAttachImpl(Connection conn, SessionAttach atc)
-    {
         Session ssn = getSession(conn, atc);
         conn.map(ssn, atc.getChannel());
+        conn.registerSession(ssn);
         ssn.sessionAttached(atc.getName());
         ssn.setState(Session.State.OPEN);
-
-        return ssn;
     }
 
     protected void setConnectionTuneOkChannelMax(final Connection conn, final int okChannelMax)
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java
index 3fc596d..110c73f 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java
@@ -21,6 +21,11 @@
 package org.apache.qpid.transport;
 
 
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.transport.network.Frame;
+import org.apache.qpid.transport.util.Logger;
+import org.apache.qpid.transport.util.Waiter;
+
 import static org.apache.qpid.transport.Option.COMPLETED;
 import static org.apache.qpid.transport.Option.SYNC;
 import static org.apache.qpid.transport.Option.TIMELY_REPLY;
@@ -30,11 +35,6 @@
 import static org.apache.qpid.transport.Session.State.NEW;
 import static org.apache.qpid.transport.Session.State.OPEN;
 import static org.apache.qpid.transport.Session.State.RESUMING;
-
-import org.apache.qpid.configuration.ClientProperties;
-import org.apache.qpid.transport.network.Frame;
-import org.apache.qpid.transport.util.Logger;
-import org.apache.qpid.transport.util.Waiter;
 import static org.apache.qpid.util.Serial.ge;
 import static org.apache.qpid.util.Serial.gt;
 import static org.apache.qpid.util.Serial.le;
@@ -161,7 +161,7 @@
         this.expiry = expiry;
     }
 
-    void setClose(boolean close)
+    protected void setClose(boolean close)
     {
         this.closing = close;
     }
@@ -410,7 +410,6 @@
             log.debug("ID: [%s] %s", this.channel, id);
         }
 
-        //if ((id % 65536) == 0)
         if ((id & 0xff) == 0)
         {
             flushProcessed(TIMELY_REPLY);
@@ -514,20 +513,12 @@
 
     void knownComplete(RangeSet kc)
     {
-        synchronized (processedLock)
+        if (kc.size() > 0)
         {
-            RangeSet newProcessed = RangeSetFactory.createRangeSet();
-            for (Range pr : processed)
+            synchronized (processedLock)
             {
-                for (Range kr : kc)
-                {
-                    for (Range r : pr.subtract(kr))
-                    {
-                        newProcessed.add(r);
-                    }
-                }
+                processed.subtract(kc) ;
             }
-            this.processed = newProcessed;
         }
     }
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionClosedException.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionClosedException.java
index 64f9039..01fe05c 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionClosedException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionClosedException.java
@@ -20,9 +20,6 @@
  */
 package org.apache.qpid.transport;
 
-import java.util.Collections;
-
-
 /**
  * SessionClosedException
  *
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionException.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionException.java
index c4fc955..6095b89 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionException.java
@@ -20,8 +20,6 @@
  */
 package org.apache.qpid.transport;
 
-import java.util.List;
-
 /**
  * SessionException
  *
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Struct.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Struct.java
index 22bd9f3..9b703a3 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Struct.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Struct.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.transport;
 
-import java.util.List;
-import java.util.Map;
-
 import org.apache.qpid.transport.codec.Decoder;
 import org.apache.qpid.transport.codec.Encodable;
 import org.apache.qpid.transport.codec.Encoder;
 
+import java.util.Map;
+
 
 /**
  * Struct
@@ -42,7 +41,7 @@
         return StructFactory.create(type);
     }
 
-    boolean dirty = true;
+    private boolean dirty = true;
 
     public boolean isDirty()
     {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractDecoder.java
index 6ff3b21..27fce6e 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractDecoder.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractDecoder.java
@@ -20,8 +20,14 @@
  */
 package org.apache.qpid.transport.codec;
 
-import java.io.UnsupportedEncodingException;
+import org.apache.qpid.transport.Binary;
+import org.apache.qpid.transport.Range;
+import org.apache.qpid.transport.RangeSet;
+import org.apache.qpid.transport.RangeSetFactory;
+import org.apache.qpid.transport.Struct;
+import org.apache.qpid.transport.Type;
 
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.LinkedHashMap;
@@ -29,8 +35,6 @@
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.transport.*;
-
 
 /**
  * AbstractDecoder
@@ -357,13 +361,13 @@
 
     private long readSize(Type t)
     {
-        if (t.fixed)
+        if (t.isFixed())
         {
-            return t.width;
+            return t.getWidth();
         }
         else
         {
-            return readSize(t.width);
+            return readSize(t.getWidth());
         }
     }
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java
index 0ccfcfc..2b93697 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java
@@ -20,23 +20,21 @@
  */
 package org.apache.qpid.transport.codec;
 
-import java.io.UnsupportedEncodingException;
-
-import java.nio.ByteBuffer;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
 import org.apache.qpid.transport.Range;
 import org.apache.qpid.transport.RangeSet;
 import org.apache.qpid.transport.Struct;
 import org.apache.qpid.transport.Type;
 
-import static org.apache.qpid.transport.util.Functions.*;
+import org.apache.qpid.transport.Xid;
+import static org.apache.qpid.transport.util.Functions.lsb;
+
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 
 /**
@@ -64,6 +62,7 @@
         ENCODINGS.put(Character.class, Type.CHAR);
         ENCODINGS.put(byte[].class, Type.VBIN32);
         ENCODINGS.put(UUID.class, Type.UUID);
+        ENCODINGS.put(Xid.class, Type.STRUCT32);
     }
 
     private final Map<String,byte[]> str8cache = new LinkedHashMap<String,byte[]>()
@@ -362,7 +361,7 @@
             Object value = entry.getValue();
             Type type = encoding(value);
             writeStr8(key);
-            put(type.code);
+            put(type.getCode());
             write(type, value);
         }
     }
@@ -383,7 +382,7 @@
         for (Object value : list)
         {
             Type type = encoding(value);
-            put(type.code);
+            put(type.getCode());
             write(type, value);
         }
     }
@@ -411,7 +410,7 @@
             type = encoding(array.get(0));
         }
 
-        put(type.code);
+        put(type.getCode());
 
         writeUint32(array.size());
 
@@ -423,18 +422,18 @@
 
     private void writeSize(Type t, int size)
     {
-        if (t.fixed)
+        if (t.isFixed())
         {
-            if (size != t.width)
+            if (size != t.getWidth())
             {
                 throw new IllegalArgumentException
-                    ("size does not match fixed width " + t.width + ": " +
+                    ("size does not match fixed width " + t.getWidth() + ": " +
                      size);
             }
         }
         else
         {
-            writeSize(t.width, size);
+            writeSize(t.getWidth(), size);
         }
     }
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java
index 10f67e1..a8ac442 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.transport.codec;
 
+import org.apache.qpid.transport.Binary;
+
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 
-import org.apache.qpid.transport.Binary;
-
 /**
  * Byte Buffer Decoder.
  * Decoder concrete implementor using a backing byte buffer for decoding data.
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java
index a4df5b5..fb3f91a 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.transport.codec;
 
+import org.apache.qpid.transport.RangeSet;
+import org.apache.qpid.transport.Struct;
+
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.transport.RangeSet;
-import org.apache.qpid.transport.Struct;
-
 
 /**
  * Decoder interface.
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java
index 7d4f02a..5a3cec5 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.transport.codec;
 
+import org.apache.qpid.transport.RangeSet;
+import org.apache.qpid.transport.Struct;
+
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.transport.RangeSet;
-import org.apache.qpid.transport.Struct;
-
 
 /**
  * Encoder interface.
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Assembler.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Assembler.java
index 8cd5c29..a80b988 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Assembler.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Assembler.java
@@ -20,15 +20,23 @@
  */
 package org.apache.qpid.transport.network;
 
+import org.apache.qpid.transport.DeliveryProperties;
+import org.apache.qpid.transport.Header;
+import org.apache.qpid.transport.MessageProperties;
+import org.apache.qpid.transport.Method;
+import org.apache.qpid.transport.ProtocolError;
+import org.apache.qpid.transport.ProtocolEvent;
+import org.apache.qpid.transport.ProtocolHeader;
+import org.apache.qpid.transport.Receiver;
+import org.apache.qpid.transport.Struct;
+import org.apache.qpid.transport.codec.BBDecoder;
+
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.qpid.transport.*;
-import org.apache.qpid.transport.codec.BBDecoder;
-
 /**
  * Assembler
  *
@@ -181,7 +189,7 @@
             command = Method.create(commandType);
             command.setSync((0x0001 & hdr) != 0);
             command.read(dec);
-            if (command.hasPayload())
+            if (command.hasPayload() && !frame.isLastSegment())
             {
                 setIncompleteCommand(channel, command);
             }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/ConnectionBinding.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/ConnectionBinding.java
index 1a8d277..5a5de59 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/ConnectionBinding.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/ConnectionBinding.java
@@ -20,8 +20,6 @@
  */
 package org.apache.qpid.transport.network;
 
-import java.nio.ByteBuffer;
-
 import org.apache.qpid.transport.Binding;
 import org.apache.qpid.transport.Connection;
 import org.apache.qpid.transport.ConnectionDelegate;
@@ -31,6 +29,8 @@
 import org.apache.qpid.transport.network.security.sasl.SASLReceiver;
 import org.apache.qpid.transport.network.security.sasl.SASLSender;
 
+import java.nio.ByteBuffer;
+
 /**
  * ConnectionBinding
  *
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Disassembler.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Disassembler.java
index 6ac9df9..fe437ec 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Disassembler.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Disassembler.java
@@ -30,16 +30,18 @@
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.Struct;
 import org.apache.qpid.transport.codec.BBEncoder;
+
 import static org.apache.qpid.transport.network.Frame.FIRST_FRAME;
 import static org.apache.qpid.transport.network.Frame.FIRST_SEG;
 import static org.apache.qpid.transport.network.Frame.HEADER_SIZE;
 import static org.apache.qpid.transport.network.Frame.LAST_FRAME;
 import static org.apache.qpid.transport.network.Frame.LAST_SEG;
 
-import static java.lang.Math.min;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 
+import static java.lang.Math.min;
+
 /**
  * Disassembler
  */
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Frame.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Frame.java
index 8493552..9416c4c 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Frame.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Frame.java
@@ -21,16 +21,11 @@
 package org.apache.qpid.transport.network;
 
 import org.apache.qpid.transport.SegmentType;
-import org.apache.qpid.transport.util.SliceIterator;
+
+import static org.apache.qpid.transport.util.Functions.str;
 
 import java.nio.ByteBuffer;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Iterator;
-
-import static org.apache.qpid.transport.util.Functions.*;
-
 
 /**
  * Frame
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/IncomingNetworkTransport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/IncomingNetworkTransport.java
index b371df6..4d42742 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/IncomingNetworkTransport.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/IncomingNetworkTransport.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.transport.network;
 
-import javax.net.ssl.SSLContext;
-
 import org.apache.qpid.protocol.ProtocolEngineFactory;
 import org.apache.qpid.transport.NetworkTransportConfiguration;
 
+import javax.net.ssl.SSLContext;
+
 public interface IncomingNetworkTransport extends NetworkTransport
 {
     public void accept(NetworkTransportConfiguration config, ProtocolEngineFactory factory, SSLContext sslContext);
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/InputHandler.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/InputHandler.java
index a2885f9..86e05db 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/InputHandler.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/InputHandler.java
@@ -20,17 +20,19 @@
  */
 package org.apache.qpid.transport.network;
 
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
 import org.apache.qpid.transport.ProtocolError;
 import org.apache.qpid.transport.ProtocolHeader;
 import org.apache.qpid.transport.Receiver;
 import org.apache.qpid.transport.SegmentType;
 
-import static org.apache.qpid.transport.util.Functions.*;
+import static org.apache.qpid.transport.network.InputHandler.State.ERROR;
+import static org.apache.qpid.transport.network.InputHandler.State.FRAME_BODY;
+import static org.apache.qpid.transport.network.InputHandler.State.FRAME_HDR;
+import static org.apache.qpid.transport.network.InputHandler.State.PROTO_HDR;
+import static org.apache.qpid.transport.util.Functions.str;
 
-import static org.apache.qpid.transport.network.InputHandler.State.*;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 
 /**
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkConnection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkConnection.java
index 7384702..2cc7c14 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkConnection.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkConnection.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.transport.network;
 
+import org.apache.qpid.transport.Sender;
+
 import java.net.SocketAddress;
 import java.nio.ByteBuffer;
 
-import org.apache.qpid.transport.Sender;
-
 public interface NetworkConnection
 {
     Sender<ByteBuffer> getSender();
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/OutgoingNetworkTransport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/OutgoingNetworkTransport.java
index c3c2487..0ebde48 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/OutgoingNetworkTransport.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/OutgoingNetworkTransport.java
@@ -20,16 +20,13 @@
  */
 package org.apache.qpid.transport.network;
 
-import java.nio.ByteBuffer;
-
-import javax.net.ssl.SSLContext;
-
 import org.apache.qpid.transport.ConnectionSettings;
 import org.apache.qpid.transport.Receiver;
 
+import javax.net.ssl.SSLContext;
+import java.nio.ByteBuffer;
+
 public interface OutgoingNetworkTransport extends NetworkTransport
 {
-    public NetworkConnection getConnection();
-
     public NetworkConnection connect(ConnectionSettings settings, Receiver<ByteBuffer> delegate, SSLContext sslContext);
 }
\ No newline at end of file
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java
index da4349b..55ba95a 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.transport.network;
 
+import org.apache.qpid.framing.ProtocolVersion;
+import org.apache.qpid.transport.TransportException;
+
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.qpid.framing.ProtocolVersion;
-import org.apache.qpid.transport.TransportException;
-
 public class Transport
 {
     public static final String QPID_TRANSPORT_PROPNAME = "qpid.transport";
@@ -54,6 +54,10 @@
         OUTGOING_PROTOCOL_TO_IMPLDEFAULTS_MAP = Collections.unmodifiableMap(map);
     }
 
+    private Transport()
+    {
+    }
+
     public static IncomingNetworkTransport getIncomingTransportInstance()
     {
         return (IncomingNetworkTransport) loadTransportClass(
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkConnection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkConnection.java
index bfc7753..4046691 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkConnection.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkConnection.java
@@ -20,15 +20,16 @@
  */
 package org.apache.qpid.transport.network.io;
 
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.nio.ByteBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.transport.Receiver;
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.network.NetworkConnection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
 
 public class IoNetworkConnection implements NetworkConnection
 {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java
index 838a662..42c8334 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java
@@ -21,7 +21,11 @@
 package org.apache.qpid.transport.network.io;
 
 import java.io.IOException;
-import java.net.*;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
 import java.nio.ByteBuffer;
 
 import javax.net.ssl.SSLContext;
@@ -29,16 +33,18 @@
 
 import org.apache.qpid.protocol.ProtocolEngine;
 import org.apache.qpid.protocol.ProtocolEngineFactory;
-import org.apache.qpid.transport.*;
+import org.apache.qpid.transport.ConnectionSettings;
+import org.apache.qpid.transport.NetworkTransportConfiguration;
+import org.apache.qpid.transport.Receiver;
+import org.apache.qpid.transport.TransportException;
 import org.apache.qpid.transport.network.IncomingNetworkTransport;
 import org.apache.qpid.transport.network.NetworkConnection;
 import org.apache.qpid.transport.network.OutgoingNetworkTransport;
-import org.apache.qpid.transport.util.Logger;
+import org.slf4j.LoggerFactory;
 
 public class IoNetworkTransport implements OutgoingNetworkTransport, IncomingNetworkTransport
 {
-
-    private static final Logger LOGGER = Logger.get(IoNetworkTransport.class);
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(IoNetworkTransport.class);
 
     private Socket _socket;
     private IoNetworkConnection _connection;
@@ -58,10 +64,13 @@
             _socket.setSendBufferSize(sendBufferSize);
             _socket.setReceiveBufferSize(receiveBufferSize);
 
-            LOGGER.debug("SO_RCVBUF : %s", _socket.getReceiveBufferSize());
-            LOGGER.debug("SO_SNDBUF : %s", _socket.getSendBufferSize());
-            LOGGER.debug("TCP_NODELAY : %s", _socket.getTcpNoDelay());
-            
+            if(LOGGER.isDebugEnabled())
+            {
+                LOGGER.debug("SO_RCVBUF : " + _socket.getReceiveBufferSize());
+                LOGGER.debug("SO_SNDBUF : " + _socket.getSendBufferSize());
+                LOGGER.debug("TCP_NODELAY : " + _socket.getTcpNoDelay());
+            }
+
             InetAddress address = InetAddress.getByName(settings.getHost());
 
             _socket.connect(new InetSocketAddress(address, settings.getPort()));
@@ -120,7 +129,7 @@
         try
         {
             _acceptor = new AcceptingThread(config, factory, sslContext);
-
+            _acceptor.setDaemon(false);
             _acceptor.start();
         }
         catch (IOException e)
@@ -133,9 +142,10 @@
 
     private class AcceptingThread extends Thread
     {
+        private volatile boolean _closed = false;
         private NetworkTransportConfiguration _config;
         private ProtocolEngineFactory _factory;
-        private SSLContext _sslContent;
+        private SSLContext _sslContext;
         private ServerSocket _serverSocket;
 
         private AcceptingThread(NetworkTransportConfiguration config,
@@ -145,9 +155,9 @@
         {
             _config = config;
             _factory = factory;
-            _sslContent = sslContext;
+            _sslContext = sslContext;
 
-            InetSocketAddress address = new InetSocketAddress(config.getHost(), config.getPort());
+            InetSocketAddress address = config.getAddress();
 
             if(sslContext == null)
             {
@@ -155,12 +165,12 @@
             }
             else
             {
-                SSLServerSocketFactory socketFactory = sslContext.getServerSocketFactory();
+                SSLServerSocketFactory socketFactory = _sslContext.getServerSocketFactory();
                 _serverSocket = socketFactory.createServerSocket();
             }
 
-            _serverSocket.bind(address);
             _serverSocket.setReuseAddress(true);
+            _serverSocket.bind(address);
 
 
         }
@@ -171,6 +181,9 @@
          */
         public void close()
         {
+            LOGGER.debug("Shutting down the Acceptor");
+            _closed = true;
+
             if (!_serverSocket.isClosed())
             {
                 try
@@ -189,11 +202,12 @@
         {
             try
             {
-                while (true)
+                while (!_closed)
                 {
+                    Socket socket = null;
                     try
                     {
-                        Socket socket = _serverSocket.accept();
+                        socket = _serverSocket.accept();
                         socket.setTcpNoDelay(_config.getTcpNoDelay());
 
                         final Integer sendBufferSize = _config.getSendBufferSize();
@@ -206,27 +220,58 @@
 
                         NetworkConnection connection = new IoNetworkConnection(socket, engine, sendBufferSize, receiveBufferSize, _timeout);
 
-
                         engine.setNetworkConnection(connection, connection.getSender());
 
                         connection.start();
-
-
                     }
                     catch(RuntimeException e)
                     {
-                        LOGGER.error(e, "Error in Acceptor thread " + _config.getPort());
+                        LOGGER.error("Error in Acceptor thread on port " + _config.getPort(), e);
+                        closeSocketIfNecessary(socket);
+                    }
+                    catch(IOException e)
+                    {
+                        if(!_closed)
+                        {
+                            LOGGER.error("Error in Acceptor thread on port " + _config.getPort(), e);
+                            closeSocketIfNecessary(socket);
+                            try
+                            {
+                                //Delay to avoid tight spinning the loop during issues such as too many open files
+                                Thread.sleep(1000);
+                            }
+                            catch (InterruptedException ie)
+                            {
+                                LOGGER.debug("Stopping acceptor due to interrupt request");
+                                _closed = true;
+                            }
+                        }
                     }
                 }
             }
-            catch (IOException e)
+            finally
             {
-                LOGGER.debug(e, "SocketException - no new connections will be accepted on port "
-                        + _config.getPort());
+                if(LOGGER.isDebugEnabled())
+                {
+                    LOGGER.debug("Acceptor exiting, no new connections will be accepted on port " + _config.getPort());
+                }
             }
         }
 
-
+        private void closeSocketIfNecessary(final Socket socket)
+        {
+            if(socket != null)
+            {
+                try
+                {
+                    socket.close();
+                }
+                catch (IOException e)
+                {
+                    LOGGER.debug("Exception while closing socket", e);
+                }
+            }
+        }
     }
 
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java
index 5b71443..7e63071 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java
@@ -26,6 +26,7 @@
 import org.apache.qpid.transport.TransportException;
 import org.apache.qpid.transport.util.Logger;
 
+import javax.net.ssl.SSLSocket;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.Socket;
@@ -33,8 +34,6 @@
 import java.nio.ByteBuffer;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import javax.net.ssl.SSLSocket;
-
 /**
  * IoReceiver
  *
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java
index 427487c..a58fea4 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java
@@ -18,6 +18,14 @@
  */
 package org.apache.qpid.transport.network.io;
 
+import org.apache.qpid.common.Closeable;
+import org.apache.qpid.thread.Threading;
+import org.apache.qpid.transport.Sender;
+import org.apache.qpid.transport.SenderClosedException;
+import org.apache.qpid.transport.SenderException;
+import org.apache.qpid.transport.TransportException;
+import org.apache.qpid.transport.util.Logger;
+
 import static org.apache.qpid.transport.util.Functions.mod;
 
 import java.io.IOException;
@@ -28,14 +36,6 @@
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.apache.qpid.common.Closeable;
-import org.apache.qpid.thread.Threading;
-import org.apache.qpid.transport.Sender;
-import org.apache.qpid.transport.SenderClosedException;
-import org.apache.qpid.transport.SenderException;
-import org.apache.qpid.transport.TransportException;
-import org.apache.qpid.transport.util.Logger;
-
 
 public final class IoSender implements Runnable, Sender<ByteBuffer>
 {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java
index 9fd65c6..51ef266 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java
@@ -20,22 +20,10 @@
  */
 package org.apache.qpid.transport.network.security;
 
-import java.nio.ByteBuffer;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-
-import org.apache.qpid.ssl.SSLContextFactory;
-import org.apache.qpid.transport.Connection;
-import org.apache.qpid.transport.ConnectionSettings;
 import org.apache.qpid.transport.Receiver;
 import org.apache.qpid.transport.Sender;
-import org.apache.qpid.transport.TransportException;
-import org.apache.qpid.transport.network.security.sasl.SASLReceiver;
-import org.apache.qpid.transport.network.security.sasl.SASLSender;
-import org.apache.qpid.transport.network.security.ssl.SSLReceiver;
-import org.apache.qpid.transport.network.security.ssl.SSLSender;
-import org.apache.qpid.transport.network.security.ssl.SSLUtil;
+
+import java.nio.ByteBuffer;
 
 public interface SecurityLayer
 {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayerFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayerFactory.java
index 0893400..442800c 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayerFactory.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayerFactory.java
@@ -21,7 +21,10 @@
 package org.apache.qpid.transport.network.security;
 
 import org.apache.qpid.ssl.SSLContextFactory;
-import org.apache.qpid.transport.*;
+import org.apache.qpid.transport.ConnectionSettings;
+import org.apache.qpid.transport.Receiver;
+import org.apache.qpid.transport.Sender;
+import org.apache.qpid.transport.TransportException;
 import org.apache.qpid.transport.network.security.sasl.SASLReceiver;
 import org.apache.qpid.transport.network.security.sasl.SASLSender;
 import org.apache.qpid.transport.network.security.ssl.SSLReceiver;
@@ -34,6 +37,10 @@
 
 public class SecurityLayerFactory
 {
+    private SecurityLayerFactory()
+    {
+    }
+
     public static SecurityLayer newInstance(ConnectionSettings settings)
     {
 
@@ -71,10 +78,10 @@
                 sslCtx = SSLContextFactory
                         .buildClientContext(settings.getTrustStorePath(),
                                 settings.getTrustStorePassword(),
-                                settings.getTrustStoreCertType(),
+                                settings.getTrustManagerFactoryAlgorithm(),
                                 settings.getKeyStorePath(),
                                 settings.getKeyStorePassword(),
-                                settings.getKeyStoreCertType(),
+                                settings.getKeyManagerFactoryAlgorithm(),
                                 settings.getCertAlias());
             }
             catch (Exception e)
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java
index 7964239..625e1a7 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java
@@ -21,21 +21,19 @@
  */
 
 
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslClient;
-
 import org.apache.qpid.transport.Connection;
 import org.apache.qpid.transport.ConnectionException;
 import org.apache.qpid.transport.ConnectionListener;
 
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslClient;
+
 public abstract class SASLEncryptor implements ConnectionListener
 {
-    protected SaslClient saslClient;
-    protected boolean securityLayerEstablished = false;
-    protected int sendBuffSize;
-    protected int recvBuffSize;
+    private SaslClient saslClient;
+    private boolean securityLayerEstablished = false;
+    private int sendBuffSize;
+    private int recvBuffSize;
 
     public boolean isSecurityLayerEstablished()
     {
@@ -63,4 +61,19 @@
     public void closed(Connection conn) {}
     
     public abstract void securityLayerEstablished();
+
+    public SaslClient getSaslClient()
+    {
+        return saslClient;
+    }
+
+    public int getSendBuffSize()
+    {
+        return sendBuffSize;
+    }
+
+    public int getRecvBuffSize()
+    {
+        return recvBuffSize;
+    }
 }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java
index 8610631..a100b96 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java
@@ -21,18 +21,16 @@
  */
 
 
-import java.nio.ByteBuffer;
-
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
-
 import org.apache.qpid.transport.Receiver;
 import org.apache.qpid.transport.SenderException;
 import org.apache.qpid.transport.util.Logger;
 
+import javax.security.sasl.SaslException;
+import java.nio.ByteBuffer;
+
 public class SASLReceiver extends SASLEncryptor implements Receiver<ByteBuffer> {
 
-    Receiver<ByteBuffer> delegate;
+    private Receiver<ByteBuffer> delegate;
     private byte[] netData;
     private static final Logger log = Logger.get(SASLReceiver.class);
     
@@ -58,11 +56,11 @@
         {
             while (buf.hasRemaining())
             {
-                int length = Math.min(buf.remaining(),recvBuffSize);
+                int length = Math.min(buf.remaining(), getRecvBuffSize());
                 buf.get(netData, 0, length);
                 try
                 {
-                    byte[] out = saslClient.unwrap(netData, 0, length);
+                    byte[] out = getSaslClient().unwrap(netData, 0, length);
                     delegate.received(ByteBuffer.wrap(out));
                 } 
                 catch (SaslException e)
@@ -79,7 +77,7 @@
     
     public void securityLayerEstablished()
     {
-        netData = new byte[recvBuffSize];
+        netData = new byte[getRecvBuffSize()];
         log.debug("SASL Security Layer Established");
     }
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java
index 2d9e4e9..61d54a8 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java
@@ -21,19 +21,17 @@
  */
 
 
-import java.nio.ByteBuffer;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
-
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.SenderException;
 import org.apache.qpid.transport.util.Logger;
 
+import javax.security.sasl.SaslException;
+import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicBoolean;
+
 public class SASLSender extends SASLEncryptor implements Sender<ByteBuffer> {
 
-    protected Sender<ByteBuffer> delegate;
+    private Sender<ByteBuffer> delegate;
     private byte[] appData;
     private final AtomicBoolean closed = new AtomicBoolean(false);
     private static final Logger log = Logger.get(SASLSender.class);
@@ -54,7 +52,7 @@
             {
                 try
                 {
-                    saslClient.dispose();
+                    getSaslClient().dispose();
                 } 
                 catch (SaslException e)
                 {
@@ -80,14 +78,14 @@
         {
             while (buf.hasRemaining())
             {
-                int length = Math.min(buf.remaining(),sendBuffSize);
-                log.debug("sendBuffSize %s", sendBuffSize);
+                int length = Math.min(buf.remaining(), getSendBuffSize());
+                log.debug("sendBuffSize %s", getSendBuffSize());
                 log.debug("buf.remaining() %s", buf.remaining());
                 
                 buf.get(appData, 0, length);
                 try
                 {
-                    byte[] out = saslClient.wrap(appData, 0, length);
+                    byte[] out = getSaslClient().wrap(appData, 0, length);
                     log.debug("out.length %s", out.length);
                     
                     delegate.send(ByteBuffer.wrap(out));
@@ -112,7 +110,7 @@
     
     public void securityLayerEstablished()
     {
-        appData = new byte[sendBuffSize];
+        appData = new byte[getSendBuffSize()];
         log.debug("SASL Security Layer Established");
     }
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java
index 4391e8a..3ab028c 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java
@@ -20,6 +20,11 @@
  */
 package org.apache.qpid.transport.network.security.ssl;
 
+import org.apache.qpid.transport.util.Logger;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.X509ExtendedKeyManager;
 import java.io.IOException;
 import java.net.Socket;
 import java.security.GeneralSecurityException;
@@ -28,25 +33,19 @@
 import java.security.PrivateKey;
 import java.security.cert.X509Certificate;
 
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.X509ExtendedKeyManager;
-
-import org.apache.qpid.transport.util.Logger;
-
 public class QpidClientX509KeyManager extends X509ExtendedKeyManager
 {
     private static final Logger log = Logger.get(QpidClientX509KeyManager.class);
     
-    X509ExtendedKeyManager delegate;
-    String alias;
+    private X509ExtendedKeyManager delegate;
+    private String alias;
     
     public QpidClientX509KeyManager(String alias, String keyStorePath,
-                           String keyStorePassword,String keyStoreCertType) throws GeneralSecurityException, IOException
+                           String keyStorePassword, String keyManagerFactoryAlgorithmName) throws GeneralSecurityException, IOException
     {
         this.alias = alias;    
         KeyStore ks = SSLUtil.getInitializedKeyStore(keyStorePath,keyStorePassword);
-        KeyManagerFactory kmf = KeyManagerFactory.getInstance(keyStoreCertType);
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithmName);
         kmf.init(ks, keyStorePassword.toCharArray());
         this.delegate = (X509ExtendedKeyManager)kmf.getKeyManagers()[0];
     }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java
index 8ad40bb..13a16d0 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java
@@ -20,19 +20,17 @@
  */
 package org.apache.qpid.transport.network.security.ssl;
 
-import java.nio.ByteBuffer;
+import org.apache.qpid.transport.Receiver;
+import org.apache.qpid.transport.TransportException;
+import org.apache.qpid.transport.network.security.SSLStatus;
+import org.apache.qpid.transport.util.Logger;
 
 import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLEngineResult;
 import javax.net.ssl.SSLEngineResult.HandshakeStatus;
 import javax.net.ssl.SSLEngineResult.Status;
 import javax.net.ssl.SSLException;
-
-import org.apache.qpid.transport.ConnectionSettings;
-import org.apache.qpid.transport.Receiver;
-import org.apache.qpid.transport.TransportException;
-import org.apache.qpid.transport.network.security.SSLStatus;
-import org.apache.qpid.transport.util.Logger;
+import java.nio.ByteBuffer;
 
 public class SSLReceiver implements Receiver<ByteBuffer>
 {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java
index 6f5aa6d..8894369 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java
@@ -19,21 +19,19 @@
  */
 package org.apache.qpid.transport.network.security.ssl;
 
-import java.nio.ByteBuffer;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLEngineResult;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLEngineResult.HandshakeStatus;
-import javax.net.ssl.SSLEngineResult.Status;
-
-import org.apache.qpid.transport.ConnectionSettings;
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.SenderException;
 import org.apache.qpid.transport.network.security.SSLStatus;
 import org.apache.qpid.transport.util.Logger;
 
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLEngineResult;
+import javax.net.ssl.SSLEngineResult.HandshakeStatus;
+import javax.net.ssl.SSLEngineResult.Status;
+import javax.net.ssl.SSLException;
+import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicBoolean;
+
 public class SSLSender implements Sender<ByteBuffer>
 {
     private static final Logger log = Logger.get(SSLSender.class);
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java
index 6bb038a..71a73db 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java
@@ -20,6 +20,11 @@
  */
 package org.apache.qpid.transport.network.security.ssl;
 
+import org.apache.qpid.transport.TransportException;
+import org.apache.qpid.transport.util.Logger;
+
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLPeerUnverifiedException;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -30,19 +35,14 @@
 import java.security.cert.Certificate;
 import java.security.cert.X509Certificate;
 
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLPeerUnverifiedException;
-
-import org.apache.qpid.ssl.SSLContextFactory;
-import org.apache.qpid.transport.ConnectionSettings;
-import org.apache.qpid.transport.TransportException;
-import org.apache.qpid.transport.util.Logger;
-
 public class SSLUtil
 {
     private static final Logger log = Logger.get(SSLUtil.class);
-    
+
+    private SSLUtil()
+    {
+    }
+
     public static void verifyHostname(SSLEngine engine,String hostnameExpected)
     {
         try
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java
index 5761228..bd3e9bb 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java
@@ -22,7 +22,7 @@
 
 import java.nio.ByteBuffer;
 
-import static java.lang.Math.*;
+import static java.lang.Math.min;
 
 
 /**
@@ -31,8 +31,11 @@
  * @author Rafael H. Schloming
  */
 
-public class Functions
+public final class Functions
 {
+    private Functions()
+    {
+    }
 
     public static final int mod(int n, int m)
     {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/SliceIterator.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/util/SliceIterator.java
deleted file mode 100644
index 3db2984..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/SliceIterator.java
+++ /dev/null
@@ -1,59 +0,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.
- *
- */
-package org.apache.qpid.transport.util;
-
-import java.nio.ByteBuffer;
-
-import java.util.Iterator;
-
-
-/**
- * SliceIterator
- *
- * @author Rafael H. Schloming
- */
-
-public class SliceIterator implements Iterator<ByteBuffer>
-{
-
-    final private Iterator<ByteBuffer> iterator;
-
-    public SliceIterator(Iterator<ByteBuffer> iterator)
-    {
-        this.iterator = iterator;
-    }
-
-    public boolean hasNext()
-    {
-        return iterator.hasNext();
-    }
-
-    public ByteBuffer next()
-    {
-        return iterator.next().slice();
-    }
-
-    public void remove()
-    {
-        throw new UnsupportedOperationException();
-    }
-
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java b/qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java
index 26cb56e..3b9a0ba 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java
@@ -20,26 +20,25 @@
  */
 package org.apache.qpid.url;
 
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import java.net.URISyntaxException;
+import java.util.HashMap;
 
 public class AMQBindingURL implements BindingURL
 {
     private static final Logger _logger = LoggerFactory.getLogger(AMQBindingURL.class);
 
-    String _url;
-    AMQShortString _exchangeClass = ExchangeDefaults.DIRECT_EXCHANGE_CLASS;
-    AMQShortString _exchangeName = new AMQShortString("");
-    AMQShortString _destinationName = new AMQShortString("");;
-    AMQShortString _queueName = new AMQShortString("");
-    AMQShortString[] _bindingKeys = new AMQShortString[0];
+    private String _url;
+    private AMQShortString _exchangeClass = ExchangeDefaults.DIRECT_EXCHANGE_CLASS;
+    private AMQShortString _exchangeName = new AMQShortString("");
+    private AMQShortString _destinationName = new AMQShortString("");;
+    private AMQShortString _queueName = new AMQShortString("");
+    private AMQShortString[] _bindingKeys = new AMQShortString[0];
     private HashMap<String, String> _options;
 
     public AMQBindingURL(String url) throws URISyntaxException
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/url/BindingURLParser.java b/qpid/java/common/src/main/java/org/apache/qpid/url/BindingURLParser.java
index 0ebfe0e..fe7b017 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/url/BindingURLParser.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/url/BindingURLParser.java
@@ -21,6 +21,12 @@
  */
 
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.framing.AMQShortString;
+
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -28,11 +34,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.qpid.exchange.ExchangeDefaults;
-import org.apache.qpid.framing.AMQShortString;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class BindingURLParser
 {
     private static final char PROPERTY_EQUALS_CHAR = '=';
@@ -183,7 +184,7 @@
         char nextChar = _url[_index];
 
         // check for the following special cases.
-        // "myQueue?durable='true'" or just "myQueue";
+        // "myQueue?durable='true'" or just "myQueue"
 
         StringBuilder builder = new StringBuilder();
         while (nextChar != COLON_CHAR && nextChar != QUESTION_MARK_CHAR && nextChar != END_OF_URL_MARKER_CHAR)
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java b/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java
index e261860..8516e7f 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.url;
 
-import java.util.HashMap;
 import java.util.Map;
 
 public class URLHelper
@@ -29,6 +28,10 @@
     public static final char ALTERNATIVE_OPTION_SEPARATOR = ',';
     public static final char BROKER_SEPARATOR = ';';
 
+    private URLHelper()
+    {
+    }
+
     public static void parseOptions(Map<String, String> optionMap, String options) throws URLSyntaxException
     {
         if ((options == null) || (options.indexOf('=') == -1))
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/BytesDataOutput.java b/qpid/java/common/src/main/java/org/apache/qpid/util/BytesDataOutput.java
new file mode 100644
index 0000000..7fca54a
--- /dev/null
+++ b/qpid/java/common/src/main/java/org/apache/qpid/util/BytesDataOutput.java
@@ -0,0 +1,178 @@
+/*
+ *
+ * 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.util;
+
+import java.io.DataOutput;
+
+public class BytesDataOutput implements DataOutput
+{
+    private int _pos = 0;
+    private byte[] _buf;
+
+    public BytesDataOutput(byte[] buf)
+    {
+        _buf = buf;
+    }
+
+    public void setBuffer(byte[] buf)
+    {
+        _buf = buf;
+        _pos = 0;
+    }
+
+    public void reset()
+    {
+        _pos = 0;
+    }
+
+    public int length()
+    {
+        return _pos;
+    }
+
+    public void write(int b)
+    {
+        _buf[_pos++] = (byte) b;
+    }
+
+    public void write(byte[] b)
+    {
+        System.arraycopy(b, 0, _buf, _pos, b.length);
+        _pos+=b.length;
+    }
+
+
+    public void write(byte[] b, int off, int len)
+    {
+        System.arraycopy(b, off, _buf, _pos, len);
+        _pos+=len;
+
+    }
+
+    public void writeBoolean(boolean v)
+    {
+        _buf[_pos++] = v ? (byte) 1 : (byte) 0;
+    }
+
+    public void writeByte(int v)
+    {
+        _buf[_pos++] = (byte) v;
+    }
+
+    public void writeShort(int v)
+    {
+        _buf[_pos++] = (byte) (v >>> 8);
+        _buf[_pos++] = (byte) v;
+    }
+
+    public void writeChar(int v)
+    {
+        _buf[_pos++] = (byte) (v >>> 8);
+        _buf[_pos++] = (byte) v;
+    }
+
+    public void writeInt(int v)
+    {
+        _buf[_pos++] = (byte) (v >>> 24);
+        _buf[_pos++] = (byte) (v >>> 16);
+        _buf[_pos++] = (byte) (v >>> 8);
+        _buf[_pos++] = (byte) v;
+    }
+
+    public void writeLong(long v)
+    {
+        _buf[_pos++] = (byte) (v >>> 56);
+        _buf[_pos++] = (byte) (v >>> 48);
+        _buf[_pos++] = (byte) (v >>> 40);
+        _buf[_pos++] = (byte) (v >>> 32);
+        _buf[_pos++] = (byte) (v >>> 24);
+        _buf[_pos++] = (byte) (v >>> 16);
+        _buf[_pos++] = (byte) (v >>> 8);
+        _buf[_pos++] = (byte)v;
+    }
+
+    public void writeFloat(float v)
+    {
+        writeInt(Float.floatToIntBits(v));
+    }
+
+    public void writeDouble(double v)
+    {
+        writeLong(Double.doubleToLongBits(v));
+    }
+
+    public void writeBytes(String s)
+    {
+        int len = s.length();
+        for (int i = 0 ; i < len ; i++)
+        {
+            _buf[_pos++] = ((byte)s.charAt(i));
+        }
+    }
+
+    public void writeChars(String s)
+    {
+        int len = s.length();
+        for (int i = 0 ; i < len ; i++)
+        {
+            int v = s.charAt(i);
+            _buf[_pos++] = (byte) (v >>> 8);
+            _buf[_pos++] = (byte) v;
+        }
+    }
+
+    public void writeUTF(String s)
+    {
+        int strlen = s.length();
+
+        int pos = _pos;
+        _pos+=2;
+
+
+        for (int i = 0; i < strlen; i++)
+        {
+            int c = s.charAt(i);
+            if ((c >= 0x0001) && (c <= 0x007F))
+            {
+                c = s.charAt(i);
+                _buf[_pos++] = (byte) c;
+
+            }
+            else if (c > 0x07FF)
+            {
+                _buf[_pos++]  = (byte) (0xE0 | ((c >> 12) & 0x0F));
+                _buf[_pos++]  = (byte) (0x80 | ((c >>  6) & 0x3F));
+                _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
+            }
+            else
+            {
+                _buf[_pos++] = (byte) (0xC0 | ((c >>  6) & 0x1F));
+                _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
+            }
+        }
+
+        int len = _pos - (pos + 2);
+
+        _buf[pos++] = (byte) (len >>> 8);
+        _buf[pos] = (byte) len;
+    }
+
+}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java b/qpid/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java
index 09478d4..3d17bbf 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java
@@ -26,7 +26,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.regex.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * CommandLineParser provides a utility for specifying the format of a command line and parsing command lines to ensure
@@ -328,9 +329,6 @@
                         expectingArgs = true;
                         optionExpectingArgs = matchedOption;
 
-                        // In the mean time set this options argument to the empty string in case no argument is ever
-                        // supplied.
-                        // options.put(matchedOption, "");
                     }
 
                     // Check if the option was matched on its own and is a flag in which case set that flag.
@@ -654,22 +652,22 @@
     protected static class CommandLineOption
     {
         /** Holds the text for the flag to match this argument with. */
-        public String option = null;
+        private String option = null;
 
         /** Holds a string describing how to use this command line argument. */
-        public String argument = null;
+        private String argument = null;
 
         /** Flag that determines whether or not this command line argument can take arguments. */
-        public boolean expectsArgs = false;
+        private boolean expectsArgs = false;
 
         /** Holds a short comment describing what this command line argument is for. */
-        public String comment = null;
+        private String comment = null;
 
         /** Flag that determines whether or not this is an mandatory command line argument. */
-        public boolean mandatory = false;
+        private boolean mandatory = false;
 
         /** A regular expression describing what format the argument to this option muist have. */
-        public String argumentFormatRegexp = null;
+        private String argumentFormatRegexp = null;
 
         /**
          * Create a command line option object that holds specific information about a command line option.
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/ConcurrentLinkedMessageQueueAtomicSize.java b/qpid/java/common/src/main/java/org/apache/qpid/util/ConcurrentLinkedMessageQueueAtomicSize.java
deleted file mode 100644
index 633cf4f..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/ConcurrentLinkedMessageQueueAtomicSize.java
+++ /dev/null
@@ -1,258 +0,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.
- *
- *
- */
-package org.apache.qpid.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Queue;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class ConcurrentLinkedMessageQueueAtomicSize<E> extends ConcurrentLinkedQueueAtomicSize<E> implements MessageQueue<E>
-{
-    private static final Logger _logger = LoggerFactory.getLogger(ConcurrentLinkedMessageQueueAtomicSize.class);
-
-    protected Queue<E> _messageHead = new ConcurrentLinkedQueueAtomicSize<E>();
-
-    protected AtomicInteger _messageHeadSize = new AtomicInteger(0);
-
-    @Override
-    public int size()
-    {
-        return super.size() + _messageHeadSize.get();
-    }
-
-    public int headSize()
-    {
-        return _messageHeadSize.get();
-    }
-
-    @Override
-    public E poll()
-    {
-        if (_messageHead.isEmpty())
-        {
-            return super.poll();
-        }
-        else
-        {
-            E e = _messageHead.poll();
-
-            if (_logger.isDebugEnabled())
-            {
-                _logger.debug("Providing item(" + e + ")from message head");
-            }
-
-            if (e != null)
-            {
-                _messageHeadSize.decrementAndGet();
-            }
-
-            return e;
-        }
-    }
-
-    @Override
-    public boolean remove(Object o)
-    {
-
-        if (_messageHead.isEmpty())
-        {
-            return super.remove(o);
-        }
-        else
-        {
-            if (_messageHead.remove(o))
-            {
-                _messageHeadSize.decrementAndGet();
-
-                return true;
-            }
-
-            return super.remove(o);
-        }
-    }
-
-    @Override
-    public boolean removeAll(Collection<?> c)
-    {
-        if (_messageHead.isEmpty())
-        {
-            return super.removeAll(c);
-        }
-        else
-        {
-            // fixme this is super.removeAll but iterator here doesn't work
-            // we need to be able to correctly decrement _messageHeadSize
-            // boolean modified = false;
-            // Iterator<?> e = iterator();
-            // while (e.hasNext())
-            // {
-            // if (c.contains(e.next()))
-            // {
-            // e.remove();
-            // modified = true;
-            // _size.decrementAndGet();
-            // }
-            // }
-            // return modified;
-
-            throw new RuntimeException("Not implemented");
-        }
-    }
-
-    @Override
-    public boolean isEmpty()
-    {
-        return (_messageHead.isEmpty() && super.isEmpty());
-    }
-
-    @Override
-    public void clear()
-    {
-        super.clear();
-        _messageHead.clear();
-    }
-
-    @Override
-    public boolean contains(Object o)
-    {
-        return _messageHead.contains(o) || super.contains(o);
-    }
-
-    @Override
-    public boolean containsAll(Collection<?> o)
-    {
-        return _messageHead.containsAll(o) || super.containsAll(o);
-    }
-
-    @Override
-    public E element()
-    {
-        if (_messageHead.isEmpty())
-        {
-            return super.element();
-        }
-        else
-        {
-            return _messageHead.element();
-        }
-    }
-
-    @Override
-    public E peek()
-    {
-        if (_messageHead.isEmpty())
-        {
-            return super.peek();
-        }
-        else
-        {
-            E o = _messageHead.peek();
-            if (_logger.isDebugEnabled())
-            {
-                _logger.debug("Peeking item (" + o + ") from message head");
-            }
-
-            return o;
-        }
-
-    }
-
-    @Override
-    public Iterator<E> iterator()
-    {
-        final Iterator<E> mainMessageIterator = super.iterator();
-
-        return new Iterator<E>()
-            {
-                final Iterator<E> _headIterator = _messageHead.iterator();
-                final Iterator<E> _mainIterator = mainMessageIterator;
-
-                Iterator<E> last;
-
-                public boolean hasNext()
-                {
-                    return _headIterator.hasNext() || _mainIterator.hasNext();
-                }
-
-                public E next()
-                {
-                    if (_headIterator.hasNext())
-                    {
-                        last = _headIterator;
-
-                        return _headIterator.next();
-                    }
-                    else
-                    {
-                        last = _mainIterator;
-
-                        return _mainIterator.next();
-                    }
-                }
-
-                public void remove()
-                {
-                    last.remove();
-                    if(last == _mainIterator)
-                    {
-                        _size.decrementAndGet();
-                    }
-                    else
-                    {
-                        _messageHeadSize.decrementAndGet();                        
-                    }
-                }
-            };
-    }
-
-    @Override
-    public boolean retainAll(Collection<?> c)
-    {
-        throw new RuntimeException("Not Implemented");
-    }
-
-    @Override
-    public Object[] toArray()
-    {
-        throw new RuntimeException("Not Implemented");
-    }
-
-    public boolean pushHead(E o)
-    {
-        if (_logger.isDebugEnabled())
-        {
-            _logger.debug("Adding item(" + o + ") to head of queue");
-        }
-
-        if (_messageHead.offer(o))
-        {
-            _messageHeadSize.incrementAndGet();
-
-            return true;
-        }
-
-        return false;
-    }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/ConcurrentLinkedQueueAtomicSize.java b/qpid/java/common/src/main/java/org/apache/qpid/util/ConcurrentLinkedQueueAtomicSize.java
deleted file mode 100644
index c4d7683..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/ConcurrentLinkedQueueAtomicSize.java
+++ /dev/null
@@ -1,70 +0,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.
- *
- */
-package org.apache.qpid.util;
-
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class ConcurrentLinkedQueueAtomicSize<E> extends ConcurrentLinkedQueue<E>
-{
-    AtomicInteger _size = new AtomicInteger(0);
-
-    public int size()
-    {
-        return _size.get();
-    }
-
-    public boolean offer(E o)
-    {
-
-        if (super.offer(o))
-        {
-            _size.incrementAndGet();
-            return true;
-        }
-
-        return false;
-    }
-
-    public E poll()
-    {
-        E e = super.poll();
-
-        if (e != null)
-        {
-            _size.decrementAndGet();
-        }
-
-        return e;
-    }
-
-    @Override
-    public boolean remove(Object o)
-    {
-        if (super.remove(o))
-        {
-            _size.decrementAndGet();
-            return true;
-        }
-
-        return false;
-    }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/ConcurrentLinkedQueueNoSize.java b/qpid/java/common/src/main/java/org/apache/qpid/util/ConcurrentLinkedQueueNoSize.java
deleted file mode 100644
index 1f16834..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/ConcurrentLinkedQueueNoSize.java
+++ /dev/null
@@ -1,38 +0,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.
- *
- */
-package org.apache.qpid.util;
-
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-public class ConcurrentLinkedQueueNoSize<E> extends ConcurrentLinkedQueue<E>
-{
-    public int size()
-    {
-        if (isEmpty())
-        {
-            return 0;
-        }
-        else
-        {
-            return 1;
-        }
-    }        
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java b/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
index ac8e3da..2d3e321 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
@@ -46,6 +46,10 @@
  */
 public class FileUtils
 {
+    private FileUtils()
+    {
+    }
+
     /**
      * Reads a text file as a string.
      *
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/MessageQueue.java b/qpid/java/common/src/main/java/org/apache/qpid/util/MessageQueue.java
deleted file mode 100644
index b5efaa6..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/MessageQueue.java
+++ /dev/null
@@ -1,43 +0,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.
- *
- *
- */
-package org.apache.qpid.util;
-
-import java.util.Queue;
-
-/**
- * Defines a queue that has a push operation to add an element to the head of the queue.
- *
- * @todo Seems like this may be pointless, the implementation uses this method to increment the message count
- *       then calls offer. Why not simply override offer and drop this interface?
- */
-public interface MessageQueue<E> extends Queue<E>
-{
-    /**
-     * Inserts the specified element into this queue, if possible. When using queues that may impose insertion
-     * restrictions (for example capacity bounds), method offer is generally preferable to method Collection.add(E),
-     * which can fail to insert an element only by throwing an exception.
-     *
-     * @param o The element to insert.
-     *
-     * @return <tt>true</tt> if it was possible to add the element to this queue, else <tt>false</tt>
-     */
-    boolean pushHead(E o);
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/NetMatcher.java b/qpid/java/common/src/main/java/org/apache/qpid/util/NetMatcher.java
index 4c653e6..971dd3f 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/NetMatcher.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/util/NetMatcher.java
@@ -29,14 +29,20 @@
     public void initInetNetworks(final Collection nets)
     {
         networks = new ArrayList();
-        for (Iterator iter = nets.iterator(); iter.hasNext(); ) try
+        for (Iterator iter = nets.iterator(); iter.hasNext(); )
         {
-            InetNetwork net = InetNetwork.getFromString((String) iter.next());
-            if (!networks.contains(net)) networks.add(net);
-        }
-        catch (java.net.UnknownHostException uhe)
-        {
-            log("Cannot resolve address: " + uhe.getMessage());
+            try
+            {
+                InetNetwork net = InetNetwork.getFromString((String) iter.next());
+                if (!networks.contains(net))
+                {
+                    networks.add(net);
+                }
+            }
+            catch (java.net.UnknownHostException uhe)
+            {
+                log("Cannot resolve address: " + uhe.getMessage());
+            }
         }
         networks.trimToSize();
     }
@@ -44,14 +50,20 @@
     public void initInetNetworks(final String[] nets)
     {
         networks = new ArrayList();
-        for (int i = 0; i < nets.length; i++) try
+        for (int i = 0; i < nets.length; i++)
         {
-            InetNetwork net = InetNetwork.getFromString(nets[i]);
-            if (!networks.contains(net)) networks.add(net);
-        }
-        catch (java.net.UnknownHostException uhe)
-        {
-            log("Cannot resolve address: " + uhe.getMessage());
+            try
+            {
+                InetNetwork net = InetNetwork.getFromString(nets[i]);
+                if (!networks.contains(net))
+                {
+                    networks.add(net);
+                }
+            }
+            catch (java.net.UnknownHostException uhe)
+            {
+                log("Cannot resolve address: " + uhe.getMessage());
+            }
         }
         networks.trimToSize();
     }
@@ -71,10 +83,13 @@
 
         boolean sameNet = false;
 
-        if (ip != null) for (Iterator iter = networks.iterator(); (!sameNet) && iter.hasNext(); )
+        if (ip != null)
         {
-            InetNetwork network = (InetNetwork) iter.next();
-            sameNet = network.contains(ip);
+            for (Iterator iter = networks.iterator(); (!sameNet) && iter.hasNext(); )
+            {
+                InetNetwork network = (InetNetwork) iter.next();
+                sameNet = network.contains(ip);
+            }
         }
         return sameNet;
     }
@@ -156,12 +171,21 @@
 
     public static InetNetwork getFromString(String netspec) throws java.net.UnknownHostException
     {
-        if (netspec.endsWith("*")) netspec = normalizeFromAsterisk(netspec);
+        if (netspec.endsWith("*"))
+        {
+            netspec = normalizeFromAsterisk(netspec);
+        }
         else
         {
             int iSlash = netspec.indexOf('/');
-            if (iSlash == -1) netspec += "/255.255.255.255";
-            else if (netspec.indexOf('.', iSlash) == -1) netspec = normalizeFromCIDR(netspec);
+            if (iSlash == -1)
+            {
+                netspec += "/255.255.255.255";
+            }
+            else if (netspec.indexOf('.', iSlash) == -1)
+            {
+                netspec = normalizeFromCIDR(netspec);
+            }
         }
 
         return new InetNetwork(InetAddress.getByName(netspec.substring(0, netspec.indexOf('/'))),
@@ -205,8 +229,12 @@
         String[] masks = {  "0.0.0.0/0.0.0.0", "0.0.0/255.0.0.0", "0.0/255.255.0.0", "0/255.255.255.0" };
         char[] srcb = netspec.toCharArray();                
         int octets = 0;
-        for (int i = 1; i < netspec.length(); i++) {
-            if (srcb[i] == '.') octets++;
+        for (int i = 1; i < netspec.length(); i++)
+        {
+            if (srcb[i] == '.')
+            {
+                octets++;
+            }
         }
         return (octets == 0) ? masks[0] : netspec.substring(0, netspec.length() -1 ).concat(masks[octets]);
     }
@@ -244,10 +272,18 @@
     private static InetAddress getByAddress(byte[] ip) throws java.net.UnknownHostException
     {
         InetAddress addr = null;
-        if (getByAddress != null) try {
-            addr = (InetAddress) getByAddress.invoke(null, new Object[] { ip });
-        } catch (IllegalAccessException e) {
-        } catch (java.lang.reflect.InvocationTargetException e) {
+        if (getByAddress != null)
+        {
+            try
+            {
+                addr = (InetAddress) getByAddress.invoke(null, new Object[] { ip });
+            }
+            catch (IllegalAccessException e)
+            {
+            }
+            catch (java.lang.reflect.InvocationTargetException e)
+            {
+            }
         }
 
         if (addr == null) {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/PrettyPrintingUtils.java b/qpid/java/common/src/main/java/org/apache/qpid/util/PrettyPrintingUtils.java
deleted file mode 100644
index 93266f2..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/PrettyPrintingUtils.java
+++ /dev/null
@@ -1,75 +0,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.
- *
- */
-package org.apache.qpid.util;
-
-/**
- * Contains pretty printing convenienve methods for producing formatted logging output, mostly for debugging purposes.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * </table>
- *
- * @todo Drop this. There are already array pretty printing methods it java.utils.Arrays.
- */
-public class PrettyPrintingUtils
-{
-    /**
-     * Pretty prints an array of ints as a string.
-     *
-     * @param array The array to pretty print.
-     *
-     * @return The pretty printed string.
-     */
-    public static String printArray(int[] array)
-    {
-        StringBuilder result = new StringBuilder("[");
-        for (int i = 0; i < array.length; i++)
-        {
-            result.append(array[i])
-                  .append((i < (array.length - 1)) ? ", " : "");
-        }
-
-        result.append(']');
-
-        return result.toString();
-    }
-
-    /**
-     * Pretty prints an array of strings as a string.
-     *
-     * @param array The array to pretty print.
-     *
-     * @return The pretty printed string.
-     */
-    public static String printArray(String[] array)
-    {
-        String result = "[";
-        for (int i = 0; i < array.length; i++)
-        {
-            result += array[i];
-            result += (i < (array.length - 1)) ? ", " : "";
-        }
-
-        result += "]";
-
-        return result;
-    }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/Serial.java b/qpid/java/common/src/main/java/org/apache/qpid/util/Serial.java
index 8ad9d00..451d5d6 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/Serial.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/util/Serial.java
@@ -23,8 +23,6 @@
 
 import java.util.Comparator;
 
-import org.apache.qpid.SerialException;
-
 /**
  * This class provides basic serial number comparisons as defined in
  * RFC 1982.
@@ -32,6 +30,9 @@
 
 public class Serial
 {
+    private Serial()
+    {
+    }
 
     public static final Comparator<Integer> COMPARATOR = new Comparator<Integer>()
     {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java b/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java
index fe1a300..f2d51cc 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java
@@ -21,7 +21,6 @@
 package org.apache.qpid.util;
 
 import java.io.UnsupportedEncodingException;
-
 import java.util.Arrays;
 import java.util.Map;
 import java.util.Properties;
@@ -37,6 +36,9 @@
 
 public final class Strings
 {
+    private Strings()
+    {
+    }
 
     private static final byte[] EMPTY = new byte[0];
 
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/UUIDs.java b/qpid/java/common/src/main/java/org/apache/qpid/util/UUIDs.java
index 4bf6b7f..d9b2dd8 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/UUIDs.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/util/UUIDs.java
@@ -28,6 +28,9 @@
 
 public final class UUIDs
 {
+    private UUIDs()
+    {
+    }
 
     public static final UUIDGen newGenerator()
     {
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/AlreadyUnblockedException.java b/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/AlreadyUnblockedException.java
deleted file mode 100644
index e0c0337..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/AlreadyUnblockedException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.apache.qpid.util.concurrent;
-/*
- * 
- * 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.
- * 
- */
-
-
-/**
- * Used to signal that a data element and its producer cannot be requeued or sent an error message when using a
- * {@link BatchSynchQueue} because the producer has already been unblocked by an unblocking take on the queue.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Signal that an unblocking take has already occurred.
- * </table>
- */
-public class AlreadyUnblockedException extends RuntimeException
-{ }
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/BatchSynchQueue.java b/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/BatchSynchQueue.java
deleted file mode 100644
index 63d8f77..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/BatchSynchQueue.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package org.apache.qpid.util.concurrent;
-/*
- * 
- * 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.
- * 
- */
-
-
-import java.util.Collection;
-import java.util.concurrent.BlockingQueue;
-
-/**
- * BatchSynchQueue is an abstraction of the classic producer/consumer buffer pattern for thread interaction. In this
- * pattern threads can deposit data onto a buffer whilst other threads take data from the buffer and perform usefull
- * work with it. A BatchSynchQueue adds to this the possibility that producers can be blocked until their data is
- * consumed or until a consumer chooses to release the producer some time after consuming the data from the queue.
- *
- * <p>There are a number of possible advantages to using this technique when compared with having the producers
- * processing their own data:
- *
- * <ul>
- * <li>Data may be deposited asynchronously in the buffer allowing the producers to continue running.</li>
- * <li>Data may be deposited synchronously in the buffer so that producers wait until their data has been processed
- *     before being allowed to continue.</li>
- * <li>Variable rates of production/consumption can be smoothed over by the buffer as it provides space in memory to
- *     hold data between production and consumption.</li>
- * <li>Consumers may be able to batch data as they consume it leading to more efficient consumption over
- *     individual data item consumption where latency associated with the consume operation can be ammortized.
- *     For example, it may be possibly to ammortize the cost of a disk seek over many producers.</li>
- * <li>Data from seperate threads can be combined together in the buffer, providing a convenient way of spreading work
- *     amongst many workers and gathering the results together again.</li>
- * <li>Different types of queue can be used to hold the buffer, resulting in different processing orders. For example,
- *     lifo, fifo, priority heap, etc.</li>
- * </ul>
- *
- * <p/>The asynchronous type of producer/consumer buffers is already well supported by the java.util.concurrent package
- * (in Java 5) and there is also a synchronous queue implementation available there too. This interface extends the
- * blocking queue with some more methods for controlling a synchronous blocking queue. In particular it adds additional
- * take methods that can be used to take data from a queue without releasing producers, so that consumers have an
- * opportunity to confirm correct processing of the data before producers are released. It also adds a put method with
- * exceptions so that consumers can signal exception cases back to producers where there are errors in the data.
- *
- * <p/>This type of queue is usefull in situations where consumers can obtain an efficiency gain by batching data
- * from many threads but where synchronous handling of that data is neccessary because producers need to know that
- * their data has been processed before they continue. For example, sending a bundle of messages together, or writing
- * many records to disk at once, may result in improved performance but the originators of the messages or disk records
- * need confirmation that their data has really been sent or saved to disk.
- *
- * <p/>The consumer can put an element back onto the queue or send an error message to the elements producer using the
- * {@link SynchRecord} interface.
- *
- * <p/>The {@link #take()}, {@link #drainTo(java.util.Collection<? super E>)}  and
- * {@link #drainTo(java.util.Collection<? super E>, int)} methods from {@link BlockingQueue} should behave as if they
- * have been called with unblock set to false. That is they take elements from the queue but leave the producers
- * blocked. These methods do not return collections of {@link SynchRecord}s so they do not supply an interface through
- * which errors or re-queuings can be applied. If these methods are used then the consumer must succesfully process
- * all the records it takes.
- *
- * <p/>The {@link #put} method should silently swallow any exceptions that consumers attempt to return to the caller.
- * In order to handle exceptions the {@link #tryPut} method must be used.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Handle synchronous puts, with possible exceptions.
- * <tr><td> Allow consumers to take many records from a queue in a batch.
- * <tr><td> Allow consumers to decide when to unblock synchronous producers.
- * </table>
- */
-public interface BatchSynchQueue<E> extends BlockingQueue<E>
-{
-    /**
-     * Tries a synchronous put into the queue. If a consumer encounters an exception condition whilst processing the
-     * data that is put, then this is returned to the caller wrapped inside a {@link SynchException}.
-     *
-     * @param e The data element to put into the queue.
-     *
-     * @throws InterruptedException If the thread is interrupted whilst waiting to write to the queue or whilst waiting
-     *                              on its entry in the queue being consumed.
-     * @throws SynchException       If a consumer encounters an error whilst processing the data element.
-     */
-    public void tryPut(E e) throws InterruptedException, SynchException;
-
-    /**
-     * Takes all available data items from the queue or blocks until some become available. The returned items
-     * are wrapped in a {@link SynchRecord} which provides an interface to requeue them or send errors to their
-     * producers, where the producers are still blocked.
-     *
-     * @param c       The collection to drain the data items into.
-     * @param unblock If set to <tt>true</tt> the producers for the taken items will be immediately unblocked.
-     *
-     * @return A count of the number of elements that were drained from the queue.
-     */
-    public SynchRef drainTo(Collection<SynchRecord<E>> c, boolean unblock);
-
-    /**
-     * Takes up to maxElements available data items from the queue or blocks until some become available. The returned
-     * items are wrapped in a {@link SynchRecord} which provides an interface to requeue them or send errors to their
-     * producers, where the producers are still blocked.
-     *
-     * @param c           The collection to drain the data items into.
-     * @param maxElements The maximum number of elements to drain.
-     * @param unblock     If set to <tt>true</tt> the producers for the taken items will be immediately unblocked.
-     *
-     * @return A count of the number of elements that were drained from the queue.
-     */
-    public SynchRef drainTo(Collection<SynchRecord<E>> c, int maxElements, boolean unblock);
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/BatchSynchQueueBase.java b/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/BatchSynchQueueBase.java
deleted file mode 100644
index 4564b1d..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/BatchSynchQueueBase.java
+++ /dev/null
@@ -1,834 +0,0 @@
-package org.apache.qpid.util.concurrent;
-/*
- * 
- * 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.
- * 
- */
-
-
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Synchronous/Asynchronous puts. Asynchronous is easiest, just wait till can write to queue and deposit data.
- * Synchronous is harder. Deposit data, but then must wait until deposited element/elements are taken before being
- * allowed to unblock and continue. Consumer needs some options here too. Can just get the data from the buffer and
- * allow any producers unblocked as a result to continue, or can get data but continue blocking while the data is
- * processed before sending a message to do the unblocking. Synch/Asynch mode to be controlled by a switch.
- * Unblocking/not unblocking during consumer processing to be controlled by the consumers calls.
- *
- * <p/>Implementing sub-classes only need to supply an implementation of a queue to produce a valid concrete
- * implementation of this. This queue is only accessed through the methods {@link #insert}, {@link #extract},
- * {@link #getBufferCapacity()}, {@link #peekAtBufferHead()}. An implementation can override these methods to implement
- * the buffer other than by a queue, for example, by using an array.
- *
- * <p/>Normal queue methods to work asynchronously.
- * <p/>Put, take and drain methods from the BlockingQueue interface work synchronously but unblock producers immediately
- * when their data is taken.
- * <p/>The additional put, take and drain methods from the BatchSynchQueue interface work synchronously and provide the
- * option to keep producers blocked until the consumer decides to release them.
- *
- * <p/>Removed take method that keeps producers blocked as it is pointless. Essentially it reduces this class to
- * synchronous processing of individual data items, which negates the point of the hand-off design. The efficiency
- * gain of the hand off design comes in being able to batch consume requests, ammortizing latency (such as caused by io)
- * accross many producers. The only advantage of the single blocking take method is that it did take advantage of the
- * queue ordering, which ma be usefull, for example to apply a priority ordering amongst producers. This is also an
- * advantage over the java.util.concurrent.SynchronousQueue which doesn't have a backing queue which can be used to
- * apply orderings. If a single item take is really needed can just use the drainTo method with a maximum of one item.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * </table>
- */
-public abstract class BatchSynchQueueBase<E> extends AbstractQueue<E> implements BatchSynchQueue<E>
-{
-    /** Used for logging. */
-    private static final Logger log = LoggerFactory.getLogger(BatchSynchQueueBase.class);
-
-    /** Holds a reference to the queue implementation that holds the buffer. */
-    Queue<SynchRecordImpl<E>> buffer;
-
-    /** Holds the number of items in the queue */
-    private int count;
-
-    /** Main lock guarding all access */
-    private ReentrantLock lock;
-
-    /** Condition for waiting takes */
-    private Condition notEmpty;
-
-    /** Condition for waiting puts */
-    private Condition notFull;
-
-    /**
-     * Creates a batch synch queue without fair thread scheduling.
-     */
-    public BatchSynchQueueBase()
-    {
-        this(false);
-    }
-
-    /**
-     * Ensures that the underlying buffer implementation is created.
-     *
-     * @param fair <tt>true</tt> if fairness is to be applied to threads waiting to access the buffer.
-     */
-    public BatchSynchQueueBase(boolean fair)
-    {
-        buffer = this.createQueue();
-
-        // Create the buffer lock with the fairness flag set accordingly.
-        lock = new ReentrantLock(fair);
-
-        // Create the non-empty and non-full condition monitors on the buffer lock.
-        notEmpty = lock.newCondition();
-        notFull = lock.newCondition();
-    }
-
-    /**
-     * Returns an iterator over the elements contained in this collection.
-     *
-     * @return An iterator over the elements contained in this collection.
-     */
-    public Iterator<E> iterator()
-    {
-        throw new RuntimeException("Not implemented.");
-    }
-
-    /**
-     * Returns the number of elements in this collection.  If the collection contains more than
-     * <tt>Integer.MAX_VALUE</tt> elements, returns <tt>Integer.MAX_VALUE</tt>.
-     *
-     * @return The number of elements in this collection.
-     */
-    public int size()
-    {
-        final ReentrantLock lock = this.lock;
-        lock.lock();
-
-        try
-        {
-            return count;
-        }
-        finally
-        {
-            lock.unlock();
-        }
-    }
-
-    /**
-     * Inserts the specified element into this queue, if possible. When using queues that may impose insertion
-     * restrictions (for example capacity bounds), method <tt>offer</tt> is generally preferable to method
-     * {@link java.util.Collection#add}, which can fail to insert an element only by throwing an exception.
-     *
-     * @param e The element to insert.
-     *
-     * @return <tt>true</tt> if it was possible to add the element to this queue, else <tt>false</tt>
-     */
-    public boolean offer(E e)
-    {
-        if (e == null)
-        {
-            throw new NullPointerException();
-        }
-
-        final ReentrantLock lock = this.lock;
-        lock.lock();
-
-        try
-        {
-            return insert(e, false);
-        }
-        finally
-        {
-            lock.unlock();
-        }
-    }
-
-    /**
-     * Inserts the specified element into this queue, waiting if necessary up to the specified wait time for space to
-     * become available.
-     *
-     * @param e       The element to add.
-     * @param timeout How long to wait before giving up, in units of <tt>unit</tt>
-     * @param unit    A <tt>TimeUnit</tt> determining how to interpret the <tt>timeout</tt> parameter.
-     *
-     * @return <tt>true</tt> if successful, or <tt>false</tt> if the specified waiting time elapses before space is
-     *         available.
-     *
-     * @throws InterruptedException If interrupted while waiting.
-     * @throws NullPointerException If the specified element is <tt>null</tt>.
-     */
-    public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
-    {
-        if (e == null)
-        {
-            throw new NullPointerException();
-        }
-
-        final ReentrantLock lock = this.lock;
-        lock.lockInterruptibly();
-
-        long nanos = unit.toNanos(timeout);
-
-        try
-        {
-            do
-            {
-                if (insert(e, false))
-                {
-                    return true;
-                }
-
-                try
-                {
-                    nanos = notFull.awaitNanos(nanos);
-                }
-                catch (InterruptedException ie)
-                {
-                    notFull.signal(); // propagate to non-interrupted thread
-                    throw ie;
-                }
-            }
-            while (nanos > 0);
-
-            return false;
-        }
-        finally
-        {
-            lock.unlock();
-        }
-    }
-
-    /**
-     * Retrieves and removes the head of this queue, or <tt>null</tt> if this queue is empty.
-     *
-     * @return The head of this queue, or <tt>null</tt> if this queue is empty.
-     */
-    public E poll()
-    {
-        final ReentrantLock lock = this.lock;
-
-        lock.lock();
-        try
-        {
-            if (count == 0)
-            {
-                return null;
-            }
-
-            E x = extract(true, true).getElement();
-
-            return x;
-        }
-        finally
-        {
-            lock.unlock();
-        }
-    }
-
-    /**
-     * Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time if no elements
-     * are present on this queue.
-     *
-     * @param timeout How long to wait before giving up, in units of <tt>unit</tt>.
-     * @param unit    A <tt>TimeUnit</tt> determining how to interpret the <tt>timeout</tt> parameter.
-     *
-     * @return The head of this queue, or <tt>null</tt> if the specified waiting time elapses before an element is present.
-     *
-     * @throws InterruptedException If interrupted while waiting.
-     */
-    public E poll(long timeout, TimeUnit unit) throws InterruptedException
-    {
-        final ReentrantLock lock = this.lock;
-        lock.lockInterruptibly();
-        try
-        {
-            long nanos = unit.toNanos(timeout);
-
-            do
-            {
-                if (count != 0)
-                {
-                    E x = extract(true, true).getElement();
-
-                    return x;
-                }
-
-                try
-                {
-                    nanos = notEmpty.awaitNanos(nanos);
-                }
-                catch (InterruptedException ie)
-                {
-                    notEmpty.signal(); // propagate to non-interrupted thread
-                    throw ie;
-                }
-            }
-            while (nanos > 0);
-
-            return null;
-        }
-        finally
-        {
-            lock.unlock();
-        }
-    }
-
-    /**
-     * Retrieves, but does not remove, the head of this queue, returning <tt>null</tt> if this queue is empty.
-     *
-     * @return The head of this queue, or <tt>null</tt> if this queue is empty.
-     */
-    public E peek()
-    {
-        final ReentrantLock lock = this.lock;
-        lock.lock();
-
-        try
-        {
-            return peekAtBufferHead();
-        }
-        finally
-        {
-            lock.unlock();
-        }
-    }
-
-    /**
-     * Returns the number of elements that this queue can ideally (in the absence of memory or resource constraints)
-     * accept without blocking, or <tt>Integer.MAX_VALUE</tt> if there is no intrinsic limit.
-     *
-     * <p>Note that you <em>cannot</em> always tell if an attempt to <tt>add</tt> an element will succeed by
-     * inspecting <tt>remainingCapacity</tt> because it may be the case that another thread is about to <tt>put</tt>
-     * or <tt>take</tt> an element.
-     *
-     * @return The remaining capacity.
-     */
-    public int remainingCapacity()
-    {
-        final ReentrantLock lock = this.lock;
-        lock.lock();
-
-        try
-        {
-            return getBufferCapacity() - count;
-        }
-        finally
-        {
-            lock.unlock();
-        }
-    }
-
-    /**
-     * Adds the specified element to this queue, waiting if necessary for space to become available.
-     *
-     * <p/>This method delegated to {@link #tryPut} which can raise {@link SynchException}s. If any are raised
-     * this method silently ignores them. Use the {@link #tryPut} method directly if you want to catch these
-     * exceptions.
-     *
-     * @param e The element to add.
-     *
-     * @throws InterruptedException If interrupted while waiting.
-     */
-    public void put(E e) throws InterruptedException
-    {
-        try
-        {
-            tryPut(e);
-        }
-        catch (SynchException ex)
-        {
-            // This exception is deliberately ignored. See the method comment for information about this.
-        }
-    }
-
-    /**
-     * Tries a synchronous put into the queue. If a consumer encounters an exception condition whilst processing the
-     * data that is put, then this is returned to the caller wrapped inside a {@link SynchException}.
-     *
-     * @param e The data element to put into the queue. Cannot be null.
-     *
-     * @throws InterruptedException If the thread is interrupted whilst waiting to write to the queue or whilst waiting
-     *                              on its entry in the queue being consumed.
-     * @throws SynchException       If a consumer encounters an error whilst processing the data element.
-     */
-    public void tryPut(E e) throws InterruptedException, SynchException
-    {
-        if (e == null)
-        {
-            throw new NullPointerException();
-        }
-
-        // final Queue<E> items = this.buffer;
-        final ReentrantLock lock = this.lock;
-        lock.lockInterruptibly();
-
-        try
-        {
-            while (count == getBufferCapacity())
-            {
-                // Release the lock and wait until the queue is not full.
-                notFull.await();
-            }
-        }
-        catch (InterruptedException ie)
-        {
-            notFull.signal(); // propagate to non-interrupted thread
-            throw ie;
-        }
-
-        // There is room in the queue so insert must succeed. Insert into the queu, release the lock and block
-        // the producer until its data is taken.
-        insert(e, true);
-    }
-
-    /**
-     * Retrieves and removes the head of this queue, waiting if no elements are present on this queue.
-     * Any producer that has its data element taken by this call will be immediately unblocked. To keep the
-     * producer blocked whilst taking just a single item, use the
-     * {@link #drainTo(java.util.Collection<org.apache.qpid.util.concurrent.SynchRecord<E>>, int, boolean)}
-     * method. There is no take method to do that because there is not usually any advantage in a synchronous hand
-     * off design that consumes data one item at a time. It is normal to consume data in chunks to ammortize consumption
-     * latencies accross many producers where possible.
-     *
-     * @return The head of this queue.
-     *
-     * @throws InterruptedException if interrupted while waiting.
-     */
-    public E take() throws InterruptedException
-    {
-        final ReentrantLock lock = this.lock;
-        lock.lockInterruptibly();
-
-        try
-        {
-            try
-            {
-                while (count == 0)
-                {
-                    // Release the lock and wait until the queue becomes non-empty.
-                    notEmpty.await();
-                }
-            }
-            catch (InterruptedException ie)
-            {
-                notEmpty.signal(); // propagate to non-interrupted thread
-                throw ie;
-            }
-
-            // There is data in the queue so extraction must succeed. Notify any waiting threads that the queue is
-            // not full, and unblock the producer that owns the data item that is taken.
-            E x = extract(true, true).getElement();
-
-            return x;
-        }
-        finally
-        {
-            lock.unlock();
-        }
-    }
-
-    /**
-     * Removes all available elements from this queue and adds them into the given collection.  This operation may be
-     * more efficient than repeatedly polling this queue. A failure encountered while attempting to <tt>add</tt> elements
-     * to collection <tt>c</tt> may result in elements being in neither, either or both collections when the associated
-     * exception is thrown. Attempts to drain a queue to itself result in <tt>IllegalArgumentException</tt>. Further,
-     * the behavior of this operation is undefined if the specified collection is modified while the operation is in
-     * progress.
-     *
-     * @param objects The collection to transfer elements into.
-     *
-     * @return The number of elements transferred.
-     *
-     * @throws NullPointerException     If objects is null.
-     * @throws IllegalArgumentException If objects is this queue.
-     */
-    public int drainTo(Collection<? super E> objects)
-    {
-        return drainTo(objects, -1);
-    }
-
-    /**
-     * Removes at most the given number of available elements from this queue and adds them into the given collection.
-     * A failure encountered while attempting to <tt>add</tt> elements to collection <tt>c</tt> may result in elements
-     * being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue
-     * to itself result in <tt>IllegalArgumentException</tt>. Further, the behavior of this operation is undefined if
-     * the specified collection is modified while the operation is in progress.
-     *
-     * @param objects     The collection to transfer elements into.
-     * @param maxElements The maximum number of elements to transfer. If this is -1 then that is interpreted as meaning
-     *                    all elements.
-     *
-     * @return The number of elements transferred.
-     *
-     * @throws NullPointerException     If c is null.
-     * @throws IllegalArgumentException If c is this queue.
-     */
-    public int drainTo(Collection<? super E> objects, int maxElements)
-    {
-        if (objects == null)
-        {
-            throw new NullPointerException();
-        }
-
-        if (objects == this)
-        {
-            throw new IllegalArgumentException();
-        }
-
-        // final Queue<E> items = this.buffer;
-        final ReentrantLock lock = this.lock;
-        lock.lock();
-
-        try
-        {
-            int n = 0;
-
-            for (int max = ((maxElements >= count) || (maxElements < 0)) ? count : maxElements; n < max; n++)
-            {
-                // Take items from the queue, do unblock the producers, but don't send not full signals yet.
-                objects.add(extract(true, false).getElement());
-            }
-
-            if (n > 0)
-            {
-                // count -= n;
-                notFull.signalAll();
-            }
-
-            return n;
-        }
-        finally
-        {
-            lock.unlock();
-        }
-    }
-
-    /**
-     * Takes all available data items from the queue or blocks until some become available. The returned items
-     * are wrapped in a {@link SynchRecord} which provides an interface to requeue them or send errors to their
-     * producers, where the producers are still blocked.
-     *
-     * @param c       The collection to drain the data items into.
-     * @param unblock If set to <tt>true</tt> the producers for the taken items will be immediately unblocked.
-     *
-     * @return A count of the number of elements that were drained from the queue.
-     */
-    public SynchRef drainTo(Collection<SynchRecord<E>> c, boolean unblock)
-    {
-        return drainTo(c, -1, unblock);
-    }
-
-    /**
-     * Takes up to maxElements available data items from the queue or blocks until some become available. The returned
-     * items are wrapped in a {@link SynchRecord} which provides an interface to requeue them or send errors to their
-     * producers, where the producers are still blocked.
-     *
-     * @param coll        The collection to drain the data items into.
-     * @param maxElements The maximum number of elements to drain.
-     * @param unblock     If set to <tt>true</tt> the producers for the taken items will be immediately unblocked.
-     *
-     * @return A count of the number of elements that were drained from the queue.
-     */
-    public SynchRef drainTo(Collection<SynchRecord<E>> coll, int maxElements, boolean unblock)
-    {
-        if (coll == null)
-        {
-            throw new NullPointerException();
-        }
-
-        // final Queue<E> items = this.buffer;
-        final ReentrantLock lock = this.lock;
-        lock.lock();
-
-        try
-        {
-            int n = 0;
-
-            for (int max = ((maxElements >= count) || (maxElements < 0)) ? count : maxElements; n < max; n++)
-            {
-                // Extract the next record from the queue, don't signall the not full condition yet and release
-                // producers depending on whether the caller wants to or not.
-                coll.add(extract(false, unblock));
-            }
-
-            if (n > 0)
-            {
-                // count -= n;
-                notFull.signalAll();
-            }
-
-            return new SynchRefImpl(n, coll);
-        }
-        finally
-        {
-            lock.unlock();
-        }
-    }
-
-    /**
-     * This abstract method should be overriden to return an empty queue. Different implementations of producer
-     * consumer buffers can control the order in which data is accessed using different queue implementations.
-     * This method allows the type of queue to be abstracted out of this class and to be supplied by concrete
-     * implementations.
-     *
-     * @return An empty queue.
-     */
-    protected abstract <T> Queue<T> createQueue();
-
-    /**
-     * Insert element into the queue, then possibly signal that the queue is not empty and block the producer
-     * on the element until permission to procede is given.
-     *
-     * <p/>If the producer is to be blocked then the lock must be released first, otherwise no other process
-     * will be able to get access to the queue. Hence, unlock and block are always set together.
-     *
-     * <p/>Call only when holding the global lock.
-     *
-     * @param unlockAndBlock <tt>true</tt>If the global queue lock should be released and the producer should be blocked.
-     *
-     * @return <tt>true</tt> if the operation succeeded, <tt>false</tt> otherwise. If the result is <tt>true</tt> this
-     *         method may not return straight away, but only after the producer is unblocked by having its data
-     *         consumed if the unlockAndBlock flag is set. In the false case the method will return straight away, no
-     *         matter what value the unlockAndBlock flag has, leaving the global lock on.
-     */
-    protected boolean insert(E x, boolean unlockAndBlock)
-    {
-        // Create a new record for the data item.
-        SynchRecordImpl<E> record = new SynchRecordImpl<E>(x);
-
-        boolean result = buffer.offer(record);
-
-        if (result)
-        {
-            count++;
-
-            // Tell any waiting consumers that the queue is not empty.
-            notEmpty.signal();
-
-            if (unlockAndBlock)
-            {
-                // Allow other threads to read/write the queue.
-                lock.unlock();
-
-                // Wait until a consumer takes this data item.
-                record.waitForConsumer();
-            }
-
-            return true;
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-    /**
-     * Extract element at current take position, advance, and signal.
-     *
-     * <p/>Call only when holding lock.
-     */
-    protected SynchRecordImpl<E> extract(boolean unblock, boolean signal)
-    {
-        SynchRecordImpl<E> result = buffer.remove();
-        count--;
-
-        if (signal)
-        {
-            notFull.signal();
-        }
-
-        if (unblock)
-        {
-            result.releaseImmediately();
-        }
-
-        return result;
-    }
-
-    /**
-     * Get the capacity of the buffer. If the buffer has no maximum capacity then Integer.MAX_VALUE is returned.
-     *
-     * <p/>Call only when holding lock.
-     *
-     * @return The maximum capacity of the buffer.
-     */
-    protected int getBufferCapacity()
-    {
-        if (buffer instanceof Capacity)
-        {
-            return ((Capacity) buffer).getCapacity();
-        }
-        else
-        {
-            return Integer.MAX_VALUE;
-        }
-    }
-
-    /**
-     * Return the head element from the buffer.
-     *
-     * <p/>Call only when holding lock.
-     *
-     * @return The head element from the buffer.
-     */
-    protected E peekAtBufferHead()
-    {
-        return buffer.peek().getElement();
-    }
-
-    public class SynchRefImpl implements SynchRef
-    {
-        /** Holds the number of synch records associated with this reference. */
-        int numRecords;
-
-        /** Holds a reference to the collection of synch records managed by this. */
-        Collection<SynchRecord<E>> records;
-
-        public SynchRefImpl(int n, Collection<SynchRecord<E>> records)
-        {
-            this.numRecords = n;
-            this.records = records;
-        }
-
-        public int getNumRecords()
-        {
-            return numRecords;
-        }
-
-        /**
-         * Any producers that have had their data elements taken from the queue but have not been unblocked are unblocked
-         * when this method is called. The exception to this is producers that have had their data put back onto the queue
-         * by a consumer. Producers that have had exceptions for their data items registered by consumers will be unblocked
-         * but will not return from their put call normally, but with an exception instead.
-         */
-        public void unblockProducers()
-        {
-            log.debug("public void unblockProducers(): called");
-
-            if (records != null)
-            {
-                for (SynchRecord<E> record : records)
-                {
-                    // This call takes account of items that have already been released, are to be requeued or are in
-                    // error.
-                    record.releaseImmediately();
-                }
-            }
-
-            records = null;
-        }
-    }
-
-    /**
-     * A SynchRecordImpl is used by a {@link BatchSynchQueue} to pair together a producer with its data. This allows
-     * the producer of data to be identified so that it can be unblocked when its data is consumed or sent errors when
-     * its data cannot be consumed.
-     */
-    public class SynchRecordImpl<E> implements SynchRecord<E>
-    {
-        /** A boolean latch that determines when the producer for this data item will be allowed to continue. */
-        BooleanLatch latch = new BooleanLatch();
-
-        /** The data element associated with this item. */
-        E element;
-
-        /**
-         * Create a new synch record.
-         *
-         * @param e The data element that the record encapsulates.
-         */
-        public SynchRecordImpl(E e)
-        {
-            // Keep the data element.
-            element = e;
-        }
-
-        /**
-         * Waits until the producer is given permission to proceded by a consumer.
-         */
-        public void waitForConsumer()
-        {
-            latch.await();
-        }
-
-        /**
-         * Gets the data element contained by this record.
-         *
-         * @return The data element contained by this record.
-         */
-        public E getElement()
-        {
-            return element;
-        }
-
-        /**
-         * Immediately releases the producer of this data record. Consumers can bring the synchronization time of
-         * producers to a minimum by using this method to release them at the earliest possible moment when batch
-         * consuming records from sychronized producers.
-         */
-        public void releaseImmediately()
-        {
-            // Check that the record has not already been released, is in error or is to be requeued.
-            latch.signal();
-
-            // Propagate errors to the producer.
-
-            // Requeue items to be requeued.
-        }
-
-        /**
-         * Tells the synch queue to put this element back onto the queue instead of releasing its producer.
-         * The element is not requeued immediately but upon calling the {@link SynchRef#unblockProducers()} method or
-         * the {@link #releaseImmediately()} method.
-         *
-         * <p/>This method will raise a runtime exception {@link AlreadyUnblockedException} if the producer for this
-         * element has already been unblocked.
-         */
-        public void reQueue()
-        {
-            throw new RuntimeException("Not implemented.");
-        }
-
-        /**
-         * Tells the synch queue to raise an exception with this elements producer. The exception is not raised
-         * immediately but upon calling the {@link SynchRef#unblockProducers()} method or the
-         * {@link #releaseImmediately()} method. The exception will be wrapped in a {@link SynchException} before it is
-         * raised on the producer.
-         *
-         * <p/>This method is unusual in that it accepts an exception as an argument. This is non-standard but is used
-         * because the exception is to be passed onto a different thread.
-         *
-         * <p/>This method will raise a runtime exception {@link AlreadyUnblockedException} if the producer for this
-         * element has already been unblocked.
-         *
-         * @param e The exception to raise on the producer.
-         */
-        public void inError(Exception e)
-        {
-            throw new RuntimeException("Not implemented.");
-        }
-    }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/BooleanLatch.java b/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/BooleanLatch.java
deleted file mode 100644
index 0e4a075..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/BooleanLatch.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.apache.qpid.util.concurrent;
-/*
- * 
- * 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.
- * 
- */
-
-
-import java.util.concurrent.locks.AbstractQueuedSynchronizer;
-
-/**
- * A BooleanLatch is like a set of traffic lights, where threads can wait at a red light until another thread gives
- * the green light. When threads arrive at the latch it is initially red. They queue up until the green signal is
- * given, at which point they can all acquire the latch in shared mode and continue to run concurrently. Once the latch
- * is signalled it cannot be reset to red again.
- *
- * <p/> The latch uses a {@link java.util.concurrent.locks.AbstractQueuedSynchronizer} to implement its synchronization.
- * This has two internal states, 0 which means that the latch is blocked, and 1 which means that the latch is open.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Block threads until a go signal is given.
- * </table>
- *
- * @todo Might be better to use a countdown latch to count down from 1. Its await method can throw interrupted
- *       exception which makes the possibility of interruption more explicit, and provides a reminder to recheck the
- *       latch condition before continuing.
- */
-public class BooleanLatch
-{
-    /** Holds the synchronizer that provides the thread queueing synchronization. */
-    private final Sync sync = new Sync();
-
-    /**
-     * Tests whether or not the latch has been signalled, that is to say that, the light is green.
-     *
-     * <p/>This method is non-blocking.
-     *
-     * @return <tt>true</tt> if the latch may be acquired; the light is green.
-     */
-    public boolean isSignalled()
-    {
-        return sync.isSignalled();
-    }
-
-    /**
-     * Waits on the latch until the signal is given and the light is green. If the light is already green then the
-     * latch will be acquired and the thread will not have to wait.
-     *
-     * <p/>This method will block until the go signal is given or the thread is otherwise interrupted. Before carrying
-     * out any processing threads that return from this method should confirm that the go signal has really been given
-     * on this latch by calling the {@link #isSignalled()} method.
-     */
-    public void await()
-    {
-        sync.acquireShared(1);
-    }
-
-    /**
-     * Releases any threads currently waiting on the latch. This flips the light to green allowing any threads that
-     * were waiting for this condition to now run.
-     *
-     * <p/>This method is non-blocking.
-     */
-    public void signal()
-    {
-        sync.releaseShared(1);
-    }
-
-    /**
-     * Implements a thread queued synchronizer. The internal state 0 means that the queue is blocked and the internl
-     * state 1 means that the queue is released and that all waiting threads can acquire the synchronizer in shared
-     * mode.
-     */
-    private static class Sync extends AbstractQueuedSynchronizer
-    {
-        /**
-         * Attempts to acquire this synchronizer in shared mode. It may be acquired once it has been released.
-         *
-         * @param ignore This parameter is ignored.
-         *
-         * @return 1 if the shared acquisition succeeds and -1 if it fails.
-         */
-        protected int tryAcquireShared(int ignore)
-        {
-            return isSignalled() ? 1 : -1;
-        }
-
-        /**
-         * Releases the synchronizer, setting its internal state to 1.
-         *
-         * @param ignore This parameter is ignored.
-         *
-         * @return <tt>true</tt> always.
-         */
-        protected boolean tryReleaseShared(int ignore)
-        {
-            setState(1);
-
-            return true;
-        }
-
-        /**
-         * Tests if the synchronizer is signalled. It is signalled when its internal state it 1.
-         *
-         * @return <tt>true</tt> if the internal state is 1, <tt>false</tt> otherwise.
-         */
-        boolean isSignalled()
-        {
-            return getState() != 0;
-        }
-    }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/Capacity.java b/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/Capacity.java
deleted file mode 100644
index a97ce0e..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/Capacity.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.apache.qpid.util.concurrent;
-/*
- * 
- * 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.
- * 
- */
-
-
-/**
- * An interface exposed by data structures that have a maximum capacity.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Report the maximum capacity.
- * </table>
- */
-public interface Capacity
-{
-    public int getCapacity();
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchBuffer.java b/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchBuffer.java
deleted file mode 100644
index bc63eb0..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchBuffer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.apache.qpid.util.concurrent;
-/*
- * 
- * 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.
- * 
- */
-
-
-import java.util.Queue;
-
-/**
- * SynchBuffer completes the {@link BatchSynchQueueBase} abstract class by providing an implementation of the underlying
- * queue as an array. This uses FIFO ordering for the queue but restricts the maximum size of the queue to a fixed
- * amount. It also has the advantage that, as the buffer does not grow and shrink dynamically, memory for the buffer
- * is allocated up front and does not create garbage during the operation of the queue.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide array based FIFO queue to create a batch synched queue around.
- * </table>
- *
- * @todo Write an array based buffer implementation that implements Queue.
- */
-public class SynchBuffer<E> extends BatchSynchQueueBase<E>
-{
-    /**
-     * Returns an empty queue, implemented as an array.
-     *
-     * @return An empty queue, implemented as an array.
-     */
-    protected <T> Queue<T> createQueue()
-    {
-        throw new RuntimeException("Not implemented.");
-    }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchException.java b/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchException.java
deleted file mode 100644
index 99a83f9..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.apache.qpid.util.concurrent;
-/*
- * 
- * 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.
- * 
- */
-
-
-/**
- * SynchException is used to encapsulate exceptions with the data elements that caused them in order to send exceptions
- * back from the consumers of a {@link BatchSynchQueue} to producers. The underlying exception should be retrieved from
- * the {@link #getCause} method.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Encapsulate a data element and exception.
- * </table>
- */
-public class SynchException extends Exception
-{
-    /** Holds the data element that is in error. */
-    Object element;
-
-    /**
-     * Creates a new BaseApplicationException object.
-     *
-     * @param message The exception message.
-     * @param cause   The underlying throwable cause. This may be null.
-     */
-    public SynchException(String message, Throwable cause, Object element)
-    {
-        super(message, cause);
-
-        // Keep the data element that was in error.
-        this.element = element;
-    }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchQueue.java b/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchQueue.java
deleted file mode 100644
index 95833f3..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchQueue.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.apache.qpid.util.concurrent;
-/*
- * 
- * 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.
- * 
- */
-
-
-import java.util.LinkedList;
-import java.util.Queue;
-
-/**
- * SynchQueue completes the {@link BatchSynchQueueBase} abstract class by providing an implementation of the underlying
- * queue as a linked list. This uses FIFO ordering for the queue and allows the queue to grow to accomodate more
- * elements as needed.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Provide linked list FIFO queue to create a batch synched queue around.
- * </table>
- */
-public class SynchQueue<E> extends BatchSynchQueueBase<E>
-{
-    /**
-     * Returns an empty queue, implemented as a linked list.
-     *
-     * @return An empty queue, implemented as a linked list.
-     */
-    protected <T> Queue<T> createQueue()
-    {
-        return new LinkedList<T>();
-    }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchRecord.java b/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchRecord.java
deleted file mode 100644
index fd740c2..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchRecord.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.qpid.util.concurrent;
-/*
- * 
- * 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.
- * 
- */
-
-
-/**
- * SynchRecord associates a data item from a {@link BatchSynchQueue} with its producer. This enables the data item data
- * item to be put back on the queue without unblocking its producer, or to send exceptions to the producer.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Get the underlying data element.
- * <tr><td> Put the data element back on the queue without unblocking its producer.
- * <tr><td> Send and exception to the data elements producer.
- * </table>
- */
-public interface SynchRecord<E>
-{
-    /**
-     * Gets the data element contained by this record.
-     *
-     * @return The data element contained by this record.
-     */
-    public E getElement();
-
-    /**
-     * Tells the synch queue to put this element back onto the queue instead of releasing its producer.
-     * The element is not requeued immediately but upon calling the {@link SynchRef#unblockProducers()} method.
-     *
-     * <p/>This method will raise a runtime exception {@link AlreadyUnblockedException} if the producer for this element
-     * has already been unblocked.
-     */
-    public void reQueue();
-
-    /**
-     * Immediately releases the producer of this data record. Consumers can bring the synchronization time of
-     * producers to a minimum by using this method to release them at the earliest possible moment when batch
-     * consuming records from sychronized producers.
-     */
-    public void releaseImmediately();
-
-    /**
-     * Tells the synch queue to raise an exception with this elements producer. The exception is not raised immediately
-     * but upon calling the {@link SynchRef#unblockProducers()} method. The exception will be wrapped in a
-     * {@link SynchException} before it is raised on the producer.
-     *
-     * <p/>This method is unusual in that it accepts an exception as an argument. This is non-standard but is used
-     * because the exception is to be passed onto a different thread.
-     *
-     * <p/>This method will raise a runtime exception {@link AlreadyUnblockedException} if the producer for this element
-     * has already been unblocked.
-     *
-     * @param e The exception to raise on the producer.
-     */
-    public void inError(Exception e);
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchRef.java b/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchRef.java
deleted file mode 100644
index efe2344..0000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/concurrent/SynchRef.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.apache.qpid.util.concurrent;
-/*
- * 
- * 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.
- * 
- */
-
-
-/**
- * A SynchRef is an interface which is returned from the synchronous take and drain methods of {@link BatchSynchQueue},
- * allowing call-backs to be made against the synchronizing strucutre. It allows the consumer to communicate when it
- * wants producers that have their data taken to be unblocked.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities
- * <tr><td> Report number of records returned by a taking operation.
- * <tr><td> Provide call-back to release producers of taken records.
- * </table>
- */
-public interface SynchRef
-{
-    /**
-     * Reports the number of records taken by the take or drain operation.
-     *
-     * @return The number of records taken by the take or drain operation.
-     */
-    public int getNumRecords();
-
-    /**
-     * Any producers that have had their data elements taken from the queue but have not been unblocked are
-     * unblocked when this method is called. The exception to this is producers that have had their data put back
-     * onto the queue by a consumer. Producers that have had exceptions for their data items registered by consumers
-     * will be unblocked but will not return from their put call normally, but with an exception instead.
-     */
-    public void unblockProducers();
-}
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/AMQExceptionTest.java b/qpid/java/common/src/test/java/org/apache/qpid/AMQExceptionTest.java
index f65427e..575058b 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/AMQExceptionTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/AMQExceptionTest.java
@@ -21,9 +21,10 @@
 package org.apache.qpid;
 
 import junit.framework.TestCase;
-import org.apache.qpid.protocol.AMQConstant;
+
 import org.apache.qpid.framing.AMQFrameDecodingException;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.protocol.AMQConstant;
 
 /**
  * This test is to ensure that when an AMQException is rethrown that the specified exception is correctly wrapped up.
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/codec/AMQDecoderTest.java b/qpid/java/common/src/test/java/org/apache/qpid/codec/AMQDecoderTest.java
index 272eb75..6540e05 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/codec/AMQDecoderTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/codec/AMQDecoderTest.java
@@ -21,12 +21,6 @@
  */
 
 
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-
 import junit.framework.TestCase;
 
 import org.apache.qpid.framing.AMQDataBlock;
@@ -35,6 +29,12 @@
 import org.apache.qpid.framing.AMQProtocolVersionException;
 import org.apache.qpid.framing.HeartbeatBody;
 
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+
 public class AMQDecoderTest extends TestCase
 {
 
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/codec/MockAMQVersionAwareProtocolSession.java b/qpid/java/common/src/test/java/org/apache/qpid/codec/MockAMQVersionAwareProtocolSession.java
index 401848c..3a95ca3 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/codec/MockAMQVersionAwareProtocolSession.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/codec/MockAMQVersionAwareProtocolSession.java
@@ -21,8 +21,6 @@
  */
 
 
-import java.nio.ByteBuffer;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQDataBlock;
 import org.apache.qpid.framing.AMQMethodBody;
@@ -34,6 +32,8 @@
 import org.apache.qpid.protocol.AMQVersionAwareProtocolSession;
 import org.apache.qpid.transport.Sender;
 
+import java.nio.ByteBuffer;
+
 public class MockAMQVersionAwareProtocolSession implements AMQVersionAwareProtocolSession
 {
 
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/configuration/QpidPropertyTest.java b/qpid/java/common/src/test/java/org/apache/qpid/configuration/QpidPropertyTest.java
new file mode 100644
index 0000000..2a8c177
--- /dev/null
+++ b/qpid/java/common/src/test/java/org/apache/qpid/configuration/QpidPropertyTest.java
@@ -0,0 +1,166 @@
+/* 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.configuration;
+
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class QpidPropertyTest extends QpidTestCase
+{
+    private static final String TEST_VALUE1 = "TEST_VALUE1";
+    private static final String TEST_VALUE2 = "TEST_VALUE2";
+    private static final String DEFAULT_VALUE = "DEFAULT_VALUE";
+
+    private String _systemPropertyName;
+    private String _deprecatedSystemPropertyName;
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        _systemPropertyName = getName() + ".current";
+        _deprecatedSystemPropertyName = getName() + ".deprecated";
+    }
+
+    public void testValueReadFromSystemProperty() throws Exception
+    {
+        setTestSystemProperty(_systemPropertyName, TEST_VALUE1);
+        assertSystemPropertiesSet(_systemPropertyName);
+
+        String propertyValue = QpidProperty.stringProperty(DEFAULT_VALUE, _systemPropertyName).get();
+        assertEquals(TEST_VALUE1, propertyValue);
+    }
+
+    public void testValueReadFromSecondChoiceSystemPropertyWhenFirstChoiceNotSet() throws Exception
+    {
+        setTestSystemProperty(_deprecatedSystemPropertyName, TEST_VALUE2);
+        assertSystemPropertiesSet(_deprecatedSystemPropertyName);
+        assertSystemPropertiesNotSet(_systemPropertyName);
+
+        String propertyValue = QpidProperty.stringProperty("default", _systemPropertyName, _deprecatedSystemPropertyName).get();
+        assertEquals(TEST_VALUE2, propertyValue);
+    }
+
+    public void testValueReadFromFirstChoiceSystemPropertyWhenBothFirstAndSecondChoiceSet() throws Exception
+    {
+        setTestSystemProperty(_systemPropertyName, TEST_VALUE1);
+        setTestSystemProperty(_deprecatedSystemPropertyName, TEST_VALUE2);
+        assertSystemPropertiesSet(_systemPropertyName, _deprecatedSystemPropertyName);
+
+        String propertyValue = QpidProperty.stringProperty("default", _systemPropertyName, _deprecatedSystemPropertyName).get();
+        assertEquals(TEST_VALUE1, propertyValue);
+    }
+
+    public void testValueIsDefaultWhenOneSystemPropertyIsNotSet() throws Exception
+    {
+        assertSystemPropertiesNotSet(_systemPropertyName);
+
+        String propertyValue = QpidProperty.stringProperty(DEFAULT_VALUE, _systemPropertyName).get();
+        assertEquals(DEFAULT_VALUE, propertyValue);
+    }
+
+    public void testValueIsDefaultWhenTwoSystemPropertiesAreNotSet() throws Exception
+    {
+        assertSystemPropertiesNotSet(_systemPropertyName, _deprecatedSystemPropertyName);
+
+        String propertyValue = QpidProperty.stringProperty(DEFAULT_VALUE, _systemPropertyName).get();
+        assertEquals(DEFAULT_VALUE, propertyValue);
+    }
+
+    public void testValueIsNullWhenNoDefaultAndNoSystemPropertiesAreSet() throws Exception
+    {
+        assertSystemPropertiesNotSet(_systemPropertyName, _deprecatedSystemPropertyName);
+
+        String nullString = null;
+        String propertyValue = QpidProperty.stringProperty(nullString, _systemPropertyName).get();
+        assertNull(propertyValue);
+    }
+
+    public void testBooleanValueReadFromSystemProperty() throws Exception
+    {
+        setTestSystemProperty(_systemPropertyName, Boolean.FALSE.toString());
+        assertSystemPropertiesSet(_systemPropertyName);
+
+        boolean propertyValue = QpidProperty.booleanProperty(Boolean.TRUE, _systemPropertyName).get();
+        assertFalse(propertyValue);
+    }
+
+    public void testBooleanValueIsDefaultWhenOneSystemPropertyIsNotSet() throws Exception
+    {
+        assertSystemPropertiesNotSet(_systemPropertyName);
+
+        Boolean propertyValue = QpidProperty.booleanProperty(Boolean.TRUE, _systemPropertyName).get();
+        assertTrue(propertyValue);
+    }
+
+    public void testIntegerValueReadFromSystemProperty() throws Exception
+    {
+        int expectedValue = 15;
+        setTestSystemProperty(_systemPropertyName, Integer.valueOf(expectedValue).toString());
+        assertSystemPropertiesSet(_systemPropertyName);
+
+        int propertyValue = QpidProperty.intProperty(14, _systemPropertyName).get();
+        assertEquals(expectedValue, propertyValue);
+    }
+
+    public void testIntegerValueIsDefaultWhenOneSystemPropertyIsNotSet() throws Exception
+    {
+        int expectedValue = 15;
+        assertSystemPropertiesNotSet(_systemPropertyName);
+
+        int propertyValue = QpidProperty.intProperty(expectedValue, _systemPropertyName).get();
+        assertEquals(expectedValue, propertyValue);
+    }
+
+    public void testLongValueReadFromSystemProperty() throws Exception
+    {
+        long expectedValue = 15;
+        setTestSystemProperty(_systemPropertyName, Long.valueOf(expectedValue).toString());
+        assertSystemPropertiesSet(_systemPropertyName);
+
+        long propertyValue = QpidProperty.longProperty(14l, _systemPropertyName).get();
+        assertEquals(expectedValue, propertyValue);
+    }
+
+    public void testLongValueIsDefaultWhenOneSystemPropertyIsNotSet() throws Exception
+    {
+        long expectedValue = 15;
+        assertSystemPropertiesNotSet(_systemPropertyName);
+
+        long propertyValue = QpidProperty.longProperty(expectedValue, _systemPropertyName).get();
+        assertEquals(expectedValue, propertyValue);
+    }
+
+    private void assertSystemPropertiesSet(String... systemPropertyNames)
+    {
+        for (String systemPropertyName : systemPropertyNames)
+        {
+            assertTrue("System property " + systemPropertyName + " should be set",
+                    System.getProperties().containsKey(systemPropertyName));
+        }
+    }
+
+    private void assertSystemPropertiesNotSet(String... systemPropertyNames)
+    {
+        for (String systemPropertyName : systemPropertyNames)
+        {
+            assertFalse("System property " + systemPropertyName + " should not be set",
+                    System.getProperties().containsKey(systemPropertyName));
+        }
+    }
+
+}
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java b/qpid/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java
index 9a805d8..bcdabfc 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java
@@ -20,11 +20,11 @@
 
 package org.apache.qpid.framing;
 
+import junit.framework.TestCase;
+
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.List;
-
-import junit.framework.TestCase;
 public class AMQShortStringTest extends TestCase
 {
 
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java b/qpid/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java
index 5e7783f..1a2c528 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java
@@ -22,16 +22,20 @@
 
 import junit.framework.TestCase;
 
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
 
 
 public class BasicContentHeaderPropertiesTest extends TestCase
 {
 
-    BasicContentHeaderProperties _testProperties;
-    FieldTable _testTable;
-    String _testString = "This is a test string";
-    int _testint = 666;
+    private BasicContentHeaderProperties _testProperties;
+    private FieldTable _testTable;
+    private String _testString = "This is a test string";
+    private int _testint = 666;
 
     /**
      * Currently only test setting/getting String, int and boolean props
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java b/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
index cb9a946..16f3561 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
@@ -20,19 +20,19 @@
  */
 package org.apache.qpid.framing;
 
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.AMQPInvalidClassException;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.qpid.AMQPInvalidClassException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class PropertyFieldTableTest extends TestCase
 {
     private static final Logger _logger = LoggerFactory.getLogger(PropertyFieldTableTest.class);
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/framing/abstraction/MessagePublishInfoImplTest.java b/qpid/java/common/src/test/java/org/apache/qpid/framing/abstraction/MessagePublishInfoImplTest.java
index 3243136..5a57db1 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/framing/abstraction/MessagePublishInfoImplTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/framing/abstraction/MessagePublishInfoImplTest.java
@@ -21,14 +21,14 @@
 package org.apache.qpid.framing.abstraction;
 
 import junit.framework.TestCase;
+
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.abstraction.MessagePublishInfoImpl;
 
 public class MessagePublishInfoImplTest extends TestCase
 {
-    MessagePublishInfoImpl _mpi;
-    final AMQShortString _exchange = new AMQShortString("exchange");
-    final AMQShortString _routingKey = new AMQShortString("routingKey");
+    private MessagePublishInfoImpl _mpi;
+    private final AMQShortString _exchange = new AMQShortString("exchange");
+    private final AMQShortString _routingKey = new AMQShortString("routingKey");
 
     public void setUp()
     {
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/pool/ReferenceCountingExecutorServiceTest.java b/qpid/java/common/src/test/java/org/apache/qpid/pool/ReferenceCountingExecutorServiceTest.java
index 35998de..de73a2f 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/pool/ReferenceCountingExecutorServiceTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/pool/ReferenceCountingExecutorServiceTest.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.pool;
 
+import junit.framework.TestCase;
+
 import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
 
-import junit.framework.TestCase;
-
 
 public class ReferenceCountingExecutorServiceTest extends TestCase
 {
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/ssl/SSLContextFactoryTest.java b/qpid/java/common/src/test/java/org/apache/qpid/ssl/SSLContextFactoryTest.java
index 288946e..69b04c9 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/ssl/SSLContextFactoryTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/ssl/SSLContextFactoryTest.java
@@ -17,24 +17,27 @@
  */
 package org.apache.qpid.ssl;
 
-import java.io.IOException;
-
-import javax.net.ssl.SSLContext;
-
 import org.apache.qpid.test.utils.QpidTestCase;
 
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+
+import java.io.IOException;
+
 public class SSLContextFactoryTest extends QpidTestCase
 {
     private static final String BROKER_KEYSTORE_PATH = TEST_RESOURCES_DIR + "/ssl/java_broker_keystore.jks";
     private static final String CLIENT_KEYSTORE_PATH = TEST_RESOURCES_DIR + "/ssl/java_client_keystore.jks";
     private static final String CLIENT_TRUSTSTORE_PATH = TEST_RESOURCES_DIR + "/ssl/java_client_truststore.jks";
     private static final String STORE_PASSWORD = "password";
-    private static final String CERT_TYPE = "SunX509";
+    private static final String DEFAULT_KEY_MANAGER_ALGORITHM = KeyManagerFactory.getDefaultAlgorithm();
+    private static final String DEFAULT_TRUST_MANAGER_ALGORITHM = TrustManagerFactory.getDefaultAlgorithm();
     private static final String CERT_ALIAS_APP1 = "app1";
 
     public void testBuildServerContext() throws Exception
     {
-        SSLContext context = SSLContextFactory.buildServerContext(BROKER_KEYSTORE_PATH, STORE_PASSWORD, CERT_TYPE);
+        SSLContext context = SSLContextFactory.buildServerContext(BROKER_KEYSTORE_PATH, STORE_PASSWORD, DEFAULT_KEY_MANAGER_ALGORITHM);
         assertNotNull("SSLContext should not be null", context);
     }
 
@@ -42,7 +45,7 @@
     {
         try
         {
-            SSLContextFactory.buildServerContext(BROKER_KEYSTORE_PATH, "sajdklsad", CERT_TYPE);
+            SSLContextFactory.buildServerContext(BROKER_KEYSTORE_PATH, "sajdklsad", DEFAULT_KEY_MANAGER_ALGORITHM);
             fail("Exception was not thrown due to incorrect password");
         }
         catch (IOException e)
@@ -55,7 +58,7 @@
     {
         try
         {
-            SSLContextFactory.buildClientContext("/path/to/nothing", STORE_PASSWORD, CERT_TYPE, CLIENT_KEYSTORE_PATH, STORE_PASSWORD, CERT_TYPE, null);
+            SSLContextFactory.buildClientContext("/path/to/nothing", STORE_PASSWORD, DEFAULT_TRUST_MANAGER_ALGORITHM, CLIENT_KEYSTORE_PATH, STORE_PASSWORD, DEFAULT_KEY_MANAGER_ALGORITHM, null);
             fail("Exception was not thrown due to incorrect path");
         }
         catch (IOException e)
@@ -66,19 +69,19 @@
 
     public void testBuildClientContextForSSLEncryptionOnly() throws Exception
     {
-        SSLContext context = SSLContextFactory.buildClientContext(CLIENT_TRUSTSTORE_PATH, STORE_PASSWORD, CERT_TYPE, null, null, null, null);
+        SSLContext context = SSLContextFactory.buildClientContext(CLIENT_TRUSTSTORE_PATH, STORE_PASSWORD, DEFAULT_TRUST_MANAGER_ALGORITHM, null, null, null, null);
         assertNotNull("SSLContext should not be null", context);
     }
 
     public void testBuildClientContextWithForClientAuth() throws Exception
     {
-        SSLContext context = SSLContextFactory.buildClientContext(CLIENT_TRUSTSTORE_PATH, STORE_PASSWORD, CERT_TYPE, CLIENT_KEYSTORE_PATH, STORE_PASSWORD, CERT_TYPE, null);
+        SSLContext context = SSLContextFactory.buildClientContext(CLIENT_TRUSTSTORE_PATH, STORE_PASSWORD, DEFAULT_TRUST_MANAGER_ALGORITHM, CLIENT_KEYSTORE_PATH, STORE_PASSWORD, DEFAULT_KEY_MANAGER_ALGORITHM, null);
         assertNotNull("SSLContext should not be null", context);
     }
     
     public void testBuildClientContextWithForClientAuthWithCertAlias() throws Exception
     {
-        SSLContext context = SSLContextFactory.buildClientContext(CLIENT_TRUSTSTORE_PATH, STORE_PASSWORD, CERT_TYPE, CLIENT_KEYSTORE_PATH, STORE_PASSWORD, CERT_TYPE, CERT_ALIAS_APP1);
+        SSLContext context = SSLContextFactory.buildClientContext(CLIENT_TRUSTSTORE_PATH, STORE_PASSWORD, DEFAULT_TRUST_MANAGER_ALGORITHM, CLIENT_KEYSTORE_PATH, STORE_PASSWORD, DEFAULT_KEY_MANAGER_ALGORITHM, CERT_ALIAS_APP1);
         assertNotNull("SSLContext should not be null", context);
     }
 }
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java b/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java
index e69f95f..94db7d8 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java
@@ -20,19 +20,22 @@
  */
 package org.apache.qpid.test.utils;
 
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.net.DatagramSocket;
 import java.net.ServerSocket;
-import java.util.*;
-
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
 
 
 public class QpidTestCase extends TestCase
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionSettingsTest.java b/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionSettingsTest.java
index 57c0549..fc4f537 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionSettingsTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionSettingsTest.java
@@ -20,12 +20,17 @@
  */
 package org.apache.qpid.transport;
 
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.TrustManagerFactory;
+
 import org.apache.qpid.configuration.ClientProperties;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class ConnectionSettingsTest extends QpidTestCase
 {
-    ConnectionSettings _conConnectionSettings;
+    private static final String TEST_ALGORITHM_NAME = "algorithmName";
+
+    private ConnectionSettings _conConnectionSettings;
 
     protected void setUp() throws Exception
     {
@@ -33,37 +38,137 @@
         _conConnectionSettings = new ConnectionSettings();
     }
 
-    public void testDefaultTCP_NODELAY()
+    public void testTcpNoDelayDefault()
     {
         assertTrue("Default for isTcpNodelay() should be true", _conConnectionSettings.isTcpNodelay());
     }
 
-    public void testSystemPropertyOverrideTrueForTCP_NODELAY()
+    public void testTcpNoDelayOverrideTrue()
     {
-        systemPropertyOverrideForTCP_NODELAYImpl(ClientProperties.QPID_TCP_NODELAY_PROP_NAME, true);
+        systemPropertyOverrideForTcpDelay(ClientProperties.QPID_TCP_NODELAY_PROP_NAME, true);
     }
     
-    public void testSystemPropertyOverrideFalseForTCP_NODELAY()
+    public void testTcpNoDelayOverrideFalse()
     {
-        systemPropertyOverrideForTCP_NODELAYImpl(ClientProperties.QPID_TCP_NODELAY_PROP_NAME, false);
+        systemPropertyOverrideForTcpDelay(ClientProperties.QPID_TCP_NODELAY_PROP_NAME, false);
     }
 
-    public void testLegacySystemPropertyOverrideTrueForTCP_NODELAY()
+    @SuppressWarnings("deprecation")
+    public void testTcpNoDelayLegacyOverrideTrue()
     {
-        systemPropertyOverrideForTCP_NODELAYImpl(ClientProperties.AMQJ_TCP_NODELAY_PROP_NAME, true);
+        systemPropertyOverrideForTcpDelay(ClientProperties.AMQJ_TCP_NODELAY_PROP_NAME, true);
     }
 
-    public void testLegacySystemPropertyOverrideFalseForTCP_NODELAY()
+    @SuppressWarnings("deprecation")
+    public void testTcpNoDelayLegacyOverrideFalse()
     {
-        systemPropertyOverrideForTCP_NODELAYImpl(ClientProperties.AMQJ_TCP_NODELAY_PROP_NAME, false);
+        systemPropertyOverrideForTcpDelay(ClientProperties.AMQJ_TCP_NODELAY_PROP_NAME, false);
     }
 
-    private void systemPropertyOverrideForTCP_NODELAYImpl(String propertyName, boolean value)
+    public void testKeyManagerFactoryAlgorithmDefault()
     {
-        //set the default via system property
-        setTestSystemProperty(propertyName, String.valueOf(value));
+        assertEquals(KeyManagerFactory.getDefaultAlgorithm(), _conConnectionSettings.getKeyManagerFactoryAlgorithm());
+    }
+
+    public void testKeyManagerFactoryAlgorithmOverridden()
+    {
+        String algorithmName = TEST_ALGORITHM_NAME;
+        systemPropertyOverrideForKeyFactoryAlgorithm(ClientProperties.QPID_SSL_KEY_MANAGER_FACTORY_ALGORITHM_PROP_NAME, algorithmName);
+    }
+
+    @SuppressWarnings("deprecation")
+    public void testKeyManagerFactoryAlgorithmLegacyOverridden()
+    {
+        String algorithmName = TEST_ALGORITHM_NAME;
+        systemPropertyOverrideForKeyFactoryAlgorithm(ClientProperties.QPID_SSL_KEY_STORE_CERT_TYPE_PROP_NAME, algorithmName);
+    }
+
+    public void testTrustManagerFactoryAlgorithmDefault()
+    {
+        assertEquals(TrustManagerFactory.getDefaultAlgorithm(), _conConnectionSettings.getTrustManagerFactoryAlgorithm());
+    }
+
+    public void testTrustManagerFactoryAlgorithmOverridden()
+    {
+        String algorithmName = TEST_ALGORITHM_NAME;
+        systemPropertyOverrideForTrustFactoryAlgorithm(ClientProperties.QPID_SSL_TRUST_MANAGER_FACTORY_ALGORITHM_PROP_NAME, algorithmName);
+    }
+
+    @SuppressWarnings("deprecation")
+    public void testTrustManagerFactoryAlgorithmLegacyOverridden()
+    {
+        String algorithmName = TEST_ALGORITHM_NAME;
+        systemPropertyOverrideForTrustFactoryAlgorithm(ClientProperties.QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME, algorithmName);
+    }
+
+    public void testSendBufferSizeDefault()
+    {
+        assertEquals("unexpected default for buffer size", 65535, _conConnectionSettings.getWriteBufferSize());
+    }
+
+    public void testSendBufferSizeOverridden()
+    {
+        systemPropertyOverrideForSocketBufferSize(ClientProperties.SEND_BUFFER_SIZE_PROP_NAME, 1024, false);
+    }
+
+    @SuppressWarnings("deprecation")
+    public void testtestSendBufferSizeOverriddenLegacyOverridden()
+    {
+        systemPropertyOverrideForSocketBufferSize(ClientProperties.LEGACY_SEND_BUFFER_SIZE_PROP_NAME, 1024, false);
+    }
+
+    public void testReceiveBufferSizeDefault()
+    {
+        assertEquals("unexpected default for buffer size", 65535, _conConnectionSettings.getReadBufferSize());
+    }
+
+    public void testReceiveBufferSizeOverridden()
+    {
+        systemPropertyOverrideForSocketBufferSize(ClientProperties.RECEIVE_BUFFER_SIZE_PROP_NAME, 1024, true);
+    }
+
+    @SuppressWarnings("deprecation")
+    public void testtestReceiveBufferSizeOverriddenLegacyOverridden()
+    {
+        systemPropertyOverrideForSocketBufferSize(ClientProperties.LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME, 1024, true);
+    }
+
+    private void systemPropertyOverrideForTcpDelay(String propertyName, boolean value)
+    {
+        resetSystemProperty(propertyName, String.valueOf(value));
+        assertEquals("Value for isTcpNodelay() is incorrect", value, _conConnectionSettings.isTcpNodelay());
+    }
+
+    private void systemPropertyOverrideForKeyFactoryAlgorithm(String propertyName, String value)
+    {
+        resetSystemProperty(propertyName, value);
+        assertEquals(value, _conConnectionSettings.getKeyManagerFactoryAlgorithm());
+    }
+
+    private void systemPropertyOverrideForTrustFactoryAlgorithm(String propertyName, String value)
+    {
+        resetSystemProperty(propertyName, value);
+        assertEquals(value, _conConnectionSettings.getTrustManagerFactoryAlgorithm());
+    }
+
+
+    private void systemPropertyOverrideForSocketBufferSize(String propertyName, int value, boolean read)
+    {
+        resetSystemProperty(propertyName, String.valueOf(value));
+        if(read)
+        {
+            assertEquals("unexpected value for receive buffer", value, _conConnectionSettings.getReadBufferSize());
+        }
+        else
+        {
+            assertEquals("unexpected value for send buffer", value, _conConnectionSettings.getWriteBufferSize());
+        }
+    }
+
+    private void resetSystemProperty(String propertyName, String value)
+    {
+        setTestSystemProperty(propertyName, value);
 
         _conConnectionSettings = new ConnectionSettings();
-        assertEquals("Value for isTcpNodelay() is incorrect", value, _conConnectionSettings.isTcpNodelay());
     }
 }
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java b/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java
index 49f6a08..f3715f3 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java
@@ -20,6 +20,11 @@
  */
 package org.apache.qpid.transport;
 
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.transport.network.ConnectionBinding;
+import org.apache.qpid.transport.network.io.IoAcceptor;
+import org.apache.qpid.transport.util.Waiter;
+
 import static org.apache.qpid.transport.Option.EXPECTED;
 import static org.apache.qpid.transport.Option.NONE;
 import static org.apache.qpid.transport.Option.SYNC;
@@ -31,11 +36,6 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.qpid.test.utils.QpidTestCase;
-import org.apache.qpid.transport.network.ConnectionBinding;
-import org.apache.qpid.transport.network.io.IoAcceptor;
-import org.apache.qpid.transport.util.Waiter;
-
 /**
  * ConnectionTest
  */
@@ -170,7 +170,7 @@
                 }
             }
         });
-        conn.connect("localhost", port, null, "guest", "guest", false);
+        conn.connect("localhost", port, null, "guest", "guest", false, null);
         return conn;
     }
 
@@ -275,7 +275,7 @@
         Connection conn = new Connection();
         conn.addConnectionListener(new FailoverConnectionListener());
         conn.setConnectionDelegate(new ClientDelegate(new ConnectionSettings()));
-        conn.connect("localhost", port, null, "guest", "guest");
+        conn.connect("localhost", port, null, "guest", "guest", false, null);
         Session ssn = conn.createSession(1);
         ssn.setSessionListener(new TestSessionListener());
 
@@ -331,7 +331,7 @@
         Connection conn = new Connection();
         conn.setConnectionDelegate(new ClientDelegate(new ConnectionSettings()));
         conn.addConnectionListener(new FailoverConnectionListener());
-        conn.connect("localhost", port, null, "guest", "guest");
+        conn.connect("localhost", port, null, "guest", "guest", false, null);
         Session ssn = conn.createSession(1);
         ssn.setSessionListener(new TestSessionListener());
 
@@ -353,7 +353,7 @@
 
         Connection conn = new Connection();
         conn.setConnectionDelegate(new ClientDelegate(new ConnectionSettings()));
-        conn.connect("localhost", port, null, "guest", "guest");
+        conn.connect("localhost", port, null, "guest", "guest", false, null);
         Session ssn = conn.createSession();
         ssn.sessionFlush(EXPECTED);
         send(ssn, "SINK 0");
@@ -367,7 +367,7 @@
         startServer();
         Connection conn = new Connection();
         conn.setConnectionDelegate(new ClientDelegate(new ConnectionSettings()));
-        conn.connect("localhost", port, null, "guest", "guest");
+        conn.connect("localhost", port, null, "guest", "guest", false, null);
         conn.connectionHeartbeat();
         conn.close();
     }
@@ -378,7 +378,7 @@
 
         Connection conn = new Connection();
         conn.setConnectionDelegate(new ClientDelegate(new ConnectionSettings()));
-        conn.connect("localhost", port, null, "guest", "guest");
+        conn.connect("localhost", port, null, "guest", "guest", false, null);
         Session ssn = conn.createSession();
         send(ssn, "EXCP 0");
         Thread.sleep(3000);
@@ -398,7 +398,7 @@
 
         Connection conn = new Connection();
         conn.setConnectionDelegate(new ClientDelegate(new ConnectionSettings()));
-        conn.connect("localhost", port, null, "guest", "guest");
+        conn.connect("localhost", port, null, "guest", "guest", false, null);
         Session ssn = conn.createSession();
         send(ssn, "EXCP 0", true);
         try
@@ -424,7 +424,7 @@
         public void closed(Connection conn)
         {
             queue = true;
-            conn.connect("localhost", port, null, "guest", "guest");
+            conn.connect("localhost", port, null, "guest", "guest", false, null);
             conn.resume();
         }
     }
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/transport/RangeSetTest.java b/qpid/java/common/src/test/java/org/apache/qpid/transport/RangeSetTest.java
index 889250e..14589eb 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/transport/RangeSetTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/transport/RangeSetTest.java
@@ -20,13 +20,15 @@
  */
 package org.apache.qpid.transport;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
 import junit.framework.TestCase;
 
-import static org.apache.qpid.util.Serial.*;
+import static org.apache.qpid.util.Serial.COMPARATOR;
+import static org.apache.qpid.util.Serial.eq;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * RangeSetTest
@@ -235,4 +237,117 @@
         assertEquals(d.getUpper(), 10);
     }
 
+    public void testSetSubtract1()
+    {
+        final RangeSet orig = createRangeSet(0, 10) ;
+        final RangeSet update = createRangeSet(3, 15) ;
+        orig.subtract(update) ;
+        checkRange(orig, 0, 2) ;
+    }
+
+    public void testSetSubtract2()
+    {
+        final RangeSet orig = createRangeSet(0, 10) ;
+        final RangeSet update = createRangeSet(3, 10) ;
+        orig.subtract(update) ;
+        checkRange(orig, 0, 2) ;
+    }
+
+    public void testSetSubtract3()
+    {
+        final RangeSet orig = createRangeSet(0, 10) ;
+        final RangeSet update = createRangeSet(3, 4) ;
+        orig.subtract(update) ;
+        checkRange(orig, 0, 2, 5, 10) ;
+    }
+
+    public void testSetSubtract4()
+    {
+        final RangeSet orig = createRangeSet(3, 15) ;
+        final RangeSet update = createRangeSet(0, 10) ;
+        orig.subtract(update) ;
+        checkRange(orig, 11, 15) ;
+    }
+
+    public void testSetSubtract5()
+    {
+        final RangeSet orig = createRangeSet(3, 10) ;
+        final RangeSet update = createRangeSet(0, 10) ;
+        orig.subtract(update) ;
+        checkRange(orig) ;
+    }
+
+    public void testSetSubtract6()
+    {
+        final RangeSet orig = createRangeSet(3, 10) ;
+        final RangeSet update = createRangeSet(0, 15) ;
+        orig.subtract(update) ;
+        checkRange(orig) ;
+    }
+
+    public void testSetSubtract7()
+    {
+        final RangeSet orig = createRangeSet(0, 10) ;
+        final RangeSet update = createRangeSet(0, 15) ;
+        orig.subtract(update) ;
+        checkRange(orig) ;
+    }
+
+    public void testSetSubtract8()
+    {
+        final RangeSet orig = createRangeSet(0, 15) ;
+        final RangeSet update = createRangeSet(0, 10) ;
+        orig.subtract(update) ;
+        checkRange(orig, 11, 15) ;
+    }
+
+    public void testSetSubtract9()
+    {
+        final RangeSet orig = createRangeSet(0, 15, 20, 30) ;
+        final RangeSet update = createRangeSet(2, 3, 5, 6, 8, 9, 22, 23, 27, 28) ;
+        orig.subtract(update) ;
+        checkRange(orig, 0, 1, 4, 4, 7, 7, 10, 15, 20, 21, 24, 26, 29, 30) ;
+    }
+
+    public void testSetSubtract10()
+    {
+        final RangeSet orig = createRangeSet(0, 15, 20, 30) ;
+        final RangeSet update = createRangeSet(0, 2, 4, 6, 10, 22, 24, 24, 27, 30) ;
+        orig.subtract(update) ;
+        checkRange(orig, 3, 3, 7, 9, 23, 23, 25, 26) ;
+    }
+
+    public void testSetSubtract11()
+    {
+        final RangeSet orig = createRangeSet(0, 2, 4, 6, 10, 22, 24, 24, 27, 30) ;
+        final RangeSet update = createRangeSet(0, 2, 4, 6, 10, 22, 24, 24, 27, 30) ;
+        orig.subtract(update) ;
+        checkRange(orig) ;
+    }
+    
+    private RangeSet createRangeSet(int ... bounds)
+    {
+        RangeSet set = RangeSetFactory.createRangeSet();
+        final int length = (bounds == null ? 0 : bounds.length) ;
+        int count = 0 ;
+        while(count < length)
+        {
+            set.add(bounds[count++], bounds[count++]) ;
+        }
+        return set ;
+    }
+    
+    private void checkRange(final RangeSet rangeSet, int ... bounds)
+    {
+        final int length = (bounds == null ? 0 : bounds.length) ;
+        assertEquals("Range count", length/2, rangeSet.size()) ;
+        final Iterator<Range> iter = rangeSet.iterator() ;
+        int count = 0 ;
+        while(count < length)
+        {
+            final Range range = iter.next() ;
+            assertEquals("Range lower", bounds[count++], range.getLower()) ;
+            assertEquals("Range upper", bounds[count++], range.getUpper()) ;
+        }
+    }
 }
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/transport/TestNetworkConnection.java b/qpid/java/common/src/test/java/org/apache/qpid/transport/TestNetworkConnection.java
index 8533c64..548e8da 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/transport/TestNetworkConnection.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/transport/TestNetworkConnection.java
@@ -20,17 +20,16 @@
  */
 package org.apache.qpid.transport;
 
+import org.apache.qpid.protocol.ProtocolEngineFactory;
+import org.apache.qpid.ssl.SSLContextFactory;
+import org.apache.qpid.transport.network.NetworkConnection;
+
 import java.net.BindException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.nio.ByteBuffer;
 
-import org.apache.qpid.protocol.ProtocolEngine;
-import org.apache.qpid.protocol.ProtocolEngineFactory;
-import org.apache.qpid.ssl.SSLContextFactory;
-import org.apache.qpid.transport.network.NetworkConnection;
-
 /**
  * Test implementation of IoSession, which is required for some tests. Methods not being used are not implemented,
  * so if this class is being used and some methods are to be used, then please update those.
@@ -67,12 +66,6 @@
         return (_remoteAddress != null) ? _remoteAddress : new InetSocketAddress(_remoteHost, _port);
     }
 
-    public void open(int port, InetAddress destination, ProtocolEngine engine, NetworkTransportConfiguration config,
-            SSLContextFactory sslFactory) throws OpenException
-    {
-
-    }
-
     public void setMaxReadIdle(int idleTime)
     {
 
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/transport/network/TransportTest.java b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/TransportTest.java
index 7039b90..c882d34 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/transport/network/TransportTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/TransportTest.java
@@ -21,10 +21,6 @@
 package org.apache.qpid.transport.network;
 
 
-import java.nio.ByteBuffer;
-
-import javax.net.ssl.SSLContext;
-
 import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.protocol.ProtocolEngineFactory;
 import org.apache.qpid.test.utils.QpidTestCase;
@@ -34,6 +30,9 @@
 import org.apache.qpid.transport.TransportException;
 import org.apache.qpid.transport.network.io.IoNetworkTransport;
 
+import javax.net.ssl.SSLContext;
+import java.nio.ByteBuffer;
+
 public class TransportTest extends QpidTestCase
 {
 
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/transport/network/io/IoAcceptor.java b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/io/IoAcceptor.java
index e075681..641bc5f 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/transport/network/io/IoAcceptor.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/io/IoAcceptor.java
@@ -24,12 +24,10 @@
 import org.apache.qpid.transport.TransportException;
 
 import java.io.IOException;
-
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.SocketAddress;
-
 import java.nio.ByteBuffer;
 
 
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/transport/network/io/IoTransport.java b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/io/IoTransport.java
index 215c6d9..e9005ab 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/transport/network/io/IoTransport.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/io/IoTransport.java
@@ -19,13 +19,13 @@
 
 package org.apache.qpid.transport.network.io;
 
-import java.net.Socket;
-import java.nio.ByteBuffer;
-
 import org.apache.qpid.transport.Binding;
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.util.Logger;
 
+import java.net.Socket;
+import java.nio.ByteBuffer;
+
 /**
  * This class provides a socket based transport using the java.io
  * classes.
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/util/ByteBufferInputStreamTest.java b/qpid/java/common/src/test/java/org/apache/qpid/util/ByteBufferInputStreamTest.java
index 0b393a4..53626b6 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/util/ByteBufferInputStreamTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/util/ByteBufferInputStreamTest.java
@@ -20,12 +20,12 @@
  */
 package org.apache.qpid.util;
 
+import junit.framework.TestCase;
+
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Arrays;
 
-import junit.framework.TestCase;
-
 public class ByteBufferInputStreamTest extends TestCase
 {
     private byte[] _data = {2, 1, 5, 3, 4};
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/util/CommandLineParserTest.java b/qpid/java/common/src/test/java/org/apache/qpid/util/CommandLineParserTest.java
index 942901f..7ba5038 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/util/CommandLineParserTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/util/CommandLineParserTest.java
@@ -21,8 +21,9 @@
 
 package org.apache.qpid.util;
 
-import junit.framework.*;
-
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/util/PropertyUtilsTest.java b/qpid/java/common/src/test/java/org/apache/qpid/util/PropertyUtilsTest.java
index 9fd18d4..c5464aa 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/util/PropertyUtilsTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/util/PropertyUtilsTest.java
@@ -40,9 +40,4 @@
         String expandedProperty = PropertyUtils.replaceProperties("${banana}xyz${concrete}");
         assertEquals(expandedProperty, "fruityxyzhorrible");
     }
-
-    public static junit.framework.Test suite()
-    {
-        return new junit.framework.TestSuite(PropertyUtilsTest.class);
-    }
 }
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/util/SerialTest.java b/qpid/java/common/src/test/java/org/apache/qpid/util/SerialTest.java
index b257856..ef8e7de 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/util/SerialTest.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/util/SerialTest.java
@@ -23,10 +23,6 @@
 
 import junit.framework.TestCase;
 
-import java.util.Random;
-
-import org.apache.qpid.SerialException;
-
 /**
  *Junit tests for the Serial class 
  */
diff --git a/qpid/java/common/templates/method/version/MethodBodyClass.vm b/qpid/java/common/templates/method/version/MethodBodyClass.vm
index 0e444b8..caa7277 100644
--- a/qpid/java/common/templates/method/version/MethodBodyClass.vm
+++ b/qpid/java/common/templates/method/version/MethodBodyClass.vm
@@ -2,9 +2,6 @@
 #set( $name = "${name.substring(0,1).toUpperCase()}${name.substring(1)}" )
 #end
 #macro( toUpperCamel $name )${name.substring(0,1).toUpperCase()}${name.substring(1)}#end
-
-
-
 #set( $amqp_ClassName = $amqpClass.Name) 
 #UpperCamel( $amqp_ClassName )
 #set( $amqp_MethodName = $amqpMethod.Name ) 
@@ -12,7 +9,6 @@
 #set( $javaClassName = "${amqp_ClassName}${amqp_MethodName}BodyImpl" )
 #set( $interfaceName = "${amqp_ClassName}${amqp_MethodName}Body" )
 #set( $amqpPackageName = "amqp_$version.getMajor()_$version.getMinor()" )
-
 #set( $filename = "${amqpPackageName}/${javaClassName}.java")
 /*
  *
@@ -46,11 +42,9 @@
  
 package org.apache.qpid.framing.amqp_$version.getMajor()_$version.getMinor();
 
-import java.io.DataInput;
 import org.apache.qpid.codec.MarkableDataInput;
 import java.io.DataOutput;
 import java.io.IOException;
-import java.util.HashMap;
 
 import org.apache.qpid.framing.*;
 import org.apache.qpid.AMQException;
diff --git a/qpid/java/common/templates/model/MethodDispatcherInterface.vm b/qpid/java/common/templates/model/MethodDispatcherInterface.vm
index ff14715..a2c6328 100644
--- a/qpid/java/common/templates/model/MethodDispatcherInterface.vm
+++ b/qpid/java/common/templates/model/MethodDispatcherInterface.vm
@@ -30,10 +30,7 @@
  

 package org.apache.qpid.framing;

 

-import org.apache.qpid.AMQException;

-

-

 public interface MethodDispatcher extends

                      ClientMethodDispatcher, ServerMethodDispatcher

 {

-}
\ No newline at end of file
+}

diff --git a/qpid/java/common/templates/model/version/MethodDispatcherInterface.vm b/qpid/java/common/templates/model/version/MethodDispatcherInterface.vm
index 8a7b667..272ceff 100644
--- a/qpid/java/common/templates/model/version/MethodDispatcherInterface.vm
+++ b/qpid/java/common/templates/model/version/MethodDispatcherInterface.vm
@@ -30,14 +30,12 @@
  
 package org.apache.qpid.framing.amqp_$version.getMajor()_$version.getMinor();
 
-import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.*;
 
-
 public interface MethodDispatcher_${version.getMajor()}_${version.getMinor()} 
     extends MethodDispatcher,
 	        ServerMethodDispatcher_${version.getMajor()}_${version.getMinor()}, 
             ClientMethodDispatcher_${version.getMajor()}_${version.getMinor()}
 {
 
-}
\ No newline at end of file
+}
diff --git a/qpid/java/systests/build.xml b/qpid/java/systests/build.xml
index fb2bae1..fd7203d 100644
--- a/qpid/java/systests/build.xml
+++ b/qpid/java/systests/build.xml
@@ -7,9 +7,9 @@
  - 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
@@ -27,7 +27,7 @@
         </and>
     </condition>
 
-    <property name="module.depends" value="client management/common broker broker/test common common/test junit-toolkit ${systests.optional.depends}"/>
+    <property name="module.depends" value="client management/common broker broker/test common common/test junit-toolkit jca ${systests.optional.depends}"/>
     <property name="module.test.src" location="src/main/java"/>
     <property name="module.test.excludes"
               value="**/DropInTest.java,**/TestClientControlledTest.java"/>
diff --git a/qpid/java/systests/etc/config-systests-firewall-2.xml b/qpid/java/systests/etc/config-systests-firewall-2.xml
index a9fd86b..5167d88 100644
--- a/qpid/java/systests/etc/config-systests-firewall-2.xml
+++ b/qpid/java/systests/etc/config-systests-firewall-2.xml
@@ -31,12 +31,12 @@
              To disasble Non-SSL port set sslOnly to true -->
         <ssl>
             <enabled>false</enabled>
+            <port>8672</port>
             <sslOnly>false</sslOnly>
             <keyStorePath>/path/to/keystore.ks</keyStorePath>
             <keyStorePassword>keystorepass</keyStorePassword>
         </ssl>
         <port>5672</port>
-        <sslport>8672</sslport>
         <socketReceiveBuffer>262144</socketReceiveBuffer>
         <socketSendBuffer>262144</socketSendBuffer>
     </connector>
@@ -44,12 +44,7 @@
         <enabled>false</enabled>
     </management>
     <advanced>
-        <filterchain enableExecutorPool="true"/>
-        <enablePooledAllocator>false</enablePooledAllocator>
-        <enableDirectBuffers>false</enableDirectBuffers>
         <framesize>65535</framesize>
-        <compressBufferOnQueue>false</compressBufferOnQueue>
-        <enableJMSXUserID>false</enableJMSXUserID>
         <locale>en_US</locale>	
     </advanced>
 
diff --git a/qpid/java/systests/etc/config-systests-firewall-3.xml b/qpid/java/systests/etc/config-systests-firewall-3.xml
index f0f3423..2bcbf53 100644
--- a/qpid/java/systests/etc/config-systests-firewall-3.xml
+++ b/qpid/java/systests/etc/config-systests-firewall-3.xml
@@ -31,12 +31,12 @@
              To disable Non-SSL port set sslOnly to true -->
         <ssl>
             <enabled>false</enabled>
+            <port>8672</port>
             <sslOnly>false</sslOnly>
             <keyStorePath>/path/to/keystore.ks</keyStorePath>
             <keyStorePassword>keystorepass</keyStorePassword>
         </ssl>
         <port>5672</port>
-        <sslport>8672</sslport>
         <socketReceiveBuffer>262144</socketReceiveBuffer>
         <socketSendBuffer>262144</socketSendBuffer>
     </connector>
@@ -44,12 +44,7 @@
         <enabled>false</enabled>
     </management>
     <advanced>
-        <filterchain enableExecutorPool="true"/>
-        <enablePooledAllocator>false</enablePooledAllocator>
-        <enableDirectBuffers>false</enableDirectBuffers>
         <framesize>65535</framesize>
-        <compressBufferOnQueue>false</compressBufferOnQueue>
-        <enableJMSXUserID>false</enableJMSXUserID>
         <locale>en_US</locale>	
     </advanced>
 
diff --git a/qpid/java/systests/etc/config-systests-settings.xml b/qpid/java/systests/etc/config-systests-settings.xml
index 8853340..5ed208b 100644
--- a/qpid/java/systests/etc/config-systests-settings.xml
+++ b/qpid/java/systests/etc/config-systests-settings.xml
@@ -25,8 +25,8 @@
             <port>15671</port>
             <enabled>false</enabled>
             <sslOnly>false</sslOnly>
-            <keyStorePath>${QPID_HOME}/../test-profiles/test_resources/ssl/java_broker_keystore.jks</keyStorePath>
-            <keyStorePassword>password</keyStorePassword>
+            <keystorePath>${QPID_HOME}/../test-profiles/test_resources/ssl/java_broker_keystore.jks</keystorePath>
+            <keystorePassword>password</keystorePassword>
         </ssl>
     </connector>
     <management>
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
index 7ea4416..6655202 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
@@ -20,19 +20,20 @@
  */
 package org.apache.qpid.client;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
-import javax.jms.Session;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
+import javax.jms.Session;
 import javax.jms.TextMessage;
 
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class AMQQueueDeferredOrderingTest extends QpidBrokerTestCase
 {
     private Connection con;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQTestConnection_0_10.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQTestConnection_0_10.java
index 09a03a1..c5dd523 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQTestConnection_0_10.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQTestConnection_0_10.java
@@ -29,6 +29,6 @@
     
     public Connection getConnection()
     {
-        return((AMQConnectionDelegate_0_10)_delegate).getQpidConnection();
+        return((AMQConnectionDelegate_0_10)getDelegate()).getQpidConnection();
     }    
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
index 29a44ec..3537dd0 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
@@ -20,12 +20,12 @@
  */
 package org.apache.qpid.client;
 
-import java.util.Hashtable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
@@ -34,12 +34,8 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.naming.Context;
-import javax.naming.spi.InitialContextFactory;
-
-import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery queue
@@ -57,15 +53,15 @@
 {
     private static final Logger _logger = LoggerFactory.getLogger(DispatcherTest.class);
 
-    Context _context;
+    private Context _context;
 
     private static final int MSG_COUNT = 6;
     private int _receivedCount = 0;
     private int _receivedCountWhileStopped = 0;
     private Connection _clientConnection, _producerConnection;
     private MessageConsumer _consumer;
-    MessageProducer _producer;
-    Session _clientSession, _producerSession;
+    private MessageProducer _producer;
+    private Session _clientSession, _producerSession;
 
     private final CountDownLatch _allFirstMessagesSent = new CountDownLatch(1); // all messages Sent Lock
     private final CountDownLatch _allSecondMessagesSent = new CountDownLatch(1); // all messages Sent Lock
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java
index ca83b99..4fd10a0 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.client;
 
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
@@ -33,10 +33,9 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.naming.Context;
-
+import java.util.UUID;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
-import java.util.UUID;
 
 /**
  * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery
@@ -51,7 +50,7 @@
 {
     private static final Logger _logger = LoggerFactory.getLogger(MessageListenerMultiConsumerTest.class);
 
-    Context _context;
+    private Context _context;
 
     private static final int MSG_COUNT = 6;
     private int receivedCount1 = 0;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/MessageListenerTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/MessageListenerTest.java
index e4d1c72..142f301 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/MessageListenerTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/MessageListenerTest.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.client;
 
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.util.LogMonitor;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.util.LogMonitor;
+
 import javax.jms.Connection;
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
@@ -37,7 +36,6 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.naming.Context;
-
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -54,7 +52,7 @@
 {
     private static final Logger _logger = LoggerFactory.getLogger(MessageListenerTest.class);
 
-    Context _context;
+    private Context _context;
 
     private static final int MSG_COUNT = 5;
     private int _receivedCount = 0;
@@ -247,7 +245,6 @@
         _awaitMessages.countDown();
     }
 
-    @Override
     public void onException(JMSException e)
     {
         _logger.info("Exception received", e);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/ResetMessageListenerTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/ResetMessageListenerTest.java
index 40a0d32..6ff6681 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/ResetMessageListenerTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/ResetMessageListenerTest.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.client;
 
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -35,7 +35,6 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.naming.Context;
-
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -52,13 +51,13 @@
 {
     private static final Logger _logger = LoggerFactory.getLogger(ResetMessageListenerTest.class);
 
-    Context _context;
+    private Context _context;
 
     private static final int MSG_COUNT = 6;
     private Connection _clientConnection, _producerConnection;
     private MessageConsumer _consumer1;
-    MessageProducer _producer;
-    Session _clientSession, _producerSession;
+    private MessageProducer _producer;
+    private Session _clientSession, _producerSession;
 
     private final CountDownLatch _allFirstMessagesSent = new CountDownLatch(MSG_COUNT); // all messages Sent Lock
     private final CountDownLatch _allSecondMessagesSent = new CountDownLatch(MSG_COUNT); // all messages Sent Lock
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/SessionCreateTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/SessionCreateTest.java
index 15900a1..d7295b2 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/SessionCreateTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/SessionCreateTest.java
@@ -20,14 +20,15 @@
  */
 package org.apache.qpid.client;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.Session;
 import javax.naming.Context;
 
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 
 /**
  * Class to check that session creation on a connection has no accidental limit
@@ -36,7 +37,7 @@
 {
     private static final Logger _logger = LoggerFactory.getLogger(MessageListenerTest.class);
 
-    Context _context;
+    private Context _context;
 
     private Connection _clientConnection;
     protected int maxSessions = 65555;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/failover/FailoverBehaviourTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/failover/FailoverBehaviourTest.java
index 45aa6a0..526db29 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/failover/FailoverBehaviourTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/failover/FailoverBehaviourTest.java
@@ -18,13 +18,10 @@
  */
 package org.apache.qpid.client.failover;
 
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.jms.ConnectionListener;
+import org.apache.qpid.jms.FailoverPolicy;
+import org.apache.qpid.test.utils.FailoverBaseCase;
 
 import javax.jms.Connection;
 import javax.jms.Destination;
@@ -39,11 +36,13 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.TransactionRolledBackException;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.jms.ConnectionListener;
-import org.apache.qpid.jms.FailoverPolicy;
-import org.apache.qpid.test.utils.FailoverBaseCase;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Test suite to test all possible failover corner cases
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessageTest.java
index bf96dae..c4b1b08 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/message/AMQPEncodedMapMessageTest.java
@@ -21,13 +21,7 @@
  */
 
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
@@ -36,23 +30,21 @@
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.message.AMQPEncodedMapMessage;
-import org.apache.qpid.client.message.AbstractJMSMessage;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.ProtocolVersion;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 
 public class AMQPEncodedMapMessageTest extends QpidBrokerTestCase
 {
     private Connection _connection;
     private Session _session;
-    MessageConsumer _consumer;
-    MessageProducer _producer;
-    UUID myUUID = UUID.randomUUID();
+    private MessageConsumer _consumer;
+    private MessageProducer _producer;
+    private UUID myUUID = UUID.randomUUID();
     
     public void setUp() throws Exception
     {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/message/NonQpidObjectMessage.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/message/NonQpidObjectMessage.java
index 857adaf..3aabfa1 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/message/NonQpidObjectMessage.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/message/NonQpidObjectMessage.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.client.message;
 
-import java.io.Serializable;
-import java.util.Enumeration;
-
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.ObjectMessage;
 import javax.jms.Session;
+import java.io.Serializable;
+import java.util.Enumeration;
 
 public class NonQpidObjectMessage implements ObjectMessage {
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java
index d91b9b9..69441d2 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/prefetch/PrefetchBehaviourTest.java
@@ -20,22 +20,24 @@
 */
 package org.apache.qpid.client.prefetch;
 
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
+import javax.jms.Destination;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageListener;
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
-
-import org.apache.qpid.configuration.ClientProperties;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import javax.jms.TextMessage;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 
 public class PrefetchBehaviourTest extends QpidBrokerTestCase
@@ -192,5 +194,42 @@
             assertEquals("Consumer A received message with unexpected index", i, msgConsumerA.getIntProperty(INDEX));
         }
     }
+
+    /**
+     * Test Goal: Verify if connection stop releases all messages in it's prefetch buffer.
+     * Test Strategy: Send 10 messages to a queue. Create a consumer with maxprefetch of 5, but never consume them.
+     *                Stop the connection. Create a new connection and a consumer with maxprefetch 10 on the same queue.
+     *                Try to receive all 10 messages.
+     */
+    public void testConnectionStop() throws Exception
+    {
+        setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, "10");
+        Connection con = getConnection();
+        con.start();
+        Session ssn = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Destination queue = ssn.createQueue("ADDR:my-queue;{create: always}");
+
+        MessageProducer prod = ssn.createProducer(queue);
+        for (int i=0; i<10;i++)
+        {
+           prod.send(ssn.createTextMessage("Msg" + i));
+        }
+
+        MessageConsumer consumer = ssn.createConsumer(queue);
+        // This is to ensure we get the first client to prefetch.
+        Message msg = consumer.receive(1000);
+        assertNotNull("The first consumer should get one message",msg);
+        con.stop();
+
+        Connection con2 = getConnection();
+        con2.start();
+        Session ssn2 = con2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageConsumer consumer2 = ssn2.createConsumer(queue);
+        for (int i=0; i<9;i++)
+        {
+           TextMessage m = (TextMessage)consumer2.receive(1000);
+           assertNotNull("The second consumer should get 9 messages, but received only " + i,m);
+        }
+    }
 }
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/redelivered/RedeliveredMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/redelivered/RedeliveredMessageTest.java
index a8fa183..cd74691 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/redelivered/RedeliveredMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/redelivered/RedeliveredMessageTest.java
@@ -1,11 +1,12 @@
 package org.apache.qpid.client.redelivered;
 
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.Session;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 public class RedeliveredMessageTest extends QpidBrokerTestCase
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/ssl/SSLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/ssl/SSLTest.java
index d754979..84c17ae 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/ssl/SSLTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/ssl/SSLTest.java
@@ -20,21 +20,20 @@
  */
 package org.apache.qpid.client.ssl;
 
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-
-import javax.jms.Session;
-
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQTestConnection_0_10;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.transport.Connection;
 
+import javax.jms.Session;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
 public class SSLTest extends QpidBrokerTestCase
 {
-    private static final String KEYSTORE = "test-profiles/test_resources/ssl/java_client_keystore.jks";
+    private static final String KEYSTORE = TEST_RESOURCES_DIR + "/ssl/java_client_keystore.jks";
     private static final String KEYSTORE_PASSWORD = "password";
-    private static final String TRUSTSTORE = "test-profiles/test_resources/ssl/java_client_truststore.jks";
+    private static final String TRUSTSTORE = TEST_RESOURCES_DIR + "/ssl/java_client_truststore.jks";
     private static final String TRUSTSTORE_PASSWORD = "password";
     private static final String CERT_ALIAS_APP1 = "app1";
     private static final String CERT_ALIAS_APP2 = "app2";
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java
index d7ee203..c8ffe85 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java
@@ -20,16 +20,16 @@
  */
 package org.apache.qpid.jms.xa;
 
-import javax.jms.XAConnection;
-import javax.jms.XAConnectionFactory;
-import javax.jms.XASession;
-import javax.transaction.xa.XAResource;
-
 import org.apache.qpid.client.AMQConnectionFactory;
 import org.apache.qpid.jms.ConnectionURL;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.util.FileUtils;
 
+import javax.jms.XAConnection;
+import javax.jms.XAConnectionFactory;
+import javax.jms.XASession;
+import javax.transaction.xa.XAResource;
+
 public class XAResourceTest extends QpidBrokerTestCase
 {
 
@@ -43,7 +43,7 @@
     public void testIsSameRMSingleCF() throws Exception
     {
         XAConnectionFactory factory = getConnectionFactory(FACTORY_NAME);
-        XAConnection conn = factory.createXAConnection();
+        XAConnection conn = factory.createXAConnection("guest","guest");
         XASession session = conn.createXASession();
         XAResource xaResource1 = session.getXAResource();
         XAResource xaResource2 = session.getXAResource();
@@ -68,9 +68,9 @@
         XAConnectionFactory factory2 = new AMQConnectionFactory(url);
         XAConnectionFactory factory3 = getConnectionFactory(ALT_FACTORY_NAME);
         
-        XAConnection conn = factory.createXAConnection();
-        XAConnection conn2 = factory2.createXAConnection();
-        XAConnection conn3 = factory3.createXAConnection();
+        XAConnection conn = factory.createXAConnection("guest","guest");
+        XAConnection conn2 = factory2.createXAConnection("guest","guest");
+        XAConnection conn3 = factory3.createXAConnection("guest","guest");
         
         XASession session = conn.createXASession();
         XASession session2 = conn2.createXASession();
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedBrokerMBeanTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedBrokerMBeanTest.java
index 97ba9af..ba0f955 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedBrokerMBeanTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedBrokerMBeanTest.java
@@ -18,13 +18,6 @@
  */
 package org.apache.qpid.management.jmx;
 
-import java.util.Collections;
-import java.util.Map;
-
-import javax.management.JMException;
-import javax.management.MBeanException;
-import javax.management.ObjectName;
-
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.management.common.mbeans.ManagedBroker;
 import org.apache.qpid.management.common.mbeans.ManagedExchange;
@@ -33,6 +26,11 @@
 import org.apache.qpid.test.utils.JMXTestUtils;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
+import javax.management.MBeanException;
+import javax.management.ObjectName;
+import java.util.Collections;
+import java.util.Map;
+
 /**
  * Tests the JMX API for the Managed Broker.
  *
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java
index a258e42..3fc370d 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java
@@ -18,10 +18,14 @@
  */
 package org.apache.qpid.management.jmx;
 
-import java.io.IOException;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.management.common.mbeans.ManagedConnection;
+import org.apache.qpid.test.utils.JMXTestUtils;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.Destination;
@@ -33,13 +37,10 @@
 import javax.management.JMException;
 import javax.management.openmbean.CompositeDataSupport;
 import javax.management.openmbean.TabularData;
-
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.management.common.mbeans.ManagedConnection;
-import org.apache.qpid.test.utils.JMXTestUtils;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
 
 public class ManagedConnectionMBeanTest extends QpidBrokerTestCase
 {
@@ -242,4 +243,36 @@
         assertNotNull("Connection MBean is null", mBean);
         assertEquals("Unexpected authorized id", "guest", mBean.getAuthorizedId());
     }
+
+    public void testClientVersion() throws Exception
+    {
+        List<ManagedConnection> connections = _jmxUtils.getManagedConnections("test");
+        assertNotNull("Connection MBean is not found", connections);
+        assertEquals("Unexpected number of connection mbeans", 1, connections.size());
+        final ManagedConnection mBean = connections.get(0);
+        assertNotNull("Connection MBean is null", mBean);
+
+        String expectedVersion = QpidProperties.getReleaseVersion();
+        assertNotNull("version should not be null", expectedVersion);
+        assertFalse("version should not be the empty string", expectedVersion.equals(""));
+        assertFalse("version should not be the string 'null'", expectedVersion.equals("null"));
+
+        assertEquals("Unexpected version", expectedVersion, mBean.getVersion());
+    }
+
+    public void testClientId() throws Exception
+    {
+        List<ManagedConnection> connections = _jmxUtils.getManagedConnections("test");
+        assertNotNull("Connection MBean is not found", connections);
+        assertEquals("Unexpected number of connection mbeans", 1, connections.size());
+        final ManagedConnection mBean = connections.get(0);
+        assertNotNull("Connection MBean is null", mBean);
+
+        String expectedClientId = _connection.getClientID();
+        assertNotNull("ClientId should not be null", expectedClientId);
+        assertFalse("ClientId should not be the empty string", expectedClientId.equals(""));
+        assertFalse("ClientId should not be the string 'null'", expectedClientId.equals("null"));
+
+        assertEquals("Unexpected ClientId", expectedClientId, mBean.getClientId());
+    }
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedQueueMBeanTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedQueueMBeanTest.java
index 0e60cc5..244e547 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedQueueMBeanTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedQueueMBeanTest.java
@@ -18,24 +18,37 @@
  */
 package org.apache.qpid.management.jmx;
 
+import org.apache.commons.lang.time.FastDateFormat;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.management.common.mbeans.ManagedQueue;
+import org.apache.qpid.server.queue.AMQQueueMBean;
+import org.apache.qpid.test.utils.JMXTestUtils;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Session;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.Session;
-import javax.jms.Connection;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.TabularData;
-
-import org.apache.commons.lang.time.FastDateFormat;
-import org.apache.qpid.management.common.mbeans.ManagedQueue;
-import org.apache.qpid.server.queue.AMQQueueMBean;
-import org.apache.qpid.test.utils.JMXTestUtils;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Tests the JMX API for the Managed Queue.
@@ -43,17 +56,41 @@
  */
 public class ManagedQueueMBeanTest extends QpidBrokerTestCase
 {
-    /**
-     * JMX helper.
-     */
+    protected static final Logger LOGGER = Logger.getLogger(ManagedQueueMBeanTest.class);
+
     private JMXTestUtils _jmxUtils;
+    private Connection _connection;
+    private Session _session;
+
+    private String _sourceQueueName;
+    private String _destinationQueueName;
+    private Destination _sourceQueue;
+    private Destination _destinationQueue;
+    private ManagedQueue _managedSourceQueue;
+    private ManagedQueue _managedDestinationQueue;
 
     public void setUp() throws Exception
     {
         _jmxUtils = new JMXTestUtils(this);
         _jmxUtils.setUp();
+
         super.setUp();
+        _sourceQueueName = getTestQueueName() + "_src";
+        _destinationQueueName = getTestQueueName() + "_dest";
+
+        _connection = getConnection();
+        _connection.start();
+
+        _session = _connection.createSession(true, Session.SESSION_TRANSACTED);
+        _sourceQueue = _session.createQueue(_sourceQueueName);
+        _destinationQueue = _session.createQueue(_destinationQueueName);
+        createQueueOnBroker(_sourceQueue);
+        createQueueOnBroker(_destinationQueue);
+
         _jmxUtils.open();
+
+        _managedSourceQueue = _jmxUtils.getManagedQueue(_sourceQueueName);
+        _managedDestinationQueue = _jmxUtils.getManagedQueue(_destinationQueueName);
     }
 
     public void tearDown() throws Exception
@@ -70,28 +107,18 @@
      */
     public void testViewSingleMessage() throws Exception
     {
-        final String queueName = getTestQueueName();
-
-        // Create queue and send numMessages messages to it.
-        final Connection con = getConnection();
-        final Session session = con.createSession(true, Session.SESSION_TRANSACTED);
-        final Destination dest = session.createQueue(queueName);
-        session.createConsumer(dest).close(); // Create a consumer only to cause queue creation
-
-        final List<Message> sentMessages = sendMessage(session, dest, 1);
+        final List<Message> sentMessages = sendMessage(_session, _sourceQueue, 1);
+        syncSession(_session);
         final Message sentMessage = sentMessages.get(0);
 
-        // Obtain the management interface.
-        final ManagedQueue managedQueue = _jmxUtils.getManagedQueue(queueName);
-        assertNotNull("ManagedQueue expected to be available", managedQueue);
-        assertEquals("Unexpected queue depth", 1, managedQueue.getMessageCount().intValue());
+        assertEquals("Unexpected queue depth", 1, _managedSourceQueue.getMessageCount().intValue());
 
         // Check the contents of the message
-        final TabularData tab = managedQueue.viewMessages(1l, 1l);
+        final TabularData tab = _managedSourceQueue.viewMessages(1l, 1l);
         assertEquals("Unexpected number of rows in table", 1, tab.size());
-        final Iterator<CompositeDataSupport> rowItr = (Iterator<CompositeDataSupport>) tab.values().iterator();
+        final Iterator<CompositeData> rowItr = (Iterator<CompositeData>) tab.values().iterator();
 
-        final CompositeDataSupport row1 = rowItr.next();
+        final CompositeData row1 = rowItr.next();
         assertNotNull("Message should have AMQ message id", row1.get(ManagedQueue.MSG_AMQ_ID));
         assertEquals("Unexpected queue position", 1l, row1.get(ManagedQueue.MSG_QUEUE_POS));
         assertEquals("Unexpected redelivered flag", Boolean.FALSE, row1.get(ManagedQueue.MSG_REDELIVERED));
@@ -109,6 +136,184 @@
     }
 
     /**
+     * Tests {@link ManagedQueue#moveMessages(long, long, String)} interface.
+     */
+    public void testMoveMessagesBetweenQueues() throws Exception
+    {
+        final int numberOfMessagesToSend = 10;
+
+        sendMessage(_session, _sourceQueue, numberOfMessagesToSend);
+        syncSession(_session);
+        assertEquals("Unexpected queue depth after send", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+        List<Long> amqMessagesIds = getAMQMessageIdsOn(_managedSourceQueue, 1, numberOfMessagesToSend);
+
+        // Move first three messages to destination
+        long fromMessageId = amqMessagesIds.get(0);
+        long toMessageId = amqMessagesIds.get(2);
+        _managedSourceQueue.moveMessages(fromMessageId, toMessageId, _destinationQueueName);
+
+        assertEquals("Unexpected queue depth on destination queue after first move", 3, _managedDestinationQueue.getMessageCount().intValue());
+        assertEquals("Unexpected queue depth on source queue after first move", 7, _managedSourceQueue.getMessageCount().intValue());
+
+        // Now move a further two messages to destination
+        fromMessageId = amqMessagesIds.get(7);
+        toMessageId = amqMessagesIds.get(8);
+        _managedSourceQueue.moveMessages(fromMessageId, toMessageId, _destinationQueueName);
+        assertEquals("Unexpected queue depth on destination queue after second move", 5, _managedDestinationQueue.getMessageCount().intValue());
+        assertEquals("Unexpected queue depth on source queue after second move", 5, _managedSourceQueue.getMessageCount().intValue());
+
+        assertMessageIndicesOn(_destinationQueue, 0, 1, 2, 7, 8);
+    }
+
+    /**
+     * Tests {@link ManagedQueue#copyMessages(long, long, String)} interface.
+     */
+    public void testCopyMessagesBetweenQueues() throws Exception
+    {
+        final int numberOfMessagesToSend = 10;
+        sendMessage(_session, _sourceQueue, numberOfMessagesToSend);
+        syncSession(_session);
+        assertEquals("Unexpected queue depth after send", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+        List<Long> amqMessagesIds = getAMQMessageIdsOn(_managedSourceQueue, 1, numberOfMessagesToSend);
+
+        // Copy first three messages to destination
+        long fromMessageId = amqMessagesIds.get(0);
+        long toMessageId = amqMessagesIds.get(2);
+        _managedSourceQueue.copyMessages(fromMessageId, toMessageId, _destinationQueueName);
+
+        assertEquals("Unexpected queue depth on destination queue after first copy", 3, _managedDestinationQueue.getMessageCount().intValue());
+        assertEquals("Unexpected queue depth on source queue after first copy", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+        // Now copy a further two messages to destination
+        fromMessageId = amqMessagesIds.get(7);
+        toMessageId = amqMessagesIds.get(8);
+        _managedSourceQueue.copyMessages(fromMessageId, toMessageId, _destinationQueueName);
+        assertEquals("Unexpected queue depth on destination queue after second copy", 5, _managedDestinationQueue.getMessageCount().intValue());
+        assertEquals("Unexpected queue depth on source queue after second copy", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+        assertMessageIndicesOn(_destinationQueue, 0, 1, 2, 7, 8);
+    }
+
+    public void testMoveMessagesBetweenQueuesWithActiveConsumerOnSourceQueue() throws Exception
+    {
+        setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, new Integer(1).toString());
+        Connection asyncConnection = getConnection();
+        asyncConnection.start();
+
+        final int numberOfMessagesToSend = 50;
+        sendMessage(_session, _sourceQueue, numberOfMessagesToSend);
+        syncSession(_session);
+        assertEquals("Unexpected queue depth after send", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+        List<Long> amqMessagesIds = getAMQMessageIdsOn(_managedSourceQueue, 1, numberOfMessagesToSend);
+
+        long fromMessageId = amqMessagesIds.get(0);
+        long toMessageId = amqMessagesIds.get(numberOfMessagesToSend - 1);
+
+        CountDownLatch consumerReadToHalfwayLatch = new CountDownLatch(numberOfMessagesToSend / 2);
+        AtomicInteger totalConsumed = new AtomicInteger(0);
+        startAsyncConsumerOn(_sourceQueue, asyncConnection, consumerReadToHalfwayLatch, totalConsumed);
+
+        boolean halfwayPointReached = consumerReadToHalfwayLatch.await(5000, TimeUnit.MILLISECONDS);
+        assertTrue("Did not read half of messages within time allowed", halfwayPointReached);
+
+        _managedSourceQueue.moveMessages(fromMessageId, toMessageId, _destinationQueueName);
+
+        asyncConnection.stop();
+
+        // The exact number of messages moved will be non deterministic, as the number of messages processed
+        // by the consumer cannot be predicited.  There is also the possibility that a message can remain
+        // on the source queue.  This situation will arise if a message has been acquired by the consumer, but not
+        // yet delivered to the client application (i.e. MessageListener#onMessage()) when the Connection#stop() occurs.
+        //
+        // The number of messages moved + the number consumed + any messages remaining on source should
+        // *always* be equal to the number we originally sent.
+
+        int numberOfMessagesReadByConsumer = totalConsumed.intValue();
+        int numberOfMessagesOnDestinationQueue = _managedDestinationQueue.getMessageCount().intValue();
+        int numberOfMessagesRemainingOnSourceQueue = _managedSourceQueue.getMessageCount().intValue();
+
+        LOGGER.debug("Async consumer read : " + numberOfMessagesReadByConsumer
+                + " Number of messages moved to destination : " + numberOfMessagesOnDestinationQueue
+                + " Number of messages remaining on source : " + numberOfMessagesRemainingOnSourceQueue);
+        assertEquals("Unexpected number of messages after move", numberOfMessagesToSend, numberOfMessagesReadByConsumer + numberOfMessagesOnDestinationQueue + numberOfMessagesRemainingOnSourceQueue);
+    }
+
+    public void testMoveMessagesBetweenQueuesWithActiveConsumerOnDestinationQueue() throws Exception
+    {
+        setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, new Integer(1).toString());
+        Connection asyncConnection = getConnection();
+        asyncConnection.start();
+
+        final int numberOfMessagesToSend = 50;
+        sendMessage(_session, _sourceQueue, numberOfMessagesToSend);
+        syncSession(_session);
+        assertEquals("Unexpected queue depth after send", numberOfMessagesToSend, _managedSourceQueue.getMessageCount().intValue());
+
+        List<Long> amqMessagesIds = getAMQMessageIdsOn(_managedSourceQueue, 1, numberOfMessagesToSend);
+        long fromMessageId = amqMessagesIds.get(0);
+        long toMessageId = amqMessagesIds.get(numberOfMessagesToSend - 1);
+
+        AtomicInteger totalConsumed = new AtomicInteger(0);
+        CountDownLatch allMessagesConsumedLatch = new CountDownLatch(numberOfMessagesToSend);
+        startAsyncConsumerOn(_destinationQueue, asyncConnection, allMessagesConsumedLatch, totalConsumed);
+
+        _managedSourceQueue.moveMessages(fromMessageId, toMessageId, _destinationQueueName);
+
+        allMessagesConsumedLatch.await(5000, TimeUnit.MILLISECONDS);
+        assertEquals("Did not consume all messages from destination queue", numberOfMessagesToSend, totalConsumed.intValue());
+    }
+
+    private void startAsyncConsumerOn(Destination queue, Connection asyncConnection,
+            final CountDownLatch requiredNumberOfMessagesRead, final AtomicInteger totalConsumed) throws Exception
+    {
+        Session session = asyncConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageConsumer consumer = session.createConsumer(queue);
+        consumer.setMessageListener(new MessageListener()
+        {
+
+            @Override
+            public void onMessage(Message arg0)
+            {
+                totalConsumed.incrementAndGet();
+                requiredNumberOfMessagesRead.countDown();
+            }
+        });
+    }
+
+    private void assertMessageIndicesOn(Destination queue, int... expectedIndices) throws Exception
+    {
+        MessageConsumer consumer = _session.createConsumer(queue);
+
+        for (int i : expectedIndices)
+        {
+            Message message = consumer.receive(1000);
+            assertNotNull("Expected message with index " + i, message);
+            assertEquals("Expected message with index " + i, i, message.getIntProperty(INDEX));
+        }
+
+        assertNull("Unexpected message encountered", consumer.receive(1000));
+    }
+
+    private List<Long> getAMQMessageIdsOn(ManagedQueue managedQueue, long startIndex, long endIndex) throws Exception
+    {
+        final SortedSet<Long> messageIds = new TreeSet<Long>();
+
+        final TabularData tab = managedQueue.viewMessages(startIndex, endIndex);
+        final Iterator<CompositeData> rowItr = (Iterator<CompositeData>) tab.values().iterator();
+        while(rowItr.hasNext())
+        {
+            final CompositeData row = rowItr.next();
+            long amqMessageId = (Long)row.get(ManagedQueue.MSG_AMQ_ID);
+            messageIds.add(amqMessageId);
+        }
+
+        return new ArrayList<Long>(messageIds);
+    }
+
+    /**
      *
      * Utility method to convert array of Strings in the form x = y into a
      * map with key/value x =&gt; y.
@@ -126,4 +331,15 @@
         }
         return headerMap;
     }
+
+    private void createQueueOnBroker(Destination destination) throws JMSException
+    {
+        _session.createConsumer(destination).close(); // Create a consumer only to cause queue creation
+    }
+
+    private void syncSession(Session session) throws Exception
+    {
+        ((AMQSession<?,?>)session).sync();
+    }
+
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageConnectionStatisticsTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageConnectionStatisticsTest.java
index 9839c6e..9465749 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageConnectionStatisticsTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageConnectionStatisticsTest.java
@@ -20,15 +20,14 @@
  */
 package org.apache.qpid.management.jmx;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.Connection;
-
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.management.common.mbeans.ManagedBroker;
 import org.apache.qpid.management.common.mbeans.ManagedConnection;
 
+import javax.jms.Connection;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Test enabling generation of message statistics on a per-connection basis.
  */
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsDeliveryTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsDeliveryTest.java
index c374d23..bdfd1e2 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsDeliveryTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsDeliveryTest.java
@@ -20,17 +20,16 @@
  */
 package org.apache.qpid.management.jmx;
 
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.management.common.mbeans.ManagedBroker;
+import org.apache.qpid.management.common.mbeans.ManagedConnection;
 
 import javax.jms.Connection;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.Session;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.management.common.mbeans.ManagedBroker;
-import org.apache.qpid.management.common.mbeans.ManagedConnection;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Test statistics for delivery and receipt.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsReportingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsReportingTest.java
index 180440c..786ef11 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsReportingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsReportingTest.java
@@ -20,10 +20,10 @@
  */
 package org.apache.qpid.management.jmx;
 
-import java.util.List;
-
 import org.apache.qpid.util.LogMonitor;
 
+import java.util.List;
+
 /**
  * Test generation of message statistics reporting.
  */
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java
index 824ae41..de45676 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java
@@ -20,12 +20,12 @@
  */
 package org.apache.qpid.management.jmx;
 
-import javax.jms.Connection;
-
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.management.common.mbeans.ManagedBroker;
 import org.apache.qpid.management.common.mbeans.ManagedConnection;
 
+import javax.jms.Connection;
+
 /**
  * Test generation of message statistics.
  */
@@ -162,29 +162,7 @@
         assertEquals("Incorrect test vhost total", 30, test.getTotalMessagesReceived());
         assertEquals("Incorrect test vhost data", 30 * 100, test.getTotalDataReceived());
     }
-    
-    /**
-     * Test message peak rate generation.
-     */
-    public void testMessagePeakRates() throws Exception
-    {
-        sendUsing(_test, 2, 10);
-        Thread.sleep(10000);
-        sendUsing(_dev, 4, 10);
-        Thread.sleep(10000);
-        
-        ManagedBroker test = _jmxUtils.getManagedBroker("test");
-        ManagedBroker dev = _jmxUtils.getManagedBroker("development");
-        
-        assertApprox("Incorrect test vhost peak messages", 0.2d, 1.0d, test.getPeakMessageReceiptRate());
-        assertApprox("Incorrect test vhost peak data", 0.2d, 10.0d, test.getPeakDataReceiptRate());
-        assertApprox("Incorrect dev vhost peak messages", 0.2d, 2.0d, dev.getPeakMessageReceiptRate());
-        assertApprox("Incorrect dev vhost peak data", 0.2d, 20.0d, dev.getPeakDataReceiptRate());
 
-        assertApprox("Incorrect server peak messages", 0.2d, 2.0d, _jmxUtils.getServerInformation().getPeakMessageReceiptRate());
-        assertApprox("Incorrect server peak data", 0.2d, 20.0d, _jmxUtils.getServerInformation().getPeakDataReceiptRate());
-    }
-    
     /**
      * Test message totals when a vhost has its statistics reset
      */
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTestCase.java
index a5b3aa2..45200ba 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTestCase.java
@@ -20,13 +20,6 @@
  */
 package org.apache.qpid.management.jmx;
 
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQDestination;
@@ -37,6 +30,13 @@
 import org.apache.qpid.test.utils.JMXTestUtils;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
 /**
  * Test generation of message statistics.
  */
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/scripts/QpidPasswdTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/scripts/QpidPasswdTest.java
new file mode 100644
index 0000000..1158a1d
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/scripts/QpidPasswdTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.scripts;
+
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.qpid.test.utils.Piper;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class QpidPasswdTest extends QpidTestCase
+{
+    private static final Logger LOGGER = LoggerFactory.getLogger(QpidPasswdTest.class);
+
+    private static final String PASSWD_SCRIPT = "qpid-passwd";
+    private static final String EXPECTED_OUTPUT = "user1:rL0Y20zC+Fzt72VPzMSk2A==";
+
+    public void testRunScript() throws Exception
+    {
+        Process process = null;
+        try
+        {
+            String scriptPath =
+                    QpidTestCase.QPID_HOME + File.separatorChar
+                    + "bin" + File.separatorChar
+                    + PASSWD_SCRIPT;
+
+            LOGGER.info("About to run script: " + scriptPath);
+
+            ProcessBuilder pb = new ProcessBuilder(scriptPath, "user1", "foo");
+            pb.redirectErrorStream(true);
+            process = pb.start();
+
+            Piper piper = new Piper(process.getInputStream(), System.out, EXPECTED_OUTPUT, EXPECTED_OUTPUT);
+            piper.start();
+
+            boolean finishedSuccessfully = piper.await(2, TimeUnit.SECONDS);
+            assertTrue(
+                    "Script should have completed with expected output " + EXPECTED_OUTPUT + ". Check standard output for actual output.",
+                    finishedSuccessfully);
+            process.waitFor();
+            piper.join();
+
+            assertEquals("Unexpected exit value from backup script", 0, process.exitValue());
+        }
+        finally
+        {
+            if (process != null)
+            {
+                process.getErrorStream().close();
+                process.getInputStream().close();
+                process.getOutputStream().close();
+            }
+        }
+
+    }
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java
index 27b4de0..9f3994f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java
@@ -20,18 +20,17 @@
  */
 package org.apache.qpid.server;
 
+import junit.framework.AssertionFailedError;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
 import org.apache.qpid.server.logging.AbstractTestLogging;
 import org.apache.qpid.util.LogMonitor;
-import org.apache.log4j.Logger;
-import org.apache.log4j.Level;
-
-import java.util.List;
-
-import junit.framework.AssertionFailedError;
 
 import javax.jms.Connection;
-import javax.jms.Session;
 import javax.jms.Queue;
+import javax.jms.Session;
+import java.util.List;
 
 /**
  * Series of tests to validate the external Java broker starts up as expected.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java
new file mode 100644
index 0000000..c42bb3b
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java
@@ -0,0 +1,147 @@
+/*
+ *  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.server;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.framing.ProtocolVersion;
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
+/**
+ * Tests to validate it is possible to disable support for particular protocol
+ * versions entirely, rather than selectively excluding them on particular ports,
+ * and it is possible to configure the reply to an unsupported protocol initiation.
+ */
+public class SupportedProtocolVersionsTest extends QpidBrokerTestCase
+{
+    public void setUp() throws Exception
+    {
+        // No-op, we call super.setUp() from test methods after appropriate config overrides
+    }
+
+    /**
+     * Test that 0-10, 0-9-1, 0-9, and 0-8 support is present when no
+     * attempt has yet been made to disable them, and forcing the client
+     * to negotiate from a particular protocol version returns a connection
+     * using the expected protocol version.
+     */
+    public void testDefaultProtocolSupport() throws Exception
+    {
+        //Start the broker without modifying its supported protocols
+        super.setUp();
+
+        //Verify requesting a 0-10 connection works
+        setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-10");
+        AMQConnection connection = (AMQConnection) getConnection();
+        assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_10, connection.getProtocolVersion());
+        connection.close();
+
+        //Verify requesting a 0-91 connection works
+        setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-9-1");
+        connection = (AMQConnection) getConnection();
+        assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_91, connection.getProtocolVersion());
+        connection.close();
+
+        //Verify requesting a 0-9 connection works
+        setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-9");
+        connection = (AMQConnection) getConnection();
+        assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_9, connection.getProtocolVersion());
+        connection.close();
+
+        //Verify requesting a 0-8 connection works
+        setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-8");
+        connection = (AMQConnection) getConnection();
+        assertEquals("Unexpected protocol version in use", ProtocolVersion.v8_0, connection.getProtocolVersion());
+        connection.close();
+    }
+
+    public void testDisabling010() throws Exception
+    {
+        //disable 0-10 support
+        setConfigurationProperty("connector.amqp010enabled", "false");
+
+        super.setUp();
+
+        //Verify initially requesting a 0-10 connection now negotiates a 0-91
+        //connection as the broker should reply with its highest supported protocol
+        setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-10");
+        AMQConnection connection = (AMQConnection) getConnection();
+        assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_91, connection.getProtocolVersion());
+        connection.close();
+    }
+
+    public void testDisabling091and010() throws Exception
+    {
+        //disable 0-91 and 0-10 support
+        setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP010ENABLED, "false");
+        setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP091ENABLED, "false");
+
+        super.setUp();
+
+        //Verify initially requesting a 0-10 connection now negotiates a 0-9
+        //connection as the broker should reply with its highest supported protocol
+        setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-10");
+        AMQConnection connection = (AMQConnection) getConnection();
+        assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_9, connection.getProtocolVersion());
+        connection.close();
+    }
+
+    public void testDisabling09and091and010() throws Exception
+    {
+        //disable 0-9, 0-91 and 0-10 support
+        setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP09ENABLED, "false");
+        setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP091ENABLED, "false");
+        setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP010ENABLED, "false");
+
+        super.setUp();
+
+        //Verify initially requesting a 0-10 connection now negotiates a 0-8
+        //connection as the broker should reply with its highest supported protocol
+        setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-10");
+        AMQConnection connection = (AMQConnection) getConnection();
+        assertEquals("Unexpected protocol version in use", ProtocolVersion.v8_0, connection.getProtocolVersion());
+        connection.close();
+    }
+
+    public void testConfiguringReplyingToUnsupported010ProtocolInitiationWith09insteadOf091() throws Exception
+    {
+        //disable 0-10 support, and set the default unsupported protocol initiation reply to 0-9
+        setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP010ENABLED, "false");
+        setConfigurationProperty(ServerConfiguration.CONNECTOR_AMQP_SUPPORTED_REPLY, "v0_9");
+
+        super.setUp();
+
+        //Verify initially requesting a 0-10 connection now negotiates a 0-9 connection as the
+        //broker should reply with its 'default unsupported protocol initiation reply' as opposed
+        //to the previous behaviour of the highest supported protocol version.
+        setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-10");
+        AMQConnection connection = (AMQConnection) getConnection();
+        assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_9, connection.getProtocolVersion());
+        connection.close();
+
+        //Verify requesting a 0-91 connection directly still works, as its support is still enabled
+        setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-9-1");
+        connection = (AMQConnection) getConnection();
+        assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_91, connection.getProtocolVersion());
+        connection.close();
+    }
+}
\ No newline at end of file
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
index 6d379e1..6f54a56 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.configuration;
 
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 /**
@@ -32,7 +33,7 @@
  */
 public class ServerConfigurationFileTest extends QpidBrokerTestCase
 {
-    ServerConfiguration _serverConfig;
+    private ServerConfiguration _serverConfig;
 
     public void setUp() throws ConfigurationException
     {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
index 4b4fbd7..3d116f1 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
@@ -21,20 +21,8 @@
 
 package org.apache.qpid.server.exchange;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.jms.Connection;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.client.AMQHeadersExchange;
 import org.apache.qpid.client.AMQNoRouteException;
 import org.apache.qpid.client.AMQQueue;
@@ -47,6 +35,18 @@
 import org.apache.qpid.url.AMQBindingURL;
 import org.apache.qpid.url.BindingURL;
 
+import javax.jms.Connection;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
 public class ReturnUnroutableMandatoryMessageTest extends QpidBrokerTestCase implements ExceptionListener
 {
     private static final Logger _logger = Logger.getLogger(ReturnUnroutableMandatoryMessageTest.class);
@@ -241,7 +241,7 @@
         con2.start();
 
         MessageProducer nonMandatoryProducer = producerSession.createProducer(valid_topic, false, false);
-        MessageProducer mandatoryProducer = producerSession.createProducer(invalid_topic);
+        MessageProducer mandatoryProducer = producerSession.createProducer(invalid_topic, false, true);
 
         // First test - should be routed
         _logger.info("Sending non-mandatory message");
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
index 470fcef..babe2d2 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
@@ -20,11 +20,8 @@
  */
 package org.apache.qpid.server.failover;
 
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQConnectionClosedException;
 import org.apache.qpid.AMQDisconnectedException;
@@ -32,15 +29,17 @@
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQConnectionURL;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionListener
 {
+    private static final Logger LOGGER = LoggerFactory.getLogger(FailoverMethodTest.class);
     private CountDownLatch _failoverComplete = new CountDownLatch(1);
-    protected static final Logger _logger = LoggerFactory.getLogger(FailoverMethodTest.class);
-
-
+    private final int _freePortWithNoBroker = findFreePort();
 
     /**
      * Test that the round robin method has the correct delays.
@@ -53,8 +52,8 @@
         //note: The first broker has no connect delay and the default 1 retry
         //        while the tcp:localhost broker has 3 retries with a 2s connect delay
         String connectionString = "amqp://guest:guest@/test?brokerlist=" +
-                                  "'tcp://:" + getPort() +
-                                  ";tcp://localhost:5670?connectdelay='2000',retries='3''";
+                                  "'tcp://localhost:" + getPort() +
+                                  ";tcp://localhost:" + _freePortWithNoBroker + "?connectdelay='2000',retries='3''";
 
         AMQConnectionURL url = new AMQConnectionURL(connectionString);
 
@@ -65,7 +64,9 @@
 
             connection.setExceptionListener(this);
 
+            LOGGER.debug("Stopping broker");
             stopBroker();
+            LOGGER.debug("Stopped broker");
 
             _failoverComplete.await(30, TimeUnit.SECONDS);
             assertEquals("failoverLatch was not decremented in given timeframe",
@@ -109,7 +110,9 @@
 
             connection.setExceptionListener(this);
 
+            LOGGER.debug("Stopping broker");
             stopBroker();
+            LOGGER.debug("Stopped broker");
 
             _failoverComplete.await(30, TimeUnit.SECONDS);
             assertEquals("failoverLatch was not decremented in given timeframe",
@@ -138,18 +141,6 @@
         }
     }
 
-    public void onException(JMSException e)
-    {
-        if (e.getLinkedException() instanceof AMQDisconnectedException || e.getLinkedException() instanceof AMQConnectionClosedException)
-        {
-            _logger.debug("Received AMQDisconnectedException");
-            _failoverComplete.countDown();
-        }
-        else
-        {
-            _logger.error("Unexpected underlying exception", e.getLinkedException());
-        }
-    }
 
     /**
      * Test that setting 'nofailover' as the failover policy does not result in
@@ -200,13 +191,11 @@
                     }
                     catch (Exception e)
                     {
-                        System.err.println(e.getMessage());
-                        e.printStackTrace();
+                        LOGGER.error("Exception whilst starting broker", e);
                     }
                 }
             });
 
-
             brokerStart.start();
             long start = System.currentTimeMillis();
 
@@ -260,11 +249,17 @@
         }
     }
 
-    public void stopBroker(int port) throws Exception
+    @Override
+    public void onException(JMSException e)
     {
-        if (isBrokerPresent(port))
+        if (e.getLinkedException() instanceof AMQDisconnectedException || e.getLinkedException() instanceof AMQConnectionClosedException)
         {
-            super.stopBroker(port);
+            LOGGER.debug("Received AMQDisconnectedException");
+            _failoverComplete.countDown();
+        }
+        else
+        {
+            LOGGER.error("Unexpected underlying exception", e.getLinkedException());
         }
     }
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/failure/HeapExhaustion.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/failure/HeapExhaustion.java
index 22a1b11..87a53a0 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/failure/HeapExhaustion.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/failure/HeapExhaustion.java
@@ -22,14 +22,15 @@
 package org.apache.qpid.server.failure;
 
 import junit.framework.TestCase;
-import org.apache.qpid.test.utils.QpidClientConnectionHelper;
-import org.apache.qpid.client.failover.FailoverException;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.protocol.AMQConstant;
 import org.apache.log4j.Logger;
 
-import javax.jms.JMSException;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.failover.FailoverException;
+import org.apache.qpid.protocol.AMQConstant;
+import org.apache.qpid.test.utils.QpidClientConnectionHelper;
+
 import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
 import java.io.IOException;
 
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
index 484c2af..b666b1f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
@@ -20,14 +20,8 @@
  */
 package org.apache.qpid.server.logging;
 
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
 import org.apache.commons.configuration.ConfigurationException;
+
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
 import org.apache.qpid.server.registry.ApplicationRegistry;
@@ -35,6 +29,13 @@
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.util.LogMonitor;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
 /**
  * Abstract superclass for logging test set up and utility methods.
  *
@@ -46,7 +47,7 @@
     public static final String TEST_LOG_PREFIX = "MESSAGE";
     protected LogMonitor _monitor;
 
-    InternalBrokerBaseCase _configLoader;
+    private InternalBrokerBaseCase _configLoader;
 
     @Override
     public void setUp() throws Exception
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AccessControlLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AccessControlLoggingTest.java
index e7da447..4b7b3f0 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AccessControlLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AccessControlLoggingTest.java
@@ -18,18 +18,17 @@
  */
 package org.apache.qpid.server.logging;
 
-import java.util.List;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Session;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.server.security.acl.AbstractACLTestCase;
 
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import java.util.List;
+
 /**
  * ACL version 2/3 file testing to verify that ACL actor logging works correctly.
  * 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
index aef98b8..02c41e1 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
@@ -20,10 +20,6 @@
 */
 package org.apache.qpid.server.logging;
 
-import javax.jms.Connection;
-import javax.jms.Queue;
-import javax.jms.Session;
-
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.framing.AMQShortString;
@@ -31,6 +27,10 @@
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.util.FileUtils;
 
+import javax.jms.Connection;
+import javax.jms.Queue;
+import javax.jms.Session;
+
 public class AlertingTest extends AbstractTestLogging
 {
     private String VIRTUALHOST = "test";
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java
index be2da12..2c7288d 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java
@@ -45,10 +45,10 @@
 
     static final String BND_PREFIX = "BND-";
 
-    Connection _connection;
-    Session _session;
-    Queue _queue;
-    Topic _topic;
+    private Connection _connection;
+    private Session _session;
+    private Queue _queue;
+    private Topic _topic;
 
     @Override
     public void setUp() throws Exception
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
index 7969ffc..dee593b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
@@ -23,11 +23,9 @@
 import junit.framework.AssertionFailedError;
 
 import org.apache.qpid.server.BrokerOptions;
-import org.apache.qpid.server.Main;
 import org.apache.qpid.transport.ConnectionException;
 import org.apache.qpid.util.LogMonitor;
 
-import java.io.File;
 import java.io.IOException;
 import java.net.Socket;
 import java.util.List;
@@ -39,7 +37,7 @@
  *
  * BRK-1001 : Startup : Version: <Version> Build: <Build>
  * BRK-1002 : Starting : Listening on <Transport> port <Port>
- * BRK-1003 : Shuting down : <Transport> port <Port>
+ * BRK-1003 : Shutting down : <Transport> port <Port>
  * BRK-1004 : Ready
  * BRK-1005 : Stopped
  * BRK-1006 : Using configuration : <path>
@@ -809,7 +807,7 @@
             setConfigurationProperty("connector.ssl.keyStorePath", getConfigurationStringProperty("management.ssl.keyStorePath"));
             setConfigurationProperty("connector.ssl.keyStorePassword", getConfigurationStringProperty("management.ssl.keyStorePassword"));
 
-            Integer sslPort = Integer.parseInt(getConfigurationStringProperty("connector.sslport"));
+            Integer sslPort = Integer.parseInt(getConfigurationStringProperty("connector.ssl.port"));
 
             startBroker();
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
index d28429a..ffe25a5 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
@@ -21,8 +21,11 @@
 package org.apache.qpid.server.logging;
 
 import javax.jms.Connection;
-import java.util.List;
+
+import org.apache.qpid.common.QpidProperties;
+
 import java.util.HashMap;
+import java.util.List;
 import java.util.TreeSet;
 
 public class ConnectionLoggingTest extends AbstractTestLogging
@@ -58,7 +61,7 @@
         // Wait until opened
         waitForMessage("CON-1001");
         
-        // Close the conneciton
+        // Close the connection
         connection.close();
 
         // Wait to ensure that the desired message is logged
@@ -66,18 +69,10 @@
 
         List<String> results = waitAndFindMatches("CON-1001");
 
-        // Validation
-        // We should have at least three messages when running InVM but when running External
-        // we will get 0-10 negotiation on con:0 whcih may close at some random point
-        // MESSAGE [con:0(/127.0.0.1:46926)] CON-1001 : Open
-        // MESSAGE [con:0(/127.0.0.1:46926)] CON-1001 : Open : Protocol Version : 0-10
         // MESSAGE [con:1(/127.0.0.1:46927)] CON-1001 : Open
         // MESSAGE [con:1(/127.0.0.1:46927)] CON-1001 : Open : Protocol Version : 0-9
-        // MESSAGE [con:0(/127.0.0.1:46926)] CON-1002 : Close
-        // MESSAGE [con:1(/127.0.0.1:46927)] CON-1001 : Open : Client ID : clientid : Protocol Version : 0-9
-
-        //So check how many connections we have in the result set and extract the last one.
-        // When running InVM we will have con:0 and externally con:1
+        // MESSAGE [con:1(/127.0.0.1:46927)] CON-1001 : Open : Client ID : clientid : Protocol Version : 0-9 : Client Version : 1.2.3_4
+        // MESSAGE [con:0(/127.0.0.1:46927)] CON-1002 : Close
 
         HashMap<Integer, List<String>> connectionData = splitResultsOnConnectionID(results);
 
@@ -87,31 +82,26 @@
         //Use just the data from the last connection for the test
         results = connectionData.get(connectionID);
 
-        // If we are running inVM or with 0-10 we will get three open messagse
-	    // if running externally with 0-8/0-9 we will also have open and close messages from the failed 0-10 negotiation 
-	    assertTrue("CON messages not logged:" + results.size(), results.size() >= 3);
+	    assertEquals("Unexpected CON-1001 messages count", 3, results.size());
 
         String log = getLogMessage(results, 0);
         //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open
         //1 & 2
         validateMessageID("CON-1001",log);
 
-        // validate the last three CON- messages.
-        // This is because when running externally we may also have logged the failed
-        // 0-10 negotiation messages if using 0-8/0-9 on the broker.
-
-        // 3 - Assert the options are correct
-        //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open : Client ID : clientid : Protocol Version : 0-9
-        validateConnectionOpen(results, 0, true, true, clientid);
+        // validate the last three CON-1001 messages.
+        //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open : Client ID : clientid : Protocol Version : 0-9 : Client Version : 1.2.3_4
+        validateConnectionOpen(results, 0, true, true, clientid, true, QpidProperties.getReleaseVersion());
 
         //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open : Protocol Version : 0-9
-        validateConnectionOpen(results, 1, true, false, null);
+        validateConnectionOpen(results, 1, true, false, null, false, null);
 
-        validateConnectionOpen(results, 2, false, false, null);
+        //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open
+        validateConnectionOpen(results, 2, false, false, null, false, null);
     }
     
     private void validateConnectionOpen(List<String> results, int positionFromEnd,
-                 boolean protocolVersionPresent, boolean clientIdOptionPresent, String clientIdValue)
+                 boolean protocolVersionPresent, boolean clientIdOptionPresent, String clientIdValue, boolean clientVersionPresent, String clientVersionValue)
     {
         String log = getLogMessageFromEnd(results, positionFromEnd);
         
@@ -128,6 +118,13 @@
                 protocolVersionPresent, fromMessage(log).contains("Protocol Version :"));
         //fixme there is no way currently to find out the negotiated protocol version
         // The delegate is the versioned class ((AMQConnection)connection)._delegate
+
+        assertEquals("unexpected Client ID option state", clientVersionPresent, fromMessage(log).contains("Client Version :"));
+
+        if(clientVersionPresent && clientVersionValue != null)
+        {
+            assertTrue("Client version value is not present: " + clientVersionValue, fromMessage(log).contains(clientVersionValue));
+        }
     }
 
     /**
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
index d45bde2..e32edff 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
@@ -20,15 +20,14 @@
  */
 package org.apache.qpid.server.logging;
 
-import org.apache.commons.configuration.Configuration;
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
 
 import javax.jms.Connection;
 import javax.jms.Queue;
 import javax.jms.Session;
-import java.util.List;
 import java.io.File;
+import java.util.List;
 
 /**
  * The MessageStore test suite validates that the follow log messages as
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java
index 07faf1e..edffa7c 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java
@@ -20,16 +20,6 @@
  */
 package org.apache.qpid.server.logging;
 
-import java.io.IOException;
-import java.util.List;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.client.AMQSession_0_10;
@@ -39,6 +29,15 @@
 import org.apache.qpid.framing.ExchangeDeleteOkBody;
 import org.apache.qpid.framing.amqp_8_0.MethodRegistry_8_0;
 
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.io.IOException;
+import java.util.List;
+
 /**
  * Exchange
  *
@@ -54,11 +53,11 @@
 
     static final String EXH_PREFIX = "EXH-";
 
-    Connection _connection;
-    Session _session;
-    Queue _queue;
-    String _name;
-    String _type;
+    private Connection _connection;
+    private Session _session;
+    private Queue _queue;
+    private String _name;
+    private String _type;
 
     @Override
     public void setUp() throws Exception
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java
index ed9109e..c8a6d02 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java
@@ -25,8 +25,8 @@
 import org.apache.qpid.test.utils.JMXTestUtils;
 import org.apache.qpid.util.LogMonitor;
 
-import java.util.List;
 import java.io.File;
+import java.util.List;
 
 /**
  * Management Console Test Suite
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
index 34d9e1f..e6e1196 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
@@ -20,13 +20,13 @@
 */
 package org.apache.qpid.server.logging;
 
-import java.util.Arrays;
-import java.util.List;
-
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
 import org.apache.qpid.util.LogMonitor;
 
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * The MessageStore test suite validates that the follow log messages as
  * specified in the Functional Specification.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java
index 76ebda0..1c7b4c6 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java
@@ -20,19 +20,19 @@
  */
 package org.apache.qpid.server.logging;
 
+import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.client.failover.FailoverException;
-import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
 
 import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.Queue;
 import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Session;
 import javax.naming.NamingException;
-import java.util.List;
 import java.io.IOException;
+import java.util.List;
 
 /**
  * The Queue test suite validates that the follow log messages as specified in
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java
index b6efe53..236202f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java
@@ -20,16 +20,18 @@
  */
 package org.apache.qpid.server.logging;
 
+import javax.jms.QueueBrowser;
 import junit.framework.AssertionFailedError;
+
 import org.apache.qpid.client.AMQConnection;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
+import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.Topic;
-import javax.jms.Message;
 import java.io.IOException;
 import java.util.List;
 
@@ -48,10 +50,10 @@
 {
     static final String SUB_PREFIX = "SUB-";
 
-    Connection _connection;
-    Session _session;
-    Queue _queue;
-    Topic _topic;
+    private Connection _connection;
+    private Session _session;
+    private Queue _queue;
+    private Topic _topic;
 
     @Override
     public void setUp() throws Exception
@@ -165,8 +167,10 @@
      */
     public void testSubscriptionCreateQueueBrowser() throws JMSException, IOException
     {
-        _session.createBrowser(_queue);
+        _connection.start();
+        QueueBrowser browser = _session.createBrowser(_queue);
 
+        browser.getEnumeration();
         //Validate
         //Ensure that we wait for the SUB log message
         waitAndFindMatches("SUB-1001");
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
index a23e40e..5f96215 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
@@ -21,13 +21,13 @@
 
 package org.apache.qpid.server.logging;
 
-import java.util.Arrays;
-import java.util.List;
-
 import junit.framework.AssertionFailedError;
 
 import org.apache.qpid.server.configuration.ServerConfiguration;
 
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * Virtualhost Test Cases
  * The virtualhost test suite validates that the follow log messages as specified in the Functional Specification.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/message/MessageProtocolConversionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/message/MessageProtocolConversionTest.java
index a179b96..2a5f8b9 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/message/MessageProtocolConversionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/message/MessageProtocolConversionTest.java
@@ -23,10 +23,8 @@
 import org.apache.qpid.AMQException;
 import org.apache.qpid.configuration.ClientProperties;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.url.AMQBindingURL;
 
 import javax.jms.*;
-import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
index 398c83a..bcad59a 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
@@ -20,16 +20,8 @@
  */
 package org.apache.qpid.server.persistent;
 
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.jms.ConnectionListener;
-import org.apache.qpid.jms.BrokerDetails;
-import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
-import org.apache.qpid.server.store.DerbyMessageStore;
-import org.apache.commons.configuration.XMLConfiguration;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
@@ -38,61 +30,28 @@
 import javax.jms.Session;
 import javax.jms.Topic;
 import javax.jms.TopicSubscriber;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
 
-import java.util.concurrent.CountDownLatch;
-import java.io.File;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 /**
- * QPID-1813 : We do not store the client id with a message so on store restart
- * that information is lost and we are unable to perform no local checks.
- *
- * QPID-1813 highlights the lack of testing here as the broker will NPE as it
- * assumes that the client id of the publisher will always exist
+ * Verifies that after recovery, a new Connection with no-local in use is
+ * able to receive messages sent prior to the broker restart.
  */
-public class NoLocalAfterRecoveryTest extends QpidBrokerTestCase implements ConnectionListener
+public class NoLocalAfterRecoveryTest extends QpidBrokerTestCase
 {
     protected final String MY_TOPIC_SUBSCRIPTION_NAME = this.getName();
     protected static final int SEND_COUNT = 10;
-    private CountDownLatch _failoverComplete = new CountDownLatch(1);
 
-    protected ConnectionURL _connectionURL;
-
-    @Override
-    protected void setUp() throws Exception
+    public void testNoLocalNotQueued() throws Exception
     {
+        if(!isBrokerStorePersistent())
+        {
+            fail("This test requires a broker with a persistent store");
+        }
 
-        XMLConfiguration configuration = new XMLConfiguration(_configFile);
-        configuration.setProperty("virtualhosts.virtualhost.test.store.class", "org.apache.qpid.server.store.DerbyMessageStore");
-        configuration.setProperty("virtualhosts.virtualhost.test.store."+ DerbyMessageStore.ENVIRONMENT_PATH_PROPERTY,
-                                  System.getProperty("QPID_WORK", System.getProperty("java.io.tmpdir")) + File.separator + "derbyDB-NoLocalAfterRecoveryTest");
-
-        File tmpFile = File.createTempFile("configFile", "test");
-        tmpFile.deleteOnExit();
-        configuration.save(tmpFile);
-
-        _configFile = tmpFile;
-        _connectionURL = getConnectionURL();
-
-        BrokerDetails details = _connectionURL.getBrokerDetails(0);
-
-        // This will attempt to failover for 3 seconds.
-        // Local testing suggests failover takes 2 seconds
-        details.setProperty(BrokerDetails.OPTIONS_RETRY, "10");
-        details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, "500");
-
-        super.setUp();        
-    }
-
-    public void test() throws Exception
-    {
-
-        Connection connection = getConnection(_connectionURL);
+        Connection connection = getConnection();
         Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
-        Topic topic = (Topic) getInitialContext().lookup("topic");
+        Topic topic = session.createTopic(MY_TOPIC_SUBSCRIPTION_NAME);
 
         TopicSubscriber noLocalSubscriber = session.
                 createDurableSubscriber(topic, MY_TOPIC_SUBSCRIPTION_NAME + "-NoLocal",
@@ -102,88 +61,104 @@
                 createDurableSubscriber(topic, MY_TOPIC_SUBSCRIPTION_NAME + "-Normal",
                                         null, false);
 
-        List<Message> sent = sendMessage(session, topic, SEND_COUNT);
-
-        session.commit();
-
-        assertEquals("Incorrect number of messages sent",
-                     SEND_COUNT, sent.size());
-
+        sendMessage(session, topic, SEND_COUNT);
 
         // Check messages can be received as expected.
         connection.start();
 
-        assertTrue("No Local Subscriber is not a no-local subscriber",
-                   noLocalSubscriber.getNoLocal());
-
-        assertFalse("Normal Subscriber is a no-local subscriber",
-                    normalSubscriber.getNoLocal());
-
-
+        //As the no-local subscriber was on the same connection the messages were
+        //published on, tit will receive no messages as they will be discarded on the broker
         List<Message> received = receiveMessage(noLocalSubscriber, SEND_COUNT);
         assertEquals("No Local Subscriber Received messages", 0, received.size());
 
         received = receiveMessage(normalSubscriber, SEND_COUNT);
         assertEquals("Normal Subscriber Received no messages",
                      SEND_COUNT, received.size());
+        session.commit();
 
+        normalSubscriber.close();
+        connection.close();
 
-        ((AMQConnection)connection).setConnectionListener(this);
-
+        //Ensure the no-local subscribers messages were discarded by restarting the broker
+        //and reconnecting to the subscription to ensure they were not recovered.
         restartBroker();
 
+        Connection connection2 = getConnection();
+        connection2.start();
 
-        //Await
-        if (!_failoverComplete.await(4000L, TimeUnit.MILLISECONDS))
-        {
-            fail("Failover Failed to compelete");
-        }
+        Session session2 = connection2.createSession(true, Session.SESSION_TRANSACTED);
+        Topic topic2 = session2.createTopic(MY_TOPIC_SUBSCRIPTION_NAME);
 
-        session.rollback();
+        TopicSubscriber noLocalSubscriber2 = session2.
+                createDurableSubscriber(topic2, MY_TOPIC_SUBSCRIPTION_NAME + "-NoLocal",
+                                        null, true);
 
-        //Failover will restablish our clients
-        assertTrue("No Local Subscriber is not a no-local subscriber",
-                   noLocalSubscriber.getNoLocal());
+        // The NO-local subscriber should not get any messages
+        received = receiveMessage(noLocalSubscriber2, SEND_COUNT);
+        session2.commit();
+        assertEquals("No Local Subscriber Received messages", 0, received.size());
 
-        assertFalse("Normal Subscriber is a no-local subscriber",
-                    normalSubscriber.getNoLocal());
+        noLocalSubscriber2.close();
 
 
-        // NOTE : here that the NO-local subscriber actually now gets ALL the
-        // messages as the connection has failed and they are consuming on a
-        // different connnection to the one that was published on.
-        received = receiveMessage(noLocalSubscriber, SEND_COUNT);
-        assertEquals("No Local Subscriber Received messages", SEND_COUNT, received.size());
-
-        received = receiveMessage(normalSubscriber, SEND_COUNT);
-        assertEquals("Normal Subscriber Received no messages",
-                     SEND_COUNT, received.size());
-
-        //leave the store in a clean state.
-        session.commit();
     }
 
-    protected List<Message> assertReceiveMessage(MessageConsumer messageConsumer,
-                                                 int count) throws JMSException
+
+    public void testNonNoLocalQueued() throws Exception
     {
-
-        List<Message> receivedMessages = new ArrayList<Message>(count);
-        for (int i = 0; i < count; i++)
+        if(!isBrokerStorePersistent())
         {
-            Message received = messageConsumer.receive(1000);
-
-            if (received != null)
-            {
-                receivedMessages.add(received);
-            }
-            else
-            {
-                fail("Only "
-                     + receivedMessages.size() + "/" + count + " received.");
-            }
+            fail("This test requires a broker with a persistent store");
         }
 
-        return receivedMessages;
+        Connection connection = getConnection();
+        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+        Topic topic = session.createTopic(MY_TOPIC_SUBSCRIPTION_NAME);
+
+        TopicSubscriber noLocalSubscriber =
+                session.createDurableSubscriber(topic, MY_TOPIC_SUBSCRIPTION_NAME + "-NoLocal", null, true);
+
+
+        sendMessage(session, topic, SEND_COUNT);
+
+        // Check messages can be received as expected.
+        connection.start();
+
+        List<Message> received = receiveMessage(noLocalSubscriber, SEND_COUNT);
+        assertEquals("No Local Subscriber Received messages", 0, received.size());
+
+
+
+        session.commit();
+
+        Connection connection3 = getConnection();
+        Session session3 = connection3.createSession(true, Session.SESSION_TRANSACTED);
+        sendMessage(session3, topic, SEND_COUNT);
+
+
+        connection.close();
+
+        //We didn't receive the messages on the durable queue for the no-local subscriber
+        //so they are still on the broker. Restart the broker, prompting their recovery.
+        restartBroker();
+
+        Connection connection2 = getConnection();
+        connection2.start();
+
+        Session session2 = connection2.createSession(true, Session.SESSION_TRANSACTED);
+        Topic topic2 = session2.createTopic(MY_TOPIC_SUBSCRIPTION_NAME);
+
+        TopicSubscriber noLocalSubscriber2 =
+                session2.createDurableSubscriber(topic2, MY_TOPIC_SUBSCRIPTION_NAME + "-NoLocal",null, true);
+
+        // The NO-local subscriber should receive messages sent from connection3
+        received = receiveMessage(noLocalSubscriber2, SEND_COUNT);
+        session2.commit();
+        assertEquals("No Local Subscriber did not receive expected messages", SEND_COUNT, received.size());
+
+        noLocalSubscriber2.close();
+
+
     }
 
     protected List<Message> receiveMessage(MessageConsumer messageConsumer,
@@ -207,29 +182,4 @@
 
         return receivedMessages;
     }
-
-    public void bytesSent(long count)
-    {
-
-    }
-
-    public void bytesReceived(long count)
-    {
-
-    }
-
-    public boolean preFailover(boolean redirect)
-    {
-        return true;
-    }
-
-    public boolean preResubscribe()
-    {
-        return true;
-    }
-
-    public void failoverComplete()
-    {
-        _failoverComplete.countDown();
-    }
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/DeepQueueConsumeWithSelector.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/DeepQueueConsumeWithSelector.java
index 4ac0d2c..21e3bfa 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/DeepQueueConsumeWithSelector.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/DeepQueueConsumeWithSelector.java
@@ -20,8 +20,8 @@
  */
 package org.apache.qpid.server.queue;
 
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java
index ddc51f6..ab0d88c 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java
@@ -21,7 +21,6 @@
 package org.apache.qpid.server.queue;
 
 import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.management.common.mbeans.ManagedBroker;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/MultipleTransactedBatchProducerTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/MultipleTransactedBatchProducerTest.java
index 277e84d..8536651 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/MultipleTransactedBatchProducerTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/MultipleTransactedBatchProducerTest.java
@@ -20,9 +20,9 @@
  */
 package org.apache.qpid.server.queue;
 
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
@@ -30,9 +30,9 @@
 import javax.jms.MessageConsumer;
 import javax.jms.MessageListener;
 import javax.jms.Session;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.util.Random;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 public class MultipleTransactedBatchProducerTest extends QpidBrokerTestCase
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PersistentTestManual.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PersistentTestManual.java
index c4e7445..62ea5fd 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PersistentTestManual.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PersistentTestManual.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.queue;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQChannelClosedException;
 import org.apache.qpid.AMQConnectionClosedException;
 import org.apache.qpid.AMQException;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityQueueTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityQueueTest.java
index 962aec0..7cb58ff 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityQueueTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityQueueTest.java
@@ -20,8 +20,12 @@
 */
 package org.apache.qpid.server.queue;
 
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -30,11 +34,8 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.naming.NamingException;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.util.HashMap;
+import java.util.Map;
 
 public class PriorityQueueTest extends QpidBrokerTestCase
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java
index 47f334a..ad8c856 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java
@@ -20,38 +20,44 @@
 */
 package org.apache.qpid.server.queue;
 
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQDestination;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+
 import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.management.common.mbeans.ManagedQueue;
 import org.apache.qpid.server.logging.AbstractTestLogging;
 import org.apache.qpid.test.utils.JMXTestUtils;
-import org.apache.qpid.framing.AMQShortString;
-
-import javax.jms.*;
-import javax.naming.NamingException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.io.IOException;
 
 public class ProducerFlowControlTest extends AbstractTestLogging
 {
     private static final int TIMEOUT = 10000;
 
-    private static final Logger _logger = Logger.getLogger(ProducerFlowControlTest.class);
-
     private Connection producerConnection;
-    private MessageProducer producer;
-    private Session producerSession;
-    private Queue queue;
     private Connection consumerConnection;
+    private Session producerSession;
     private Session consumerSession;
-
+    private MessageProducer producer;
     private MessageConsumer consumer;
-    private final AtomicInteger _sentMessages = new AtomicInteger();
+    private Queue queue;
+
+    private final AtomicInteger _sentMessages = new AtomicInteger(0);
 
     private JMXTestUtils _jmxUtils;
     private boolean _jmxUtilConnected;
@@ -77,38 +83,35 @@
 
     public void tearDown() throws Exception
     {
-        if(_jmxUtilConnected)
+        try
         {
-            try
+            if(_jmxUtilConnected)
             {
-                _jmxUtils.close();
+                try
+                {
+                    _jmxUtils.close();
+                }
+                catch (IOException e)
+                {
+                    e.printStackTrace();
+                }
             }
-            catch (IOException e)
-            {
-                e.printStackTrace();
-            }
+            producerConnection.close();
+            consumerConnection.close();
         }
-        producerConnection.close();
-        consumerConnection.close();
-        super.tearDown();
+        finally
+        {
+            super.tearDown();
+        }
     }
 
-    public void testCapacityExceededCausesBlock()
-            throws JMSException, NamingException, AMQException, InterruptedException
+    public void testCapacityExceededCausesBlock() throws Exception
     {
         String queueName = getTestQueueName();
-        
-        final Map<String,Object> arguments = new HashMap<String, Object>();
-        arguments.put("x-qpid-capacity",1000);
-        arguments.put("x-qpid-flow-resume-capacity",800);
-        ((AMQSession) producerSession).createQueue(new AMQShortString(queueName), true, false, false, arguments);
-        queue = producerSession.createQueue("direct://amq.direct/"+queueName+"/"+queueName+"?durable='false'&autodelete='true'");
-        ((AMQSession) producerSession).declareAndBind((AMQDestination)queue);
+
+        createAndBindQueueWithFlowControlEnabled(producerSession, queueName, 1000, 800);
         producer = producerSession.createProducer(queue);
 
-        _sentMessages.set(0);
-
-
         // try to send 5 messages (should block after 4)
         sendMessagesAsync(producer, producerSession, 5, 50L);
 
@@ -135,22 +138,14 @@
 
     }
 
-    public void testBrokerLogMessages()
-            throws JMSException, NamingException, AMQException, InterruptedException, IOException
+
+    public void testBrokerLogMessages() throws Exception
     {
         String queueName = getTestQueueName();
         
-        final Map<String,Object> arguments = new HashMap<String, Object>();
-        arguments.put("x-qpid-capacity",1000);
-        arguments.put("x-qpid-flow-resume-capacity",800);
-        ((AMQSession) producerSession).createQueue(new AMQShortString(queueName), true, false, false, arguments);
-        queue = producerSession.createQueue("direct://amq.direct/"+queueName+"/"+queueName+"?durable='false'&autodelete='true'");
-        ((AMQSession) producerSession).declareAndBind((AMQDestination)queue);
+        createAndBindQueueWithFlowControlEnabled(producerSession, queueName, 1000, 800);
         producer = producerSession.createProducer(queue);
 
-        _sentMessages.set(0);
-
-
         // try to send 5 messages (should block after 4)
         sendMessagesAsync(producer, producerSession, 5, 50L);
 
@@ -162,41 +157,28 @@
         consumerConnection.start();
 
 
-        while(consumer.receive(1000) != null);
+        while(consumer.receive(1000) != null) {};
 
         results = waitAndFindMatches("QUE-1004");
 
         assertEquals("Did not find correct number of UNDERFULL queue underfull messages", 1, results.size());
-
-
-        
     }
 
 
-    public void testClientLogMessages()
-            throws JMSException, NamingException, AMQException, InterruptedException, IOException
+    public void testClientLogMessages() throws Exception
     {
         String queueName = getTestQueueName();
-        
+
         setTestClientSystemProperty("qpid.flow_control_wait_failure","3000");
         setTestClientSystemProperty("qpid.flow_control_wait_notify_period","1000");
 
         Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
-
-        final Map<String,Object> arguments = new HashMap<String, Object>();
-        arguments.put("x-qpid-capacity",1000);
-        arguments.put("x-qpid-flow-resume-capacity",800);
-        ((AMQSession) session).createQueue(new AMQShortString(queueName), true, false, false, arguments);
-        queue = producerSession.createQueue("direct://amq.direct/"+queueName+"/"+queueName+"?durable='false'&autodelete='true'");
-        ((AMQSession) session).declareAndBind((AMQDestination)queue);
+        createAndBindQueueWithFlowControlEnabled(session, queueName, 1000, 800);
         producer = session.createProducer(queue);
 
-        _sentMessages.set(0);
-
-
         // try to send 5 messages (should block after 4)
-        MessageSender sender = sendMessagesAsync(producer, producerSession, 5, 50L);
+        MessageSender sender = sendMessagesAsync(producer, session, 5, 50L);
 
         List<String> results = waitAndFindMatches("Message send delayed by", TIMEOUT);
         assertTrue("No delay messages logged by client",results.size()!=0);
@@ -205,26 +187,16 @@
                                                   + " flow control", TIMEOUT);
         assertEquals("Incorrect number of send failure messages logged by client (got " + results.size() + " delay "
                      + "messages)",1,failedMessages.size());
-
-
-
     }
 
 
-    public void testFlowControlOnCapacityResumeEqual()
-            throws JMSException, NamingException, AMQException, InterruptedException
+    public void testFlowControlOnCapacityResumeEqual() throws Exception
     {
         String queueName = getTestQueueName();
         
-        final Map<String,Object> arguments = new HashMap<String, Object>();
-        arguments.put("x-qpid-capacity",1000);
-        arguments.put("x-qpid-flow-resume-capacity",1000);
-        ((AMQSession) producerSession).createQueue(new AMQShortString(queueName), true, false, false, arguments);
-        queue = producerSession.createQueue("direct://amq.direct/"+queueName+"/"+queueName+"?durable='false'&autodelete='true'");
-        ((AMQSession) producerSession).declareAndBind((AMQDestination)queue);
+        createAndBindQueueWithFlowControlEnabled(producerSession, queueName, 1000, 1000);
         producer = producerSession.createProducer(queue);
 
-        _sentMessages.set(0);
 
         // try to send 5 messages (should block after 4)
         sendMessagesAsync(producer, producerSession, 5, 50L);
@@ -236,7 +208,6 @@
         consumer = consumerSession.createConsumer(queue);
         consumerConnection.start();
 
-
         consumer.receive();
 
         Thread.sleep(1000);
@@ -247,23 +218,16 @@
     }
 
 
-    public void testFlowControlSoak()
-            throws Exception, NamingException, AMQException, InterruptedException
+    public void testFlowControlSoak() throws Exception
     {
         String queueName = getTestQueueName();
         
-        _sentMessages.set(0);
+
         final int numProducers = 10;
         final int numMessages = 100;
 
-        final Map<String,Object> arguments = new HashMap<String, Object>();
-        arguments.put("x-qpid-capacity",6000);
-        arguments.put("x-qpid-flow-resume-capacity",3000);
+        createAndBindQueueWithFlowControlEnabled(producerSession, queueName, 6000, 3000);
 
-        ((AMQSession) consumerSession).createQueue(new AMQShortString(queueName), false, false, false, arguments);
-
-        queue = producerSession.createQueue("direct://amq.direct/"+queueName+"/"+queueName+"?durable='false'&autodelete='false'");
-        ((AMQSession) consumerSession).declareAndBind((AMQDestination)queue);
         consumerConnection.start();
 
         Connection[] producers = new Connection[numProducers];
@@ -303,58 +267,38 @@
 
     }
 
-
-
-    public void testSendTimeout()
-            throws JMSException, NamingException, AMQException, InterruptedException
+    public void testSendTimeout() throws Exception
     {
         String queueName = getTestQueueName();
-        
+        final String expectedMsg = isBroker010() ? "Exception when sending message:timed out waiting for message credit"
+                : "Unable to send message for 3 seconds due to broker enforced flow control";
+
         setTestClientSystemProperty("qpid.flow_control_wait_failure","3000");
         Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
-
-        final Map<String,Object> arguments = new HashMap<String, Object>();
-        arguments.put("x-qpid-capacity",1000);
-        arguments.put("x-qpid-flow-resume-capacity",800);
-        ((AMQSession) session).createQueue(new AMQShortString(queueName), true, false, false, arguments);
-        queue = producerSession.createQueue("direct://amq.direct/"+queueName+"/"+queueName+"?durable='false'&autodelete='true'");
-        ((AMQSession) session).declareAndBind((AMQDestination)queue);
+        createAndBindQueueWithFlowControlEnabled(producerSession, queueName, 1000, 800);
         producer = session.createProducer(queue);
 
-        _sentMessages.set(0);
-
-
         // try to send 5 messages (should block after 4)
-        MessageSender sender = sendMessagesAsync(producer, producerSession, 5, 100L);
+        MessageSender sender = sendMessagesAsync(producer, session, 5, 100L);
 
-        
-        Thread.sleep(10000);
-
-        Exception e = sender.getException();
+        Exception e = sender.awaitSenderException(10000);
 
         assertNotNull("No timeout exception on sending", e);
 
+
+        assertEquals("Unexpected exception reason", expectedMsg, e.getMessage());
+
     }
-    
-    
-    public void testFlowControlAttributeModificationViaJMX()
-    throws JMSException, NamingException, AMQException, InterruptedException, Exception
+
+    public void testFlowControlAttributeModificationViaJMX() throws Exception
     {
         _jmxUtils.open();
         _jmxUtilConnected = true;
         
         String queueName = getTestQueueName();
-        
-        //create queue
-        final Map<String,Object> arguments = new HashMap<String, Object>();
-        arguments.put("x-qpid-capacity",0);
-        arguments.put("x-qpid-flow-resume-capacity",0);
-        ((AMQSession) producerSession).createQueue(new AMQShortString(queueName), true, false, false, arguments);
 
-        queue = producerSession.createQueue("direct://amq.direct/"+queueName+"/"+queueName+"?durable='false'&autodelete='true'");
-
-        ((AMQSession) producerSession).declareAndBind((AMQDestination)queue);
+        createAndBindQueueWithFlowControlEnabled(producerSession, queueName, 0, 0);
         producer = producerSession.createProducer(queue);
         
         Thread.sleep(1000);
@@ -375,7 +319,7 @@
         assertFalse("Queue should not be overfull", queueMBean.isFlowOverfull());
         
         // try to send 2 messages (should block after 1)
-        _sentMessages.set(0);
+
         sendMessagesAsync(producer, producerSession, 2, 50L);
 
         Thread.sleep(2000);
@@ -406,13 +350,23 @@
         consumer.receive();
         
         //perform a synchronous op on the connection
-        ((AMQSession) consumerSession).sync();
+        ((AMQSession<?,?>) consumerSession).sync();
         
         assertFalse("Queue should not be overfull", queueMBean.isFlowOverfull());
         
         consumer.receive();
     }
 
+    private void createAndBindQueueWithFlowControlEnabled(Session session, String queueName, int capacity, int resumeCapacity) throws Exception
+    {
+        final Map<String,Object> arguments = new HashMap<String, Object>();
+        arguments.put("x-qpid-capacity",capacity);
+        arguments.put("x-qpid-flow-resume-capacity",resumeCapacity);
+        ((AMQSession<?,?>) session).createQueue(new AMQShortString(queueName), true, false, false, arguments);
+        queue = session.createQueue("direct://amq.direct/"+queueName+"/"+queueName+"?durable='false'&autodelete='true'");
+        ((AMQSession<?,?>) session).declareAndBind((AMQDestination)queue);
+    }
+
     private MessageSender sendMessagesAsync(final MessageProducer producer,
                                             final Session producerSession,
                                             final int numMessages,
@@ -435,7 +389,7 @@
 
             try
             {
-                ((AMQSession)producerSession).sync();
+                ((AMQSession<?,?>)producerSession).sync();
             }
             catch (AMQException e)
             {
@@ -456,7 +410,6 @@
 
     private static final byte[] BYTE_300 = new byte[300];
 
-
     private Message nextMessage(int msg, Session producerSession) throws JMSException
     {
         BytesMessage send = producerSession.createBytesMessage();
@@ -466,22 +419,19 @@
         return send;
     }
 
-
     private class MessageSender implements Runnable
     {
-        private final MessageProducer _producer;
-        private final Session _producerSession;
+        private final MessageProducer _senderProducer;
+        private final Session _senderSession;
         private final int _numMessages;
-
-
-
-        private JMSException _exception;
+        private volatile JMSException _exception;
+        private CountDownLatch _exceptionThrownLatch = new CountDownLatch(1);
         private long _sleepPeriod;
 
         public MessageSender(MessageProducer producer, Session producerSession, int numMessages, long sleepPeriod)
         {
-            _producer = producer;
-            _producerSession = producerSession;
+            _senderProducer = producer;
+            _senderSession = producerSession;
             _numMessages = numMessages;
             _sleepPeriod = sleepPeriod;
         }
@@ -490,16 +440,18 @@
         {
             try
             {
-                sendMessages(_producer, _producerSession, _numMessages, _sleepPeriod);
+                sendMessages(_senderProducer, _senderSession, _numMessages, _sleepPeriod);
             }
             catch (JMSException e)
             {
                 _exception = e;
+                _exceptionThrownLatch.countDown();
             }
         }
 
-        public JMSException getException()
+        public Exception awaitSenderException(long timeout) throws InterruptedException
         {
+            _exceptionThrownLatch.await(timeout, TimeUnit.MILLISECONDS);
             return _exception;
         }
     }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java
index aeeecb2..dd57c1e 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java
@@ -21,6 +21,11 @@
 
 package org.apache.qpid.server.queue;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -29,11 +34,6 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 /**
  * Test Case to ensure that messages are correctly returned.
  * This includes checking:
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SortedQueueTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SortedQueueTest.java
index 181fe9d..14dee60 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SortedQueueTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SortedQueueTest.java
@@ -19,11 +19,15 @@
  */
 package org.apache.qpid.server.queue;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
@@ -34,14 +38,12 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.naming.NamingException;
-import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.configuration.ClientProperties;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicInteger;
 
 public class SortedQueueTest extends QpidBrokerTestCase
 {
@@ -54,6 +56,7 @@
     private Connection _producerConnection;
     private Session _producerSession;
     private Connection _consumerConnection;
+    private long _receiveInterval;
 
     protected void setUp() throws Exception
     {
@@ -64,6 +67,7 @@
         _producerConnection = getConnection();
         _consumerConnection = getConnection();
         _producerSession = _producerConnection.createSession(true, Session.SESSION_TRANSACTED);
+        _receiveInterval = isBrokerStorePersistent() ? 3000l : 1500l;
     }
 
     protected void tearDown() throws Exception
@@ -94,7 +98,7 @@
         _consumerConnection.start();
         TextMessage received;
         int messageCount = 0;
-        while((received = (TextMessage) consumer.receive(1000)) != null)
+        while((received = (TextMessage) consumer.receive(_receiveInterval)) != null)
         {
             assertEquals("Received message with unexpected sorted key value", VALUES_SORTED[messageCount],
                             received.getStringProperty(TEST_SORT_KEY));
@@ -138,17 +142,15 @@
             _producerSession.commit();
         }
 
-        synchronized(consumerThread)
+        try
         {
-            try
-            {
-                consumerThread.join(5000L);
-            }
-            catch(InterruptedException e)
-            {
-                fail("Test failed waiting for consumer to complete");
-            }
+            consumerThread.join(getConsumerThreadJoinInterval());
         }
+        catch(InterruptedException e)
+        {
+            fail("Test failed waiting for consumer to complete");
+        }
+
         assertTrue("Consumer timed out", consumerThread.isStopped());
         assertEquals("Incorrect number of messages received", VALUES.length, consumerThread.getConsumed());
 
@@ -172,23 +174,26 @@
             _producerSession.commit();
         }
 
-        synchronized(consumerThread)
+        try
         {
-            try
-            {
-                consumerThread.join(5000L);
-            }
-            catch(InterruptedException e)
-            {
-                fail("Test failed waiting for consumer to complete");
-            }
+            consumerThread.join(getConsumerThreadJoinInterval());
         }
+        catch(InterruptedException e)
+        {
+            fail("Test failed waiting for consumer to complete");
+        }
+
         assertTrue("Consumer timed out", consumerThread.isStopped());
         assertEquals("Incorrect number of messages received", 200, consumerThread.getConsumed());
 
         producer.close();
     }
 
+    private long getConsumerThreadJoinInterval()
+    {
+        return isBrokerStorePersistent() ? 50000L: 5000L;
+    }
+
     public void testSortOrderWithNonUniqueKeys() throws JMSException, NamingException, AMQException
     {
         final Queue queue = createQueue();
@@ -211,7 +216,7 @@
         TextMessage received = null;
         int messageCount = 0;
 
-        while((received = (TextMessage) consumer.receive(1000)) != null)
+        while((received = (TextMessage) consumer.receive(_receiveInterval)) != null)
         {
             assertEquals("Received message with unexpected sorted key value", "samesortkeyvalue",
                             received.getStringProperty(TEST_SORT_KEY));
@@ -247,7 +252,7 @@
         TextMessage received;
         int messageCount = 0;
 
-        while((received = (TextMessage) consumer.receive(1000)) != null)
+        while((received = (TextMessage) consumer.receive(_receiveInterval)) != null)
         {
             assertEquals("Received message with unexpected sorted key value", SUBSET_KEYS[messageCount / 10],
                             received.getStringProperty(TEST_SORT_KEY));
@@ -362,16 +367,16 @@
     private Message assertReceiveMessage(final MessageConsumer consumer)
             throws JMSException
     {
-        final Message received = (TextMessage) consumer.receive(10000);
+        final Message received = (TextMessage) consumer.receive(_receiveInterval);
         assertNotNull("Received message is unexpectedly null", received);
         return received;
     }
 
     private class TestConsumerThread extends Thread
     {
-        private boolean _stopped = false;
+        private final AtomicInteger _consumed = new AtomicInteger(0);
+        private volatile boolean _stopped = false;
         private int _count = 0;
-        private int _consumed = 0;
         private int _sessionType = Session.AUTO_ACKNOWLEDGE;
         private Queue _queue;
 
@@ -402,7 +407,7 @@
                 conn.start();
 
                 Message msg;
-                while((msg = consumer.receive(1000)) != null)
+                while((msg = consumer.receive(_receiveInterval)) != null)
                 {
                     if(_sessionType == Session.SESSION_TRANSACTED)
                     {
@@ -415,7 +420,7 @@
                          {
                              LOGGER.debug("transacted session commit");
                             session.commit();
-                            _consumed++;
+                            _consumed.incrementAndGet();
                          }
                     }
                     else if(_sessionType == Session.CLIENT_ACKNOWLEDGE)
@@ -429,18 +434,18 @@
                          {
                              LOGGER.debug("client ack session acknowledge");
                              msg.acknowledge();
-                             _consumed++;
+                             _consumed.incrementAndGet();
                          }
                     }
                     else
                     {
                         LOGGER.debug("auto ack session");
-                        _consumed++;
+                        _consumed.incrementAndGet();
                     }
 
                     _count++;
                     LOGGER.debug("Message consumed with key: " + msg.getStringProperty(TEST_SORT_KEY));
-                    LOGGER.debug("Message consumed with consumed index: " + _consumed);
+                    LOGGER.debug("Message consumed with consumed index: " + _consumed.get());
                 }
 
                 _stopped = true;
@@ -453,14 +458,14 @@
            }
         }
 
-        public synchronized boolean isStopped()
+        public boolean isStopped()
         {
             return _stopped;
         }
 
-        public synchronized int getConsumed()
+        public int getConsumed()
         {
-            return _consumed;
+            return _consumed.get();
         }
     }
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java
index abb0781..3ac0872 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java
@@ -21,8 +21,15 @@
 
 package org.apache.qpid.server.queue;
 
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
+import junit.framework.Assert;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
@@ -32,16 +39,8 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.TopicSubscriber;
-
-import junit.framework.Assert;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
 
 public class TimeToLiveTest extends QpidBrokerTestCase
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
index 262051f..8ccf74a 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
@@ -18,6 +18,21 @@
  */
 package org.apache.qpid.server.security.acl;
 
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.lang.StringUtils;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQConnectionURL;
+import org.apache.qpid.jms.ConnectionListener;
+import org.apache.qpid.protocol.AMQConstant;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.url.URLSyntaxException;
+
+import javax.jms.Connection;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.naming.NamingException;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -27,21 +42,6 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-import javax.jms.Connection;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.naming.NamingException;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.lang.StringUtils;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.jms.ConnectionListener;
-import org.apache.qpid.protocol.AMQConstant;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.url.URLSyntaxException;
-
 /**
  * Abstract test case for ACLs.
  * 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExhaustiveACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExhaustiveACLTest.java
index 4f2464e..50c8069 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExhaustiveACLTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExhaustiveACLTest.java
@@ -18,14 +18,14 @@
  */
 package org.apache.qpid.server.security.acl;
 
-import javax.jms.Connection;
-import javax.jms.Session;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.protocol.AMQConstant;
 
+import javax.jms.Connection;
+import javax.jms.Session;
+
 /**
  * ACL version 2/3 file testing to verify that ACL entries control queue creation with specific properties.
  *
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java
index 427d253..6e4f12b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java
@@ -18,14 +18,14 @@
  */
 package org.apache.qpid.server.security.acl;
 
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
-
 import org.apache.qpid.management.common.mbeans.ServerInformation;
 import org.apache.qpid.server.management.ManagedObject;
 import org.apache.qpid.server.security.access.ObjectType;
 import org.apache.qpid.test.utils.JMXTestUtils;
 
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+
 /**
  * Tests that access to the JMX interface is governed only by {@link ObjectType#METHOD}/{@link ObjectType#ALL}
  * rules and AMQP rights have no effect.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java
index e9b8a2e..0e45ca9 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java
@@ -18,6 +18,10 @@
  */
 package org.apache.qpid.server.security.acl;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.protocol.AMQConstant;
+import org.apache.qpid.url.URLSyntaxException;
+
 import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.JMSException;
@@ -31,10 +35,6 @@
 import javax.jms.TopicSubscriber;
 import javax.naming.NamingException;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.protocol.AMQConstant;
-import org.apache.qpid.url.URLSyntaxException;
-
 /**
  * Tests the V2 ACLs.  The tests perform basic AMQP operations like creating queues or excahnges and publishing and consuming messages, using
  * JMS to contact the broker.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
index 044a0af..f5adf81 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
@@ -18,20 +18,22 @@
  */
 package org.apache.qpid.server.security.firewall;
 
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+import org.apache.qpid.client.AMQConnectionURL;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
-
-import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 
 public class FirewallConfigTest extends QpidBrokerTestCase 
 {
     private File _tmpConfig, _tmpVirtualhosts;
-    
+    private String _ipAddressOfBrokerHost;
+
     @Override
     protected void setUp() throws Exception
     {
@@ -47,12 +49,13 @@
         _tmpVirtualhosts = File.createTempFile("virtualhosts-systests-firewall", ".xml");
         setSystemProperty("QPID_FIREWALL_VIRTUALHOSTS_SETTINGS", _tmpVirtualhosts.getAbsolutePath());
         _tmpVirtualhosts.deleteOnExit();
+
+        _ipAddressOfBrokerHost = getIpAddressOfBrokerHost();
     }
 
     private void writeFirewallFile(boolean allow, boolean inVhost) throws IOException
     {
         FileWriter out = new FileWriter(inVhost ? _tmpVirtualhosts : _tmpConfig);
-        String ipAddr = "127.0.0.1"; // FIXME: get this from InetAddress.getLocalHost().getAddress() ?
         if (inVhost) 
         {
             out.write("<virtualhosts><virtualhost><test>");
@@ -62,7 +65,7 @@
             out.write("<broker>");
         }
         out.write("<security><firewall>");
-        out.write("<rule access=\""+((allow) ? "allow" : "deny")+"\" network=\""+ipAddr +"\"/>");
+        out.write("<rule access=\""+((allow) ? "allow" : "deny")+"\" network=\"" + _ipAddressOfBrokerHost + "\"/>");
         out.write("</firewall></security>");
         if (inVhost)
         {
@@ -81,26 +84,23 @@
         _configFile = new File("build/etc/config-systests-firewall-2.xml");
         
         super.setUp();
-        
-        Connection conn = null;
         try 
         {
             //Try to get a connection to the 'test2' vhost
             //This is expected to succeed as it is allowed at the vhost level
-            conn = getConnection(new AMQConnectionURL("amqp://guest:guest@clientid/test2?brokerlist='" + getBroker() + "'"));
+            getConnection(new AMQConnectionURL("amqp://guest:guest@clientid/test2?brokerlist='" + getBroker() + "'"));
         } 
         catch (JMSException e)
         {
             e.getLinkedException().printStackTrace();
             fail("The connection was expected to succeed: " + e.getMessage());
         }
-        
-        conn = null;
+
         try 
         {
             //Try to get a connection to the 'test' vhost
             //This is expected to fail as it is denied at the broker level
-            conn = getConnection();
+            getConnection();
             fail("We expected the connection to fail");
         } 
         catch (JMSException e)
@@ -114,13 +114,11 @@
         _configFile = new File("build/etc/config-systests-firewall-3.xml");
         
         super.setUp();
-        
-        Connection conn = null;
         try 
         {
             //Try to get a connection to the 'test2' vhost
             //This is expected to fail as it is denied at the vhost level
-            conn = getConnection(new AMQConnectionURL("amqp://guest:guest@clientid/test2?brokerlist='" + getBroker() + "'"));
+            getConnection(new AMQConnectionURL("amqp://guest:guest@clientid/test2?brokerlist='" + getBroker() + "'"));
             fail("The connection was expected to fail");
         } 
         catch (JMSException e)
@@ -128,12 +126,11 @@
             //ignore
         }
 
-        conn = null;
         try 
         {
             //Try to get a connection to the 'test' vhost
             //This is expected to succeed as it is allowed at the broker level
-            conn = getConnection();
+            getConnection();
         } 
         catch (JMSException e)
         {
@@ -269,4 +266,18 @@
         
         assertEquals("Second connection check failed", !initial, checkConnection());
     }
+
+    private String getIpAddressOfBrokerHost()
+    {
+        String brokerHost = getBroker().getHost();
+        try
+        {
+            return InetAddress.getByName(brokerHost).getHostAddress();
+        }
+        catch (UnknownHostException e)
+        {
+            throw new RuntimeException("Could not determine IP address of host : " + brokerHost, e);
+        }
+
+    }
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java
index bf9d0e0..555c4dd 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/store/PersistentStoreTest.java
@@ -26,147 +26,117 @@
 
 import javax.jms.Connection;
 import javax.jms.Destination;
-import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
-import javax.jms.Queue;
 import javax.jms.Session;
-
 import java.util.ArrayList;
 import java.util.List;
 
 public class PersistentStoreTest extends QpidBrokerTestCase
 {
-
     private static final int NUM_MESSAGES = 100;
     private Connection _con;
     private Session _session;
-    private Queue _destination;
-    private MessageConsumer _consumer;
+    private Destination _destination;
 
-    public void setUp() throws Exception, JMSException
+    public void setUp() throws Exception
     {
         super.setUp();
         _con = getConnection();
-        _con.start();
+    }
+
+    public void testCommittedMessagesSurviveBrokerNormalShutdown() throws Exception
+    {
+        sendAndCommitMessages();
+        stopBroker();
+        startBroker();
+        confirmBrokerStillHasCommittedMessages();
+    }
+
+    public void testCommittedMessagesSurviveBrokerAbnormalShutdown() throws Exception
+    {
+        if (isInternalBroker())
+        {
+            return;
+        }
+
+        sendAndCommitMessages();
+        killBroker();
+        startBroker();
+        confirmBrokerStillHasCommittedMessages();
+    }
+
+    public void testCommittedMessagesSurviveBrokerNormalShutdownMidTransaction() throws Exception
+    {
+        sendAndCommitMessages();
+        sendMoreMessagesWithoutCommitting();
+        stopBroker();
+        startBroker();
+        confirmBrokerStillHasCommittedMessages();
+    }
+
+    public void testCommittedMessagesSurviveBrokerAbnormalShutdownMidTransaction() throws Exception
+    {
+        if (isInternalBroker())
+        {
+            return;
+        }
+        sendAndCommitMessages();
+        sendMoreMessagesWithoutCommitting();
+        killBroker();
+        startBroker();
+        confirmBrokerStillHasCommittedMessages();
+    }
+
+    private void sendAndCommitMessages() throws Exception
+    {
         _session = _con.createSession(true, Session.SESSION_TRANSACTED);
         _destination = _session.createQueue(getTestQueueName());
-        _consumer = _session.createConsumer(_destination);
-        _consumer.close();
+        // Create queue by consumer side-effect
+        _session.createConsumer(_destination).close();
 
         sendMessage(_session, _destination, NUM_MESSAGES);
         _session.commit();
     }
 
-    /** Checks that a new consumer on a new connection can get NUM_MESSAGES from _destination */
-    private void checkMessages() throws Exception, JMSException
+    private void sendMoreMessagesWithoutCommitting() throws Exception
     {
-        _con = getConnection();
-        _session = _con.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        _con.start();
-        _consumer = _session.createConsumer(_destination);
+        sendMessage(_session, _destination, 5);
+        // sync to ensure that messages have reached the broker
+        ((AMQSession<?,?>) _session).sync();
+    }
+
+    private void confirmBrokerStillHasCommittedMessages() throws Exception
+    {
+        Connection con = getConnection();
+        Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        con.start();
+        Destination destination = session.createQueue(getTestQueueName());
+        MessageConsumer consumer = session.createConsumer(destination);
         for (int i = 1; i <= NUM_MESSAGES; i++)
         {
-            Message msg = _consumer.receive(RECEIVE_TIMEOUT);
+            Message msg = consumer.receive(RECEIVE_TIMEOUT);
             assertNotNull("Message " + i + " not received", msg);
             assertEquals("Did not receive the expected message", i, msg.getIntProperty(INDEX));
         }
-        
-        Message msg = _consumer.receive(100);
+
+        Message msg = consumer.receive(100);
         if(msg != null)
         {
             fail("No more messages should be received, but received additional message with index: " + msg.getIntProperty(INDEX));
         }
     }
 
-//    /**
-//     * starts the server, sends 100 messages, restarts the server and gets 100 messages back
-//     * the test formerly referred to as BDB-Qpid-1
-//     * @throws Exception
-//     */
-//    public void testStartStop() throws Exception
-//    {
-//        restartBroker(); -- Not Currently a gracefull restart so not BDB-Qpid-1
-//        checkMessages();
-//    }
-
     /**
-     * starts the server, sends 100 messages, nukes then starts the server and gets 100 messages back
-     * the test formerly referred to as BDB-Qpid-2
-     *
-     * @throws Exception
-     */
-    public void testForcibleStartStop() throws Exception
-    {
-        restartBroker();
-        checkMessages();
-    }
-
-//    /**
-//     * starts the server, sends 100 committed messages, 5 uncommited ones,
-//     * restarts the server and gets 100 messages back
-//     * the test formerly referred to as BDB-Qpid-5
-//     * @throws Exception
-//     */
-//    public void testStartStopMidTransaction() throws Exception
-//    {
-//        sendMessage(_session, _destination, 5);
-//        restartBroker(); -- Not Currently a gracefull restart so not BDB-Qpid-1
-//        checkMessages();
-//    }
-
-    /**
-     * starts the server, sends 100 committed messages, 5 uncommited ones,
-     * nukes and starts the server and gets 100 messages back
-     * the test formerly referred to as BDB-Qpid-6
-     *
-     * @throws Exception
-     */
-    public void testForcibleStartStopMidTransaction() throws Exception
-    {
-        sendMessage(_session, _destination, 5);
-        //sync to ensure that the above messages have reached the broker
-        ((AMQSession) _session).sync();
-        restartBroker();
-        checkMessages();
-    }
-
-    /**
-     * starts the server, sends 100 committed messages, 5 uncommited ones,
-     * restarts the client and gets 100 messages back.
-     * the test formerly referred to as BDB-Qpid-7
-     *
-     * FIXME: is this a PersistentStoreTest? Seems more like a transaction test to me.. aidan
-     *
-     * @throws Exception
-     */
-    public void testClientDeathMidTransaction() throws Exception
-    {
-        sendMessage(_session, _destination, 5);
-        _con.close();
-        checkMessages();
-    }
-
-//    /**
-//     * starts the server, sends 50 committed messages, copies $QPID_WORK to a new location,
-//     * sends 10 messages, stops the server, nukes the store, restores the copy, starts the server
-//     * checks that we get the first 50 back.
-//     */
-//    public void testHotBackup()
-//    {
-//        -- removing as this will leave 100msgs on a queue
-//    }
-
-    /**
-     * This test requires that we can send messages without commiting.
+     * This test requires that we can send messages without committing.
      * QTC always commits the messages sent via sendMessages.
      *
      * @param session the session to use for sending
      * @param destination where to send them to
      * @param count no. of messages to send
      *
-     * @return the sent messges
+     * @return the sent messages
      *
      * @throws Exception
      */
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java
index 2d450cf..8ffc099 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java
@@ -22,20 +22,21 @@
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQStoreException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.federation.Bridge;
 import org.apache.qpid.server.federation.BrokerLink;
-import org.apache.qpid.server.message.EnqueableMessage;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.logging.LogSubject;
+import org.apache.qpid.server.message.EnqueableMessage;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.queue.AMQQueue;
 
+import java.nio.ByteBuffer;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.nio.ByteBuffer;
 
 public class SlowMessageStore implements MessageStore, DurableConfigurationStore
 {
@@ -312,6 +313,17 @@
             _underlying.abortTran();
             doPostDelay("abortTran");
         }
+
+        public void removeXid(long format, byte[] globalId, byte[] branchId) throws AMQStoreException
+        {
+            _underlying.removeXid(format, globalId, branchId);
+        }
+
+        public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
+                throws AMQStoreException
+        {
+            _underlying.recordXid(format, globalId, branchId, enqueues, dequeues);
+        }
     }
 
     public void updateQueue(AMQQueue queue) throws AMQStoreException
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/util/AveragedRun.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/util/AveragedRun.java
index 1d17985..b7732a8 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/util/AveragedRun.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/util/AveragedRun.java
@@ -20,10 +20,8 @@
  */
 package org.apache.qpid.server.util;
 
-import org.apache.qpid.server.util.TimedRun;
-
-import java.util.concurrent.Callable;
 import java.util.Collection;
+import java.util.concurrent.Callable;
 
 public class AveragedRun implements Callable<RunStats>
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/GlobalTopicsTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/GlobalTopicsTest.java
index aff5d1b..6297478 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/GlobalTopicsTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/GlobalTopicsTest.java
@@ -20,11 +20,6 @@
  */
 package org.apache.qpid.systest;
 
-import org.apache.commons.configuration.ConfigurationException;
-
-import javax.naming.NamingException;
-import java.io.IOException;
-
 public class GlobalTopicsTest extends GlobalQueuesTest
 {
     @Override
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/MergeConfigurationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/MergeConfigurationTest.java
index e4efac6..993d71e 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/MergeConfigurationTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/MergeConfigurationTest.java
@@ -21,25 +21,10 @@
 package org.apache.qpid.systest;
 
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.AMQChannelClosedException;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQSession_0_10;
-import org.apache.qpid.jms.ConnectionListener;
-import org.apache.qpid.protocol.AMQConstant;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
 import javax.jms.Session;
-import javax.jms.Topic;
 import javax.naming.NamingException;
 import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
 
 public class MergeConfigurationTest extends TestingBaseCase
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/TestingBaseCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/TestingBaseCase.java
index 08a7b7a..86c9462 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/TestingBaseCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/TestingBaseCase.java
@@ -21,9 +21,8 @@
 package org.apache.qpid.systest;
 
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.AMQChannelClosedException;
+
 import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQSession_0_10;
 import org.apache.qpid.jms.ConnectionListener;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
@@ -44,7 +43,7 @@
 public class TestingBaseCase extends QpidBrokerTestCase implements ExceptionListener, ConnectionListener
 {
 
-    Topic _destination;
+    private Topic _destination;
     protected CountDownLatch _disconnectionLatch = new CountDownLatch(1);
     protected int MAX_QUEUE_MESSAGE_COUNT;
     protected int MESSAGE_SIZE = DEFAULT_MESSAGE_SIZE;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/CancelTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/CancelTest.java
deleted file mode 100644
index 107c730..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/CancelTest.java
+++ /dev/null
@@ -1,100 +0,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.
- *
- */
-
-package org.apache.qpid.test.client;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.QueueBrowser;
-import javax.jms.Session;
-import java.util.Enumeration;
-
-public class CancelTest extends QpidBrokerTestCase
-{
-    private static final Logger _logger = Logger.getLogger(CancelTest.class);
-
-    private Connection _clientConnection;
-    private Session _clientSession;
-    private Queue _queue;
-
-    public void setUp() throws Exception
-    {
-
-        super.setUp();
-
-        _queue = (Queue) getInitialContext().lookup("queue");
-
-        //Create Client
-        _clientConnection = getConnection();
-
-        _clientConnection.start();
-
-        _clientSession = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-        //Ensure _queue is created
-        _clientSession.createConsumer(_queue).close();
-    }
-
-    /**
-     * Simply
-     * This test originally did not assert anything but was just checking
-     * that a message could be browsed and consumed without throwing an exception.
-     * It now checks that at least a message is browsed and that a message is received.
-     */
-    public void test() throws Exception
-    {
-        Connection producerConnection = getConnection();
-
-        producerConnection.start();
-
-        Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        MessageProducer producer = producerSession.createProducer(_queue);
-        producer.send(producerSession.createTextMessage());
-        producerConnection.close();
-
-
-        QueueBrowser browser = _clientSession.createBrowser(_queue);
-        Enumeration e = browser.getEnumeration();
-
-        assertTrue(e.hasMoreElements());
-
-        int i = 0;
-        while (e.hasMoreElements())
-        {
-            e.nextElement();
-            if(++i > 1)
-            {
-                fail("Two many elemnts to browse!");
-            }
-        }
-
-        browser.close();
-
-        MessageConsumer consumer = _clientSession.createConsumer(_queue);
-        assertNotNull( consumer.receive(2000l) );
-        consumer.close();
-    }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/DupsOkTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/DupsOkTest.java
index a94d975..e06ed6e 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/DupsOkTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/DupsOkTest.java
@@ -1,8 +1,8 @@
 package org.apache.qpid.test.client;
 
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
@@ -96,7 +96,7 @@
 
         consumer.setMessageListener(new MessageListener()
         {
-            int _msgCount = 0;
+            private int _msgCount = 0;
 
             public void onMessage(Message message)
             {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/FlowControlTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/FlowControlTest.java
index e1f639a..f8bc051 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/FlowControlTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/FlowControlTest.java
@@ -20,12 +20,19 @@
 */
 package org.apache.qpid.test.client;
 
+import org.apache.log4j.Logger;
+
 import org.apache.qpid.client.AMQSession_0_8;
 import org.apache.qpid.client.message.AbstractJMSMessage;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.log4j.Logger;
 
-import javax.jms.*;
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
 
 public class FlowControlTest extends QpidBrokerTestCase
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java
new file mode 100644
index 0000000..b746a5b
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/ImmediateAndMandatoryPublishingTest.java
@@ -0,0 +1,290 @@
+/*
+ * 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.test.client;
+
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.TimeUnit;
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.Topic;
+import org.apache.qpid.client.AMQNoConsumersException;
+import org.apache.qpid.client.AMQNoRouteException;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
+public class ImmediateAndMandatoryPublishingTest extends QpidBrokerTestCase implements ExceptionListener
+{
+    private Connection _connection;
+    private BlockingQueue<JMSException> _exceptions;
+
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        _exceptions = new ArrayBlockingQueue<JMSException>(1);
+        _connection = getConnection();
+        _connection.setExceptionListener(this);
+    }
+
+    public void testPublishP2PWithNoConsumerAndImmediateOnAndAutoAck() throws Exception
+    {
+        publishIntoExistingDestinationWithNoConsumerAndImmediateOn(Session.AUTO_ACKNOWLEDGE, false);
+    }
+
+    public void testPublishP2PWithNoConsumerAndImmediateOnAndTx() throws Exception
+    {
+        publishIntoExistingDestinationWithNoConsumerAndImmediateOn(Session.SESSION_TRANSACTED, false);
+    }
+
+    public void testPublishPubSubWithDisconnectedDurableSubscriberAndImmediateOnAndAutoAck() throws Exception
+    {
+        publishIntoExistingDestinationWithNoConsumerAndImmediateOn(Session.AUTO_ACKNOWLEDGE, true);
+    }
+
+    public void testPublishPubSubWithDisconnectedDurableSubscriberAndImmediateOnAndTx() throws Exception
+    {
+        publishIntoExistingDestinationWithNoConsumerAndImmediateOn(Session.SESSION_TRANSACTED, true);
+    }
+
+    public void testPublishP2PIntoNonExistingDesitinationWithMandatoryOnAutoAck() throws Exception
+    {
+        publishWithMandatoryOnImmediateOff(Session.AUTO_ACKNOWLEDGE, false);
+    }
+
+    public void testPublishP2PIntoNonExistingDesitinationWithMandatoryOnAndTx() throws Exception
+    {
+        publishWithMandatoryOnImmediateOff(Session.SESSION_TRANSACTED, false);
+    }
+
+    public void testPubSubMandatoryAutoAck() throws Exception
+    {
+        publishWithMandatoryOnImmediateOff(Session.AUTO_ACKNOWLEDGE, true);
+    }
+
+    public void testPubSubMandatoryTx() throws Exception
+    {
+        publishWithMandatoryOnImmediateOff(Session.SESSION_TRANSACTED, true);
+    }
+
+    public void testP2PNoMandatoryAutoAck() throws Exception
+    {
+        publishWithMandatoryOffImmediateOff(Session.AUTO_ACKNOWLEDGE, false);
+    }
+
+    public void testP2PNoMandatoryTx() throws Exception
+    {
+        publishWithMandatoryOffImmediateOff(Session.SESSION_TRANSACTED, false);
+    }
+
+    public void testPubSubWithImmediateOnAndAutoAck() throws Exception
+    {
+        consumerCreateAndClose(true, false);
+
+        Message message = produceMessage(Session.AUTO_ACKNOWLEDGE, true, false, true);
+
+        JMSException exception = _exceptions.poll(10, TimeUnit.SECONDS);
+        assertNotNull("JMSException is expected", exception);
+        AMQNoRouteException noRouteException = (AMQNoRouteException) exception.getLinkedException();
+        assertNotNull("AMQNoRouteException should be linked to JMSEXception", noRouteException);
+        Message bounceMessage = (Message) noRouteException.getUndeliveredMessage();
+        assertNotNull("Bounced Message is expected", bounceMessage);
+        assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID());
+    }
+
+    private void publishIntoExistingDestinationWithNoConsumerAndImmediateOn(int acknowledgeMode, boolean pubSub)
+            throws JMSException, InterruptedException
+    {
+        consumerCreateAndClose(pubSub, true);
+
+        Message message = produceMessage(acknowledgeMode, pubSub, false, true);
+
+        JMSException exception = _exceptions.poll(10, TimeUnit.SECONDS);
+        assertNotNull("JMSException is expected", exception);
+        AMQNoConsumersException noConsumerException = (AMQNoConsumersException) exception.getLinkedException();
+        assertNotNull("AMQNoConsumersException should be linked to JMSEXception", noConsumerException);
+        Message bounceMessage = (Message) noConsumerException.getUndeliveredMessage();
+        assertNotNull("Bounced Message is expected", bounceMessage);
+        assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID());
+    }
+
+    private void publishWithMandatoryOnImmediateOff(int acknowledgeMode, boolean pubSub) throws JMSException,
+            InterruptedException
+    {
+        Message message = produceMessage(acknowledgeMode, pubSub, true, false);
+
+        JMSException exception = _exceptions.poll(10, TimeUnit.SECONDS);
+        assertNotNull("JMSException is expected", exception);
+        AMQNoRouteException noRouteException = (AMQNoRouteException) exception.getLinkedException();
+        assertNotNull("AMQNoRouteException should be linked to JMSEXception", noRouteException);
+        Message bounceMessage = (Message) noRouteException.getUndeliveredMessage();
+        assertNotNull("Bounced Message is expected", bounceMessage);
+        assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID());
+    }
+
+    private void publishWithMandatoryOffImmediateOff(int acknowledgeMode, boolean pubSub) throws JMSException,
+            InterruptedException
+    {
+        produceMessage(acknowledgeMode, pubSub, false, false);
+
+        JMSException exception = _exceptions.poll(1, TimeUnit.SECONDS);
+        assertNull("Unexpected JMSException", exception);
+    }
+
+    private void consumerCreateAndClose(boolean pubSub, boolean durable) throws JMSException
+    {
+        Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Destination destination = null;
+        MessageConsumer consumer = null;
+        if (pubSub)
+        {
+            destination = session.createTopic(getTestQueueName());
+            if (durable)
+            {
+                consumer = session.createDurableSubscriber((Topic) destination, getTestName());
+            }
+            else
+            {
+                consumer = session.createConsumer(destination);
+            }
+        }
+        else
+        {
+            destination = session.createQueue(getTestQueueName());
+            consumer = session.createConsumer(destination);
+        }
+        consumer.close();
+    }
+
+    private Message produceMessage(int acknowledgeMode, boolean pubSub, boolean mandatory, boolean immediate)
+            throws JMSException
+    {
+        Session session = _connection.createSession(acknowledgeMode == Session.SESSION_TRANSACTED, acknowledgeMode);
+        Destination destination = null;
+        if (pubSub)
+        {
+            destination = session.createTopic(getTestQueueName());
+        }
+        else
+        {
+            destination = session.createQueue(getTestQueueName());
+        }
+
+        MessageProducer producer = ((AMQSession<?, ?>) session).createProducer(destination, mandatory, immediate);
+        Message message = session.createMessage();
+        producer.send(message);
+        if (session.getTransacted())
+        {
+            session.commit();
+        }
+        return message;
+    }
+
+    public void testMandatoryAndImmediateDefaults() throws JMSException, InterruptedException
+    {
+        Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        // publish to non-existent queue - should get mandatory failure
+        MessageProducer producer = session.createProducer(session.createQueue(getTestQueueName()));
+        Message message = session.createMessage();
+        producer.send(message);
+
+        JMSException exception = _exceptions.poll(10, TimeUnit.SECONDS);
+        assertNotNull("JMSException is expected", exception);
+        AMQNoRouteException noRouteException = (AMQNoRouteException) exception.getLinkedException();
+        assertNotNull("AMQNoRouteException should be linked to JMSEXception", noRouteException);
+        Message bounceMessage = (Message) noRouteException.getUndeliveredMessage();
+        assertNotNull("Bounced Message is expected", bounceMessage);
+        assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID());
+
+        producer = session.createProducer(null);
+        message = session.createMessage();
+        producer.send(session.createQueue(getTestQueueName()), message);
+
+        exception = _exceptions.poll(10, TimeUnit.SECONDS);
+        assertNotNull("JMSException is expected", exception);
+        noRouteException = (AMQNoRouteException) exception.getLinkedException();
+        assertNotNull("AMQNoRouteException should be linked to JMSEXception", noRouteException);
+        bounceMessage = (Message) noRouteException.getUndeliveredMessage();
+        assertNotNull("Bounced Message is expected", bounceMessage);
+        assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID());
+
+
+        // publish to non-existent topic - should get no failure
+        producer = session.createProducer(session.createTopic(getTestQueueName()));
+        message = session.createMessage();
+        producer.send(message);
+
+        exception = _exceptions.poll(1, TimeUnit.SECONDS);
+        assertNull("Unexpected JMSException", exception);
+
+        producer = session.createProducer(null);
+        message = session.createMessage();
+        producer.send(session.createTopic(getTestQueueName()), message);
+
+        exception = _exceptions.poll(1, TimeUnit.SECONDS);
+        assertNull("Unexpected JMSException", exception);
+
+        session.close();
+    }
+
+    public void testMandatoryAndImmediateSystemProperties() throws JMSException, InterruptedException
+    {
+        setTestClientSystemProperty("qpid.default_mandatory","true");
+        Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        // publish to non-existent topic - should get mandatory failure
+
+        MessageProducer producer = session.createProducer(session.createTopic(getTestQueueName()));
+        Message message = session.createMessage();
+        producer.send(message);
+
+        JMSException exception = _exceptions.poll(10, TimeUnit.SECONDS);
+        assertNotNull("JMSException is expected", exception);
+        AMQNoRouteException noRouteException = (AMQNoRouteException) exception.getLinkedException();
+        assertNotNull("AMQNoRouteException should be linked to JMSEXception", noRouteException);
+        Message bounceMessage = (Message) noRouteException.getUndeliveredMessage();
+        assertNotNull("Bounced Message is expected", bounceMessage);
+        assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID());
+
+        // now set topic specific system property to false - should no longer get mandatory failure on new producer
+        setTestClientSystemProperty("qpid.default_mandatory_topic","false");
+        producer = session.createProducer(null);
+        message = session.createMessage();
+        producer.send(session.createTopic(getTestQueueName()), message);
+
+        exception = _exceptions.poll(1, TimeUnit.SECONDS);
+        if(exception != null)
+        {
+            exception.printStackTrace();
+        }
+        assertNull("Unexpected JMSException", exception);
+
+    }
+
+    public void onException(JMSException exception)
+    {
+        _exceptions.add(exception);
+    }
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java
index f2ac590..6b6b4a7 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java
@@ -20,13 +20,7 @@
  */
 package org.apache.qpid.test.client;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.FailoverBaseCase;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
+import java.util.Enumeration;
 import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -37,8 +31,10 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.naming.NamingException;
-import java.util.Enumeration;
-import java.util.Random;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 public class QueueBrowserAutoAckTest extends QpidBrokerTestCase
 {
@@ -424,4 +420,21 @@
         validate(messages);
     }
 
+    public void testBrowsingWhileStopped() throws JMSException
+    {
+        _clientConnection.stop();
+
+        try
+        {
+            QueueBrowser browser = _clientSession.createBrowser(getTestQueue());
+            Enumeration messages = browser.getEnumeration();
+            fail("Expected exception when attempting to browse on a stopped connection did not occur");
+        }
+        catch(javax.jms.IllegalStateException e)
+        {
+            // pass
+        }
+
+    }
+
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/RollbackOrderTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/RollbackOrderTest.java
index b944f2d..a53c3d3 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/RollbackOrderTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/RollbackOrderTest.java
@@ -20,14 +20,20 @@
  */
 package org.apache.qpid.test.client;
 
-import org.apache.qpid.test.utils.*;
-import javax.jms.*;
+import junit.framework.AssertionFailedError;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Queue;
+import javax.jms.Session;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import junit.framework.ComparisonFailure;
-import junit.framework.AssertionFailedError;
-
 /**
  * RollbackOrderTest, QPID-1864, QPID-1871
  *
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
index feae7c9..e1f93b9 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
@@ -20,31 +20,8 @@
  */
 package org.apache.qpid.test.client.destination;
 
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.QueueBrowser;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicSession;
-import javax.jms.TopicSubscriber;
-import javax.naming.Context;
-import javax.naming.InitialContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQAnyDestination;
 import org.apache.qpid.client.AMQConnection;
@@ -58,8 +35,17 @@
 import org.apache.qpid.messaging.Address;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.transport.ExecutionErrorCode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.*;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
 public class AddressBasedDestinationTest extends QpidBrokerTestCase
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/failover/FailoverTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/failover/FailoverTest.java
index 5b01c28..b82c375 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/failover/FailoverTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/failover/FailoverTest.java
@@ -21,9 +21,11 @@
 
 package org.apache.qpid.test.client.failover;
 
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.jms.ConnectionListener;
+import org.apache.qpid.test.utils.FailoverBaseCase;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
@@ -34,11 +36,9 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.naming.NamingException;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.jms.ConnectionListener;
-import org.apache.qpid.test.utils.FailoverBaseCase;
+import java.util.Random;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 public class FailoverTest extends FailoverBaseCase implements ConnectionListener
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSDestinationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSDestinationTest.java
index 2d326d7..5b350d2 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSDestinationTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSDestinationTest.java
@@ -20,11 +20,11 @@
  */
 package org.apache.qpid.test.client.message;
 
-import org.apache.qpid.configuration.ClientProperties;
 import org.apache.qpid.client.AMQAnyDestination;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQTopic;
 import org.apache.qpid.client.CustomJMSXProperty;
+import org.apache.qpid.configuration.ClientProperties;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.management.common.mbeans.ManagedQueue;
 import org.apache.qpid.test.utils.JMXTestUtils;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSReplyToTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSReplyToTest.java
new file mode 100644
index 0000000..fe8180d
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/JMSReplyToTest.java
@@ -0,0 +1,169 @@
+/*
+ *
+ * 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.test.client.message;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.IllegalStateException;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TemporaryQueue;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
+/**
+ * Tests that {@link Message#setJMSReplyTo(Destination)} can be used to pass a {@link Destination} between
+ * messaging clients as is commonly used in request/response messaging pattern implementations.
+ */
+public class JMSReplyToTest extends QpidBrokerTestCase
+{
+    private AtomicReference<Throwable> _caughtException = new AtomicReference<Throwable>();
+    private Queue _requestQueue;
+    private Connection _connection;
+    private Session _session;
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        _requestQueue = startAsyncRespondingJmsConsumerOnSeparateConnection();
+
+        _connection = getConnection();
+        _connection.start();
+        _session = _connection.createSession(false,  Session.AUTO_ACKNOWLEDGE);
+    }
+
+    public void testRequestResponseUsingJmsReplyTo() throws Exception
+    {
+        final String responseQueueName = getTestQueueName() + ".response";
+        Queue replyToQueue = _session.createQueue(responseQueueName);
+        sendRequestAndValidateResponse(replyToQueue);
+    }
+
+    public void testRequestResponseUsingTemporaryJmsReplyTo() throws Exception
+    {
+        TemporaryQueue replyToQueue = _session.createTemporaryQueue();
+
+        sendRequestAndValidateResponse(replyToQueue);
+    }
+
+    private void sendRequestAndValidateResponse(Queue replyToQueue) throws JMSException, Exception
+    {
+        MessageConsumer replyConsumer = _session.createConsumer(replyToQueue);
+
+        Message requestMessage = createRequestMessageWithJmsReplyTo(_session, replyToQueue);
+        sendRequest(_requestQueue, _session, requestMessage);
+
+        receiveAndValidateResponse(replyConsumer, requestMessage);
+
+        assertNull("Async responder caught unexpected exception", _caughtException.get());
+    }
+
+    private Message createRequestMessageWithJmsReplyTo(Session session, Queue replyToQueue)
+            throws JMSException
+    {
+        Message requestMessage = session.createTextMessage("My request");
+        requestMessage.setJMSReplyTo(replyToQueue);
+        return requestMessage;
+    }
+
+    private void sendRequest(final Queue requestQueue, Session session, Message requestMessage) throws Exception
+    {
+        MessageProducer producer = session.createProducer(requestQueue);
+        producer.send(requestMessage);
+    }
+
+    private void receiveAndValidateResponse(MessageConsumer replyConsumer, Message requestMessage) throws JMSException
+    {
+        Message responseMessage = replyConsumer.receive(RECEIVE_TIMEOUT);
+        assertNotNull("Response message not received", responseMessage);
+        assertEquals("Correlation id of the response should match message id of the request",
+                responseMessage.getJMSCorrelationID(), requestMessage.getJMSMessageID());
+    }
+
+    private Queue startAsyncRespondingJmsConsumerOnSeparateConnection() throws Exception
+    {
+        final String requestQueueName = getTestQueueName() + ".request";
+        final Connection responderConnection =  getConnection();
+        responderConnection.start();
+        final Session responderSession = responderConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        final Queue requestQueue = responderSession.createQueue(requestQueueName);
+
+        final MessageConsumer requestConsumer = responderSession.createConsumer(requestQueue);
+        requestConsumer.setMessageListener(new AsyncResponder(responderSession));
+
+        return requestQueue;
+    }
+
+    private final class AsyncResponder implements MessageListener
+    {
+        private final Session _responderSession;
+
+        private AsyncResponder(Session responderSession)
+        {
+            _responderSession = responderSession;
+        }
+
+        @Override
+        public void onMessage(Message requestMessage)
+        {
+            try
+            {
+                Destination replyTo = getReplyToQueue(requestMessage);
+
+                Message responseMessage = _responderSession.createMessage();
+                responseMessage.setJMSCorrelationID(requestMessage.getJMSMessageID());
+
+                sendResponseToQueue(replyTo, responseMessage);
+            }
+            catch (Throwable t)
+            {
+                _caughtException.set(t);
+            }
+        }
+
+        private Destination getReplyToQueue(Message requestMessage) throws JMSException, IllegalStateException
+        {
+            Destination replyTo = requestMessage.getJMSReplyTo();
+            if (replyTo == null)
+            {
+                throw new IllegalStateException("JMSReplyTo was null on message " + requestMessage);
+            }
+            return replyTo;
+        }
+
+        private void sendResponseToQueue(Destination replyTo, Message responseMessage)
+                throws JMSException
+        {
+            MessageProducer responseProducer = _responderSession.createProducer(replyTo);
+            responseProducer.send(responseMessage);
+        }
+    }
+
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/MessageToStringTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/MessageToStringTest.java
index 1071861..dc1f690 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/MessageToStringTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/MessageToStringTest.java
@@ -20,14 +20,12 @@
  */
 package org.apache.qpid.test.client.message;
 
-import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.BytesMessage;
 import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
 import javax.jms.MapMessage;
 import javax.jms.Message;
@@ -49,7 +47,7 @@
     private Connection _connection;
     private Session _session;
     private Queue _queue;
-    MessageConsumer _consumer;
+    private MessageConsumer _consumer;
     private static final String BYTE_TEST = "MapByteTest";
 
     public void setUp() throws Exception
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/ObjectMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/ObjectMessageTest.java
index fa16152..3bd2c4a 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/ObjectMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/ObjectMessageTest.java
@@ -20,10 +20,9 @@
  */
 package org.apache.qpid.test.client.message;
 
-import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
@@ -38,8 +37,8 @@
 {
     private Connection _connection;
     private Session _session;
-    MessageConsumer _consumer;
-    MessageProducer _producer;
+    private MessageConsumer _consumer;
+    private MessageProducer _producer;
 
     public void setUp() throws Exception
     {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java
index b1c8b56..2c7f426 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java
@@ -20,7 +20,16 @@
  */
 package org.apache.qpid.test.client.message;
 
-import java.util.concurrent.CountDownLatch;
+import junit.framework.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.BasicMessageProducer;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.DeliveryMode;
 import javax.jms.Destination;
@@ -32,18 +41,7 @@
 import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
-
-import junit.framework.Assert;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.BasicMessageProducer;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.concurrent.CountDownLatch;
 
 public class SelectorTest extends QpidBrokerTestCase implements MessageListener
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/queue/LVQTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/queue/LVQTest.java
index 14fbd1d..5156640 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/queue/LVQTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/queue/LVQTest.java
@@ -20,6 +20,11 @@
  */
 package org.apache.qpid.test.client.queue;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.Message;
@@ -28,11 +33,6 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
-import org.apache.qpid.test.client.destination.AddressBasedDestinationTest;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class LVQTest extends QpidBrokerTestCase
 {
     private static final Logger _logger = LoggerFactory.getLogger(LVQTest.class);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/queue/QueuePolicyTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/queue/QueuePolicyTest.java
index e7c3fad..b785326 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/queue/QueuePolicyTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/queue/QueuePolicyTest.java
@@ -20,6 +20,13 @@
 */
 package org.apache.qpid.test.client.queue;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.MessageConsumer;
@@ -27,12 +34,6 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class QueuePolicyTest extends QpidBrokerTestCase
 {
     private static final Logger _logger = LoggerFactory.getLogger(QueuePolicyTest.class);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
index 85565a3..ee81e7c 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
@@ -20,7 +20,10 @@
  */
 package org.apache.qpid.test.client.timeouts;
 
-import java.io.File;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
@@ -30,13 +33,6 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 
-import org.apache.commons.configuration.XMLConfiguration;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * This tests that when the commit takes a long time(due to POST_COMMIT_DELAY) that the commit does not timeout
  * This test must be run in conjunction with SyncWaiteTimeoutDelay or be run with POST_COMMIT_DELAY > 30s to ensure
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitTimeoutDelayTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitTimeoutDelayTest.java
index 6189c37..2846723 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitTimeoutDelayTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitTimeoutDelayTest.java
@@ -20,8 +20,8 @@
  */
 package org.apache.qpid.test.client.timeouts;
 
-import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQTimeoutException;
 
 import javax.jms.JMSException;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailureUserPrompt.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailureUserPrompt.java
index 889df4a..118ddff 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailureUserPrompt.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CauseFailureUserPrompt.java
@@ -20,8 +20,6 @@
  */
 package org.apache.qpid.test.framework;
 
-import org.apache.qpid.test.framework.CauseFailure;
-
 import java.io.IOException;
 
 /**
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEnd.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEnd.java
index 824edd7..ffde385 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEnd.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEnd.java
@@ -20,7 +20,11 @@
  */
 package org.apache.qpid.test.framework;
 
-import javax.jms.*;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
 
 /**
  * A CircuitEnd is a pair consisting of one message producer and one message consumer, that represents one end of a
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEndBase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEndBase.java
index d5a3351..5730752 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEndBase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/CircuitEndBase.java
@@ -20,7 +20,11 @@
  */
 package org.apache.qpid.test.framework;
 
-import javax.jms.*;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
 
 /**
  * A CircuitEndBase is a pair consisting of one message producer and one message consumer, that represents one end of a
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java
index 7d06aba..afb7b5b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java
@@ -38,7 +38,6 @@
 
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
-
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.ArrayList;
@@ -59,7 +58,7 @@
     private final Logger log = Logger.getLogger(ExceptionMonitor.class);
 
     /** Holds the received exceptions. */
-    List<Exception> exceptions = new ArrayList<Exception>();
+    private List<Exception> exceptions = new ArrayList<Exception>();
 
     /**
      * Receives incoming exceptions.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
index f866cd5..ecbb710 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
@@ -23,14 +23,12 @@
 import org.apache.log4j.Logger;
 import org.apache.log4j.NDC;
 
-import org.apache.qpid.test.framework.BrokerLifecycleAware;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 import org.apache.qpid.junit.extensions.SetupTaskAware;
 import org.apache.qpid.junit.extensions.SetupTaskHandler;
 import org.apache.qpid.junit.extensions.util.ParsedProperties;
 import org.apache.qpid.junit.extensions.util.TestContextProperties;
+import org.apache.qpid.test.framework.sequencers.CircuitFactory;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkClientBaseCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkClientBaseCase.java
deleted file mode 100644
index 2322955..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkClientBaseCase.java
+++ /dev/null
@@ -1,31 +0,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.
- *
- */
-package org.apache.qpid.test.framework;
-
-/**
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td>
- * </table>
- */
-public class FrameworkClientBaseCase
-{
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalAMQPCircuitFactory.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalAMQPCircuitFactory.java
index 4c8f301..899a808 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalAMQPCircuitFactory.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalAMQPCircuitFactory.java
@@ -23,12 +23,17 @@
 import org.apache.log4j.Logger;
 
 import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.junit.extensions.util.ParsedProperties;
 import org.apache.qpid.test.framework.localcircuit.LocalAMQPPublisherImpl;
 import org.apache.qpid.test.framework.localcircuit.LocalPublisherImpl;
 
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-import javax.jms.*;
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.Topic;
 
 /**
  * LocalAMQPCircuitFactory is a test sequencer that creates test circuits with publishing and receiving ends rooted
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java
index ec70759..b8fd4cc 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java
@@ -22,16 +22,20 @@
 
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.junit.extensions.util.ParsedProperties;
 import org.apache.qpid.test.framework.localcircuit.LocalCircuitImpl;
 import org.apache.qpid.test.framework.localcircuit.LocalPublisherImpl;
 import org.apache.qpid.test.framework.localcircuit.LocalReceiverImpl;
 import org.apache.qpid.test.framework.sequencers.CircuitFactory;
 import org.apache.qpid.test.utils.ConversationFactory;
 
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-import javax.jms.*;
-
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.Topic;
 import java.util.List;
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicLong;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java
index 3fac969..5265c04 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/MessageMonitor.java
@@ -24,7 +24,6 @@
 
 import javax.jms.Message;
 import javax.jms.MessageListener;
-
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/MessagingTestConfigProperties.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/MessagingTestConfigProperties.java
index 6d72402..ceece2d 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/MessagingTestConfigProperties.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/MessagingTestConfigProperties.java
@@ -23,7 +23,6 @@
 import org.apache.qpid.junit.extensions.util.ParsedProperties;
 
 import javax.jms.Session;
-
 import java.util.Properties;
 
 /**
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java
index f1adeea..919faa4 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java
@@ -22,15 +22,23 @@
 
 import org.apache.log4j.Logger;
 
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.*;
-
 import org.apache.qpid.junit.extensions.util.ParsedProperties;
 
-import javax.jms.*;
+import static org.apache.qpid.test.framework.MessagingTestConfigProperties.BROKER_PROPNAME;
+import static org.apache.qpid.test.framework.MessagingTestConfigProperties.CONNECTION_NAME;
+import static org.apache.qpid.test.framework.MessagingTestConfigProperties.PASSWORD_PROPNAME;
+import static org.apache.qpid.test.framework.MessagingTestConfigProperties.USERNAME_PROPNAME;
+import static org.apache.qpid.test.framework.MessagingTestConfigProperties.VIRTUAL_HOST_PROPNAME;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-
 import java.util.Map;
 
 /**
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockReference.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockReference.java
index 8bce752..8ee8d82 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockReference.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockReference.java
@@ -23,7 +23,11 @@
 import org.apache.qpid.junit.extensions.ShutdownHookable;
 
 import java.io.IOException;
-import java.net.*;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.net.SocketException;
+import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 
 /**
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockSynchronizer.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockSynchronizer.java
index c89112e..226c846 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockSynchronizer.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/clocksynch/UDPClockSynchronizer.java
@@ -24,7 +24,12 @@
 import org.apache.qpid.junit.extensions.util.ParsedProperties;
 
 import java.io.IOException;
-import java.net.*;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.net.SocketException;
+import java.net.SocketTimeoutException;
+import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 import java.util.Arrays;
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedCircuitImpl.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedCircuitImpl.java
index f375eda..6c950fc 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedCircuitImpl.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedCircuitImpl.java
@@ -22,18 +22,21 @@
 
 import org.apache.log4j.Logger;
 
-import org.apache.qpid.test.framework.*;
-import org.apache.qpid.test.utils.ConversationFactory;
-
 import org.apache.qpid.junit.extensions.TimingController;
 import org.apache.qpid.junit.extensions.TimingControllerAware;
 import org.apache.qpid.junit.extensions.util.ParsedProperties;
+import org.apache.qpid.test.framework.Assertion;
+import org.apache.qpid.test.framework.Circuit;
+import org.apache.qpid.test.framework.Publisher;
+import org.apache.qpid.test.framework.Receiver;
+import org.apache.qpid.test.framework.TestClientDetails;
+import org.apache.qpid.test.framework.TestUtils;
+import org.apache.qpid.test.utils.ConversationFactory;
 
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.Session;
-
 import java.util.LinkedList;
 import java.util.List;
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedPublisherImpl.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedPublisherImpl.java
index c51f710..130e908 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedPublisherImpl.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedPublisherImpl.java
@@ -20,11 +20,10 @@
  */
 package org.apache.qpid.test.framework.distributedcircuit;
 
+import org.apache.qpid.junit.extensions.util.ParsedProperties;
 import org.apache.qpid.test.framework.Assertion;
 import org.apache.qpid.test.framework.Publisher;
 
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
 /**
  * DistributedPublisherImpl represents the status of the publishing side of a test circuit. Its main purpose is to
  * provide assertions that can be applied to verify the behaviour of a non-local publisher.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedReceiverImpl.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedReceiverImpl.java
index 863921e..4b801e7 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedReceiverImpl.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/DistributedReceiverImpl.java
@@ -20,11 +20,10 @@
  */
 package org.apache.qpid.test.framework.distributedcircuit;
 
+import org.apache.qpid.junit.extensions.util.ParsedProperties;
 import org.apache.qpid.test.framework.Assertion;
 import org.apache.qpid.test.framework.Receiver;
 
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
 /**
  * DistributedReceiverImpl represents the status of the receiving side of a test circuit. Its main purpose is to
  * provide assertions that can be applied to verify the behaviour of a non-local receiver.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/TestClientCircuitEnd.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/TestClientCircuitEnd.java
index dce2706..09bcf24 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/TestClientCircuitEnd.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedcircuit/TestClientCircuitEnd.java
@@ -22,13 +22,22 @@
 
 import org.apache.log4j.Logger;
 
-import org.apache.qpid.test.framework.*;
-import org.apache.qpid.test.framework.distributedtesting.TestClientControlledTest;
-
 import org.apache.qpid.junit.extensions.util.ParsedProperties;
 import org.apache.qpid.junit.extensions.util.TestContextProperties;
+import org.apache.qpid.test.framework.CircuitEnd;
+import org.apache.qpid.test.framework.ExceptionMonitor;
+import org.apache.qpid.test.framework.LocalCircuitFactory;
+import org.apache.qpid.test.framework.MessageMonitor;
+import org.apache.qpid.test.framework.MessagingTestConfigProperties;
+import org.apache.qpid.test.framework.TestUtils;
+import org.apache.qpid.test.framework.distributedtesting.TestClientControlledTest;
 
-import javax.jms.*;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
 
 /**
  * A TestClientCircuitEnd is a {@link CircuitEnd} that may be controlled from a
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/Coordinator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/Coordinator.java
index d532109..e07b141 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/Coordinator.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/Coordinator.java
@@ -20,24 +20,11 @@
  */
 package org.apache.qpid.test.framework.distributedtesting;
 
-import java.net.InetAddress;
-import java.util.*;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import javax.jms.*;
-
 import junit.framework.Test;
 import junit.framework.TestResult;
 import junit.framework.TestSuite;
-
 import org.apache.log4j.Logger;
 import org.apache.log4j.NDC;
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import org.apache.qpid.test.framework.MessagingTestConfigProperties;
-import org.apache.qpid.test.framework.TestClientDetails;
-import org.apache.qpid.test.framework.TestUtils;
-import org.apache.qpid.test.framework.clocksynch.UDPClockReference;
-import org.apache.qpid.test.utils.ConversationFactory;
 
 import org.apache.qpid.junit.extensions.TKTestRunner;
 import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
@@ -45,6 +32,26 @@
 import org.apache.qpid.junit.extensions.util.MathUtils;
 import org.apache.qpid.junit.extensions.util.ParsedProperties;
 import org.apache.qpid.junit.extensions.util.TestContextProperties;
+import org.apache.qpid.test.framework.FrameworkBaseCase;
+import org.apache.qpid.test.framework.MessagingTestConfigProperties;
+import org.apache.qpid.test.framework.TestClientDetails;
+import org.apache.qpid.test.framework.TestUtils;
+import org.apache.qpid.test.framework.clocksynch.UDPClockReference;
+import org.apache.qpid.test.utils.ConversationFactory;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.LinkedBlockingQueue;
 
 /**
  * <p/>Implements the coordinator client described in the interop testing specification
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/DistributedTestDecorator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/DistributedTestDecorator.java
index bdcfc99..49a01d3 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/DistributedTestDecorator.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/DistributedTestDecorator.java
@@ -21,22 +21,20 @@
 package org.apache.qpid.test.framework.distributedtesting;
 
 import junit.framework.TestResult;
-
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
 import org.apache.qpid.test.framework.FrameworkBaseCase;
 import org.apache.qpid.test.framework.TestClientDetails;
 import org.apache.qpid.test.framework.sequencers.CircuitFactory;
 import org.apache.qpid.test.utils.ConversationFactory;
 
-import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
-
 import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
-
-import java.util.*;
+import java.util.Collection;
+import java.util.Set;
 
 /**
  * DistributedTestDecorator is a base class for writing test decorators that invite test clients to participate in
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/FanOutTestDecorator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/FanOutTestDecorator.java
index eed9b1f..809bb1d 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/FanOutTestDecorator.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/FanOutTestDecorator.java
@@ -22,9 +22,9 @@
 
 import junit.framework.Test;
 import junit.framework.TestResult;
-
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
 import org.apache.qpid.test.framework.DropInTest;
 import org.apache.qpid.test.framework.FrameworkBaseCase;
 import org.apache.qpid.test.framework.TestClientDetails;
@@ -32,13 +32,10 @@
 import org.apache.qpid.test.framework.sequencers.FanOutCircuitFactory;
 import org.apache.qpid.test.utils.ConversationFactory;
 
-import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
-
 import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
-
 import java.util.Iterator;
 import java.util.Set;
 
@@ -60,7 +57,7 @@
     private static final Logger log = Logger.getLogger(FanOutTestDecorator.class);
 
     /** Holds the currently running test case. */
-    FrameworkBaseCase currentTest = null;
+    private FrameworkBaseCase currentTest = null;
 
     /**
      * Creates a wrapped suite test decorator from another one.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropTestDecorator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropTestDecorator.java
index 413d555..dd50070 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropTestDecorator.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/InteropTestDecorator.java
@@ -22,20 +22,21 @@
 
 import junit.framework.Test;
 import junit.framework.TestResult;
-
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
 import org.apache.qpid.test.framework.FrameworkBaseCase;
 import org.apache.qpid.test.framework.TestClientDetails;
 import org.apache.qpid.test.framework.sequencers.CircuitFactory;
 import org.apache.qpid.test.framework.sequencers.InteropCircuitFactory;
 import org.apache.qpid.test.utils.ConversationFactory;
 
-import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
-
 import javax.jms.Connection;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 /**
  * DistributedTestDecorator is a test decorator, written to implement the interop test specification. Given a list
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/OptOutTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/OptOutTestCase.java
index 008b89a..229c6a3 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/OptOutTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/OptOutTestCase.java
@@ -20,8 +20,8 @@
  */
 package org.apache.qpid.test.framework.distributedtesting;
 
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
 import org.apache.qpid.test.framework.FrameworkBaseCase;
+import org.apache.qpid.test.framework.sequencers.CircuitFactory;
 
 /**
  * An OptOutTestCase is a test case that automatically fails. It is used when a list of test clients has been generated
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java
index 3377036..f9b8cbb 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java
@@ -23,6 +23,9 @@
 import org.apache.log4j.Logger;
 import org.apache.log4j.NDC;
 
+import org.apache.qpid.junit.extensions.SleepThrottle;
+import org.apache.qpid.junit.extensions.util.ParsedProperties;
+import org.apache.qpid.junit.extensions.util.TestContextProperties;
 import org.apache.qpid.test.framework.MessagingTestConfigProperties;
 import org.apache.qpid.test.framework.TestUtils;
 import org.apache.qpid.test.framework.clocksynch.ClockSynchThread;
@@ -30,13 +33,21 @@
 import org.apache.qpid.test.utils.ReflectionUtils;
 import org.apache.qpid.test.utils.ReflectionUtilsException;
 
-import org.apache.qpid.junit.extensions.SleepThrottle;
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.junit.extensions.util.TestContextProperties;
-
-import javax.jms.*;
-
-import java.util.*;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.Topic;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Implements a test client as described in the interop testing spec
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClientControlledTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClientControlledTest.java
index 30fd382..2e64c9c 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClientControlledTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClientControlledTest.java
@@ -22,7 +22,6 @@
 
 import javax.jms.JMSException;
 import javax.jms.Message;
-import javax.jms.MessageListener;
 import javax.jms.Session;
 
 /**
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/listeners/XMLTestListener.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/listeners/XMLTestListener.java
index c79029c..ad2c196 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/listeners/XMLTestListener.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/listeners/XMLTestListener.java
@@ -23,7 +23,6 @@
 import junit.framework.AssertionFailedError;
 import junit.framework.Test;
 import junit.framework.TestCase;
-
 import org.apache.log4j.Logger;
 
 import org.apache.qpid.junit.extensions.ShutdownHookable;
@@ -32,7 +31,13 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.Writer;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
 /**
  * Listens for test results for a named test and outputs these in the standard JUnit XML format to the specified
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalAMQPPublisherImpl.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalAMQPPublisherImpl.java
index 4388c7f..6a0e8cb 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalAMQPPublisherImpl.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalAMQPPublisherImpl.java
@@ -22,9 +22,13 @@
 
 import org.apache.qpid.client.AMQNoConsumersException;
 import org.apache.qpid.client.AMQNoRouteException;
-import org.apache.qpid.test.framework.*;
-
 import org.apache.qpid.junit.extensions.util.ParsedProperties;
+import org.apache.qpid.test.framework.AMQPPublisher;
+import org.apache.qpid.test.framework.Assertion;
+import org.apache.qpid.test.framework.AssertionBase;
+import org.apache.qpid.test.framework.CircuitEndBase;
+import org.apache.qpid.test.framework.ExceptionMonitor;
+import org.apache.qpid.test.framework.MessageMonitor;
 
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java
index 3910912..dc9ee0a 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java
@@ -22,12 +22,19 @@
 
 import org.apache.log4j.Logger;
 
-import org.apache.qpid.test.framework.*;
-
 import org.apache.qpid.junit.extensions.util.ParsedProperties;
+import org.apache.qpid.test.framework.Assertion;
+import org.apache.qpid.test.framework.Circuit;
+import org.apache.qpid.test.framework.CircuitEnd;
+import org.apache.qpid.test.framework.ExceptionMonitor;
+import org.apache.qpid.test.framework.MessagingTestConfigProperties;
+import org.apache.qpid.test.framework.Publisher;
+import org.apache.qpid.test.framework.Receiver;
+import org.apache.qpid.test.framework.TestUtils;
 
-import javax.jms.*;
-
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Message;
 import java.util.LinkedList;
 import java.util.List;
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalPublisherImpl.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalPublisherImpl.java
index 3ec3f62..9920be0 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalPublisherImpl.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalPublisherImpl.java
@@ -20,9 +20,15 @@
  */
 package org.apache.qpid.test.framework.localcircuit;
 
-import org.apache.qpid.test.framework.*;
-
 import org.apache.qpid.junit.extensions.util.ParsedProperties;
+import org.apache.qpid.test.framework.Assertion;
+import org.apache.qpid.test.framework.AssertionBase;
+import org.apache.qpid.test.framework.CircuitEnd;
+import org.apache.qpid.test.framework.CircuitEndBase;
+import org.apache.qpid.test.framework.ExceptionMonitor;
+import org.apache.qpid.test.framework.MessageMonitor;
+import org.apache.qpid.test.framework.NotApplicableAssertion;
+import org.apache.qpid.test.framework.Publisher;
 
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalReceiverImpl.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalReceiverImpl.java
index 74f414c..bb242fa 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalReceiverImpl.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalReceiverImpl.java
@@ -20,9 +20,14 @@
  */
 package org.apache.qpid.test.framework.localcircuit;
 
-import org.apache.qpid.test.framework.*;
-
 import org.apache.qpid.junit.extensions.util.ParsedProperties;
+import org.apache.qpid.test.framework.Assertion;
+import org.apache.qpid.test.framework.CircuitEnd;
+import org.apache.qpid.test.framework.CircuitEndBase;
+import org.apache.qpid.test.framework.ExceptionMonitor;
+import org.apache.qpid.test.framework.MessageMonitor;
+import org.apache.qpid.test.framework.NotApplicableAssertion;
+import org.apache.qpid.test.framework.Receiver;
 
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java
index e699529..9b5d40f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/CircuitFactory.java
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.test.framework.sequencers;
 
+import org.apache.qpid.junit.extensions.util.ParsedProperties;
 import org.apache.qpid.test.framework.Assertion;
 import org.apache.qpid.test.framework.Circuit;
 import org.apache.qpid.test.framework.TestClientDetails;
 import org.apache.qpid.test.utils.ConversationFactory;
 
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
 import javax.jms.Connection;
 import java.util.List;
 import java.util.Properties;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java
index 8a9c48d..833f5fb6 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/FanOutCircuitFactory.java
@@ -22,6 +22,7 @@
 
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.junit.extensions.util.ParsedProperties;
 import org.apache.qpid.test.framework.Assertion;
 import org.apache.qpid.test.framework.Circuit;
 import org.apache.qpid.test.framework.TestClientDetails;
@@ -29,10 +30,11 @@
 import org.apache.qpid.test.framework.distributedcircuit.DistributedCircuitImpl;
 import org.apache.qpid.test.utils.ConversationFactory;
 
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-import javax.jms.*;
-
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Properties;
@@ -63,7 +65,7 @@
 public class FanOutCircuitFactory extends BaseCircuitFactory
 {
     /** Used for debugging. */
-    Logger log = Logger.getLogger(FanOutCircuitFactory.class);
+    private Logger log = Logger.getLogger(FanOutCircuitFactory.class);
 
     /**
      * Creates a test circuit for the test, configered by the test parameters specified.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java
index 7df80bb..a4c6888 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/sequencers/InteropCircuitFactory.java
@@ -22,6 +22,7 @@
 
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.junit.extensions.util.ParsedProperties;
 import org.apache.qpid.test.framework.Assertion;
 import org.apache.qpid.test.framework.Circuit;
 import org.apache.qpid.test.framework.TestClientDetails;
@@ -29,10 +30,11 @@
 import org.apache.qpid.test.framework.distributedcircuit.DistributedCircuitImpl;
 import org.apache.qpid.test.utils.ConversationFactory;
 
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-
-import javax.jms.*;
-
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Properties;
@@ -56,7 +58,7 @@
 public class InteropCircuitFactory extends BaseCircuitFactory
 {
     /** Used for debugging. */
-    Logger log = Logger.getLogger(InteropCircuitFactory.class);
+    private Logger log = Logger.getLogger(InteropCircuitFactory.class);
 
     /**
      * Creates a test circuit for the test, configered by the test parameters specified.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java
deleted file mode 100644
index a5a0d4e..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java
+++ /dev/null
@@ -1,119 +0,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.
- *
- */
-package org.apache.qpid.test.testcases;
-
-import org.apache.qpid.test.framework.*;
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.*;
-import org.apache.qpid.test.framework.localcircuit.LocalCircuitImpl;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-/**
- * FailoverTest provides testing of fail-over over a local-circuit implementation. The circuit being tested may be
- * against an in-vm broker or against an external broker, with the failure mechanism abstracted out of the test case.
- * Automatic failures can be simulated against an in-vm broker. Currently the test must interact with the user to
- * simulate failures on an external broker.
- *
- * Things to test:
- * In tx, failure duing tx causes tx to error on subsequent sends/receives or commits/rollbacks.
- * Outside of tx, reconnection allows msg flow to continue but there may be loss.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td>
- * </table>
- *
- * @todo This test is designed to be run over a local circuit only. For in-vm using automatic failures, for external
- *       brokers by prompting the user (or maybe using a script). Enforce the local-circuit only nature of the tests as
- *       well as thinking about how other local-circuit tests might be implemented. For example, could add a method
- *       to the framework base case for local only tests to call, that allows them access to the local-circuit
- *       implementation and so on.
- *
- * @todo More. Need to really expand the set of fail-over tests.
- */
-public class FailoverTest extends FrameworkBaseCase
-{
-    /* Used for debugging purposes. */
-    // private static final Logger log = Logger.getLogger(FailoverTest.class);
-
-    /**
-     * Creates a new test case with the specified name.
-     *
-     * @param name The test case name.
-     */
-    public FailoverTest(String name)
-    {
-        super(name);
-    }
-
-    /**
-     * Checks that all messages sent within a transaction are receieved despite a fail-over occuring outside of
-     * the transaction.
-     *
-     * @throws JMSException Allowed to fall through and fail test.
-     */
-    public void testTxP2PFailover() throws Exception
-    {
-        // Set up the test properties to match the test cases requirements.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        getTestProps().setProperty(ACK_MODE_PROPNAME, Session.AUTO_ACKNOWLEDGE);
-        getTestProps().setProperty(PUBSUB_PROPNAME, false);
-
-        // MessagingTestConfigProperties props = this.getTestParameters();
-
-        // Create the test circuit from the test configuration parameters.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        // Create an assertion that all messages are received.
-        Assertion allMessagesReceived = testCircuit.getReceiver().allMessagesReceivedAssertion(getTestProps());
-
-        // This test case assumes it is using a local circuit.
-        LocalCircuitImpl localCircuit = (LocalCircuitImpl) testCircuit;
-
-        Session producerSession = localCircuit.getLocalPublisherCircuitEnd().getSession();
-        MessageProducer producer = localCircuit.getLocalPublisherCircuitEnd().getProducer();
-        // MessageConsumer consumer = localCircuit.getLocalReceiverCircuitEnd().getConsumer();
-
-        // Send some test messages.
-        for (int i = 0; i < 100; i++)
-        {
-            producer.send(TestUtils.createTestMessageOfSize(producerSession, 10));
-            producerSession.commit();
-
-            // Cause a failover.
-            if (i == 50)
-            {
-                getFailureMechanism().causeFailure();
-            }
-
-            // Wait for the reconnection to complete.
-        }
-
-        // Check that trying to send within the original transaction fails.
-
-        // Check that all messages sent were received.
-        assertTrue("All messages sent were not received back again.", allMessagesReceived.apply());
-    }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java
deleted file mode 100644
index 3001211..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java
+++ /dev/null
@@ -1,303 +0,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.
- *
- */
-package org.apache.qpid.test.testcases;
-
-import org.apache.qpid.test.framework.AMQPPublisher;
-import org.apache.qpid.test.framework.Circuit;
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import org.apache.qpid.test.framework.MessagingTestConfigProperties;
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.*;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-
-import org.apache.qpid.junit.extensions.util.TestContextProperties;
-
-/**
- * ImmediateMessageTest tests for the desired behaviour of immediate messages. Immediate messages are a non-JMS
- * feature. A message may be marked with an immediate delivery flag, which means that a consumer must be connected
- * to receive the message, through a valid route, when it is sent, or when its transaction is committed in the case
- * of transactional messaging. If this is not the case, the broker should return the message with a NO_CONSUMERS code.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Check that an immediate message is sent succesfully not using transactions when a consumer is connected.
- * <tr><td> Check that an immediate message is committed succesfully in a transaction when a consumer is connected.
- * <tr><td> Check that an immediate message results in no consumers code, not using transactions, when a consumer is
- *          disconnected.
- * <tr><td> Check that an immediate message results in no consumers code, in a transaction, when a consumer is
- *          disconnected.
- * <tr><td> Check that an immediate message results in no route code, not using transactions, when no outgoing route is
- *          connected.
- * <tr><td> Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is
- *          connected.
- * <tr><td> Check that an immediate message is sent succesfully not using transactions when a consumer is connected.
- * <tr><td> Check that an immediate message is committed succesfully in a transaction when a consumer is connected.
- * <tr><td> Check that an immediate message results in no consumers code, not using transactions, when a consumer is
- *          disconnected.
- * <tr><td> Check that an immediate message results in no consumers code, in a transaction, when a consumer is
- *          disconnected.
- * <tr><td> Check that an immediate message results in no route code, not using transactions, when no outgoing route is
- *          connected.
- * <tr><td> Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is
- *          connected.
- * </table>
- *
- * @todo All of these test cases will be generated by a test generator that thoroughly tests all combinations of test
- *       circuits.
- */
-public class ImmediateMessageTest extends FrameworkBaseCase
-{
-    /**
-     * Creates a new test case with the specified name.
-     *
-     * @param name The test case name.
-     */
-    public ImmediateMessageTest(String name)
-    {
-        super(name);
-    }
-
-    /** Check that an immediate message is sent succesfully not using transactions when a consumer is connected. */
-    public void test_QPID_517_ImmediateOkNoTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        getTestProps().setProperty(PUBSUB_PROPNAME, false);
-
-        // Run the default test sequence over the test circuit checking for no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noExceptionsAssertion(getTestProps()))));
-    }
-
-    /** Check that an immediate message is committed succesfully in a transaction when a consumer is connected. */
-    public void test_QPID_517_ImmediateOkTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        getTestProps().setProperty(PUBSUB_PROPNAME, false);
-
-        // Send one message with no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noExceptionsAssertion(getTestProps()))));
-    }
-
-    /** Check that an immediate message results in no consumers code, not using transactions, when a consumer is disconnected. */
-    public void test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        getTestProps().setProperty(PUBSUB_PROPNAME, false);
-
-        // Disconnect the consumer.
-        getTestProps().setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
-
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        // Send one message and get a linked no consumers exception.
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noConsumersAssertion(getTestProps()))));
-    }
-
-    /** Check that an immediate message results in no consumers code, in a transaction, when a consumer is disconnected. */
-    public void test_QPID_517_ImmediateFailsConsumerDisconnectedTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        getTestProps().setProperty(PUBSUB_PROPNAME, false);
-
-        // Disconnect the consumer.
-        getTestProps().setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
-
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        // Send one message and get a linked no consumers exception.
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noConsumersAssertion(getTestProps()))));
-    }
-
-    /** Check that an immediate message results in no route code, not using transactions, when no outgoing route is connected. */
-    public void test_QPID_517_ImmediateFailsNoRouteNoTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        getTestProps().setProperty(PUBSUB_PROPNAME, false);
-
-        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
-        // collect its messages).
-        getTestProps().setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
-
-        // Send one message and get a linked no route exception.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(getTestProps()))));
-    }
-
-    /** Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is connected. */
-    public void test_QPID_517_ImmediateFailsNoRouteTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        getTestProps().setProperty(PUBSUB_PROPNAME, false);
-
-        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
-        // collect its messages).
-        getTestProps().setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
-
-        // Send one message and get a linked no route exception.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(getTestProps()))));
-    }
-
-    /** Check that an immediate message is sent succesfully not using transactions when a consumer is connected. */
-    public void test_QPID_517_ImmediateOkNoTxPubSub() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        getTestProps().setProperty(PUBSUB_PROPNAME, true);
-
-        // Send one message with no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(getTestProps()))));
-    }
-
-    /** Check that an immediate message is committed succesfully in a transaction when a consumer is connected. */
-    public void test_QPID_517_ImmediateOkTxPubSub() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        getTestProps().setProperty(PUBSUB_PROPNAME, true);
-
-        // Send one message with no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(getTestProps()))));
-    }
-
-    /** Check that an immediate message results in no consumers code, not using transactions, when a consumer is disconnected. */
-    public void test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxPubSub() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        getTestProps().setProperty(PUBSUB_PROPNAME, true);
-
-        // Use durable subscriptions, so that the route remains open with no subscribers.
-        getTestProps().setProperty(DURABLE_SUBSCRIPTION_PROPNAME, true);
-
-        // Disconnect the consumer.
-        getTestProps().setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
-
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        // Send one message and get a linked no consumers exception.
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noConsumersAssertion(getTestProps()))));
-    }
-
-    /** Check that an immediate message results in no consumers code, in a transaction, when a consumer is disconnected. */
-    public void test_QPID_517_ImmediateFailsConsumerDisconnectedTxPubSub() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        getTestProps().setProperty(PUBSUB_PROPNAME, true);
-
-        // Use durable subscriptions, so that the route remains open with no subscribers.
-        getTestProps().setProperty(DURABLE_SUBSCRIPTION_PROPNAME, true);
-
-        // Disconnect the consumer.
-        getTestProps().setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
-
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        // Send one message and get a linked no consumers exception.
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noConsumersAssertion(getTestProps()))));
-    }
-
-    /** Check that an immediate message results in no route code, not using transactions, when no outgoing route is connected. */
-    public void test_QPID_517_ImmediateFailsNoRouteNoTxPubSub() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        getTestProps().setProperty(PUBSUB_PROPNAME, true);
-
-        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
-        // collect its messages).
-        getTestProps().setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
-
-        // Send one message and get a linked no route exception.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(getTestProps()))));
-    }
-
-    /** Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is connected. */
-    public void test_QPID_517_ImmediateFailsNoRouteTxPubSub() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        getTestProps().setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        getTestProps().setProperty(PUBSUB_PROPNAME, true);
-
-        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
-        // collect its messages).
-        getTestProps().setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
-
-        // Send one message and get a linked no route exception.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(getTestProps()))));
-    }
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-
-        setTestProps(TestContextProperties.getInstance(MessagingTestConfigProperties.defaults));
-
-        /** All these tests should have the immediate flag on. */
-        getTestProps().setProperty(IMMEDIATE_PROPNAME, true);
-        getTestProps().setProperty(MANDATORY_PROPNAME, false);
-
-        /** Bind the receivers consumer by default. */
-        getTestProps().setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, true);
-        getTestProps().setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, true);
-    }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/MandatoryMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/MandatoryMessageTest.java
deleted file mode 100644
index b4c4eb9..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/MandatoryMessageTest.java
+++ /dev/null
@@ -1,321 +0,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.
- *
- */
-package org.apache.qpid.test.testcases;
-
-import org.apache.qpid.test.framework.AMQPPublisher;
-import org.apache.qpid.test.framework.Circuit;
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import org.apache.qpid.test.framework.MessagingTestConfigProperties;
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.*;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.junit.extensions.util.TestContextProperties;
-
-/**
- * MandatoryMessageTest tests for the desired behaviour of mandatory messages. Mandatory messages are a non-JMS
- * feature. A message may be marked with a mandatory delivery flag, which means that a valid route for the message
- * must exist, when it is sent, or when its transaction is committed in the case of transactional messaging. If this
- * is not the case, the broker should return the message with a NO_CONSUMERS code.
- *
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Check that an mandatory message is sent succesfully not using transactions when a consumer is connected.
- * <tr><td> Check that an mandatory message is committed succesfully in a transaction when a consumer is connected.
- * <tr><td> Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected
- *          but the route exists.
- * <tr><td> Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but
- *          the route exists.
- * <tr><td> Check that an mandatory message results in no route code, not using transactions, when no consumer is
- *          connected.
- * <tr><td> Check that an mandatory message results in no route code, upon transaction commit, when a consumer is
- *          connected.
- * <tr><td> Check that an mandatory message is sent succesfully not using transactions when a consumer is connected.
- * <tr><td> Check that an mandatory message is committed succesfully in a transaction when a consumer is connected.
- * <tr><td> Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected
- *          but the route exists.
- * <tr><td> Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but
- *          the route exists.
- * <tr><td> Check that an mandatory message results in no route code, not using transactions, when no consumer is
- *          connected.
- * <tr><td> Check that an mandatory message results in no route code, upon transaction commit, when a consumer is
- *          connected.
- * </table>
- *
- * @todo All of these test cases will be generated by a test generator that thoroughly tests all combinations of test
- *       circuits.
- */
-public class MandatoryMessageTest extends FrameworkBaseCase
-{
-    /** Used to read the tests configurable properties through. */
-    ParsedProperties testProps;
-
-    /**
-     * Creates a new test case with the specified name.
-     *
-     * @param name The test case name.
-     */
-    public MandatoryMessageTest(String name)
-    {
-        super(name);
-    }
-
-    /** Check that an mandatory message is sent succesfully not using transactions when a consumer is connected. */
-    public void test_QPID_508_MandatoryOkNoTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        testProps.setProperty(PUBSUB_PROPNAME, false);
-
-        // Run the default test sequence over the test circuit checking for no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
-    }
-
-    /** Check that an mandatory message is committed succesfully in a transaction when a consumer is connected. */
-    public void test_QPID_508_MandatoryOkTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        testProps.setProperty(PUBSUB_PROPNAME, false);
-
-        // Run the default test sequence over the test circuit checking for no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
-    }
-
-    /**
-     * Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected but
-     * the route exists.
-     */
-    public void test_QPID_517_MandatoryOkConsumerDisconnectedNoTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        testProps.setProperty(PUBSUB_PROPNAME, false);
-
-        // Disconnect the consumer.
-        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
-
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        // Send one message with no errors.
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
-    }
-
-    /**
-     * Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but
-     * the route exists.
-     */
-    public void test_QPID_517_MandatoryOkConsumerDisconnectedTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        testProps.setProperty(PUBSUB_PROPNAME, false);
-
-        // Disconnect the consumer.
-        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
-
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        // Send one message with no errors.
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
-    }
-
-    /** Check that an mandatory message results in no route code, not using transactions, when no consumer is connected. */
-    public void test_QPID_508_MandatoryFailsNoRouteNoTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        testProps.setProperty(PUBSUB_PROPNAME, false);
-
-        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
-        // collect its messages).
-        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
-
-        // Send one message and get a linked no route exception.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
-    }
-
-    /** Check that an mandatory message results in no route code, upon transaction commit, when a consumer is connected. */
-    public void test_QPID_508_MandatoryFailsNoRouteTxP2P() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        testProps.setProperty(PUBSUB_PROPNAME, false);
-
-        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
-        // collect its messages).
-        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
-
-        // Send one message and get a linked no route exception.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
-    }
-
-    /** Check that an mandatory message is sent succesfully not using transactions when a consumer is connected. */
-    public void test_QPID_508_MandatoryOkNoTxPubSub() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        testProps.setProperty(PUBSUB_PROPNAME, true);
-
-        // Run the default test sequence over the test circuit checking for no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
-    }
-
-    /** Check that an mandatory message is committed succesfully in a transaction when a consumer is connected. */
-    public void test_QPID_508_MandatoryOkTxPubSub() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        testProps.setProperty(PUBSUB_PROPNAME, true);
-
-        // Run the default test sequence over the test circuit checking for no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
-    }
-
-    /**
-     * Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected but
-     * the route exists.
-     */
-    public void test_QPID_517_MandatoryOkConsumerDisconnectedNoTxPubSub()  throws Exception
-    {
-        // Ensure transactional sessions are off.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        testProps.setProperty(PUBSUB_PROPNAME, true);
-
-        // Use durable subscriptions, so that the route remains open with no subscribers.
-        testProps.setProperty(DURABLE_SUBSCRIPTION_PROPNAME, true);
-
-        // Disconnect the consumer.
-        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
-
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        // Send one message with no errors.
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
-    }
-
-    /**
-     * Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but
-     * the route exists.
-     */
-    public void test_QPID_517_MandatoryOkConsumerDisconnectedTxPubSub() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        testProps.setProperty(PUBSUB_PROPNAME, true);
-
-        // Use durable subscriptions, so that the route remains open with no subscribers.
-        testProps.setProperty(DURABLE_SUBSCRIPTION_PROPNAME, true);
-
-        // Disconnect the consumer.
-        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
-
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        // Send one message with no errors.
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
-    }
-
-    /** Check that an mandatory message results in no route code, not using transactions, when no consumer is connected. */
-    public void test_QPID_508_MandatoryFailsNoRouteNoTxPubSub() throws Exception
-    {
-        // Ensure transactional sessions are off.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        testProps.setProperty(PUBSUB_PROPNAME, true);
-
-        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
-        // collect its messages).
-        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
-
-        // Send one message and get a linked no route exception.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
-    }
-
-    /** Check that an mandatory message results in no route code, upon transaction commit, when a consumer is connected. */
-    public void test_QPID_508_MandatoryFailsNoRouteTxPubSub() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        testProps.setProperty(PUBSUB_PROPNAME, true);
-
-        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
-        // collect its messages).
-        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
-
-        // Send one message and get a linked no route exception.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
-    }
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-
-        testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
-
-        /** All these tests should have the mandatory flag on. */
-        testProps.setProperty(IMMEDIATE_PROPNAME, false);
-        testProps.setProperty(MANDATORY_PROPNAME, true);
-
-        /** Bind the receivers consumer by default. */
-        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, true);
-        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, true);
-    }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/RollbackTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/RollbackTest.java
deleted file mode 100644
index edcde79..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/RollbackTest.java
+++ /dev/null
@@ -1,132 +0,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.
- *
- */
-package org.apache.qpid.test.testcases;
-
-import org.apache.qpid.test.framework.Circuit;
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import org.apache.qpid.test.framework.MessagingTestConfigProperties;
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.*;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-
-import org.apache.qpid.junit.extensions.util.ParsedProperties;
-import org.apache.qpid.junit.extensions.util.TestContextProperties;
-
-/**
- * RollbackTest tests the rollback ability of transactional messaging.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Check messages sent but rolled back are never received.
- * <tr><td> Check messages received but rolled back are redelivered on subsequent receives.
- * <tr><td> Attempting to rollback outside of a transaction results in an IllegalStateException.
- * </table>
- */
-public class RollbackTest extends FrameworkBaseCase
-{
-    /** Used to read the tests configurable properties through. */
-    private ParsedProperties testProps;
-
-    /**
-     * Creates a new test case with the specified name.
-     *
-     * @param name The test case name.
-     */
-    public RollbackTest(String name)
-    {
-        super(name);
-    }
-
-    /** Check messages sent but rolled back are never received. */
-    public void testRolledbackMessageNotDelivered() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
-        testProps.setProperty(ROLLBACK_PUBLISHER_PROPNAME, true);
-
-        // Run the default test sequence over the test circuit checking for no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(testCircuit.getPublisher().noExceptionsAssertion(testProps),
-                    testCircuit.getReceiver().noMessagesReceivedAssertion(testProps))));
-    }
-
-    /** Check messages received but rolled back are redelivered on subsequent receives. */
-    public void testRolledbackMessagesSubsequentlyReceived() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        testProps.setProperty(TRANSACTED_RECEIVER_PROPNAME, true);
-        testProps.setProperty(ROLLBACK_RECEIVER_PROPNAME, true);
-
-        // Run the default test sequence over the test circuit checking for no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1,
-                assertionList(testCircuit.getPublisher().noExceptionsAssertion(testProps),
-                    testCircuit.getReceiver().allMessagesReceivedAssertion(testProps))));
-    }
-
-    /** Attempting to rollback outside of a transaction results in an IllegalStateException. */
-    public void testRollbackUnavailableOutsideTransactionPublisher() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
-        testProps.setProperty(ROLLBACK_PUBLISHER_PROPNAME, true);
-
-        // Run the default test sequence over the test circuit checking for no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().channelClosedAssertion(testProps))));
-    }
-
-    /** Attempting to rollback outside of a transaction results in an IllegalStateException. */
-    public void testRollbackUnavailableOutsideTransactionReceiver() throws Exception
-    {
-        // Ensure transactional sessions are on.
-        testProps.setProperty(TRANSACTED_RECEIVER_PROPNAME, false);
-        testProps.setProperty(ROLLBACK_RECEIVER_PROPNAME, true);
-
-        // Run the default test sequence over the test circuit checking for no errors.
-        CircuitFactory circuitFactory = getCircuitFactory();
-        Circuit testCircuit = circuitFactory.createCircuit(getConnection(), testProps);
-
-        assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getReceiver().channelClosedAssertion(testProps))));
-    }
-
-    /**
-     * Sets up all tests to have an active outward route and consumer by default.
-     *
-     * @throws Exception Any exceptions are allowed to fall through and fail the test.
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-
-        testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
-
-        /** Bind the receivers consumer by default. */
-        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, true);
-        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, true);
-    }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeTest.java
index e6461c8..841d0ea 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/AcknowledgeTest.java
@@ -29,9 +29,9 @@
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
-import javax.jms.MessageProducer;
 
 /**
  * Test the various JMS Acknowledge Modes the single testAcking method does all
@@ -56,7 +56,6 @@
 
         _queue = getTestQueue();
 
-        _logger.info("AT: setup");
         //Create Producer put some messages on the queue
         _connection = getConnection();
     }
@@ -70,13 +69,10 @@
         // These should all end up being prefetched by session
         sendMessage(_consumerSession, _queue, 1);
 
-        if(!transacted)
-        {
-            ((AMQSession)_consumerSession).sync();
-        }
+        syncIfNotTransacted(transacted);
 
         assertEquals("Wrong number of messages on queue", 1,
-                     ((AMQSession) _consumerSession).getQueueDepth((AMQDestination) _queue));
+                     ((AMQSession<?,?>) _consumerSession).getQueueDepth((AMQDestination) _queue));
     }
 
     /**
@@ -114,6 +110,7 @@
             {
                 //Send the next message
                 _producer.send(createNextMessage(_consumerSession, count));
+                syncIfNotTransacted(transacted);
             }
 
             doAcknowlegement(msg);
@@ -128,7 +125,7 @@
         }
 
         assertEquals("Wrong number of messages on queue", 0,
-                     ((AMQSession) _consumerSession).getQueueDepth((AMQDestination) _queue));
+                     ((AMQSession<?,?>) _consumerSession).getQueueDepth((AMQDestination) _queue));
     }
 
     /**
@@ -181,4 +178,11 @@
         testAcking(false, AMQSession.PRE_ACKNOWLEDGE);
     }
 
+    private void syncIfNotTransacted(boolean transacted) throws Exception
+    {
+        if(!transacted)
+        {
+            ((AMQSession<?,?>)_consumerSession).sync();
+        }
+    }
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/ClientAcknowledgeTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/ClientAcknowledgeTest.java
index 06be5cf..291e169 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/ClientAcknowledgeTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/ClientAcknowledgeTest.java
@@ -18,6 +18,8 @@
  */
 package org.apache.qpid.test.unit.ack;
 
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
@@ -25,8 +27,6 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 public class ClientAcknowledgeTest extends QpidBrokerTestCase
 {
     private static final long ONE_DAY_MS = 1000l * 60 * 60 * 24;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/RecoverTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/RecoverTest.java
index 2fd3811..23ea4ac 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/RecoverTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/RecoverTest.java
@@ -19,15 +19,15 @@
  */
 package org.apache.qpid.test.unit.ack;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.configuration.ClientProperties;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.jms.Session;
-import org.apache.qpid.test.utils.FailoverBaseCase;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.jms.Connection;
 import javax.jms.Destination;
@@ -38,7 +38,6 @@
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.TextMessage;
-
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -383,8 +382,8 @@
 
         cons.setMessageListener(new MessageListener()
         {               
-            int messageSeen = 0;
-            int expectedIndex = 0;
+            private int messageSeen = 0;
+            private int expectedIndex = 0;
 
             public void onMessage(Message message)
             {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
index 0731d56..a121b39 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
@@ -20,7 +20,8 @@
 package org.apache.qpid.test.unit.basic;
 
 import junit.framework.Assert;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQDestination;
@@ -30,20 +31,17 @@
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.transport.util.Waiter;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.jms.BytesMessage;
 import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
+import javax.jms.MessageConsumer;
 import javax.jms.MessageListener;
 import javax.jms.MessageNotReadableException;
 import javax.jms.MessageNotWriteableException;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
-
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -281,4 +279,46 @@
         test._count = count;
         test.test();
     }
+
+    public void testModificationAfterSend() throws Exception
+    {
+        Connection connection = getConnection();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        BytesMessage jmsMsg = session.createBytesMessage();
+        Destination destination = getTestQueue();
+
+        /* Set the constant message contents. */
+
+        jmsMsg.setStringProperty("foo", "test");
+
+        /* Pre-populate the message body buffer to the target size. */
+        byte[] jmsMsgBodyBuffer = new byte[1024];
+
+        connection.start();
+
+        /* Send messages. */
+        MessageProducer producer = session.createProducer(destination);
+
+        MessageConsumer consumer = session.createConsumer(destination);
+        
+        for(int writtenMsgCount = 0; writtenMsgCount < 10; writtenMsgCount++)
+        {
+            /* Set the per send message contents. */
+            jmsMsgBodyBuffer[0] = (byte) writtenMsgCount;
+            jmsMsg.writeBytes(jmsMsgBodyBuffer, 0, jmsMsgBodyBuffer.length);
+            /** Try to write a message. */
+            producer.send(jmsMsg);
+        }
+
+
+        for(int writtenMsgCount = 0; writtenMsgCount < 10; writtenMsgCount++)
+        {
+            BytesMessage recvdMsg = (BytesMessage) consumer.receive(1000L);
+            assertNotNull("Expected to receive message " + writtenMsgCount + " but did not", recvdMsg);
+            assertEquals("Message "+writtenMsgCount+" not of expected size", (long) ((writtenMsgCount + 1)*1024),
+                         recvdMsg.getBodyLength());
+
+        }
+    }
+
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
index 3af215d..599c806 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
@@ -20,6 +20,9 @@
  */
 package org.apache.qpid.test.unit.basic;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQQueue;
@@ -30,15 +33,11 @@
 import org.apache.qpid.framing.FieldTableFactory;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.jms.BytesMessage;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
 import javax.jms.MessageProducer;
-
 import java.io.ByteArrayInputStream;
 import java.io.DataInputStream;
 import java.io.IOException;
@@ -56,7 +55,7 @@
     private final ArrayList<JMSBytesMessage> received = new ArrayList<JMSBytesMessage>();
     private FieldTable _expected;
     private int _count = 10;
-    public String _connectionString = "vm://:1";
+    private String _connectionString = "vm://:1";
     private CountDownLatch _waitForCompletion;
 
     protected void setUp() throws Exception
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/InvalidDestinationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/InvalidDestinationTest.java
index c9f6a22..53f37cd 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/InvalidDestinationTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/InvalidDestinationTest.java
@@ -25,12 +25,12 @@
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import javax.jms.Session;
-import javax.jms.QueueSession;
+import javax.jms.InvalidDestinationException;
 import javax.jms.Queue;
 import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
 import javax.jms.TextMessage;
-import javax.jms.InvalidDestinationException;
 
 public class InvalidDestinationTest extends QpidBrokerTestCase
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java
index d97e22e..7bd737e 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java
@@ -21,14 +21,14 @@
 package org.apache.qpid.test.unit.basic;
 
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.MessageConsumer;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MapMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
index 9f13ddc..3f99893 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
@@ -21,6 +21,8 @@
 package org.apache.qpid.test.unit.basic;
 
 import junit.framework.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQQueue;
@@ -28,9 +30,6 @@
 import org.apache.qpid.client.message.JMSMapMessage;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.MapMessage;
@@ -40,7 +39,6 @@
 import javax.jms.MessageNotWriteableException;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
-
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
index 87eae32..3c26cbb 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
@@ -19,6 +19,9 @@
  */
 package org.apache.qpid.test.unit.basic;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQSession;
@@ -26,9 +29,6 @@
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
@@ -72,6 +72,11 @@
         {
             _connection.close();
         }
+
+        public MessageCounter[] getCounters()
+        {
+            return _counters;
+        }
     }
 
     private class Publisher
@@ -151,7 +156,7 @@
     {
         for (int i = 0; i < receivers.length; i++)
         {
-            waitForCompletion(expected, wait, receivers[i]._counters);
+            waitForCompletion(expected, wait, receivers[i].getCounters());
         }
     }
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
index c8e7368..10d53b7 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
@@ -20,6 +20,8 @@
 package org.apache.qpid.test.unit.basic;
 
 import junit.framework.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQDestination;
@@ -28,15 +30,11 @@
 import org.apache.qpid.client.message.JMSObjectMessage;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
 import javax.jms.MessageNotWriteableException;
 import javax.jms.MessageProducer;
-
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Iterator;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
index 3b8b494..52213d1 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
@@ -20,20 +20,14 @@
  */
 package org.apache.qpid.test.unit.basic;
 
-import junit.framework.Assert;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.message.JMSTextMessage;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.url.BindingURL;
-import org.apache.qpid.url.AMQBindingURL;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 import javax.jms.Connection;
 import javax.jms.Destination;
@@ -45,30 +39,33 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.net.URISyntaxException;
+import junit.framework.Assert;
 
-import java.lang.reflect.*;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.message.JMSTextMessage;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class PropertyValueTest extends QpidBrokerTestCase implements MessageListener
 {
     private static final Logger _logger = LoggerFactory.getLogger(PropertyValueTest.class);
 
-    private int count = 0;
     private AMQConnection _connection;
     private Destination _destination;
     private AMQSession _session;
     private final List<JMSTextMessage> received = new ArrayList<JMSTextMessage>();
     private final List<String> messages = new ArrayList<String>();
+    private Map<String, Destination> _replyToDestinations;
     private int _count = 1;
     public String _connectionString = "vm://:1";
     private static final String USERNAME = "guest";
 
     protected void setUp() throws Exception
     {
+        _replyToDestinations = new HashMap<String, Destination>();
         super.setUp();
     }
 
@@ -239,13 +236,12 @@
             }
 
             m.setJMSReplyTo(q);
-            m.setStringProperty("TempQueue", q.toString());
+
+            m.setStringProperty("ReplyToIndex", String.valueOf(i));
+            _replyToDestinations.put(String.valueOf(i), q);
 
             _logger.debug("Message:" + m);
 
-            Assert.assertEquals("Check temp queue has been set correctly", m.getJMSReplyTo().toString(),
-                m.getStringProperty("TempQueue"));
-
             m.setJMSType("Test");
             m.setLongProperty("UnsignedInt", (long) 4294967295L);
             m.setLongProperty("Long", (long) Long.MAX_VALUE);
@@ -292,8 +288,8 @@
             Assert.assertEquals("Check Priority properties are correctly transported", 8, m.getJMSPriority());
 
             // Queue
-            Assert.assertEquals("Check ReplyTo properties are correctly transported", AMQDestination.createDestination(new AMQBindingURL(m.getStringProperty("TempQueue"))),
-                m.getJMSReplyTo());
+            String replyToIndex = m.getStringProperty("ReplyToIndex");
+            Assert.assertEquals("Check ReplyTo properties are correctly transported", _replyToDestinations.get(replyToIndex), m.getJMSReplyTo());
 
             Assert.assertEquals("Check Type properties are correctly transported", "Test", m.getJMSType());
 
@@ -304,24 +300,7 @@
             Assert.assertEquals("Check Long properties are correctly transported", (long) Long.MAX_VALUE,
                 m.getLongProperty("Long"));
             Assert.assertEquals("Check String properties are correctly transported", "Test", m.getStringProperty("String"));
-/*
-            // AMQP Tests Specific values
 
-            Assert.assertEquals("Check Timestamp properties are correctly transported", m.getStringProperty("time-str"),
-                ((AMQMessage) m).getTimestampProperty(new AMQShortString("time")).toString());
-
-            // Decimal
-            BigDecimal bd = new BigDecimal(Integer.MAX_VALUE);
-
-            Assert.assertEquals("Check decimal properties are correctly transported", bd.setScale(Byte.MAX_VALUE),
-                ((AMQMessage) m).getDecimalProperty(new AMQShortString("decimal")));
-
-            // Void
-            ((AMQMessage) m).setVoidProperty(new AMQShortString("void"));
-
-            Assert.assertTrue("Check void properties are correctly transported",
-                              ((AMQMessage) m).getPropertyHeaders().containsKey("void"));
-*/
             //JMSXUserID
             if (m.getStringProperty("JMSXUserID") != null)
             {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/PubSubTwoConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/PubSubTwoConnectionTest.java
index c257dac..3ef8524 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/PubSubTwoConnectionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/PubSubTwoConnectionTest.java
@@ -20,6 +20,11 @@
  */
 package org.apache.qpid.test.unit.basic;
 
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
@@ -27,11 +32,6 @@
 import javax.jms.TextMessage;
 import javax.jms.Topic;
 
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 /**
  * @author Apache Software Foundation
  */
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/ReceiveTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
index bc44617..c764eda 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
@@ -20,15 +20,15 @@
  */
 package org.apache.qpid.test.unit.basic;
 
-import javax.jms.MessageConsumer;
-import javax.jms.Message;
-
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+
 public class ReceiveTest extends QpidBrokerTestCase
 {
     private AMQConnection _connection;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/SessionStartTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
index ee837fd..cc64dbb 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
@@ -20,6 +20,9 @@
  */
 package org.apache.qpid.test.unit.basic;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQQueue;
@@ -27,9 +30,6 @@
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/TextMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
index a87de8a..0a568d5 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
@@ -21,6 +21,8 @@
 package org.apache.qpid.test.unit.basic;
 
 import junit.framework.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQQueue;
@@ -29,9 +31,6 @@
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -39,7 +38,6 @@
 import javax.jms.MessageNotWriteableException;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
-
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java
index 3c7962d..48d290c 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java
@@ -19,12 +19,13 @@
  *
  */
 package org.apache.qpid.test.unit.basic.close;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.client.AMQConnection;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQSessionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQSessionTest.java
index c33dde5..0d81b66 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQSessionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQSessionTest.java
@@ -20,16 +20,16 @@
  */
 package org.apache.qpid.test.unit.client;
 
-import javax.jms.JMSException;
-import javax.jms.QueueReceiver;
-import javax.jms.TopicSubscriber;
-
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.client.AMQTopic;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
+import javax.jms.JMSException;
+import javax.jms.QueueReceiver;
+import javax.jms.TopicSubscriber;
+
 /**
  * Tests for QueueReceiver and TopicSubscriber creation methods on AMQSession
  */
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/MaxDeliveryCountTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/MaxDeliveryCountTest.java
index e59dac8..fa0fe7e 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/MaxDeliveryCountTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/MaxDeliveryCountTest.java
@@ -20,10 +20,15 @@
  */
 package org.apache.qpid.test.unit.client;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.server.queue.AMQQueueFactory;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.Destination;
@@ -35,15 +40,10 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.Topic;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.configuration.ClientProperties;
-import org.apache.qpid.server.queue.AMQQueueFactory;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Test that the MaxRedelivery feature works as expected, allowing the client to reject
@@ -298,7 +298,7 @@
         consumer.close();
 
         //check the source queue is now empty
-        assertEquals("The queue should have 0 msgs left", 0, ((AMQSession<?,?>) clientSession).getQueueDepth(checkQueue));
+        assertEquals("The queue should have 0 msgs left", 0, ((AMQSession<?,?>) clientSession).getQueueDepth(checkQueue, true));
 
         //check the DLQ has the required number of rejected-without-requeue messages
         verifyDLQdepth(redeliverMsgs.size(), clientSession, durableSub);
@@ -341,7 +341,7 @@
         }
 
         assertEquals("The DLQ should have " + expected + " msgs on it", expected,
-                        ((AMQSession<?,?>) clientSession).getQueueDepth(checkQueueDLQ));
+                        ((AMQSession<?,?>) clientSession).getQueueDepth(checkQueueDLQ, true));
     }
 
     private void verifyDLQcontent(Connection clientConnection, List<Integer> redeliverMsgs, String destName, boolean durableSub) throws JMSException
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/QueueSessionFactoryTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/QueueSessionFactoryTest.java
index ef90ab8..370e44b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/QueueSessionFactoryTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/QueueSessionFactoryTest.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.test.unit.client;
 
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.QueueConnection;
 import javax.jms.QueueSession;
 import javax.jms.Session;
 import javax.jms.Topic;
 import javax.jms.TopicSession;
 
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 /**
  * Ensures that queue specific session factory method {@link QueueConnection#createQueueSession()} create sessions
  * of type {@link QueueSession} and that those sessions correctly restrict the available JMS operations
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/TopicSessionFactoryTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/TopicSessionFactoryTest.java
index 6397f15..ce15d45 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/TopicSessionFactoryTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/TopicSessionFactoryTest.java
@@ -20,14 +20,14 @@
  */
 package org.apache.qpid.test.unit.client;
 
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Queue;
 import javax.jms.QueueSession;
 import javax.jms.Session;
 import javax.jms.TopicConnection;
 import javax.jms.TopicSession;
 
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 /**
  * Ensures that topic specific session factory method {@link TopicConnection#createTopicSession()} create sessions
  * of type {@link TopicSession} and that those sessions correctly restrict the available JMS operations
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
index aae8b1f..1c9ee27 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
@@ -21,14 +21,13 @@
 package org.apache.qpid.test.unit.client.channelclose;
 
 import junit.textui.TestRunner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.jms.Destination;
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
@@ -37,7 +36,6 @@
 import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
-
 import java.util.ArrayList;
 import java.util.List;
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java
index 2e8a2d0..c20eefd 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java
@@ -20,17 +20,23 @@
  */
 package org.apache.qpid.test.unit.client.channelclose;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.failover.FailoverException;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.framing.*;
+import org.apache.qpid.framing.AMQFrame;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.ChannelCloseOkBody;
+import org.apache.qpid.framing.ChannelOpenBody;
+import org.apache.qpid.framing.ChannelOpenOkBody;
+import org.apache.qpid.framing.ExchangeDeclareBody;
+import org.apache.qpid.framing.ExchangeDeclareOkBody;
 import org.apache.qpid.jms.ConnectionListener;
 import org.apache.qpid.protocol.AMQConstant;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.ExceptionListener;
@@ -46,7 +52,7 @@
 {
     private static final Logger _logger = LoggerFactory.getLogger(ChannelCloseTest.class);
 
-    Connection _connection;
+    private Connection _connection;
     private Session _session;
     private static final long SYNC_TIMEOUT = 500;
     private int TEST = 0;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/CloseWithBlockingReceiveTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/CloseWithBlockingReceiveTest.java
index 56d03dc..b7874ee 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/CloseWithBlockingReceiveTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/CloseWithBlockingReceiveTest.java
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.test.unit.client.channelclose;
 
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQTopic;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+
 /**
  * @author Apache Software Foundation
  */
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java
new file mode 100644
index 0000000..6b83929
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java
@@ -0,0 +1,127 @@
+/*
+ *
+ * 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.test.unit.client.connection;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.qpid.AMQConnectionClosedException;
+import org.apache.qpid.AMQDisconnectedException;
+import org.apache.qpid.management.jmx.ManagedConnectionMBeanTest;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.transport.ConnectionException;
+
+import javax.jms.Connection;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Session;
+
+/**
+ * Tests the behaviour of the client when the Broker terminates client connection
+ * by the Broker being shutdown gracefully or otherwise.
+ *
+ * @see ManagedConnectionMBeanTest
+ */
+public class BrokerClosesClientConnectionTest extends QpidBrokerTestCase
+{
+    private Connection _connection;
+    private boolean _isExternalBroker;
+    private final RecordingExceptionListener _recordingExceptionListener = new RecordingExceptionListener();
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        _connection = getConnection();
+        _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        _connection.setExceptionListener(_recordingExceptionListener);
+
+        _isExternalBroker = isExternalBroker();
+    }
+
+    public void testClientCloseOnNormalBrokerShutdown() throws Exception
+    {
+        final Class<? extends Exception> expectedLinkedException = isBroker010() ? ConnectionException.class : AMQConnectionClosedException.class;
+
+        stopBroker();
+
+        JMSException exception = _recordingExceptionListener.awaitException(10000);
+        assertConnectionCloseWasReported(exception, expectedLinkedException);
+
+        ensureCanCloseWithoutException();
+    }
+
+    public void testClientCloseOnBrokerKill() throws Exception
+    {
+        final Class<? extends Exception> expectedLinkedException = isBroker010() ? ConnectionException.class : AMQDisconnectedException.class;
+
+        if (!_isExternalBroker)
+        {
+            return;
+        }
+
+        killBroker();
+
+        JMSException exception = _recordingExceptionListener.awaitException(10000);
+        assertConnectionCloseWasReported(exception, expectedLinkedException);
+
+        ensureCanCloseWithoutException();
+    }
+
+    private void ensureCanCloseWithoutException()
+    {
+        try
+        {
+            _connection.close();
+        }
+        catch (JMSException e)
+        {
+            fail("Connection should close without exception" + e.getMessage());
+        }
+    }
+
+    private void assertConnectionCloseWasReported(JMSException exception, Class<? extends Exception> linkedExceptionClass)
+    {
+        assertNotNull("Broker shutdown should be reported to the client via the ExceptionListener", exception);
+        assertNotNull("JMXException should have linked exception", exception.getLinkedException());
+
+        assertEquals("Unexpected linked exception", linkedExceptionClass, exception.getLinkedException().getClass());
+    }
+
+    private final class RecordingExceptionListener implements ExceptionListener
+    {
+        private final CountDownLatch _exceptionReceivedLatch = new CountDownLatch(1);
+        private volatile JMSException _exception;
+
+        @Override
+        public void onException(JMSException exception)
+        {
+            _exception = exception;
+        }
+
+        public JMSException awaitException(long timeoutInMillis) throws InterruptedException
+        {
+            _exceptionReceivedLatch.await(timeoutInMillis, TimeUnit.MILLISECONDS);
+            return _exception;
+        }
+    }
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java
deleted file mode 100644
index 20044b7..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java
+++ /dev/null
@@ -1,62 +0,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.
- *
- */
-package org.apache.qpid.test.unit.client.connection;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Session;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-/**
- * ConnectionCloseTest
- *
- */
-
-public class ConnectionCloseTest extends QpidBrokerTestCase
-{
-
-    /**
-     * This test is added due to QPID-3453 to test connection closing when AMQ
-     * session is not closed but underlying transport session is in detached
-     * state and transport connection is closed
-     */
-    public void testConnectionCloseOnOnForcibleBrokerStop() throws Exception
-    {
-        Connection connection = getConnection();
-        connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        stopBroker();
-
-        // we need to close connection explicitly in order to verify that
-        // closing of connection having transport session in DETACHED state and
-        // transport connection in CLOSED state does not throw an exception
-        try
-        {
-            connection.close();
-        }
-        catch (JMSException e)
-        {
-            // session closing should not fail
-            fail("Cannot close connection:" + e.getMessage());
-        }
-    }
-
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionStartTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionStartTest.java
index ac14f8e..0650531 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionStartTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionStartTest.java
@@ -20,8 +20,10 @@
  */
 package org.apache.qpid.test.unit.client.connection;
 
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -30,18 +32,15 @@
 import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 public class ConnectionStartTest extends QpidBrokerTestCase
 {
 
-    String _broker = "vm://:1";
+    private String _broker = "vm://:1";
 
-    AMQConnection _connection;
+    private AMQConnection _connection;
     private Session _consumerSess;
     private MessageConsumer _consumer;
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
index f18f365..375626a 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
@@ -20,10 +20,6 @@
  */
 package org.apache.qpid.test.unit.client.connection;
 
-import javax.jms.Connection;
-import javax.jms.QueueSession;
-import javax.jms.TopicSession;
-
 import org.apache.qpid.AMQConnectionFailureException;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQUnresolvedAddressException;
@@ -40,12 +36,16 @@
 import org.apache.qpid.jms.Session;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
+import javax.jms.Connection;
+import javax.jms.QueueSession;
+import javax.jms.TopicSession;
+
 public class ConnectionTest extends QpidBrokerTestCase
 {
 
-    String _broker_NotRunning = "tcp://localhost:" + findFreePort();
+    private String _broker_NotRunning = "tcp://localhost:" + findFreePort();
 
-    String _broker_BadDNS = "tcp://hg3sgaaw4lgihjs";
+    private String _broker_BadDNS = "tcp://hg3sgaaw4lgihjs";
 
     public void testSimpleConnection() throws Exception
     {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java
deleted file mode 100644
index 0057422..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java
+++ /dev/null
@@ -1,64 +0,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.
- *
- */
-package org.apache.qpid.test.unit.client.connection;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import javax.jms.Connection;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-
-/**
- * ExceptionListenerTest
- *
- */
-
-public class ExceptionListenerTest extends QpidBrokerTestCase
-{
-
-    public void testBrokerDeath() throws Exception
-    {
-        Connection conn = getConnection("guest", "guest");
-
-        conn.start();
-
-        final CountDownLatch fired = new CountDownLatch(1);
-        conn.setExceptionListener(new ExceptionListener()
-        {
-            public void onException(JMSException e)
-            {
-                _logger.debug("&&&&&&&&&&&&&&&&&&&&&&&&&&&& Caught exception &&&&&&&&&&&&&&&&&&&&&&&&&&&& ", e);
-                fired.countDown();
-            }
-        });
-        _logger.debug("%%%%%%%%%%%%%%%% Stopping Broker %%%%%%%%%%%%%%%%%%%%%");
-        stopBroker();
-        _logger.debug("%%%%%%%%%%%%%%%% Stopped Broker  %%%%%%%%%%%%%%%%%%%%%");
-
-        if (!fired.await(5, TimeUnit.SECONDS))
-        {
-            fail("exception listener was not fired");
-        }
-    }
-
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/Client.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/Client.java
deleted file mode 100644
index b60fe76..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/Client.java
+++ /dev/null
@@ -1,143 +0,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.
- *
- */
-package org.apache.qpid.test.unit.client.forwardall;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-
-/**
- * Declare a private temporary response queue,
- * send a message to amq.direct with a well known routing key with the
- * private response queue as the reply-to destination
- * consume responses.
- */
-public class Client implements MessageListener
-{
-    private static final Logger _logger = LoggerFactory.getLogger(Client.class);
-
-    private final AMQConnection _connection;
-    private final AMQSession _session;
-    private final int _expected;
-    private int _count;
-    private static QpidBrokerTestCase _qct;
-
-    Client(String broker, int expected) throws Exception
-    {
-        this(connect(broker), expected);
-    }
-
-    public static void setQTC(QpidBrokerTestCase qtc)
-    {
-        _qct = qtc;
-    }
-    Client(AMQConnection connection, int expected) throws Exception
-    {
-        _connection = connection;
-        _expected = expected;
-        _session = (AMQSession) _connection.createSession(true, AMQSession.NO_ACKNOWLEDGE);
-        AMQQueue response =
-            new AMQQueue(_connection.getDefaultQueueExchangeName(), new AMQShortString("ResponseQueue"), true);
-        _session.createConsumer(response).setMessageListener(this);
-        _connection.start();
-      //  AMQQueue service = new SpecialQueue(_connection, "ServiceQueue");
-        AMQQueue service  = (AMQQueue)  _session.createQueue("ServiceQueue") ;
-        Message request = _session.createTextMessage("Request!");
-        request.setJMSReplyTo(response);
-        MessageProducer prod = _session.createProducer(service);
-        prod.send(request);
-        _session.commit();
-    }
-
-    void shutdownWhenComplete() throws Exception
-    {
-        waitUntilComplete();
-        _connection.close();
-    }
-
-    public synchronized void onMessage(Message response)
-    {
-
-        _logger.info("Received " + (++_count) + " of " + _expected + " responses.");
-        if (_count == _expected)
-        {
-
-            notifyAll();
-        }
-        try
-        {
-            _session.commit();
-        }
-        catch (JMSException e)
-        {
-            
-        }
-
-    }
-
-    synchronized void waitUntilComplete() throws Exception
-    {
-
-        if (_count < _expected)
-        {
-            wait(60000);
-        }
-
-        if (_count < _expected)
-        {
-            throw new Exception("Didn't receive all messages... got " + _count + " expected " + _expected);
-        }
-    }
-
-    static AMQConnection connect(String broker) throws Exception
-    {
-        //return new AMQConnection(broker, "guest", "guest", "Client" + System.currentTimeMillis(), "test");
-         return (AMQConnection) _qct.getConnection("guest", "guest") ;
-    }
-
-    public static void main(String[] argv) throws Exception
-    {
-        final String connectionString;
-        final int expected;
-        if (argv.length == 0)
-        {
-            connectionString = "localhost:5672";
-            expected = 100;
-        }
-        else
-        {
-            connectionString = argv[0];
-            expected = Integer.parseInt(argv[1]);
-        }
-
-        new Client(connect(connectionString), expected).shutdownWhenComplete();
-    }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java
deleted file mode 100644
index 45945eb..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java
+++ /dev/null
@@ -1,69 +0,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.
- *
- */
-package org.apache.qpid.test.unit.client.forwardall;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Runs the Service's and Client parts of the test in the same process
- * as the broker
- */
-public class CombinedTest extends QpidBrokerTestCase
-{
-    private static final Logger _logger = LoggerFactory.getLogger(CombinedTest.class);
-    private int run = 0;
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        Service.setQTC(this);
-        Client.setQTC(this);
-    }
-
-    protected void tearDown() throws Exception
-    {
-        ServiceCreator.closeAll();
-        super.tearDown();
-    }
-
-    public void testForwardAll() throws Exception
-    {
-        while (run < 10)
-        {
-            int services =1;
-            ServiceCreator.start("vm://:1", services);
-
-            _logger.info("Starting " + ++run + " client...");
-
-            new Client("vm://:1", services).shutdownWhenComplete();
-
-
-            _logger.info("Completed " + run + " successfully!");
-        }
-    }
-
-    public static junit.framework.Test suite()
-    {
-        return new junit.framework.TestSuite(CombinedTest.class);
-    }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/Service.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/Service.java
deleted file mode 100644
index 160700b..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/Service.java
+++ /dev/null
@@ -1,95 +0,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.
- *
- */
-package org.apache.qpid.test.unit.client.forwardall;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-/**
- * Declare a queue and bind it to amq.direct with a 'well known' routing key,
- * register a consumer for this queue and send a response to every message received.
- */
-public class Service implements MessageListener
-{
-    private final AMQConnection _connection;
-    private final AMQSession _session;
-
-    private static QpidBrokerTestCase _qct;
-     
-
-    public static void setQTC(QpidBrokerTestCase qtc)
-    {
-        _qct = qtc;
-    }
-    Service(String broker) throws Exception
-    {
-        this(connect(broker));
-    }
-
-    Service(AMQConnection connection) throws Exception
-    {
-        _connection = connection;
-        //AMQQueue queue = new SpecialQueue(connection, "ServiceQueue");
-        _session = (AMQSession) _connection.createSession(true, AMQSession.NO_ACKNOWLEDGE);
-          AMQQueue queue  = (AMQQueue)  _session.createQueue("ServiceQueue") ;
-        _session.createConsumer(queue).setMessageListener(this);
-        _connection.start();
-    }
-
-    public void onMessage(Message request)
-    {
-        try
-        {
-            Message response = _session.createTextMessage("Response!");
-            Destination replyTo = request.getJMSReplyTo();
-            _session.createProducer(replyTo).send(response);
-            _session.commit();
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace(System.out);
-        }
-    }
-
-    public void close() throws JMSException
-    {
-        _connection.close();
-    }
-
-    static AMQConnection connect(String broker) throws Exception
-    {
-        //return new AMQConnection(broker, "guest", "guest", "Client" + System.currentTimeMillis(), "test");
-          return (AMQConnection) _qct.getConnection("guest", "guest") ;
-    }
-
-//    public static void main(String[] argv) throws Exception
-//    {
-//        String broker = argv.length == 0? "localhost:5672" : argv[0];
-//        new Service(broker);
-//    }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/ServiceCreator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/ServiceCreator.java
deleted file mode 100644
index be16f6b..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/ServiceCreator.java
+++ /dev/null
@@ -1,112 +0,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.
- *
- */
-package org.apache.qpid.test.unit.client.forwardall;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jms.JMSException;
-
-public class ServiceCreator implements Runnable
-{
-    private static final Logger _logger = LoggerFactory.getLogger(ServiceCreator.class);
-
-    private static Thread[] threads;
-    private static ServiceCreator[] _services;
-
-    private final String broker;
-    private Service service;
-
-    ServiceCreator(String broker)
-    {
-        this.broker = broker;
-    }
-
-    public void run()
-    {
-        try
-        {
-            service = new Service(broker);
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace(System.out);
-        }
-    }
-
-    public void closeSC() throws JMSException
-    {
-        service.close();
-    }
-
-    static void closeAll()
-    {
-        for (int i = 0; i < _services.length; i++)
-        {
-            try
-            {
-                _services[i].closeSC();
-            }
-            catch (JMSException e)
-            {
-                // ignore
-            }
-        }
-    }
-
-    static void start(String broker, int services) throws InterruptedException
-    {
-        threads = new Thread[services];
-        _services = new ServiceCreator[services];
-        ServiceCreator runner = new ServiceCreator(broker);
-        // start services
-        _logger.info("Starting " + services + " services...");
-        for (int i = 0; i < services; i++)
-        {
-            threads[i] = new Thread(runner);
-            _services[i] = runner;
-            threads[i].start();
-        }
-
-        for (int i = 0; i < threads.length; i++)
-        {
-            threads[i].join();
-        }
-    }
-
-    public static void main(String[] argv) throws Exception
-    {
-        final String connectionString;
-        final int services;
-        if (argv.length == 0)
-        {
-            connectionString = "localhost:5672";
-            services = 100;
-        }
-        else
-        {
-            connectionString = argv[0];
-            services = Integer.parseInt(argv[1]);
-        }
-
-        start(connectionString, services);
-    }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java
deleted file mode 100644
index 27371b0..0000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java
+++ /dev/null
@@ -1,46 +0,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.
- *
- */
-package org.apache.qpid.test.unit.client.forwardall;
-
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.framing.AMQShortString;
-
-/**
- * Queue that allows several private queues to be registered and bound
- * to an exchange with the same routing key.
- *
- */
-class SpecialQueue extends AMQQueue
-{
-    private final AMQShortString name;
-
-    SpecialQueue(AMQConnection con, String name)
-    {
-        super(con, name, true);
-        this.name = new AMQShortString(name);
-    }
-
-    public AMQShortString getRoutingKey()
-    {
-        return name;
-    }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
index 8ad8fa7..728ef85 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
@@ -20,24 +20,24 @@
  */
 package org.apache.qpid.test.unit.client.message;
 
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
 
 public class ObjectMessageTest extends QpidBrokerTestCase implements MessageListener
 {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
index 836684c..1a7e9df 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
@@ -20,11 +20,6 @@
  */
 package org.apache.qpid.test.unit.client.protocol;
 
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.net.UnknownHostException;
-
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
 import org.apache.qpid.client.protocol.AMQProtocolSession;
@@ -32,6 +27,11 @@
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.transport.TestNetworkConnection;
 
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.UnknownHostException;
+
 public class AMQProtocolSessionTest extends QpidBrokerTestCase
 {
     private static class TestProtocolSession extends AMQProtocolSession
@@ -44,7 +44,7 @@
 
         public TestNetworkConnection getNetworkConnection()
         {
-            return (TestNetworkConnection) _protocolHandler.getNetworkConnection();
+            return (TestNetworkConnection) getProtocolHandler().getNetworkConnection();
         }
 
         public AMQShortString genQueueName()
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/temporaryqueue/TemporaryQueueTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/temporaryqueue/TemporaryQueueTest.java
index c98e403..41ab35f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/temporaryqueue/TemporaryQueueTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/temporaryqueue/TemporaryQueueTest.java
@@ -21,6 +21,10 @@
 
 package org.apache.qpid.test.unit.client.temporaryqueue;
 
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.MessageConsumer;
@@ -29,10 +33,6 @@
 import javax.jms.TemporaryQueue;
 import javax.jms.TextMessage;
 
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 /**
  * Tests the behaviour of {@link TemporaryQueue}.
  */
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/CloseBeforeAckTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/CloseBeforeAckTest.java
index 039a172..4da9a1d 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/CloseBeforeAckTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/CloseBeforeAckTest.java
@@ -21,14 +21,12 @@
 package org.apache.qpid.test.unit.close;
 
 import junit.framework.Assert;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.junit.concurrency.TestRunnable;
 import org.apache.qpid.junit.concurrency.ThreadTestCoordinator;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.Message;
@@ -47,8 +45,8 @@
 {
     private static final Logger log = LoggerFactory.getLogger(CloseBeforeAckTest.class);
 
-    Connection connection;
-    Session session;
+    private Connection connection;
+    private Session session;
     public static final String TEST_QUEUE_NAME = "TestQueue";
     private int TEST_COUNT = 25;
 
@@ -70,9 +68,9 @@
         }
     }
 
-    TestThread1 testThread1 = new TestThread1();
+    private TestThread1 testThread1 = new TestThread1();
 
-    TestRunnable testThread2 =
+    private TestRunnable testThread2 =
         new TestRunnable()
         {
             public void runWithExceptions() throws Exception
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java
index 6bc6c59..f2387fa 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java
@@ -21,7 +21,6 @@
 package org.apache.qpid.test.unit.close;
 
 import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.framing.AMQFrame;
 import org.apache.qpid.framing.AMQShortString;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java
index f5e0ed7..a4e9a99 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java
@@ -20,22 +20,21 @@
  */
 package org.apache.qpid.test.unit.close;
 
-import org.apache.qpid.AMQException;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.test.utils.QpidClientConnection;
-import org.apache.qpid.client.message.AbstractJMSMessage;
-import org.apache.qpid.url.URLSyntaxException;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.message.AbstractJMSMessage;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.test.utils.QpidClientConnection;
+import org.apache.qpid.url.URLSyntaxException;
+
 import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.Queue;
 import javax.jms.Session;
-
 import java.util.concurrent.atomic.AtomicInteger;
 
 public class MessageRequeueTest extends QpidBrokerTestCase
@@ -55,7 +54,7 @@
 
     private long[] receieved = new long[numTestMessages + 1];
     private boolean passed = false;
-    QpidClientConnection conn;
+    private QpidClientConnection conn;
 
 
     protected void setUp() throws Exception
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java
index 8a6dfb8..957063b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java
@@ -19,15 +19,15 @@
  *
  */package org.apache.qpid.test.unit.close;
 
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Session;
 import javax.jms.Topic;
 import javax.jms.TopicPublisher;
 import javax.jms.TopicSession;
 
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 /**
  * @author Apache Software Foundation
  */
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
index 80422cf..c292c71 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
@@ -17,6 +17,12 @@
  */
 package org.apache.qpid.test.unit.ct;
 
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.Message;
 import javax.jms.MessageProducer;
@@ -29,12 +35,6 @@
 import javax.jms.TopicSession;
 import javax.jms.TopicSubscriber;
 
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 /**
  *   Crash Recovery tests for durable subscription
  *
@@ -379,7 +379,7 @@
         
         // Create durable subscriber that matches A
         TopicSubscriber subA = session.createDurableSubscriber(topic, 
-                "testResubscribeWithChangedSelector",
+                "testResubscribeWithChangedSelectorAndRestart",
                 "Match = True", false);
 
         // Send 1 matching message and 1 non-matching message
@@ -397,8 +397,8 @@
                      ((TextMessage) rMsg).getText());
 
         // Queue has no messages left
-        AMQQueue subQueueTmp = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
-        assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueueTmp));
+        AMQQueue subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
+        assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue, true));
         
         rMsg = subA.receive(1000);
         assertNull(rMsg);
@@ -423,8 +423,7 @@
         //verify no messages are now present on the queue as changing selector should have issued
         //an unsubscribe and thus deleted the previous durable backing queue for the subscription.
         //check the dur sub's underlying queue now has msg count 0
-        AMQQueue subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
-        assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue));
+        assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue, true));
         
         // Check that new messages are received properly
         msg = session.createTextMessage("testResubscribeWithChangedSelectorAndRestart1");
@@ -444,8 +443,8 @@
         assertNull(rMsg);
 
         //check the dur sub's underlying queue now has msg count 0
-        subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
-        assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue));
+        assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue, true));
+        conn.close();
 
         //now restart the server
         try
@@ -467,8 +466,7 @@
 
         //verify no messages now present on the queue after we restart the broker
         //check the dur sub's underlying queue now has msg count 0
-        subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
-        assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue));
+        assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session).getQueueDepth(subQueue, true));
 
         // Reconnect with new selector that matches B
         TopicSubscriber subC = session.createDurableSubscriber(topic, 
@@ -484,8 +482,7 @@
         producer.send(msg);
 
         //check the dur sub's underlying queue now has msg count 1
-        subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorAndRestart");
-        assertEquals("Msg count should be 1", 1, ((AMQSession<?, ?>) session).getQueueDepth(subQueue));
+        assertEquals("Msg count should be 1", 1, ((AMQSession<?, ?>) session).getQueueDepth(subQueue, true));
         
         rMsg = subC.receive(1000);
         assertNotNull(rMsg);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
index 97452ad..3f2d6f9 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
@@ -20,6 +20,9 @@
  */
 package org.apache.qpid.test.unit.message;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQPInvalidClassException;
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQQueue;
@@ -29,9 +32,6 @@
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.Message;
@@ -42,7 +42,6 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.Topic;
-
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/StreamMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
index 39691a5..e861b4f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
@@ -20,9 +20,8 @@
  */
 package org.apache.qpid.test.unit.message;
 
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQHeadersExchange;
@@ -32,15 +31,11 @@
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.url.AMQBindingURL;
 import org.apache.qpid.url.BindingURL;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.jms.Connection;
-import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageEOFException;
@@ -48,6 +43,9 @@
 import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.StreamMessage;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * @author Apache Software Foundation
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java
index 978ebfa..e07c0ec 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java
@@ -20,10 +20,7 @@
  */
 package org.apache.qpid.test.unit.message;
 
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.util.Properties;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.Destination;
@@ -32,8 +29,10 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.naming.InitialContext;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.Properties;
 
 
 /**
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
index e948aaf..a07e531 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
@@ -20,8 +20,15 @@
  */
 package org.apache.qpid.test.unit.topic;
 
-import java.io.IOException;
-import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.management.common.JMXConnnectionFactory;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 import javax.jms.Connection;
 import javax.jms.InvalidDestinationException;
@@ -37,15 +44,8 @@
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
 import javax.management.remote.JMXConnector;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.management.common.JMXConnnectionFactory;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.Set;
 
 /**
  * @todo Code to check that a consumer gets only one particular method could be factored into a re-usable method (as
@@ -116,12 +116,10 @@
 
         _logger.info("Producer sending message A");
         producer.send(session1.createTextMessage("A"));
-        
-        ((AMQSession<?, ?>) session1).sync();
-        
+
         //check the dur sub's underlying queue now has msg count 1
         AMQQueue subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "MySubscription");
-        assertEquals("Msg count should be 1", 1, ((AMQSession<?, ?>) session1).getQueueDepth(subQueue));
+        assertEquals("Msg count should be 1", 1, ((AMQSession<?, ?>) session1).getQueueDepth(subQueue, true));
 
         Message msg;
         _logger.info("Receive message on consumer 1:expecting A");
@@ -139,11 +137,9 @@
         msg = consumer2.receive(NEGATIVE_RECEIVE_TIMEOUT);
         _logger.info("Receive message on consumer 1 :expecting null");
         assertEquals(null, msg);
-        
-        ((AMQSession<?, ?>) session2).sync();
-        
+
         //check the dur sub's underlying queue now has msg count 0
-        assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session2).getQueueDepth(subQueue));
+        assertEquals("Msg count should be 0", 0, ((AMQSession<?, ?>) session2).getQueueDepth(subQueue, true));
 
         consumer2.close();
         _logger.info("Unsubscribe session2/consumer2");
@@ -151,7 +147,7 @@
         
         ((AMQSession<?, ?>) session2).sync();
         
-        if(isJavaBroker() && isExternalBroker())
+        if(isJavaBroker())
         {
             //Verify that the queue was deleted by querying for its JMX MBean
             _jmxc = JMXConnnectionFactory.getJMXConnection(5000, "127.0.0.1",
@@ -635,7 +631,7 @@
         // should be 5 or 10 messages on queue now
         // (5 for the java broker due to use of server side selectors, and 10 for the cpp broker due to client side selectors only)
         AMQQueue queue = new AMQQueue("amq.topic", "clientid" + ":" + "sameMessageSelector");
-        assertEquals("Queue depth is wrong", isJavaBroker() ? 5 : 10, ((AMQSession<?, ?>) session).getQueueDepth(queue));
+        assertEquals("Queue depth is wrong", isJavaBroker() ? 5 : 10, ((AMQSession<?, ?>) session).getQueueDepth(queue, true));
 
         // now recreate the durable subscriber and check the received messages
         TopicSubscriber subTwo = session.createDurableSubscriber(topic, "sameMessageSelector", "testprop = TRUE", false);
@@ -721,11 +717,11 @@
         msg = session.createTextMessage("testResubscribeWithChangedSelectorAndRestart2");
         msg.setBooleanProperty("Match", false);
         producer.send(msg);
-        ((AMQSession)session).sync();
+
         // should be 1 or 2 messages on queue now
         // (1 for the java broker due to use of server side selectors, and 2 for the cpp broker due to client side selectors only)
         AMQQueue queue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelectorNoClose");
-        assertEquals("Queue depth is wrong", isJavaBroker() ? 1 : 2, ((AMQSession<?, ?>) session).getQueueDepth(queue));
+        assertEquals("Queue depth is wrong", isJavaBroker() ? 1 : 2, ((AMQSession<?, ?>) session).getQueueDepth(queue, true));
 
         conn.start();
         
@@ -739,7 +735,7 @@
         assertNull(rMsg);
         
         // Check queue has no messages
-        assertEquals("Queue should be empty", 0, ((AMQSession<?, ?>) session).getQueueDepth(queue));
+        assertEquals("Queue should be empty", 0, ((AMQSession<?, ?>) session).getQueueDepth(queue, true));
         
         conn.close();
     }
@@ -793,7 +789,7 @@
         // should be 1 or 2 messages on queue now
         // (1 for the java broker due to use of server side selectors, and 2 for the cpp broker due to client side selectors only)
         AMQQueue queue = new AMQQueue("amq.topic", "clientid" + ":" + "subscriptionName");
-        assertEquals("Queue depth is wrong", isJavaBroker() ? 1 : 2, ((AMQSession<?, ?>) session).getQueueDepth(queue));
+        assertEquals("Queue depth is wrong", isJavaBroker() ? 1 : 2, ((AMQSession<?, ?>) session).getQueueDepth(queue, true));
         
         conn.start();
         
@@ -807,7 +803,7 @@
         assertNull(rMsg);
         
         // Check queue has no messages
-        assertEquals("Queue should be empty", 0, ((AMQSession<?, ?>) session).getQueueDepth(queue));
+        assertEquals("Queue should be empty", 0, ((AMQSession<?, ?>) session).getQueueDepth(queue, true));
         
         conn.close();
     }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TemporaryTopicTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TemporaryTopicTest.java
index c89b13a..a5b9ce8 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TemporaryTopicTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TemporaryTopicTest.java
@@ -20,6 +20,8 @@
  */
 package org.apache.qpid.test.unit.topic;
 
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.MessageConsumer;
@@ -28,8 +30,6 @@
 import javax.jms.TemporaryTopic;
 import javax.jms.TextMessage;
 
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 
 /**
  * Tests the behaviour of {@link TemporaryTopic}.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TopicPublisherTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TopicPublisherTest.java
index 5874133..5fbbc7f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TopicPublisherTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TopicPublisherTest.java
@@ -20,16 +20,16 @@
  */
 package org.apache.qpid.test.unit.topic;
 
-import javax.jms.MessageConsumer;
-import javax.jms.TextMessage;
-import javax.jms.TopicPublisher;
-import javax.jms.TopicSession;
-
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.client.AMQTopic;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSession;
+
 /**
  * @author Apache Software Foundation
  */
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java
index 826545a..5dae98f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java
@@ -20,6 +20,12 @@
  */
 package org.apache.qpid.test.unit.topic;
 
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
 import javax.jms.Connection;
 import javax.jms.InvalidDestinationException;
 import javax.jms.Message;
@@ -32,12 +38,6 @@
 import javax.jms.TopicSession;
 import javax.jms.TopicSubscriber;
 
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 
 /** @author Apache Software Foundation */
 public class TopicSessionTest extends QpidBrokerTestCase
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java
index b8b5a29..0be4f7f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java
@@ -20,15 +20,22 @@
  */
 package org.apache.qpid.test.unit.transacted;
 
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.configuration.ClientProperties;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jms.*;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactedTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactedTest.java
index 3c0f951..4f7d592 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactedTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactedTest.java
@@ -21,6 +21,9 @@
 package org.apache.qpid.test.unit.transacted;
 
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQSession;
@@ -28,9 +31,6 @@
 import org.apache.qpid.jms.Session;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.jms.Connection;
 import javax.jms.IllegalStateException;
 import javax.jms.JMSException;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java
index 2b90d38..e2b0f00 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java
@@ -20,10 +20,19 @@
  */
 package org.apache.qpid.test.unit.transacted;
 
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
+import junit.framework.TestCase;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQConnectionURL;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.jms.ConnectionURL;
+import org.apache.qpid.jms.Session;
+import org.apache.qpid.protocol.AMQConstant;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.util.LogMonitor;
 
 import javax.jms.DeliveryMode;
 import javax.jms.ExceptionListener;
@@ -33,25 +42,17 @@
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.TextMessage;
-
-import junit.framework.TestCase;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.jms.Session;
-import org.apache.qpid.protocol.AMQConstant;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.util.LogMonitor;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * The {@link TestCase} for transaction timeout testing.
  */
 public abstract class TransactionTimeoutTestCase extends QpidBrokerTestCase implements ExceptionListener
 {
+    private static final int ALERT_MESSAGE_TOLERANCE = 6;
     public static final String VIRTUALHOST = "test";
     public static final String TEXT = "0123456789abcdefghiforgettherest";
     public static final String CHN_OPEN_TXN = "CHN-1007";
@@ -138,16 +139,21 @@
 
     /**
      * Send a number of messages to the queue, optionally pausing after each.
+     *
+     * Need to sync to ensure that the Broker has received the message(s) in order
+     * the test and broker start timing the idle transaction from the same point in time.
      */
     protected void send(int count, float delay) throws Exception
     {
         for (int i = 0; i < count; i++)
         {
-	        sleep(delay);
+            sleep(delay);
             Message msg = _psession.createTextMessage(TEXT);
             msg.setIntProperty("i", i);
-	        _producer.send(msg);
+            _producer.send(msg);
         }
+
+        ((AMQSession<?, ?>)_psession).sync();
     }
     
     /**
@@ -184,7 +190,7 @@
         }
         else
         {
-	        assertTrue(idleErr, idleMsgs.size() >= idle - 2 && idleMsgs.size() <= idle + 2);
+	        assertTrue(idleErr, idleMsgs.size() >= idle - ALERT_MESSAGE_TOLERANCE && idleMsgs.size() <= idle + ALERT_MESSAGE_TOLERANCE);
         }
         
         if (open == 0)
@@ -193,7 +199,7 @@
         }
         else
         {
-            assertTrue(openErr, openMsgs.size() >= open - 2 && openMsgs.size() <= open + 2);
+            assertTrue(openErr, openMsgs.size() >= open - ALERT_MESSAGE_TOLERANCE && openMsgs.size() <= open + ALERT_MESSAGE_TOLERANCE);
         }
     }
 
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/AbstractXATestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/AbstractXATestCase.java
index f39f640..b5d1bff 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/AbstractXATestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/AbstractXATestCase.java
@@ -20,9 +20,15 @@
 import org.apache.qpid.dtx.XidImpl;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-import javax.transaction.xa.Xid;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.TextMessage;
+import javax.jms.XASession;
 import javax.transaction.xa.XAResource;
-import javax.jms.*;
+import javax.transaction.xa.Xid;
 import java.util.Random;
 
 /**
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/FaultTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/FaultTest.java
index 47705f8..e940a73 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/FaultTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/FaultTest.java
@@ -21,15 +21,20 @@
  */
 
 
+import junit.framework.TestSuite;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jms.*;
-import javax.transaction.xa.Xid;
-import javax.transaction.xa.XAResource;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.XAQueueConnection;
+import javax.jms.XAQueueConnectionFactory;
+import javax.jms.XAQueueSession;
 import javax.transaction.xa.XAException;
-
-import junit.framework.TestSuite;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
 
 
 public class FaultTest extends AbstractXATestCase
@@ -113,7 +118,7 @@
             _queueFactory = getConnectionFactory();
             _xaqueueConnection = _queueFactory.createXAQueueConnection("guest", "guest");
             XAQueueSession session = _xaqueueConnection.createXAQueueSession();
-            _queueConnection = _queueFactory.createQueueConnection();
+            _queueConnection = _queueFactory.createQueueConnection("guest","guest");
             _nonXASession = _queueConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
             init(session, _queue);
         }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/QueueTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/QueueTest.java
index d2abc0e..3fbe763 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/QueueTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/QueueTest.java
@@ -17,15 +17,26 @@
  */
 package org.apache.qpid.test.unit.xa;
 
-import javax.jms.*;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-import javax.transaction.xa.XAException;
-
 import junit.framework.TestSuite;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.XAQueueConnection;
+import javax.jms.XAQueueConnectionFactory;
+import javax.jms.XAQueueSession;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
 public class QueueTest extends AbstractXATestCase
 {
     /* this clas logger */
@@ -151,11 +162,12 @@
             // create a standard session
             try
             {
-                _queueConnection = _queueFactory.createQueueConnection();
+                _queueConnection = _queueFactory.createQueueConnection("guest", "guest");
                 _nonXASession = _queueConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
             }
             catch (JMSException e)
             {
+                e.printStackTrace();
                 fail("cannot create queue session: " + e.getMessage());
             }
             init(session, _queue);
@@ -627,7 +639,8 @@
                 TextMessage message1 = (TextMessage) nonXAConsumer.receive(1000);
                 if (message1 != null)
                 {
-                    fail("The queue is not empty! ");
+
+                    fail("The queue is not empty! " + message1.getLongProperty(_sequenceNumberPropertyName));
                 }
             }
             catch (JMSException e)
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/TopicTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/TopicTest.java
index 99d0f0a..d955979 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/TopicTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/xa/TopicTest.java
@@ -17,18 +17,19 @@
  */
 package org.apache.qpid.test.unit.xa;
 
-import javax.jms.*;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-import javax.transaction.xa.XAException;
-
 import junit.framework.TestSuite;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
+import org.apache.qpid.configuration.ClientProperties;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jms.*;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
 /**
  *
  *
@@ -105,7 +106,7 @@
             }
             catch (Exception e)
             {
-                fail("Exception thrown when cleaning standard connection: " + e.getStackTrace());
+                fail("Exception thrown when cleaning standard connection: " + e);
             }
         }
         super.tearDown();
@@ -118,6 +119,7 @@
     {
         if (!isBroker08())
         {
+            setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, "1");
             // lookup test queue
             try
             {
@@ -652,7 +654,12 @@
                     {
 
                         message = (TextMessage) xaDurSub.receive(1000);
-                        _logger.debug(" received message: " + message.getLongProperty(_sequenceNumberPropertyName));
+
+                        if(message != null)
+                        {
+                            _logger.debug(" received message: " + message.getLongProperty(_sequenceNumberPropertyName));
+                        }
+
                         if (message == null)
                         {
                             fail("no message received! expected: " + i);
@@ -884,35 +891,40 @@
                     // receive 3 message within tx1: 3, 4 and 7
                     _xaResource.start(xid1, XAResource.TMRESUME);
                     // receive messages 3, 4 and 7
+                    Set<Long> expected = new HashSet<Long>();
+                    expected.add(3L);
+                    expected.add(4L);
+                    expected.add(7L);
                     message = (TextMessage) xaDurSub.receive(1000);
                     if (message == null)
                     {
-                        fail("no message received! expected: " + 3);
+                        fail("no message received! expected one of: " + expected);
                     }
-                    else if (message.getLongProperty(_sequenceNumberPropertyName) != 3)
+                    else if (!expected.remove(message.getLongProperty(_sequenceNumberPropertyName)))
                     {
                         fail("wrong sequence number: " + message
-                                .getLongProperty(_sequenceNumberPropertyName) + " 3 was expected");
+                                .getLongProperty(_sequenceNumberPropertyName) + " expected one from " + expected);
                     }
                     message = (TextMessage) xaDurSub.receive(1000);
                     if (message == null)
                     {
-                        fail("no message received! expected: " + 4);
+                        fail("no message received! expected one of: " + expected);
                     }
-                    else if (message.getLongProperty(_sequenceNumberPropertyName) != 4)
+                    else if (!expected.remove(message.getLongProperty(_sequenceNumberPropertyName)))
                     {
+
                         fail("wrong sequence number: " + message
-                                .getLongProperty(_sequenceNumberPropertyName) + " 4 was expected");
+                                .getLongProperty(_sequenceNumberPropertyName) + " expected one from " + expected);
                     }
                     message = (TextMessage) xaDurSub.receive(1000);
                     if (message == null)
                     {
-                        fail("no message received! expected: " + 7);
+                        fail("no message received! expected one of: " + expected);
                     }
-                    else if (message.getLongProperty(_sequenceNumberPropertyName) != 7)
+                    else if (!expected.remove(message.getLongProperty(_sequenceNumberPropertyName)))
                     {
                         fail("wrong sequence number: " + message
-                                .getLongProperty(_sequenceNumberPropertyName) + " 7 was expected");
+                                .getLongProperty(_sequenceNumberPropertyName) + " expected one from " + expected);
                     }
                 }
                 catch (Exception e)
@@ -938,8 +950,18 @@
 
                 try
                 {
-                    // consume messages 1 - 4
-                    //----- start xid1
+                    // consume messages: could be any from (1 - 4, 7-10)
+                    //----- start xid4
+                    Set<Long> expected = new HashSet<Long>();
+                    Set<Long> xid4msgs = new HashSet<Long>();
+                    for(long l = 1; l <= 4l; l++)
+                    {
+                        expected.add(l);
+                    }
+                    for(long l = 7; l <= 10l; l++)
+                    {
+                        expected.add(l);
+                    }
                     _xaResource.start(xid4, XAResource.TMNOFLAGS);
                     for (int i = 1; i <= 4; i++)
                     {
@@ -948,9 +970,14 @@
                         {
                             fail("no message received! expected: " + i);
                         }
-                        else if (message.getLongProperty(_sequenceNumberPropertyName) != i)
+
+                        long seqNo = message.getLongProperty(_sequenceNumberPropertyName);
+                        xid4msgs.add(seqNo);
+
+                        if (!expected.remove(seqNo))
                         {
-                            fail("wrong sequence number: " + message.getLongProperty(_sequenceNumberPropertyName));
+                            fail("wrong sequence number: " + seqNo +
+                                 " expected one from " + expected);
                         }
                     }
                     _xaResource.end(xid4, XAResource.TMSUSPEND);
@@ -963,15 +990,17 @@
                         {
                             fail("no message received! expected: " + i);
                         }
-                        else if (message.getLongProperty(_sequenceNumberPropertyName) != i)
+                        else if (!expected.remove(message.getLongProperty(_sequenceNumberPropertyName)))
                         {
-                            fail("wrong sequence number: " + message.getLongProperty(_sequenceNumberPropertyName));
+                            fail("wrong sequence number: " + message.getLongProperty(_sequenceNumberPropertyName)
+                                + " expected one from " + expected);
                         }
                     }
                     _xaResource.end(xid5, XAResource.TMSUSPEND);
                     // abort tx4
                     _xaResource.prepare(xid4);
                     _xaResource.rollback(xid4);
+                    expected.addAll(xid4msgs);
                     // consume messages 1-4 with tx5
                     _xaResource.start(xid5, XAResource.TMRESUME);
                     for (int i = 1; i <= 4; i++)
@@ -981,13 +1010,15 @@
                         {
                             fail("no message received! expected: " + i);
                         }
-                        else if (message.getLongProperty(_sequenceNumberPropertyName) != i)
+                        else if (!expected.remove(message.getLongProperty(_sequenceNumberPropertyName)))
                         {
-                            fail("wrong sequence number: " + message.getLongProperty(_sequenceNumberPropertyName));
+                            fail("wrong sequence number: " + message.getLongProperty(_sequenceNumberPropertyName)
+                                 + " expected one from " + expected);
                         }
                     }
                     _xaResource.end(xid5, XAResource.TMSUSPEND);
                     // commit tx5
+
                     _xaResource.prepare(xid5);
                     _xaResource.commit(xid5, false);
                 }
@@ -1604,6 +1635,7 @@
                 }
                 _xaResource.end(xid2, XAResource.TMSUCCESS);
                 _xaResource.commit(xid2, true);
+                _session.close();
             }
             catch (Exception e)
             {
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java
index 8345803..66b3fe0 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java
@@ -22,5 +22,7 @@
 
 public interface BrokerHolder
 {
+    String getWorkingDirectory();
     void shutdown();
+    void kill();
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/ConversationFactory.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/ConversationFactory.java
index e153b2e..3a9354d 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/ConversationFactory.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/ConversationFactory.java
@@ -21,11 +21,19 @@
 package org.apache.qpid.test.utils;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.test.utils.ReflectionUtils;
 
-import javax.jms.*;
-
-import java.util.*;
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
@@ -113,19 +121,19 @@
     private Session session;
 
     /** The message consumer for incoming messages. */
-    MessageConsumer consumer;
+    private MessageConsumer consumer;
 
     /** The message producer for outgoing messages. */
-    MessageProducer producer;
+    private MessageProducer producer;
 
     /** The well-known or temporary destination to receive replies on. */
-    Destination receiveDestination;
+    private Destination receiveDestination;
 
     /** Holds the queue implementation class for the reply queue. */
-    Class<? extends BlockingQueue> queueClass;
+    private Class<? extends BlockingQueue> queueClass;
 
     /** Used to hold any replies that are received outside of the context of a conversation. */
-    BlockingQueue<Message> deadLetterBox = new LinkedBlockingQueue<Message>();
+    private BlockingQueue<Message> deadLetterBox = new LinkedBlockingQueue<Message>();
 
     /* Used to hold conversation state on a per thread basis. */
     /*
@@ -143,7 +151,7 @@
      */
 
     /** Generates new coversation id's as needed. */
-    AtomicLong conversationIdGenerator = new AtomicLong();
+    private AtomicLong conversationIdGenerator = new AtomicLong();
 
     /**
      * Creates a conversation helper on the specified connection with the default sending destination, and listening
@@ -238,13 +246,13 @@
     public class Conversation
     {
         /** Holds the correlation id for the context. */
-        long conversationId;
+        private long conversationId;
 
         /**
          * Holds the send destination for the context. This will automatically be updated to the most recently received
          * reply-to destination.
          */
-        Destination sendDestination;
+        private Destination sendDestination;
 
         /**
          * Sends a message to the default sending location. The correlation id of the message will be assigned by this
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java
index 1021758..f6c4814 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java
@@ -20,15 +20,13 @@
  */
 package org.apache.qpid.test.utils;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.client.AMQConnectionFactory;
 import org.apache.qpid.util.FileUtils;
 
 import javax.naming.NamingException;
-import javax.jms.JMSException;
-import javax.naming.NamingException;
-
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class FailoverBaseCase extends QpidBrokerTestCase
 {
@@ -36,8 +34,6 @@
 
     public static final long DEFAULT_FAILOVER_TIME = 10000L;
 
-    protected int failingPort;
-
     protected void setUp() throws java.lang.Exception
     {
         super.setUp();
@@ -68,15 +64,6 @@
         return _connectionFactory;
     }
 
-    @Override
-    public void stopBroker(int port) throws Exception
-    {
-        if (isBrokerPresent(port))
-        {
-            super.stopBroker(port);
-        }
-    }
-
     public void tearDown() throws Exception
     {
         try
@@ -92,11 +79,11 @@
         }
     }
 
-
     public void failBroker(int port)
     {
         try
         {
+            //TODO: use killBroker instead
             stopBroker(port);
         }
         catch (Exception e)
@@ -104,6 +91,4 @@
             throw new RuntimeException(e);
         }
     }
-
-        
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java
index 340f00f..adda9ca 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java
@@ -21,14 +21,17 @@
 package org.apache.qpid.test.utils;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.server.Broker;
 
 public class InternalBrokerHolder implements BrokerHolder
 {
     private static final Logger LOGGER = Logger.getLogger(InternalBrokerHolder.class);
-    private final Broker _broker;
 
-    public InternalBrokerHolder(final Broker broker)
+    private final Broker _broker;
+    private final String _workingDirectory;
+
+    public InternalBrokerHolder(final Broker broker, String workingDirectory)
     {
         if(broker == null)
         {
@@ -36,6 +39,13 @@
         }
 
         _broker = broker;
+        _workingDirectory = workingDirectory;
+    }
+
+    @Override
+    public String getWorkingDirectory()
+    {
+        return _workingDirectory;
     }
 
     public void shutdown()
@@ -47,4 +57,12 @@
         LOGGER.info("Broker instance shutdown");
     }
 
+    @Override
+    public void kill()
+    {
+        // Can't kill a internal broker as we would also kill ourselves as we share the same JVM.
+        shutdown();
+    }
+
+
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java
index 3a17106..2b7c3f2 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java
@@ -20,31 +20,30 @@
  */
 package org.apache.qpid.test.utils;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
+import junit.framework.TestCase;
+import org.apache.commons.configuration.ConfigurationException;
+
+import org.apache.qpid.management.common.JMXConnnectionFactory;
+import org.apache.qpid.management.common.mbeans.ConfigurationManagement;
+import org.apache.qpid.management.common.mbeans.LoggingManagement;
+import org.apache.qpid.management.common.mbeans.ManagedBroker;
+import org.apache.qpid.management.common.mbeans.ManagedConnection;
+import org.apache.qpid.management.common.mbeans.ManagedExchange;
+import org.apache.qpid.management.common.mbeans.ManagedQueue;
+import org.apache.qpid.management.common.mbeans.ServerInformation;
+import org.apache.qpid.management.common.mbeans.UserManagement;
 
 import javax.management.JMException;
 import javax.management.MBeanException;
 import javax.management.MBeanServerConnection;
 import javax.management.MBeanServerInvocationHandler;
-import javax.management.ObjectName;
 import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
 import javax.management.remote.JMXConnector;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.management.common.JMXConnnectionFactory;
-import org.apache.qpid.management.common.mbeans.ManagedBroker;
-import org.apache.qpid.management.common.mbeans.ManagedConnection;
-import org.apache.qpid.management.common.mbeans.ManagedExchange;
-import org.apache.qpid.management.common.mbeans.LoggingManagement;
-import org.apache.qpid.management.common.mbeans.ConfigurationManagement;
-import org.apache.qpid.management.common.mbeans.ManagedQueue;
-import org.apache.qpid.management.common.mbeans.ServerInformation;
-import org.apache.qpid.management.common.mbeans.UserManagement;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
 
 /**
  * JMX access for tests.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java
new file mode 100644
index 0000000..9413e38
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java
@@ -0,0 +1,130 @@
+/*
+ *
+ * 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.test.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.log4j.Logger;
+
+public final class Piper extends Thread
+{
+    private static final Logger LOGGER = Logger.getLogger(Piper.class);
+
+    private final BufferedReader _in;
+    private final PrintStream _out;
+    private final String _ready;
+    private final CountDownLatch _latch;
+    private final String _stopped;
+    private final String _prefix;
+    private volatile boolean _seenReady;
+    private volatile String _stopLine;
+
+    public Piper(InputStream in, PrintStream out, String ready, String stopped)
+    {
+        this(in, out, ready, stopped, null);
+    }
+
+    public Piper(InputStream in, PrintStream out, String ready, String stopped, String prefix)
+    {
+        _in = new BufferedReader(new InputStreamReader(in));
+        _out = out;
+        _ready = ready;
+        _stopped = stopped;
+        _seenReady = false;
+        _prefix = prefix;
+
+        if (this._ready != null && !this._ready.equals(""))
+        {
+            this._latch = new CountDownLatch(1);
+        }
+        else
+        {
+            this._latch = null;
+        }
+    }
+
+    public boolean await(long timeout, TimeUnit unit) throws InterruptedException
+    {
+        if (_latch == null)
+        {
+            return true;
+        }
+        else
+        {
+            _latch.await(timeout, unit);
+            return _seenReady;
+        }
+    }
+
+    public void run()
+    {
+        try
+        {
+            String line;
+            while ((line = _in.readLine()) != null)
+            {
+                if (_prefix != null)
+                {
+                    line = _prefix + line;
+                }
+                _out.println(line);
+
+                if (_latch != null && line.contains(_ready))
+                {
+                    _seenReady = true;
+                    _latch.countDown();
+                }
+
+                if (!_seenReady && line.contains(_stopped))
+                {
+                    _stopLine = line;
+                }
+            }
+        }
+        catch (IOException e)
+        {
+            LOGGER.warn(e.getMessage() + " : Broker stream from unexpectedly closed; last log lines written by Broker may be lost.");
+        }
+        finally
+        {
+            if (_latch != null)
+            {
+                _latch.countDown();
+            }
+        }
+    }
+
+    public String getStopLine()
+    {
+        return _stopLine;
+    }
+
+    String getReady()
+    {
+        return _ready;
+    }
+}
\ No newline at end of file
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
index 9a8da14..32c6094 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
@@ -17,43 +17,11 @@
  */
 package org.apache.qpid.test.utils;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.io.PrintStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQConnectionFactory;
 import org.apache.qpid.client.AMQQueue;
@@ -72,6 +40,34 @@
 import org.apache.qpid.util.FileUtils;
 import org.apache.qpid.util.LogMonitor;
 
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
 /**
  * Qpid base class for system testing test cases.
  */
@@ -126,7 +122,6 @@
     private static final String BROKER_LOG_PREFIX = "broker.log.prefix";
     private static final String BROKER_PERSITENT = "broker.persistent";
     private static final String BROKER_PROTOCOL_EXCLUDES = "broker.protocol.excludes";
-    
 
     // values
     protected static final String JAVA = "java";
@@ -154,7 +149,7 @@
 
     protected File _outputFile;
 
-    protected PrintStream _brokerOutputStream;
+    protected PrintStream _testcaseOutputStream;
 
     protected Map<Integer, BrokerHolder> _brokers = new HashMap<Integer, BrokerHolder>();
 
@@ -195,10 +190,10 @@
         super();
     }
     
-	public Logger getLogger()
-	{
-		return QpidBrokerTestCase._logger;
-	}
+    public Logger getLogger()
+    {
+        return QpidBrokerTestCase._logger;
+    }
 
     public void runBare() throws Throwable
     {
@@ -228,12 +223,12 @@
 
             if (_interleaveBrokerLog)
             {
-            	_brokerOutputStream = out;
+                _testcaseOutputStream = out;
             }
             else
             {
-            	_brokerOutputStream = new PrintStream(new FileOutputStream(String
-    					.format("%s/TEST-%s.broker.out", _output, qname)), true);
+                _testcaseOutputStream = new PrintStream(new FileOutputStream(String
+                        .format("%s/TEST-%s.broker.out", _output, qname)), true);
             }
         }
 
@@ -278,7 +273,7 @@
                 out.close();
                 if (!_interleaveBrokerLog)
                 {
-                	_brokerOutputStream.close();
+                    _testcaseOutputStream.close();
                 }
             }
         }
@@ -307,103 +302,6 @@
         startBroker();
     }
 
-    private static final class Piper extends Thread
-    {
-
-        private LineNumberReader in;
-        private PrintStream out;
-        private String ready;
-        private CountDownLatch latch;
-        private boolean seenReady;
-        private String stopped;
-        private String stopLine;
-
-        public Piper(InputStream in, PrintStream out, String ready)
-        {
-            this(in, out, ready, null);
-        }
-
-        public Piper(InputStream in, PrintStream out, String ready, String stopped)
-        {
-            this.in = new LineNumberReader(new InputStreamReader(in));
-            this.out = out;
-            this.ready = ready;
-            this.stopped = stopped;
-            this.seenReady = false;
-
-            if (this.ready != null && !this.ready.equals(""))
-            {
-                this.latch = new CountDownLatch(1);
-            }
-            else
-            {
-                this.latch = null;
-            }
-        }
-
-        public Piper(InputStream in, PrintStream out)
-        {
-            this(in, out, null);
-        }
-
-        public boolean await(long timeout, TimeUnit unit) throws InterruptedException
-        {
-            if (latch == null)
-            {
-                return true;
-            }
-            else
-            {
-                latch.await(timeout, unit);
-                return seenReady;
-            }
-        }
-
-        public void run()
-        {
-            try
-            {
-                String line;
-                while ((line = in.readLine()) != null)
-                {
-                	if (_interleaveBrokerLog)
-                	{
-                		line = _brokerLogPrefix + line;
-                	}
-                	out.println(line);
-
-                    if (latch != null && line.contains(ready))
-                    {
-                        seenReady = true;
-                        latch.countDown();
-                    }
-
-                    if (!seenReady && line.contains(stopped))
-                    {
-                        stopLine = line;
-                    }
-                }
-            }
-            catch (IOException e)
-            {
-                // this seems to happen regularly even when
-                // exits are normal
-            }
-            finally
-            {
-                if (latch != null)
-                {
-                    latch.countDown();
-                }
-            }
-        }
-
-        public String getStopLine()
-        {
-            return stopLine;
-        }
-    }
-
     /**
      * Return the management port in use by the broker on this main port
      *
@@ -489,7 +387,7 @@
             _logger.info("starting internal broker (same JVM)");
             broker.startup(options);
 
-            _brokers.put(port, new InternalBrokerHolder(broker));
+            _brokers.put(port, new InternalBrokerHolder(broker, System.getProperty("QPID_WORK")));
         }
         else if (!_brokerType.equals(BrokerType.EXTERNAL))
         {
@@ -563,18 +461,19 @@
             // cpp broker requires that the work directory is created
             createBrokerWork(qpidWork);
 
-            Process process = pb.start();;
+            Process process = pb.start();
 
             Piper p = new Piper(process.getInputStream(),
-            		            _brokerOutputStream,
+                                _testcaseOutputStream,
                                 System.getProperty(BROKER_READY),
-                                System.getProperty(BROKER_STOPPED));
+                                System.getProperty(BROKER_STOPPED),
+                                _interleaveBrokerLog ? _brokerLogPrefix : null);
 
             p.start();
 
             if (!p.await(30, TimeUnit.SECONDS))
             {
-                _logger.info("broker failed to become ready (" + p.ready + "):" + p.getStopLine());
+                _logger.info("broker failed to become ready (" + p.getReady() + "):" + p.getStopLine());
                 //Ensure broker has stopped
                 process.destroy();
                 cleanBrokerWork(qpidWork);
@@ -595,7 +494,7 @@
                 // this is expect if the broker started successfully
             }
 
-            _brokers.put(port, new SpawnedBrokerHolder(process));
+            _brokers.put(port, new SpawnedBrokerHolder(process, qpidWork));
         }
     }
 
@@ -742,11 +641,31 @@
 
     public void stopBroker(int port) throws Exception
     {
-        port = getPort(port);
+        if (isBrokerPresent(port))
+        {
+            port = getPort(port);
 
-        _logger.info("stopping broker on port : " + port);
-        BrokerHolder broker = _brokers.remove(port);
-        broker.shutdown();
+            _logger.info("stopping broker on port : " + port);
+            BrokerHolder broker = _brokers.remove(port);
+            broker.shutdown();
+        }
+    }
+
+    public void killBroker() throws Exception
+    {
+        killBroker(0);
+    }
+
+    public void killBroker(int port) throws Exception
+    {
+        if (isBrokerPresent(port))
+        {
+            port = getPort(port);
+
+            _logger.info("killing broker on port : " + port);
+            BrokerHolder broker = _brokers.remove(port);
+            broker.kill();
+        }
     }
 
     public boolean isBrokerPresent(int port) throws Exception
@@ -755,7 +674,13 @@
 
         return _brokers.containsKey(port);
     }
-    
+
+    public BrokerHolder getBroker(int port) throws Exception
+    {
+        port = getPort(port);
+        return _brokers.get(port);
+    }
+
     /**
      * Attempt to set the Java Broker to use the BDBMessageStore for persistence
      * Falling back to the DerbyMessageStore if
@@ -984,7 +909,6 @@
     /**
      * we assume that the environment is correctly set
      * i.e. -Djava.naming.provider.url="..//example010.properties"
-     * TODO should be a way of setting that through maven
      *
      * @return an initial context
      *
@@ -1158,13 +1082,13 @@
     /**
      * Send messages to the given destination.
      *
-     * If session is transacted then messages will be commited before returning
+     * If session is transacted then messages will be committed before returning
      *
      * @param session the session to use for sending
      * @param destination where to send them to
      * @param count no. of messages to send
      *
-     * @return the sent messges
+     * @return the sent messages
      *
      * @throws Exception
      */
@@ -1357,6 +1281,6 @@
 
     protected int getFailingPort()
     {
-    	return FAILING_PORT;
+        return FAILING_PORT;
     }
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidClientConnection.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidClientConnection.java
index 16f7bfd..0e0032d 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidClientConnection.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidClientConnection.java
@@ -21,13 +21,12 @@
 
 package org.apache.qpid.test.utils;
 
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.JMSAMQException;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.JMSAMQException;
+
 import javax.jms.Connection;
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/ReflectionUtils.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/ReflectionUtils.java
index 7946c6a..83294c1 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/ReflectionUtils.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/ReflectionUtils.java
@@ -21,6 +21,7 @@
 package org.apache.qpid.test.utils;
 
 import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
@@ -225,4 +226,34 @@
             throw new ReflectionUtilsException("NoSuchMethodException", e);
         }
     }
+
+    @SuppressWarnings("unchecked")
+    public static <T> T getDeclaredField(final Object obj, final String fieldName)
+    {
+        try
+        {
+            final Field field = obj.getClass().getDeclaredField(fieldName);
+            if (!field.isAccessible())
+            {
+                field.setAccessible(true);
+            }
+            return (T) field.get(obj);
+        }
+        catch (NoSuchFieldException e)
+        {
+            throw new ReflectionUtilsException("Unable to read field " + fieldName + "from object " + obj, e);
+        }
+        catch (SecurityException e)
+        {
+            throw new ReflectionUtilsException("Unable to read field " + fieldName + "from object " + obj, e);
+        }
+        catch (IllegalArgumentException e)
+        {
+            throw new ReflectionUtilsException("Unable to read field " + fieldName + "from object " + obj, e);
+        }
+        catch (IllegalAccessException e)
+        {
+            throw new ReflectionUtilsException("Unable to read field " + fieldName + "from object " + obj, e);
+        }
+    }
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
index 65239bb..50b1ea7 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
@@ -20,15 +20,20 @@
  */
 package org.apache.qpid.test.utils;
 
+import java.io.IOException;
+
 import org.apache.log4j.Logger;
 
 public class SpawnedBrokerHolder implements BrokerHolder
 {
     private static final Logger LOGGER = Logger.getLogger(SpawnedBrokerHolder.class);
 
+    private final boolean _isWindows = String.valueOf(System.getProperty("os.name")).toLowerCase().contains("windows");
     private final Process _process;
+    private final Integer _pid;
+    private final String _workingDirectory;
 
-    public SpawnedBrokerHolder(final Process process)
+    public SpawnedBrokerHolder(final Process process, final String workingDirectory)
     {
         if(process == null)
         {
@@ -36,14 +41,87 @@
         }
 
         _process = process;
+        _pid = retrieveUnixPidIfPossible();
+        _workingDirectory = workingDirectory;
+    }
+
+    @Override
+    public String getWorkingDirectory()
+    {
+        return _workingDirectory;
     }
 
     public void shutdown()
     {
         LOGGER.info("Destroying broker process");
-
         _process.destroy();
 
+        reapChildProcess();
+    }
+
+    @Override
+    public void kill()
+    {
+        if (_pid == null)
+        {
+            LOGGER.info("Destroying broker process");
+            _process.destroy();
+        }
+        else
+        {
+            LOGGER.info("Killing broker process with PID " + _pid);
+            sendSigkillForImmediateShutdown(_pid);
+        }
+
+        reapChildProcess();
+    }
+
+    private void sendSigkillForImmediateShutdown(Integer pid)
+    {
+        boolean killSuccessful = false;
+        try
+        {
+            final Process killProcess = Runtime.getRuntime().exec("kill -KILL " + pid);
+            killProcess.waitFor();
+            killSuccessful = killProcess.exitValue() == 0;
+        }
+        catch (IOException e)
+        {
+            LOGGER.error("Error whilst killing process " + _pid, e);
+        }
+        catch (InterruptedException e)
+        {
+            Thread.currentThread().interrupt();
+        }
+        finally
+        {
+            if (!killSuccessful)
+            {
+                _process.destroy();
+            }
+        }
+    }
+
+    private Integer retrieveUnixPidIfPossible()
+    {
+        if(!_isWindows)
+        {
+            try
+            {
+                Integer pid = ReflectionUtils.getDeclaredField(_process, "pid");
+                LOGGER.info("PID " + pid);
+                return pid;
+            }
+            catch (ReflectionUtilsException e)
+            {
+                LOGGER.warn("Could not get pid for process, Broker process shutdown will be ungraceful");
+            }
+        }
+        return null;
+    }
+
+    private void reapChildProcess()
+    {
         try
         {
             _process.waitFor();
@@ -51,8 +129,21 @@
         }
         catch (InterruptedException e)
         {
-            LOGGER.error("Interrupted whilst waiting for process destruction");
+            LOGGER.error("Interrupted whilst waiting for process shutdown");
             Thread.currentThread().interrupt();
         }
+        finally
+        {
+            try
+            {
+                _process.getInputStream().close();
+                _process.getErrorStream().close();
+                _process.getOutputStream().close();
+            }
+            catch (IOException e)
+            {
+            }
+        }
     }
+
 }
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/util/ClasspathScanner.java b/qpid/java/systests/src/main/java/org/apache/qpid/util/ClasspathScanner.java
index 8cae846..151d147 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/util/ClasspathScanner.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/util/ClasspathScanner.java
@@ -20,13 +20,18 @@
  */
 package org.apache.qpid.util;
 
+import org.apache.log4j.Logger;
+
 import java.io.File;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.log4j.Logger;
-
 /**
  * An ClasspathScanner scans the classpath for classes that implement an interface or extend a base class and have names
  * that match a regular expression.
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java b/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java
index c09e633..2b99289 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java
@@ -30,8 +30,8 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.LineNumberReader;
-import java.util.List;
 import java.util.LinkedList;
+import java.util.List;
 
 /**
  * Utility to simplify the monitoring of Log4j file output
diff --git a/qpid/java/tools/src/main/java/org/apache/qpid/testkit/Receiver.java b/qpid/java/tools/src/main/java/org/apache/qpid/testkit/Receiver.java
index b4294ee..8dcf59e 100644
--- a/qpid/java/tools/src/main/java/org/apache/qpid/testkit/Receiver.java
+++ b/qpid/java/tools/src/main/java/org/apache/qpid/testkit/Receiver.java
@@ -70,13 +70,13 @@
  */
 public class Receiver extends Client implements MessageListener
 {
-	long msg_count = 0;
-	int sequence = 0;
-	boolean syncRcv = Boolean.getBoolean("sync_rcv");
-	boolean jmsDurableSub = Boolean.getBoolean("jms_durable_sub");
-	boolean checkForDups = Boolean.getBoolean("check_for_dups");
-	MessageConsumer consumer;
-    List<Integer> duplicateMessages = new ArrayList<Integer>();
+	private long msg_count = 0;
+	private int sequence = 0;
+	private boolean syncRcv = Boolean.getBoolean("sync_rcv");
+	private boolean jmsDurableSub = Boolean.getBoolean("jms_durable_sub");
+	private boolean checkForDups = Boolean.getBoolean("check_for_dups");
+	private MessageConsumer consumer;
+    private List<Integer> duplicateMessages = new ArrayList<Integer>();
     
     public Receiver(Connection con,String addr) throws Exception
     {
diff --git a/qpid/java/tools/src/main/java/org/apache/qpid/tools/JNDICheck.java b/qpid/java/tools/src/main/java/org/apache/qpid/tools/JNDICheck.java
index 2390516..c604b24 100644
--- a/qpid/java/tools/src/main/java/org/apache/qpid/tools/JNDICheck.java
+++ b/qpid/java/tools/src/main/java/org/apache/qpid/tools/JNDICheck.java
@@ -70,8 +70,8 @@
 
     private static String JAVA_NAMING = "java.naming.factory.initial";
 
-    Context _context = null;
-    Hashtable _environment = null;
+    private Context _context = null;
+    private Hashtable _environment = null;
 
     public JNDICheck(String propertyFile)
     {
diff --git a/qpid/java/tools/src/main/java/org/apache/qpid/tools/LatencyTest.java b/qpid/java/tools/src/main/java/org/apache/qpid/tools/LatencyTest.java
index 90ee7e2..16149d1 100644
--- a/qpid/java/tools/src/main/java/org/apache/qpid/tools/LatencyTest.java
+++ b/qpid/java/tools/src/main/java/org/apache/qpid/tools/LatencyTest.java
@@ -56,24 +56,24 @@
 
 public class LatencyTest extends PerfBase implements MessageListener
 {
-    MessageProducer producer;
-    MessageConsumer consumer;
-    Message msg;
-    byte[] payload;
-    long maxLatency = 0;
-    long minLatency = Long.MAX_VALUE;
-    long totalLatency = 0;  // to calculate avg latency.
-    int rcvdMsgCount = 0;
-    double stdDev = 0;
-    double avgLatency = 0;
-    boolean warmup_mode = true;
-    boolean transacted = false;
-    int transSize = 0;
+    private MessageProducer producer;
+    private MessageConsumer consumer;
+    private Message msg;
+    private byte[] payload;
+    private long maxLatency = 0;
+    private long minLatency = Long.MAX_VALUE;
+    private long totalLatency = 0;  // to calculate avg latency.
+    private int rcvdMsgCount = 0;
+    private double stdDev = 0;
+    private double avgLatency = 0;
+    private boolean warmup_mode = true;
+    private boolean transacted = false;
+    private int transSize = 0;
 
-    final List<Long> latencies;
-    final Lock lock = new ReentrantLock();
-    final Condition warmedUp;
-    final Condition testCompleted;
+    private final List<Long> latencies;
+    private final Lock lock = new ReentrantLock();
+    private final Condition warmedUp;
+    private final Condition testCompleted;
 
     public LatencyTest()
     {
diff --git a/qpid/java/tools/src/main/java/org/apache/qpid/tools/QpidBench.java b/qpid/java/tools/src/main/java/org/apache/qpid/tools/QpidBench.java
index 602fcc6..e2d1799 100644
--- a/qpid/java/tools/src/main/java/org/apache/qpid/tools/QpidBench.java
+++ b/qpid/java/tools/src/main/java/org/apache/qpid/tools/QpidBench.java
@@ -689,7 +689,7 @@
     {
         org.apache.qpid.transport.Connection conn =
             new org.apache.qpid.transport.Connection();
-        conn.connect(opts.broker, opts.port, null, "guest", "guest",false);
+        conn.connect(opts.broker, opts.port, null, "guest", "guest", false, null);
         return conn;
     }