qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kgiu...@apache.org
Subject svn commit: r1172657 [12/21] - in /qpid/branches/qpid-3346/qpid: ./ cpp/ cpp/bindings/ cpp/bindings/qmf2/examples/cpp/ cpp/bindings/qpid/dotnet/ cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/Properties/ cpp/bindings/qpid/dotnet/examples/csha...
Date Mon, 19 Sep 2011 15:13:38 GMT
Modified: qpid/branches/qpid-3346/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java (original)
+++ qpid/branches/qpid-3346/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java Mon Sep 19 15:13:18 2011
@@ -20,15 +20,19 @@
  */
 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.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.PropertiesPrincipalDatabaseManager;
-
-import java.util.Properties;
+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;
 
 public class TestApplicationRegistry extends ApplicationRegistry
 {
@@ -42,15 +46,46 @@ public class TestApplicationRegistry ext
     public void initialise() throws Exception
     {
         CurrentActor.setDefault(new BrokerActor(new NullRootMessageLogger()));
+        GenericActor.setDefaultMessageLogger(new NullRootMessageLogger());
         super.initialise();
     }
 
-    protected void createDatabaseManager(ServerConfiguration configuration) throws Exception
+    /**
+     * @see org.apache.qpid.server.registry.ApplicationRegistry#createAuthenticationManager()
+     */
+    @Override
+    protected AuthenticationManager createAuthenticationManager() throws ConfigurationException
     {
-        Properties users = new Properties();
+        final Properties users = new Properties();
         users.put("guest","guest");
         users.put("admin","admin");
-        _databaseManager = new PropertiesPrincipalDatabaseManager("testPasswordFile", users);
+
+        final PropertiesPrincipalDatabase ppd = new PropertiesPrincipalDatabase(users);
+
+        AuthenticationManager pdam =  new PrincipalDatabaseAuthenticationManager()
+        {
+
+            /**
+             * @see org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager#configure(org.apache.qpid.server.configuration.plugins.ConfigurationPlugin)
+             */
+            @Override
+            public void configure(ConfigurationPlugin config) throws ConfigurationException
+            {
+                // We don't pass configuration to this test instance.
+            }
+
+            @Override
+            public void initialise()
+            {
+                setPrincipalDatabase(ppd);
+
+                super.initialise();
+            }
+        };
+
+        pdam.initialise();
+
+        return pdam;
     }
 
 }

Modified: qpid/branches/qpid-3346/qpid/java/build.deps
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/build.deps?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/build.deps (original)
+++ qpid/branches/qpid-3346/qpid/java/build.deps Mon Sep 19 15:13:18 2011
@@ -17,8 +17,6 @@
 # under the License.
 #
 
-backport-util-concurrent=lib/backport-util-concurrent-2.2.jar
-
 commons-beanutils-core=lib/commons-beanutils-core-1.8.0.jar
 commons-cli=lib/commons-cli-1.0.jar
 commons-codec=lib/commons-codec-1.3.jar
@@ -36,9 +34,6 @@ junit=lib/junit-3.8.1.jar
 
 log4j=lib/log4j-1.2.12.jar
 
-mina-core=lib/mina-core-1.0.1.jar
-mina-filter-ssl=lib/mina-filter-ssl-1.0.1.jar
-
 slf4j-api=lib/slf4j-api-1.6.1.jar
 slf4j-log4j=lib/slf4j-log4j12-1.6.1.jar
 
@@ -57,7 +52,7 @@ felix.libs=${osgi-core} ${felix-framewor
 commons-configuration.libs = ${commons-beanutils-core} ${commons-digester} \
   ${commons-codec} ${commons-lang} ${commons-collections} ${commons-configuration}
 
-common.libs=${slf4j-api} ${backport-util-concurrent} ${mina-core} ${mina-filter-ssl} 
+common.libs=${slf4j-api}
 client.libs=${geronimo-jms}
 tools.libs=${commons-configuration.libs} ${log4j}
 broker.libs=${commons-cli} ${commons-logging} ${log4j} ${slf4j-log4j} \
@@ -105,30 +100,27 @@ ecl-equinox-launcher-solaris-gtk-sparc=l
 
 management-common.libs=
 
+management-eclipse-plugin.core-libs=${ibm-icu} ${ecl-core-jface} ${ecl-core-jface-databinding} \
+    ${ecl-core-commands} ${ecl-core-contenttype} ${ecl-core-databinding} ${ecl-core-expressions} \
+    ${ecl-core-jobs} ${ecl-core-runtime} ${ecl-equinox-app} ${ecl-equinox-common} ${ecl-equinox-launcher} \
+    ${ecl-equinox-prefs} ${ecl-equinox-registry} ${ecl-help} ${ecl-osgi} ${ecl-swt} ${ecl-ui} ${ecl-ui-forms} \
+    ${ecl-ui-workbench} ${apache-commons-codec}
+
+management-eclipse-plugin.swt-libs=${ecl-swt-win32-win32-x86} ${ecl-swt-linux-gtk-x86} ${ecl-swt-macosx-carbon} \
+    ${ecl-swt-linux-gtk-x86_64} ${ecl-swt-solaris-gtk-sparc}
+
+management-eclipse-plugin.libs=${management-eclipse-plugin.core-libs} ${management-eclipse-plugin.swt-libs}
+
 management-eclipse-plugin-win32-win32-x86.libs=${management-eclipse-plugin.core-libs} \
-    ${ecl-swt-win32-win32-x86} ${ecl-equinox-launcher-win32-win32-x86}
+    ${ecl-swt-win32-win32-x86} ${ecl-equinox-launcher-win32-win32-x86} ${ecl-core-runtime-compat-registry}
 management-eclipse-plugin-linux-gtk-x86.libs=${management-eclipse-plugin.core-libs} \
-    ${ecl-swt-linux-gtk-x86} ${ecl-equinox-launcher-linux-gtk-x86}
+    ${ecl-swt-linux-gtk-x86} ${ecl-equinox-launcher-linux-gtk-x86} ${ecl-core-runtime-compat-registry}
 management-eclipse-plugin-linux-gtk-x86_64.libs=${management-eclipse-plugin.core-libs} \
-    ${ecl-swt-linux-gtk-x86_64} ${ecl-equinox-launcher-linux-gtk-x86_64}
+    ${ecl-swt-linux-gtk-x86_64} ${ecl-equinox-launcher-linux-gtk-x86_64} ${ecl-core-runtime-compat-registry}
 management-eclipse-plugin-macosx.libs=${management-eclipse-plugin.core-libs} \
-    ${ecl-swt-macosx-carbon} ${ecl-equinox-launcher-macosx-carbon}
+    ${ecl-swt-macosx-carbon} ${ecl-equinox-launcher-macosx-carbon} ${ecl-core-runtime-compat-registry}
 management-eclipse-plugin-solaris-gtk-sparc.libs=${management-eclipse-plugin.core-libs} \
-    ${ecl-swt-solaris-gtk-sparc} ${ecl-equinox-launcher-solaris-gtk-sparc}
-
-management-eclipse-plugin.core-libs=${ibm-icu} ${ecl-core-jface} ${ecl-core-jface-databinding} \
-    ${ecl-core-commands} ${ecl-core-contenttype} ${ecl-core-databinding} ${ecl-core-expressions} \
-    ${ecl-core-jobs} ${ecl-core-runtime} ${ecl-core-runtime-compat-registry} ${ecl-equinox-app} \
-    ${ecl-equinox-common} ${ecl-equinox-launcher} ${ecl-equinox-prefs} ${ecl-equinox-registry} \
-    ${ecl-help} ${ecl-osgi} ${ecl-swt} ${ecl-ui} ${ecl-ui-forms} ${ecl-ui-workbench} ${apache-commons-codec}
-    
-management-eclipse-plugin.platform-libs=${ecl-equinox-launcher-win32-win32-x86} \
-    ${ecl-equinox-launcher-linux-gtk-x86} ${ecl-equinox-launcher-macosx-carbon} \
-    ${ecl-swt-win32-win32-x86} ${ecl-swt-linux-gtk-x86} ${ecl-swt-macosx-carbon} \
-    ${ecl-swt-linux-gtk-x86_64} ${ecl-equinox-launcher-linux-gtk-x86_64} \
-    ${ecl-swt-solaris-gtk-sparc} ${ecl-equinox-launcher-solaris-gtk-sparc}
-
-management-eclipse-plugin.libs=${management-eclipse-plugin.core-libs} ${management-eclipse-plugin.platform-libs}
+    ${ecl-swt-solaris-gtk-sparc} ${ecl-equinox-launcher-solaris-gtk-sparc} ${ecl-core-runtime-compat-registry}
     
 common.test.libs=${test.libs}
 broker.test.libs=${test.libs}
@@ -141,5 +133,5 @@ systests.libs=${test.libs}
 broker-plugins.test.libs=${test.libs} 
 broker-plugins-experimental-info.test.libs=${test.libs} ${servlet-api} ${jetty} ${jetty-util} ${jetty-servlet-tester}
 
-management-eclipse-plugin.test.libs=${systests.libs}
+management-eclipse-plugin.test.libs=${test.libs}
 management-common.test.libs=${test.libs}

Modified: qpid/branches/qpid-3346/qpid/java/build.xml
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/build.xml?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/build.xml (original)
+++ qpid/branches/qpid-3346/qpid/java/build.xml Mon Sep 19 15:13:18 2011
@@ -22,15 +22,15 @@
 
   <import file="common.xml"/>
 
-
   <findSubProjects name="broker-plugins" dir="broker-plugins"/>
+  <findSubProjects name="client-plugins" dir="client-plugins"/>
   <findSubProjects name="management" dir="management" excludes="common,example"/>
 
   <property name="modules.core"       value="junit-toolkit common management/common broker client tools"/>
   <property name="modules.examples"   value="client/example management/example"/>
   <property name="modules.tests"      value="systests perftests integrationtests testkit"/>
   <property name="modules.management" value="${management}"/>
-  <property name="modules.plugin"     value="${broker-plugins}"/>
+  <property name="modules.plugin"     value="${broker-plugins} ${client-plugins}"/>
   <property name="modules"            value="${modules.core} ${modules.examples}
    ${modules.management} ${modules.tests} ${modules.plugin}"/>
 
@@ -77,7 +77,7 @@
     <iterate target="compile-tests"/>
   </target>
 
-  <target name="test" description="execute tests">
+  <target name="test" description="execute tests" depends="manifest">
 
     <delete file="${build.failed}"/>
 

Modified: qpid/branches/qpid-3346/qpid/java/client/README.txt
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/README.txt?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/README.txt (original)
+++ qpid/branches/qpid-3346/qpid/java/client/README.txt Mon Sep 19 15:13:18 2011
@@ -24,7 +24,7 @@ run more easily.
 E.g, in order to run the Hello example, you would add the client+example library
 files to the java classpath and launch the example like follows:
 
-java -cp "lib/qpid-all.jar:example/lib/qpid-client-examples-<version>.jar" \
+java -cp "lib/qpid-all.jar:example/lib/qpid-client-example-<version>.jar" \
     org.apache.qpid.example.Hello
 
 NOTE: The client uses the SL4FJ API for its logging. You must supply a logging 

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java Mon Sep 19 15:13:18 2011
@@ -26,7 +26,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.qpid.jms.BrokerDetails;
-import org.apache.qpid.jms.ConnectionURL;
+import org.apache.qpid.transport.ConnectionSettings;
 import org.apache.qpid.url.URLHelper;
 import org.apache.qpid.url.URLSyntaxException;
 
@@ -38,8 +38,6 @@ public class AMQBrokerDetails implements
 
     private Map<String, String> _options = new HashMap<String, String>();
 
-    private SSLConfiguration _sslConfiguration;
-
     public AMQBrokerDetails(){}
     
     public AMQBrokerDetails(String url) throws URLSyntaxException
@@ -200,11 +198,10 @@ public class AMQBrokerDetails implements
         }
     }
 
-    public AMQBrokerDetails(String host, int port, SSLConfiguration sslConfiguration)
+    public AMQBrokerDetails(String host, int port)
     {
         _host = host;
         _port = port;
-        _sslConfiguration = sslConfiguration;
     }
 
     public String getHost()
@@ -280,16 +277,6 @@ public class AMQBrokerDetails implements
         setProperty(OPTIONS_CONNECT_TIMEOUT, Long.toString(timeout));
     }
 
-    public SSLConfiguration getSSLConfiguration()
-    {
-        return _sslConfiguration;
-    }
-
-    public void setSSLConfiguration(SSLConfiguration sslConfig)
-    {
-        _sslConfiguration = sslConfig;
-    }
-
     public String toString()
     {
         StringBuffer sb = new StringBuffer();
@@ -316,9 +303,8 @@ public class AMQBrokerDetails implements
 
         return _host.equalsIgnoreCase(bd.getHost()) &&
                (_port == bd.getPort()) &&
-               _transport.equalsIgnoreCase(bd.getTransport()) &&
-               compareSSLConfigurations(bd.getSSLConfiguration());
-        //todo do we need to compare all the options as well?
+               _transport.equalsIgnoreCase(bd.getTransport());
+        //TODO do we need to compare all the options as well?
     }
 
     @Override
@@ -359,24 +345,6 @@ public class AMQBrokerDetails implements
         return optionsURL.toString();
     }
 
-    // Do we need to do a more in-depth comparison?
-    private boolean compareSSLConfigurations(SSLConfiguration other)
-    {
-        boolean retval = false;
-        if (_sslConfiguration == null &&
-                other == null)
-        {
-            retval = true;
-        }
-        else if (_sslConfiguration != null &&
-                other != null)
-        {
-            retval = true;
-        }
-
-        return retval;
-    }
-
     public static String checkTransport(String broker)
     {
         if ((!broker.contains("://")))
@@ -398,4 +366,82 @@ public class AMQBrokerDetails implements
     {
         _options = props;
     }
+
+    public ConnectionSettings buildConnectionSettings()
+    {
+        ConnectionSettings conSettings = new ConnectionSettings();
+
+        conSettings.setHost(getHost());
+        conSettings.setPort(getPort());
+
+        // ------------ sasl options ---------------
+        if (getProperty(BrokerDetails.OPTIONS_SASL_MECHS) != null)
+        {
+            conSettings.setSaslMechs(
+                    getProperty(BrokerDetails.OPTIONS_SASL_MECHS));
+        }
+
+        // Sun SASL Kerberos client uses the
+        // protocol + servername as the service key.
+
+        if (getProperty(BrokerDetails.OPTIONS_SASL_PROTOCOL_NAME) != null)
+        {
+            conSettings.setSaslProtocol(
+                    getProperty(BrokerDetails.OPTIONS_SASL_PROTOCOL_NAME));
+        }
+
+
+        if (getProperty(BrokerDetails.OPTIONS_SASL_SERVER_NAME) != null)
+        {
+            conSettings.setSaslServerName(
+                    getProperty(BrokerDetails.OPTIONS_SASL_SERVER_NAME));
+        }
+
+        conSettings.setUseSASLEncryption(
+                getBooleanProperty(BrokerDetails.OPTIONS_SASL_ENCRYPTION));
+
+        // ------------- ssl options ---------------------
+        conSettings.setUseSSL(getBooleanProperty(BrokerDetails.OPTIONS_SSL));
+
+        if (getProperty(BrokerDetails.OPTIONS_TRUST_STORE) != null)
+        {
+            conSettings.setTrustStorePath(
+                    getProperty(BrokerDetails.OPTIONS_TRUST_STORE));
+        }
+
+        if (getProperty(BrokerDetails.OPTIONS_TRUST_STORE_PASSWORD) != null)
+        {
+            conSettings.setTrustStorePassword(
+                    getProperty(BrokerDetails.OPTIONS_TRUST_STORE_PASSWORD));
+        }
+
+        if (getProperty(BrokerDetails.OPTIONS_KEY_STORE) != null)
+        {
+            conSettings.setKeyStorePath(
+                    getProperty(BrokerDetails.OPTIONS_KEY_STORE));
+        }
+
+        if (getProperty(BrokerDetails.OPTIONS_KEY_STORE_PASSWORD) != null)
+        {
+            conSettings.setKeyStorePassword(
+                    getProperty(BrokerDetails.OPTIONS_KEY_STORE_PASSWORD));
+        }
+
+        if (getProperty(BrokerDetails.OPTIONS_SSL_CERT_ALIAS) != null)
+        {
+            conSettings.setCertAlias(
+                    getProperty(BrokerDetails.OPTIONS_SSL_CERT_ALIAS));
+        }
+        // ----------------------------
+
+        conSettings.setVerifyHostname(getBooleanProperty(BrokerDetails.OPTIONS_SSL_VERIFY_HOSTNAME));
+
+        if (getProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY) != null)
+        {
+            conSettings.setTcpNodelay(
+                    getBooleanProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY));
+        }
+
+        return conSettings;
+    }
 }

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java Mon Sep 19 15:13:18 2011
@@ -147,9 +147,6 @@ public class AMQConnection extends Close
      */
     private QpidConnectionMetaData _connectionMetaData;
 
-    /** Configuration info for SSL */
-    private SSLConfiguration _sslConfiguration;
-
     private AMQShortString _defaultTopicExchangeName = ExchangeDefaults.TOPIC_EXCHANGE_NAME;
     private AMQShortString _defaultQueueExchangeName = ExchangeDefaults.DIRECT_EXCHANGE_NAME;
     private AMQShortString _temporaryTopicExchangeName = ExchangeDefaults.TOPIC_EXCHANGE_NAME;
@@ -173,8 +170,8 @@ public class AMQConnection extends Close
     //Indicates the sync publish options (persistent|all)
     //By default it's async publish
     private String _syncPublish = "";
-    
-    // Indicates whether to use the old map message format or the 
+
+    // Indicates whether to use the old map message format or the
     // new amqp-0-10 encoded format.
     private boolean _useLegacyMapMessageFormat;
 
@@ -194,74 +191,33 @@ public class AMQConnection extends Close
         this(new AMQConnectionURL(
                 ConnectionURL.AMQ_PROTOCOL + "://" + username + ":" + password + "@"
                 + ((clientName == null) ? "" : clientName) + "/" + virtualHost + "?brokerlist='"
-                + AMQBrokerDetails.checkTransport(broker) + "'"), null);
-    }
-
-    /**
-     * @param broker      brokerdetails
-     * @param username    username
-     * @param password    password
-     * @param clientName  clientid
-     * @param virtualHost virtualhost
-     *
-     * @throws AMQException
-     * @throws URLSyntaxException
-     */
-    public AMQConnection(String broker, String username, String password, String clientName, String virtualHost,
-                         SSLConfiguration sslConfig) throws AMQException, URLSyntaxException
-    {
-        this(new AMQConnectionURL(
-                ConnectionURL.AMQ_PROTOCOL + "://" + username + ":" + password + "@"
-                + ((clientName == null) ? "" : clientName) + "/" + virtualHost + "?brokerlist='"
-                + AMQBrokerDetails.checkTransport(broker) + "'"), sslConfig);
+                + AMQBrokerDetails.checkTransport(broker) + "'"));
     }
 
     public AMQConnection(String host, int port, String username, String password, String clientName, String virtualHost)
             throws AMQException, URLSyntaxException
     {
-        this(host, port, false, username, password, clientName, virtualHost, null);
-    }
-
-    public AMQConnection(String host, int port, String username, String password, String clientName, String virtualHost,
-                         SSLConfiguration sslConfig) throws AMQException, URLSyntaxException
-    {
-        this(host, port, false, username, password, clientName, virtualHost, sslConfig);
-    }
-
-    public AMQConnection(String host, int port, boolean useSSL, String username, String password, String clientName,
-                         String virtualHost, SSLConfiguration sslConfig) throws AMQException, URLSyntaxException
-    {
         this(new AMQConnectionURL(
-                useSSL
-                ? (ConnectionURL.AMQ_PROTOCOL + "://" + username + ":" + password + "@"
-                   + ((clientName == null) ? "" : clientName) + virtualHost + "?brokerlist='tcp://" + host + ":" + port
-                   + "'" + "," + BrokerDetails.OPTIONS_SSL + "='true'")
-                : (ConnectionURL.AMQ_PROTOCOL + "://" + username + ":" + password + "@"
-                   + ((clientName == null) ? "" : clientName) + virtualHost + "?brokerlist='tcp://" + host + ":" + port
-                   + "'" + "," + BrokerDetails.OPTIONS_SSL + "='false'")), sslConfig);
+                   ConnectionURL.AMQ_PROTOCOL + "://" + username + ":" + password + "@"
+                   + ((clientName == null) ? "" : clientName) + virtualHost + "?brokerlist='tcp://" + host + ":" + port + "'"));
     }
 
     public AMQConnection(String connection) throws AMQException, URLSyntaxException
     {
-        this(new AMQConnectionURL(connection), null);
-    }
-
-    public AMQConnection(String connection, SSLConfiguration sslConfig) throws AMQException, URLSyntaxException
-    {
-        this(new AMQConnectionURL(connection), sslConfig);
+        this(new AMQConnectionURL(connection));
     }
 
     /**
      * @todo Some horrible stuff going on here with setting exceptions to be non-null to detect if an exception
      * was thrown during the connection! Intention not clear. Use a flag anyway, not exceptions... Will fix soon.
      */
-    public AMQConnection(ConnectionURL connectionURL, SSLConfiguration sslConfig) throws AMQException
+    public AMQConnection(ConnectionURL connectionURL) throws AMQException
     {
         if (connectionURL == null)
         {
             throw new IllegalArgumentException("Connection must be specified");
         }
-        
+
         // set this connection maxPrefetch
         if (connectionURL.getOption(ConnectionURL.OPTIONS_MAXPREFETCH) != null)
         {
@@ -311,7 +267,7 @@ public class AMQConnection extends Close
             // use the default value set for all connections
             _syncPublish = System.getProperty((ClientProperties.SYNC_PUBLISH_PROP_NAME),_syncPublish);
         }
-        
+
         if (connectionURL.getOption(ConnectionURL.OPTIONS_USE_LEGACY_MAP_MESSAGE_FORMAT) != null)
         {
             _useLegacyMapMessageFormat =  Boolean.parseBoolean(
@@ -322,16 +278,16 @@ public class AMQConnection extends Close
             // use the default value set for all connections
             _useLegacyMapMessageFormat = Boolean.getBoolean(ClientProperties.USE_LEGACY_MAP_MESSAGE_FORMAT);
         }
-        
+
         String amqpVersion = System.getProperty((ClientProperties.AMQP_VERSION), "0-10");
         _logger.debug("AMQP version " + amqpVersion);
-        
+
         _failoverPolicy = new FailoverPolicy(connectionURL, this);
         BrokerDetails brokerDetails = _failoverPolicy.getCurrentBrokerDetails();
-        if ("0-8".equals(amqpVersion)) 
+        if ("0-8".equals(amqpVersion))
         {
             _delegate = new AMQConnectionDelegate_8_0(this);
-        } 
+        }
         else if ("0-9".equals(amqpVersion))
         {
             _delegate = new AMQConnectionDelegate_0_9(this);
@@ -350,7 +306,6 @@ public class AMQConnection extends Close
             _logger.info("Connection:" + connectionURL);
         }
 
-        _sslConfiguration = sslConfig;
         _connectionURL = connectionURL;
 
         _clientName = connectionURL.getClientName();
@@ -418,6 +373,7 @@ public class AMQConnection extends Close
                 brokerDetails = _failoverPolicy.getNextBrokerDetails();
             }
         }
+        verifyClientID();
 
         if (_logger.isDebugEnabled())
         {
@@ -504,7 +460,7 @@ public class AMQConnection extends Close
             Class partypes[] = new Class[1];
             partypes[0] = AMQConnection.class;
             _delegate = (AMQConnectionDelegate) c.getConstructor(partypes).newInstance(this);
-            //Update our session to use this new protocol version 
+            //Update our session to use this new protocol version
             _protocolHandler.getProtocolSession().setProtocolVersion(_delegate.getProtocolVersion());
 
         }
@@ -547,7 +503,7 @@ public class AMQConnection extends Close
 
     public boolean attemptReconnection(String host, int port)
     {
-        BrokerDetails bd = new AMQBrokerDetails(host, port, _sslConfiguration);
+        BrokerDetails bd = new AMQBrokerDetails(host, port);
 
         _failoverPolicy.setBroker(bd);
 
@@ -1074,7 +1030,7 @@ public class AMQConnection extends Close
     {
         _username = id;
     }
-    
+
     public String getPassword()
     {
         return _password;
@@ -1227,7 +1183,7 @@ public class AMQConnection extends Close
 
             if (code != null)
             {
-                je = new JMSException(Integer.toString(code.getCode()), "Exception thrown against " + toString() + ": " + cause);
+                je = new JMSException("Exception thrown against " + toString() + ": " + cause, Integer.toString(code.getCode()));
             }
             else
             {
@@ -1250,7 +1206,7 @@ public class AMQConnection extends Close
             {
                 je.setLinkedException((Exception) cause);
             }
-            
+
             je.initCause(cause);
         }
 
@@ -1283,7 +1239,7 @@ public class AMQConnection extends Close
             {
                 _logger.info("Not a hard-error connection not closing: " + cause);
             }
-            
+
             // deliver the exception if there is a listener
             if (_exceptionListener != null)
             {
@@ -1293,7 +1249,7 @@ public class AMQConnection extends Close
             {
                 _logger.error("Throwable Received but no listener set: " + cause);
             }
-    
+
             // if we are closing the connection, close sessions first
             if (closer)
             {
@@ -1351,17 +1307,17 @@ public class AMQConnection extends Close
     }
 
     /**
-     * Returns connection url. 
+     * Returns connection url.
      * @return connection url
      */
     public ConnectionURL getConnectionURL()
     {
         return _connectionURL;
     }
-    
+
     /**
      * Returns stringified connection url.   This url is suitable only for display
-     * as {@link AMQConnectionURL#toString()} converts any password to asterisks. 
+     * as {@link AMQConnectionURL#toString()} converts any password to asterisks.
      * @return connection url
      */
     public String toURL()
@@ -1375,11 +1331,6 @@ public class AMQConnection extends Close
                              AMQConnectionFactory.class.getName(), null); // factory location
     }
 
-    public SSLConfiguration getSSLConfiguration()
-    {
-        return _sslConfiguration;
-    }
-
     public AMQShortString getDefaultTopicExchangeName()
     {
         return _defaultTopicExchangeName;
@@ -1434,7 +1385,18 @@ public class AMQConnection extends Close
     {
         return _delegate.getProtocolVersion();
     }
-
+    
+    public String getBrokerUUID()
+    {
+        if(getProtocolVersion().equals(ProtocolVersion.v0_10))
+        {
+            return ((AMQConnectionDelegate_0_10)_delegate).getUUID();
+        }
+        else
+        {
+            return null;
+        }
+    }
     public boolean isFailingOver()
     {
         return (_protocolHandler.getFailoverLatch() != null);
@@ -1477,9 +1439,27 @@ public class AMQConnection extends Close
     {
         return _sessions.getNextChannelId();
     }
-    
+
     public boolean isUseLegacyMapMessageFormat()
     {
         return _useLegacyMapMessageFormat;
     }
+
+    private void verifyClientID() throws AMQException
+    {
+        if (Boolean.getBoolean(ClientProperties.QPID_VERIFY_CLIENT_ID))
+        {
+            try
+            {
+                if (!_delegate.verifyClientID())
+                {
+                    throw new AMQException(AMQConstant.ALREADY_EXISTS,"ClientID must be unique");
+                }
+            }
+            catch(JMSException e)
+            {
+                    throw new AMQException(e.getMessage(),e);
+            }
+        }
+    }
 }

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java Mon Sep 19 15:13:18 2011
@@ -57,10 +57,12 @@ public interface AMQConnectionDelegate
     void closeConnection(long timeout) throws JMSException, AMQException;
 
     <T, E extends Exception> T executeRetrySupport(FailoverProtectedOperation<T,E> operation) throws E;
-    
+
     int getMaxChannelID();
 
     int getMinChannelID();
 
     ProtocolVersion getProtocolVersion();
+
+    boolean verifyClientID() throws JMSException, AMQException;
 }

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java Mon Sep 19 15:13:18 2011
@@ -1,6 +1,6 @@
 package org.apache.qpid.client;
 /*
- * 
+ *
  * 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
@@ -8,16 +8,16 @@ package org.apache.qpid.client;
  * 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.
- * 
+ *
  */
 
 
@@ -35,6 +35,7 @@ import javax.jms.XASession;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.failover.FailoverException;
 import org.apache.qpid.client.failover.FailoverProtectedOperation;
+import org.apache.qpid.client.transport.ClientConnectionDelegate;
 import org.apache.qpid.configuration.ClientProperties;
 import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.jms.BrokerDetails;
@@ -43,10 +44,13 @@ import org.apache.qpid.jms.Session;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.transport.Connection;
 import org.apache.qpid.transport.ConnectionClose;
+import org.apache.qpid.transport.ConnectionCloseCode;
 import org.apache.qpid.transport.ConnectionException;
 import org.apache.qpid.transport.ConnectionListener;
 import org.apache.qpid.transport.ConnectionSettings;
 import org.apache.qpid.transport.ProtocolVersionException;
+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;
@@ -59,6 +63,10 @@ public class AMQConnectionDelegate_0_10 
     private static final Logger _logger = LoggerFactory.getLogger(AMQConnectionDelegate_0_10.class);
 
     /**
+     * The name of the UUID property
+     */
+    private static final String UUID_NAME = "qpid.federation_tag";
+    /**
      * The AMQ Connection.
      */
     private AMQConnection _conn;
@@ -86,7 +94,14 @@ public class AMQConnectionDelegate_0_10 
     /**
      * create a Session and start it if required.
      */
+
     public Session createSession(boolean transacted, int acknowledgeMode, int prefetchHigh, int prefetchLow)
+    throws JMSException
+    {
+        return createSession(transacted,acknowledgeMode,prefetchHigh,prefetchLow,null);
+    }
+
+    public Session createSession(boolean transacted, int acknowledgeMode, int prefetchHigh, int prefetchLow, String name)
             throws JMSException
     {
         _conn.checkNotClosed();
@@ -101,7 +116,7 @@ public class AMQConnectionDelegate_0_10 
         try
         {
             session = new AMQSession_0_10(_qpidConnection, _conn, channelId, transacted, acknowledgeMode, prefetchHigh,
-                                          prefetchLow);
+                    prefetchLow,name);
             _conn.registerSession(channelId, session);
             if (_conn._started)
             {
@@ -179,8 +194,8 @@ public class AMQConnectionDelegate_0_10 
                         + _conn.getPassword());
             }
 
-            ConnectionSettings conSettings = new ConnectionSettings();
-            retriveConnectionSettings(conSettings,brokerDetail);
+            ConnectionSettings conSettings = retriveConnectionSettings(brokerDetail);
+            _qpidConnection.setConnectionDelegate(new ClientConnectionDelegate(conSettings, _conn.getConnectionURL()));
             _qpidConnection.connect(conSettings);
 
             _conn._connected = true;
@@ -262,10 +277,10 @@ public class AMQConnectionDelegate_0_10 
         }
 
         ConnectionClose close = exc.getClose();
-        if (close == null)
+        if (close == null || close.getReplyCode() == ConnectionCloseCode.CONNECTION_FORCED)
         {
             _conn.getProtocolHandler().setFailoverLatch(new CountDownLatch(1));
-            
+
             try
             {
                 if (_conn.firePreFailover(false) && _conn.attemptReconnection())
@@ -334,78 +349,20 @@ public class AMQConnectionDelegate_0_10 
     {
         return ProtocolVersion.v0_10;
     }
-    
-    private void retriveConnectionSettings(ConnectionSettings conSettings, BrokerDetails brokerDetail)
+
+    public String getUUID()
+    {
+        return (String)_qpidConnection.getServerProperties().get(UUID_NAME);
+    }
+
+    private ConnectionSettings retriveConnectionSettings(BrokerDetails brokerDetail)
     {
+        ConnectionSettings conSettings = brokerDetail.buildConnectionSettings();
 
-        conSettings.setHost(brokerDetail.getHost());
-        conSettings.setPort(brokerDetail.getPort());
         conSettings.setVhost(_conn.getVirtualHost());
         conSettings.setUsername(_conn.getUsername());
         conSettings.setPassword(_conn.getPassword());
-        
-        // ------------ sasl options ---------------
-        if (brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_MECHS) != null)
-        {
-            conSettings.setSaslMechs(
-                    brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_MECHS));
-        }
 
-        // Sun SASL Kerberos client uses the
-        // protocol + servername as the service key.
-        
-        if (brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_PROTOCOL_NAME) != null)
-        {
-            conSettings.setSaslProtocol(
-                    brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_PROTOCOL_NAME));
-        }
-        
-        
-        if (brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_SERVER_NAME) != null)
-        {
-            conSettings.setSaslServerName(
-                    brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_SERVER_NAME));
-        }
-                        
-        conSettings.setUseSASLEncryption(
-                brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SASL_ENCRYPTION));
-
-        // ------------- ssl options ---------------------
-        conSettings.setUseSSL(brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SSL));
-        
-        if (brokerDetail.getProperty(BrokerDetails.OPTIONS_TRUST_STORE) != null)
-        {
-            conSettings.setTrustStorePath(
-                    brokerDetail.getProperty(BrokerDetails.OPTIONS_TRUST_STORE));
-        }
-
-        if (brokerDetail.getProperty(BrokerDetails.OPTIONS_TRUST_STORE_PASSWORD) != null)
-        {
-            conSettings.setTrustStorePassword(
-                    brokerDetail.getProperty(BrokerDetails.OPTIONS_TRUST_STORE_PASSWORD));
-        }
-        
-        if (brokerDetail.getProperty(BrokerDetails.OPTIONS_KEY_STORE) != null)
-        {
-            conSettings.setKeyStorePath(
-                    brokerDetail.getProperty(BrokerDetails.OPTIONS_KEY_STORE));
-        }
-        
-        if (brokerDetail.getProperty(BrokerDetails.OPTIONS_KEY_STORE_PASSWORD) != null)
-        {
-            conSettings.setKeyStorePassword(
-                    brokerDetail.getProperty(BrokerDetails.OPTIONS_KEY_STORE_PASSWORD));
-        }
-
-        if (brokerDetail.getProperty(BrokerDetails.OPTIONS_SSL_CERT_ALIAS) != null)
-        {
-            conSettings.setCertAlias(
-                    brokerDetail.getProperty(BrokerDetails.OPTIONS_SSL_CERT_ALIAS));
-        }
-        // ----------------------------
-        
-        conSettings.setVerifyHostname(brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SSL_VERIFY_HOSTNAME));
-        
         // Pass client name from connection URL
         Map<String, Object> clientProps = new HashMap<String, Object>();
         try
@@ -417,16 +374,12 @@ public class AMQConnectionDelegate_0_10 
         {
             // Ignore
         }
-        
-        if (brokerDetail.getProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY) != null)
-        {
-            conSettings.setTcpNodelay(
-                    brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY));
-        }
-        
+
         conSettings.setHeartbeatInterval(getHeartbeatInterval(brokerDetail));
+
+        return conSettings;
     }
-    
+
     // The idle_timeout prop is in milisecs while
     // the new heartbeat prop is in secs
     private int getHeartbeatInterval(BrokerDetails brokerDetail)
@@ -441,7 +394,7 @@ public class AMQConnectionDelegate_0_10 
         {
             heartbeat = Integer.parseInt(brokerDetail.getProperty(BrokerDetails.OPTIONS_HEARTBEAT));
         }
-        else if (Integer.getInteger(ClientProperties.IDLE_TIMEOUT_PROP_NAME) != null) 
+        else if (Integer.getInteger(ClientProperties.IDLE_TIMEOUT_PROP_NAME) != null)
         {
             heartbeat = Integer.getInteger(ClientProperties.IDLE_TIMEOUT_PROP_NAME)/1000;
             _logger.warn("JVM arg -Didle_timeout=<mili_secs> is deprecated, please use -Dqpid.heartbeat=<secs>");
@@ -449,12 +402,37 @@ public class AMQConnectionDelegate_0_10 
         else
         {
             heartbeat = Integer.getInteger(ClientProperties.HEARTBEAT,ClientProperties.HEARTBEAT_DEFAULT);
-        } 
+        }
         return heartbeat;
     }
-    
+
     protected org.apache.qpid.transport.Connection getQpidConnection()
     {
         return _qpidConnection;
     }
+
+    public boolean verifyClientID() throws JMSException, AMQException
+    {
+        int prefetch = (int)_conn.getMaxPrefetch();
+        AMQSession_0_10 ssn = (AMQSession_0_10)createSession(false, 1,prefetch,prefetch,_conn.getClientID());
+        org.apache.qpid.transport.Session ssn_0_10 = ssn.getQpidSession();
+        try
+        {
+            ssn_0_10.awaitOpen();
+        }
+        catch(SessionException se)
+        {
+            //if due to non unique client id for user return false, otherwise wrap and re-throw.
+            if (ssn_0_10.getDetachCode() != null &&
+                ssn_0_10.getDetachCode() == SessionDetachCode.SESSION_BUSY)
+            {
+                return false;
+            }
+            else
+            {
+                throw new AMQException(AMQConstant.INTERNAL_ERROR, "Unexpected SessionException thrown while awaiting session opening", se);
+            }
+        }
+        return true;
+    }
 }

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java Mon Sep 19 15:13:18 2011
@@ -23,6 +23,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.security.Security;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.EnumSet;
@@ -31,6 +33,7 @@ import java.util.Set;
 
 import javax.jms.JMSException;
 import javax.jms.XASession;
+import javax.net.ssl.SSLContext;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.failover.FailoverException;
@@ -52,7 +55,9 @@ import org.apache.qpid.ssl.SSLContextFac
 import org.apache.qpid.transport.ConnectionSettings;
 import org.apache.qpid.transport.network.NetworkConnection;
 import org.apache.qpid.transport.network.OutgoingNetworkTransport;
-import org.apache.qpid.transport.network.mina.MinaNetworkTransport;
+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;
 
@@ -93,21 +98,34 @@ public class AMQConnectionDelegate_8_0 i
 
         StateWaiter waiter = _conn._protocolHandler.createWaiter(openOrClosedStates);
 
-        ConnectionSettings settings = new ConnectionSettings();
-        settings.setHost(brokerDetail.getHost());
-        settings.setPort(brokerDetail.getPort());
+        ConnectionSettings settings = brokerDetail.buildConnectionSettings();
         settings.setProtocol(brokerDetail.getTransport());
 
-        SSLConfiguration sslConfig = _conn.getSSLConfiguration();
-        SSLContextFactory sslFactory = null;
-        if (sslConfig != null)
+        SSLContext sslContext = null;
+        if (settings.isUseSSL())
         {
-            sslFactory = new SSLContextFactory(sslConfig.getKeystorePath(), sslConfig.getKeystorePassword(), sslConfig.getCertType());
+            try
+            {
+                sslContext = SSLContextFactory.buildClientContext(
+                                settings.getTrustStorePath(),
+                                settings.getTrustStorePassword(),
+                                settings.getTrustStoreCertType(),
+                                settings.getKeyStorePath(),
+                                settings.getKeyStorePassword(),
+                                settings.getKeyStoreCertType(),
+                                settings.getCertAlias());
+            }
+            catch (GeneralSecurityException e)
+            {
+                throw new AMQException("Unable to create SSLContext: " + e.getMessage(), e);
+            }
         }
 
-        OutgoingNetworkTransport transport = new MinaNetworkTransport();
-        NetworkConnection network = transport.connect(settings, _conn._protocolHandler, sslFactory);
-        _conn._protocolHandler.setNetworkConnection(network);
+        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();
         // this blocks until the connection has been set up or when an error
         // has prevented the connection being set up
@@ -332,4 +350,9 @@ public class AMQConnectionDelegate_8_0 i
     {
         return ProtocolVersion.v8_0;
     }
+
+    public boolean verifyClientID() throws JMSException
+    {
+        return true;
+    }
 }

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java Mon Sep 19 15:13:18 2011
@@ -44,210 +44,34 @@ public class AMQConnectionFactory implem
                                              ObjectFactory, Referenceable, XATopicConnectionFactory,
                                              XAQueueConnectionFactory, XAConnectionFactory
 {
-    private String _host;
-    private int _port;
-    private String _defaultUsername;
-    private String _defaultPassword;
-    private String _virtualPath;
+    private final ConnectionURL _connectionDetails;
 
-    private ConnectionURL _connectionDetails;
-    private SSLConfiguration _sslConfig;
-
-    public AMQConnectionFactory()
-    {
-    }
-
-    /**
-     * This is the Only constructor used!
-     * It is used form the context and from the JNDI objects.
-     */
-    public AMQConnectionFactory(String url) throws URLSyntaxException
-    {
-        _connectionDetails = new AMQConnectionURL(url);
-    }
-
-    /**
-     * This constructor is never used!
-     */
-    public AMQConnectionFactory(ConnectionURL url)
+    public AMQConnectionFactory(final String url) throws URLSyntaxException
     {
-        _connectionDetails = url;
-    }
-
-    /**
-     * This constructor is never used!
-     */
-    public AMQConnectionFactory(String broker, String username, String password, String clientName, String virtualHost)
-            throws URLSyntaxException
-    {
-        this(new AMQConnectionURL(
-                ConnectionURL.AMQ_PROTOCOL + "://" + username + ":" + password + "@" + clientName + "/" + virtualHost + "?brokerlist='" + broker + "'"));
-    }
-
-    /**
-     * This constructor is never used!
-     */
-    public AMQConnectionFactory(String host, int port, String virtualPath)
-    {
-        this(host, port, "guest", "guest", virtualPath);
-    }
-
-    /**
-     * This constructor is never used!
-     */
-    public AMQConnectionFactory(String host, int port, String defaultUsername, String defaultPassword,
-                                String virtualPath)
-    {
-        _host = host;
-        _port = port;
-        _defaultUsername = defaultUsername;
-        _defaultPassword = defaultPassword;
-        _virtualPath = virtualPath;
-
-//todo when setting Host/Port has been resolved then we can use this otherwise those methods won't work with the following line.
-//        _connectionDetails = new AMQConnectionURL(
-//                ConnectionURL.AMQ_PROTOCOL + "://" +
-//                        _defaultUsername + ":" + _defaultPassword + "@" +
-//                        virtualPath + "?brokerlist='tcp://" + host + ":" + port + "'");
-    }
-
-    /**
-     * @return The _defaultPassword.
-     */
-    public final String getDefaultPassword(String password)
-    {
-        if (_connectionDetails != null)
+        if (url == null)
         {
-            return _connectionDetails.getPassword();
+            throw new IllegalArgumentException("url cannot be null");
         }
-        else
-        {
-            return _defaultPassword;
-        }
-    }
-
-    /**
-     * @param password The _defaultPassword to set.
-     */
-    public final void setDefaultPassword(String password)
-    {
-        if (_connectionDetails != null)
-        {
-            _connectionDetails.setPassword(password);
-        }
-        _defaultPassword = password;
-    }
-
-    /**
-     * Getter for SSLConfiguration
-     *
-     * @return SSLConfiguration if set, otherwise null
-     */
-    public final SSLConfiguration getSSLConfiguration()
-    {
-        return _sslConfig;
-    }
 
-    /**
-     * Setter for SSLConfiguration
-     *
-     * @param sslConfig config to store
-     */
-    public final void setSSLConfiguration(SSLConfiguration sslConfig)
-    {
-        _sslConfig = sslConfig;
-    }
-
-    /**
-     * @return The _defaultPassword.
-     */
-    public final String getDefaultUsername(String password)
-    {
-        if (_connectionDetails != null)
-        {
-            return _connectionDetails.getUsername();
-        }
-        else
-        {
-            return _defaultUsername;
-        }
+        _connectionDetails = new AMQConnectionURL(url);
     }
 
-    /**
-     * @param username The _defaultUsername to set.
-     */
-    public final void setDefaultUsername(String username)
+    public AMQConnectionFactory(ConnectionURL url)
     {
-        if (_connectionDetails != null)
+        if (url == null)
         {
-            _connectionDetails.setUsername(username);
+            throw new IllegalArgumentException("url cannot be null");
         }
-        _defaultUsername = username;
-    }
-
-    /**
-     * @return The _host .
-     */
-    public final String getHost()
-    {
-        //todo this doesn't make sense in a multi broker URL as we have no current as that is done by AMQConnection
-        return _host;
-    }
 
-    /**
-     * @param host The _host to set.
-     */
-    public final void setHost(String host)
-    {
-        //todo if _connectionDetails is set then run _connectionDetails.addBrokerDetails()
-        // Should perhaps have this method changed to setBroker(host,port)
-        _host = host;
-    }
-
-    /**
-     * @return _port The _port to set.
-     */
-    public final int getPort()
-    {
-        //todo see getHost
-        return _port;
-    }
-
-    /**
-     * @param port The port to set.
-     */
-    public final void setPort(int port)
-    {
-        //todo see setHost
-        _port = port;
+        _connectionDetails = url;
     }
 
     /**
-     * @return he _virtualPath.
+     * @return the virtualPath of the connection details.
      */
     public final String getVirtualPath()
     {
-        if (_connectionDetails != null)
-        {
-            return _connectionDetails.getVirtualHost();
-        }
-        else
-        {
-            return _virtualPath;
-        }
-    }
-
-    /**
-     * @param path The _virtualPath to set.
-     */
-    public final void setVirtualPath(String path)
-    {
-        if (_connectionDetails != null)
-        {
-            _connectionDetails.setVirtualHost(path);
-        }
-
-        _virtualPath = path;
+        return _connectionDetails.getVirtualHost();
     }
 
     public static String getUniqueClientID()
@@ -267,19 +91,11 @@ public class AMQConnectionFactory implem
     {
         try
         {
-            if (_connectionDetails != null)
-            {
-                if (_connectionDetails.getClientName() == null || _connectionDetails.getClientName().equals(""))
-                {
-                    _connectionDetails.setClientName(getUniqueClientID());
-                }
-                return new AMQConnection(_connectionDetails, _sslConfig);
-            }
-            else
+            if (_connectionDetails.getClientName() == null || _connectionDetails.getClientName().equals(""))
             {
-                return new AMQConnection(_host, _port, _defaultUsername, _defaultPassword, getUniqueClientID(),
-                                         _virtualPath);
+                _connectionDetails.setClientName(getUniqueClientID());
             }
+            return new AMQConnection(_connectionDetails);
         }
         catch (Exception e)
         {
@@ -288,8 +104,6 @@ public class AMQConnectionFactory implem
             jmse.initCause(e);
             throw jmse;
         }
-
-
     }
 
     public Connection createConnection(String userName, String password) throws JMSException
@@ -299,34 +113,35 @@ public class AMQConnectionFactory implem
     
     public Connection createConnection(String userName, String password, String id) throws JMSException
     {
-        try
+        if (_connectionDetails != null)
         {
-            if (_connectionDetails != null)
+            try
             {
-                _connectionDetails.setUsername(userName);
-                _connectionDetails.setPassword(password);
+                ConnectionURL connectionDetails = new AMQConnectionURL(_connectionDetails.toString());
+                connectionDetails.setUsername(userName);
+                connectionDetails.setPassword(password);
                 
                 if (id != null && !id.equals(""))
                 {
-                    _connectionDetails.setClientName(id);
+                    connectionDetails.setClientName(id);
                 } 
-                else if (_connectionDetails.getClientName() == null || _connectionDetails.getClientName().equals(""))
+                else if (connectionDetails.getClientName() == null || connectionDetails.getClientName().equals(""))
                 {
-                    _connectionDetails.setClientName(getUniqueClientID());
+                    connectionDetails.setClientName(getUniqueClientID());
                 }
-                return new AMQConnection(_connectionDetails, _sslConfig);
+                return new AMQConnection(connectionDetails);
             }
-            else
+            catch (Exception e)
             {
-                return new AMQConnection(_host, _port, userName, password, (id != null ? id : getUniqueClientID()), _virtualPath);
+                JMSException jmse = new JMSException("Error creating connection: " + e.getMessage());
+                jmse.setLinkedException(e);
+                jmse.initCause(e);
+                throw jmse;
             }
         }
-        catch (Exception e)
+        else
         {
-            JMSException jmse = new JMSException("Error creating connection: " + e.getMessage());
-            jmse.setLinkedException(e);
-            jmse.initCause(e);
-            throw jmse;
+            throw new JMSException("The connection factory wasn't created with a proper URL, the connection details are empty");
         }
     }
 
@@ -361,12 +176,6 @@ public class AMQConnectionFactory implem
         return _connectionDetails.toString();
     }
 
-
-    public final void setConnectionURLString(String url) throws URLSyntaxException
-    {
-        _connectionDetails = new AMQConnectionURL(url);
-    }
-
     /**
      * JNDI interface to create objects from References.
      *
@@ -457,7 +266,7 @@ public class AMQConnectionFactory implem
     {
         try
         {
-            return new XAConnectionImpl(_connectionDetails, _sslConfig);
+            return new XAConnectionImpl(_connectionDetails);
         }
         catch (Exception e)
         {
@@ -484,19 +293,30 @@ public class AMQConnectionFactory implem
     {
         if (_connectionDetails != null)
         {
-            _connectionDetails.setUsername(username);
-            _connectionDetails.setPassword(password);
-
-            if (_connectionDetails.getClientName() == null || _connectionDetails.getClientName().equals(""))
+            try
             {
-                _connectionDetails.setClientName(getUniqueClientID());
+                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;
             }
         }
         else
         {
-            throw new JMSException("A URL must be specified to access XA connections");
-        }
-        return createXAConnection();
+            throw new JMSException("The connection factory wasn't created with a proper URL, the connection details are empty");
+        }        
     }
 
 

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java Mon Sep 19 15:13:18 2011
@@ -97,7 +97,10 @@ import org.apache.qpid.framing.FieldTabl
 import org.apache.qpid.framing.FieldTableFactory;
 import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.jms.Session;
+import org.apache.qpid.protocol.AMQConstant;
 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;
 
@@ -606,8 +609,9 @@ public abstract class AMQSession<C exten
      * Acknowledges all unacknowledged messages on the session, for all message consumers on the session.
      *
      * @throws IllegalStateException If the session is closed.
+     * @throws JMSException if there is a problem during acknowledge process.
      */
-    public void acknowledge() throws IllegalStateException
+    public void acknowledge() throws IllegalStateException, JMSException
     {
         if (isClosed())
         {
@@ -625,7 +629,15 @@ public abstract class AMQSession<C exten
             {
                 break;
             }
-            acknowledgeMessage(tag, false);
+
+            try
+            {
+                acknowledgeMessage(tag, false);
+            }
+            catch (TransportException e)
+            {
+                throw toJMSException("Exception while acknowledging message(s):" + e.getMessage(), e);
+            }
         }
     }
 
@@ -763,6 +775,10 @@ public abstract class AMQSession<C exten
                         _logger.debug(
                                 "Got FailoverException during channel close, ignored as channel already marked as closed.");
                     }
+                    catch (TransportException e)
+                    {
+                        throw toJMSException("Error closing session:" + e.getMessage(), e);
+                    }
                     finally
                     {
                         _connection.deregisterSession(_channelId);
@@ -874,6 +890,10 @@ public abstract class AMQSession<C exten
         {
             throw new JMSAMQException("Fail-over interrupted commit. Status of the commit is uncertain.", e);
         }
+        catch(TransportException e)
+        {
+            throw toJMSException("Session exception occured while trying to commit: " + e.getMessage(), e);
+        }
     }
 
     public abstract void sendCommit() throws AMQException, FailoverException;
@@ -1071,6 +1091,10 @@ public abstract class AMQSession<C exten
                 ex.setLinkedException(e);
                 throw ex;
             }
+            catch(TransportException e)
+            {
+                throw toJMSException("Error when verifying destination", e);
+            }
         }
         
         String messageSelector = ((selector == null) || (selector.trim().length() == 0)) ? null : selector;
@@ -1156,6 +1180,10 @@ public abstract class AMQSession<C exten
     
             return subscriber;
         }
+        catch (TransportException e)
+        {
+            throw toJMSException("Exception while creating durable subscriber:" + e.getMessage(), e);
+        }
         finally
         {
             _subscriberDetails.unlock();
@@ -1405,7 +1433,6 @@ public abstract class AMQSession<C exten
     {
         checkNotClosed();
 
-        // return (QueueSender) createProducer(queue);
         return new QueueSenderAdapter(createProducer(queue), queue);
     }
 
@@ -1442,7 +1469,6 @@ public abstract class AMQSession<C exten
         checkNotClosed();
         Topic dest = checkValidTopic(topic);
 
-        // AMQTopic dest = new AMQTopic(topic.getTopicName());
         return new TopicSubscriberAdaptor(dest, (C) createExclusiveConsumer(dest));
     }
 
@@ -1727,13 +1753,14 @@ public abstract class AMQSession<C exten
         // Ensure that the session is not transacted.
         checkNotTransacted();
 
-        // flush any acks we are holding in the buffer.
-        flushAcknowledgments();
-        
-        // this is set only here, and the before the consumer's onMessage is called it is set to false
-        _inRecovery = true;
+
         try
         {
+            // flush any acks we are holding in the buffer.
+            flushAcknowledgments();
+
+            // this is set only here, and the before the consumer's onMessage is called it is set to false
+            _inRecovery = true;
 
             boolean isSuspended = isSuspended();
 
@@ -1769,7 +1796,10 @@ public abstract class AMQSession<C exten
         {
             throw new JMSAMQException("Recovery was interrupted by fail-over. Recovery status is not known.", e);
         }
-       
+        catch(TransportException e)
+        {
+            throw toJMSException("Recover failed: " + e.getMessage(), e);
+        }
     }
 
     protected abstract void sendRecover() throws AMQException, FailoverException;
@@ -1854,6 +1884,10 @@ public abstract class AMQSession<C exten
             {
                 throw new JMSAMQException("Fail-over interrupted rollback. Status of the rollback is uncertain.", e);
             }
+            catch (TransportException e)
+            {
+                throw toJMSException("Failure to rollback:" + e.getMessage(), e);
+            }
         }
     }
 
@@ -1900,7 +1934,14 @@ public abstract class AMQSession<C exten
      */
     public void unsubscribe(String name) throws JMSException
     {
-        unsubscribe(name, false);
+        try
+        {
+            unsubscribe(name, false);
+        }
+        catch (TransportException e)
+        {
+            throw toJMSException("Exception while unsubscribing:" + e.getMessage(), e);
+        }
     }
     
     /**
@@ -2021,8 +2062,16 @@ public abstract class AMQSession<C exten
                         // 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);
 
-                        C consumer = createMessageConsumer(amqd, prefetchHigh, prefetchLow,
-                                                                              noLocal, exclusive, messageSelector, ft, noConsume, autoClose);
+                        C consumer;
+                        try
+                        {
+                            consumer = createMessageConsumer(amqd, prefetchHigh, prefetchLow,
+                                                             noLocal, exclusive, messageSelector, ft, noConsume, autoClose);
+                        }
+                        catch(TransportException e)
+                        {
+                            throw toJMSException("Exception while creating consumer: " + e.getMessage(), e);
+                        }
 
                         if (_messageListener != null)
                         {
@@ -2059,7 +2108,10 @@ public abstract class AMQSession<C exten
                             ex.initCause(e);
                             throw ex;
                         }
-
+                        catch (TransportException e)
+                        {
+                            throw toJMSException("Exception while registering consumer:" + e.getMessage(), e);
+                        }
                         return consumer;
                     }
                 }, _connection).execute();
@@ -2601,8 +2653,18 @@ public abstract class AMQSession<C exten
                     {
                         checkNotClosed();
                         long producerId = getNextProducerId();
-                        P producer = createMessageProducer(destination, mandatory,
-                                                           immediate, waitUntilSent, producerId);
+
+                        P producer;
+                        try
+                        {
+                            producer = createMessageProducer(destination, mandatory,
+                                    immediate, waitUntilSent, producerId);
+                        }
+                        catch (TransportException e)
+                        {
+                            throw toJMSException("Exception while creating producer:" + e.getMessage(), e);
+                        }
+
                         registerProducer(producerId, producer);
 
                         return producer;
@@ -3009,6 +3071,10 @@ public abstract class AMQSession<C exten
             {
                 throw new AMQException(null, "Fail-over interrupted suspend/unsuspend channel.", e);
             }
+            catch (TransportException e)
+            {
+                throw new AMQException(AMQConstant.getConstant(getErrorCode(e)), e.getMessage(), e);
+            }
         }
     }
 
@@ -3486,4 +3552,27 @@ public abstract class AMQSession<C exten
     {
     	return DECLARE_EXCHANGES;
     }
+
+    JMSException toJMSException(String message, TransportException e)
+    {
+        int code = getErrorCode(e);
+        JMSException jmse = new JMSException(message, Integer.toString(code));
+        jmse.setLinkedException(e);
+        jmse.initCause(e);
+        return jmse;
+    }
+
+    private int getErrorCode(TransportException e)
+    {
+        int code = AMQConstant.INTERNAL_ERROR.getCode();
+        if (e instanceof SessionException)
+        {
+            SessionException se = (SessionException) e;
+            if(se.getException() != null && se.getException().getErrorCode() != null)
+            {
+                code = se.getException().getErrorCode().getValue();
+            }
+        }
+        return code;
+    }
 }

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java Mon Sep 19 15:13:18 2011
@@ -72,6 +72,7 @@ import org.apache.qpid.transport.RangeSe
 import org.apache.qpid.transport.Session;
 import org.apache.qpid.transport.SessionException;
 import org.apache.qpid.transport.SessionListener;
+import org.apache.qpid.transport.TransportException;
 import org.apache.qpid.util.Serial;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -159,13 +160,20 @@ public class AMQSession_0_10 extends AMQ
      */
     AMQSession_0_10(org.apache.qpid.transport.Connection qpidConnection, AMQConnection con, int channelId,
                     boolean transacted, int acknowledgeMode, MessageFactoryRegistry messageFactoryRegistry,
-                    int defaultPrefetchHighMark, int defaultPrefetchLowMark)
+                    int defaultPrefetchHighMark, int defaultPrefetchLowMark,String name)
     {
 
         super(con, channelId, transacted, acknowledgeMode, messageFactoryRegistry, defaultPrefetchHighMark,
               defaultPrefetchLowMark);
         _qpidConnection = qpidConnection;
-        _qpidSession = _qpidConnection.createSession(1);
+        if (name == null)
+        {
+            _qpidSession = _qpidConnection.createSession(1);
+        }
+        else
+        {
+            _qpidSession = _qpidConnection.createSession(name,1);
+        }
         _qpidSession.setSessionListener(this);
         if (_transacted)
         {
@@ -192,11 +200,12 @@ public class AMQSession_0_10 extends AMQ
      * @param qpidConnection      The connection
      */
     AMQSession_0_10(org.apache.qpid.transport.Connection qpidConnection, AMQConnection con, int channelId,
-                    boolean transacted, int acknowledgeMode, int defaultPrefetchHigh, int defaultPrefetchLow)
+                    boolean transacted, int acknowledgeMode, int defaultPrefetchHigh, int defaultPrefetchLow,
+                    String name)
     {
 
         this(qpidConnection, con, channelId, transacted, acknowledgeMode, MessageFactoryRegistry.newDefaultRegistry(),
-             defaultPrefetchHigh, defaultPrefetchLow);
+             defaultPrefetchHigh, defaultPrefetchLow,name);
     }
 
     private void addUnacked(int id)
@@ -540,7 +549,6 @@ public class AMQSession_0_10 extends AMQ
     }
     
     public boolean isQueueBound(final String exchangeName, final String queueName, final String bindingKey,Map<String,Object> args)
-    throws JMSException
     {
         boolean res;
         ExchangeBoundResult bindingQueryResult =
@@ -684,6 +692,10 @@ public class AMQSession_0_10 extends AMQ
             
             throw ex;
         }
+        catch(TransportException e)
+        {
+            throw toJMSException("Exception while creating message producer:" + e.getMessage(), e);
+        }
 
     }
 
@@ -986,7 +998,8 @@ public class AMQSession_0_10 extends AMQ
         }
     }
 
-    @Override public void commit() throws JMSException
+    @Override
+    public void commit() throws JMSException
     {
         checkTransacted();
         try
@@ -999,6 +1012,10 @@ public class AMQSession_0_10 extends AMQ
             }
             sendCommit();
         }
+        catch(TransportException e)
+        {
+            throw toJMSException("Session exception occured while trying to commit: " + e.getMessage(), e);
+        }
         catch (AMQException e)
         {
             throw new JMSAMQException("Failed to commit: " + e.getMessage(), e);
@@ -1368,5 +1385,5 @@ public class AMQSession_0_10 extends AMQ
         sb.append(">");
         return sb.toString();
     }
-    
+
 }

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java Mon Sep 19 15:13:18 2011
@@ -27,6 +27,7 @@ import org.apache.qpid.client.protocol.A
 import org.apache.qpid.framing.*;
 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;
 
@@ -419,6 +420,10 @@ public abstract class BasicMessageConsum
 
             return null;
         }
+        catch(TransportException e)
+        {
+            throw _session.toJMSException("Exception while receiving:" + e.getMessage(), e);
+        }
         finally
         {
             releaseReceiving();
@@ -489,6 +494,10 @@ public abstract class BasicMessageConsum
 
             return null;
         }
+        catch(TransportException e)
+        {
+            throw _session.toJMSException("Exception while receiving:" + e.getMessage(), e);
+        }
         finally
         {
             releaseReceiving();
@@ -582,6 +591,10 @@ public abstract class BasicMessageConsum
                     {
                         throw new JMSAMQException("FailoverException interrupted basic cancel.", e);
                     }
+                    catch (TransportException e)
+                    {
+                        throw _session.toJMSException("Exception while closing consumer: " + e.getMessage(), e);
+                    }
                 }
             }
             else
@@ -775,7 +788,7 @@ public abstract class BasicMessageConsum
 
     }
 
-    void postDeliver(AbstractJMSMessage msg) throws JMSException
+    void postDeliver(AbstractJMSMessage msg)
     {
         switch (_acknowledgeMode)
         {

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java Mon Sep 19 15:13:18 2011
@@ -23,9 +23,7 @@ import org.apache.qpid.client.AMQDestina
 import org.apache.qpid.client.AMQDestination.DestSyntax;
 import org.apache.qpid.client.failover.FailoverException;
 import org.apache.qpid.client.message.*;
-import org.apache.qpid.client.messaging.address.Node.QueueNode;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQInternalException;
@@ -365,21 +363,28 @@ public class BasicMessageConsumer_0_10 e
     public void setMessageListener(final MessageListener messageListener) throws JMSException
     {
         super.setMessageListener(messageListener);
-        if (messageListener != null && capacity == 0)
-        {
-            _0_10session.getQpidSession().messageFlow(getConsumerTagString(),
-                                                      MessageCreditUnit.MESSAGE, 1,
-                                                      Option.UNRELIABLE);
-        }
-        if (messageListener != null && !_synchronousQueue.isEmpty())
+        try
         {
-            Iterator messages=_synchronousQueue.iterator();
-            while (messages.hasNext())
+            if (messageListener != null && capacity == 0)
             {
-                AbstractJMSMessage message=(AbstractJMSMessage) messages.next();
-                messages.remove();
-                _session.rejectMessage(message, true);
+                _0_10session.getQpidSession().messageFlow(getConsumerTagString(),
+                                                          MessageCreditUnit.MESSAGE, 1,
+                                                          Option.UNRELIABLE);
             }
+            if (messageListener != null && !_synchronousQueue.isEmpty())
+            {
+                Iterator messages=_synchronousQueue.iterator();
+                while (messages.hasNext())
+                {
+                    AbstractJMSMessage message=(AbstractJMSMessage) messages.next();
+                    messages.remove();
+                    _session.rejectMessage(message, true);
+                }
+            }
+        }
+        catch(TransportException e)
+        {
+            throw _session.toJMSException("Exception while setting message listener:"+ e.getMessage(), e);
         }
     }
 
@@ -443,7 +448,7 @@ public class BasicMessageConsumer_0_10 e
         return o;
     }
 
-    void postDeliver(AbstractJMSMessage msg) throws JMSException
+    void postDeliver(AbstractJMSMessage msg)
     {
         super.postDeliver(msg);
         if (_acknowledgeMode == org.apache.qpid.jms.Session.NO_ACKNOWLEDGE && !_session.isInRecovery())

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java Mon Sep 19 15:13:18 2011
@@ -39,6 +39,7 @@ import org.apache.qpid.client.message.Ab
 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;
 import org.slf4j.Logger;
@@ -266,7 +267,7 @@ public abstract class BasicMessageProduc
         return _destination;
     }
 
-    public void close()
+    public void close() throws JMSException
     {
         _closed.set(true);
         _session.deregisterProducer(_producerId);
@@ -498,7 +499,14 @@ public abstract class BasicMessageProduc
             message.setJMSMessageID(messageId);
         }
 
-        sendMessage(destination, origMessage, message, messageId, deliveryMode, priority, timeToLive, mandatory, immediate, wait);
+        try
+        {
+            sendMessage(destination, origMessage, message, messageId, deliveryMode, priority, timeToLive, mandatory, immediate, wait);
+        }
+        catch (TransportException e)
+        {
+            throw getSession().toJMSException("Exception whilst sending:" + e.getMessage(), e);
+        }
 
         if (message != origMessage)
         {
@@ -596,6 +604,13 @@ public abstract class BasicMessageProduc
 
     public boolean isBound(AMQDestination destination) throws JMSException
     {
-        return _session.isQueueBound(destination.getExchangeName(), null, destination.getRoutingKey());
+        try
+        {
+            return _session.isQueueBound(destination.getExchangeName(), null, destination.getRoutingKey());
+        }
+        catch (TransportException e)
+        {
+            throw getSession().toJMSException("Exception whilst checking destination binding:" + e.getMessage(), e);
+        }
     }
 }

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java Mon Sep 19 15:13:18 2011
@@ -35,8 +35,8 @@ import org.apache.qpid.client.AMQDestina
 import org.apache.qpid.client.AMQDestination.DestSyntax;
 import org.apache.qpid.client.message.AMQMessageDelegate_0_10;
 import org.apache.qpid.client.message.AbstractJMSMessage;
+import org.apache.qpid.client.message.QpidMessageProperties;
 import org.apache.qpid.client.messaging.address.Link.Reliability;
-import org.apache.qpid.client.messaging.address.Node.QueueNode;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
 import org.apache.qpid.transport.DeliveryProperties;
 import org.apache.qpid.transport.Header;
@@ -46,6 +46,7 @@ import org.apache.qpid.transport.Message
 import org.apache.qpid.transport.MessageDeliveryPriority;
 import org.apache.qpid.transport.MessageProperties;
 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;
@@ -178,7 +179,7 @@ public class BasicMessageProducer_0_10 e
         
         if (destination.getDestSyntax() == AMQDestination.DestSyntax.ADDR && 
            (destination.getSubject() != null || 
-              (messageProps.getApplicationHeaders() != null && messageProps.getApplicationHeaders().get("qpid.subject") != null))
+              (messageProps.getApplicationHeaders() != null && messageProps.getApplicationHeaders().get(QpidMessageProperties.QPID_SUBJECT) != null))
            )
         {
             Map<String,Object> appProps = messageProps.getApplicationHeaders();
@@ -188,20 +189,21 @@ public class BasicMessageProducer_0_10 e
                 messageProps.setApplicationHeaders(appProps);          
             }
             
-            if (appProps.get("qpid.subject") == null)
+            if (appProps.get(QpidMessageProperties.QPID_SUBJECT) == null)
             {
                 // use default subject in address string
-                appProps.put("qpid.subject",destination.getSubject());
+                appProps.put(QpidMessageProperties.QPID_SUBJECT,destination.getSubject());
             }
                     
-            if (destination.getTargetNode().getType() == AMQDestination.TOPIC_TYPE)
+            if (destination.getAddressType() == AMQDestination.TOPIC_TYPE)
             {
                 deliveryProp.setRoutingKey((String)
-                        messageProps.getApplicationHeaders().get("qpid.subject"));                
+                        messageProps.getApplicationHeaders().get(QpidMessageProperties.QPID_SUBJECT));                
             }
         }
-        
-        messageProps.setContentLength(message.getContentLength());
+
+        ByteBuffer data = message.getData();
+        messageProps.setContentLength(data.remaining());
 
         // send the message
         try
@@ -220,8 +222,8 @@ public class BasicMessageProducer_0_10 e
             boolean unreliable = (destination.getDestSyntax() == DestSyntax.ADDR) &&
                                  (destination.getLink().getReliability() == Reliability.UNRELIABLE);
             
-            org.apache.mina.common.ByteBuffer data = message.getData();
-            ByteBuffer buffer = data == null ? ByteBuffer.allocate(0) : data.buf().slice();
+
+            ByteBuffer buffer = data == null ? ByteBuffer.allocate(0) : data.slice();
             
             ssn.messageTransfer(destination.getExchangeName() == null ? "" : destination.getExchangeName().toString(), 
                                 MessageAcceptMode.NONE,
@@ -244,14 +246,14 @@ public class BasicMessageProducer_0_10 e
         }
     }
 
-
+    @Override
     public boolean isBound(AMQDestination destination) throws JMSException
     {
         return _session.isQueueBound(destination);
     }
     
     @Override
-    public void close()
+    public void close() throws JMSException
     {
         super.close();
         AMQDestination dest = _destination;
@@ -260,10 +262,18 @@ public class BasicMessageProducer_0_10 e
             if (dest.getDelete() == AddressOption.ALWAYS ||
                 dest.getDelete() == AddressOption.SENDER )
             {
-                ((AMQSession_0_10) getSession()).getQpidSession().queueDelete(
+                try
+                {
+                    ((AMQSession_0_10) getSession()).getQpidSession().queueDelete(
                         _destination.getQueueName());
+                }
+                catch(TransportException e)
+                {
+                    throw getSession().toJMSException("Exception while closing producer:" + e.getMessage(), e);
+                }
             }
         }
     }
+
 }
 

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java Mon Sep 19 15:13:18 2011
@@ -27,14 +27,13 @@ import javax.jms.Message;
 import javax.jms.Topic;
 import javax.jms.Queue;
 
-import org.apache.mina.common.ByteBuffer;
+import java.nio.ByteBuffer;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.message.AbstractJMSMessage;
-import org.apache.qpid.client.message.AMQMessageDelegate;
 import org.apache.qpid.client.message.AMQMessageDelegate_0_8;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
 import org.apache.qpid.framing.AMQFrame;
-import org.apache.qpid.framing.BasicConsumeBody;
 import org.apache.qpid.framing.BasicContentHeaderProperties;
 import org.apache.qpid.framing.BasicPublishBody;
 import org.apache.qpid.framing.CompositeAMQDataBlock;
@@ -186,7 +185,9 @@ public class BasicMessageProducer_0_8 ex
 
         if (frames.length == (offset + 1))
         {
-            frames[offset] = ContentBody.createAMQFrame(channelId, new ContentBody(payload));
+            byte[] data = new byte[payload.remaining()];
+            payload.get(data);
+            frames[offset] = ContentBody.createAMQFrame(channelId, new ContentBody(data));
         }
         else
         {
@@ -198,7 +199,10 @@ public class BasicMessageProducer_0_8 ex
                 payload.position((int) framePayloadMax * (i - offset));
                 int length = (remaining >= framePayloadMax) ? (int) framePayloadMax : (int) remaining;
                 payload.limit(payload.position() + length);
-                frames[i] = ContentBody.createAMQFrame(channelId, new ContentBody(payload.slice()));
+                byte[] data = new byte[payload.remaining()];
+                payload.get(data);
+
+                frames[i] = ContentBody.createAMQFrame(channelId, new ContentBody(data));
 
                 remaining -= length;
             }

Modified: qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/XAConnectionImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/XAConnectionImpl.java?rev=1172657&r1=1172656&r2=1172657&view=diff
==============================================================================
--- qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/XAConnectionImpl.java (original)
+++ qpid/branches/qpid-3346/qpid/java/client/src/main/java/org/apache/qpid/client/XAConnectionImpl.java Mon Sep 19 15:13:18 2011
@@ -31,9 +31,9 @@ public class XAConnectionImpl extends AM
     /**
      * Create a XAConnection from a connectionURL
      */
-    public XAConnectionImpl(ConnectionURL connectionURL, SSLConfiguration sslConfig) throws AMQException
+    public XAConnectionImpl(ConnectionURL connectionURL) throws AMQException
     {
-        super(connectionURL, sslConfig);
+        super(connectionURL);
     }
 
     //-- interface XAConnection



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message