Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2D93B95B3 for ; Sat, 12 Nov 2011 16:38:08 +0000 (UTC) Received: (qmail 67105 invoked by uid 500); 12 Nov 2011 16:38:08 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 67065 invoked by uid 500); 12 Nov 2011 16:38:07 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 67058 invoked by uid 99); 12 Nov 2011 16:38:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Nov 2011 16:38:07 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Nov 2011 16:38:04 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4C300238897F for ; Sat, 12 Nov 2011 16:37:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1201283 - in /activemq/activemq-dotnet: Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs Apache.NMS/trunk/src/main/csharp/NMSConnectionFactory.cs Date: Sat, 12 Nov 2011 16:37:44 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111112163744.4C300238897F@eris.apache.org> Author: tabish Date: Sat Nov 12 16:37:43 2011 New Revision: 1201283 URL: http://svn.apache.org/viewvc?rev=1201283&view=rev Log: fix for: https://issues.apache.org/jira/browse/AMQNET-347 Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConnectionFactory.cs Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs?rev=1201283&r1=1201282&r2=1201283&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionFactory.cs Sat Nov 12 16:37:43 2011 @@ -180,9 +180,16 @@ namespace Apache.NMS.ActiveMQ set { Tracer.Info("BrokerUri set = " + value.OriginalString); - - brokerUri = new Uri(URISupport.StripPrefix(value.OriginalString, "activemq:")); - + + if(value.OriginalString.StartsWith("activemqnettx:")) + { + brokerUri = new Uri(URISupport.StripPrefix(value.OriginalString, "activemqnettx:")); + } + else + { + brokerUri = new Uri(URISupport.StripPrefix(value.OriginalString, "activemq:")); + } + if(!String.IsNullOrEmpty(brokerUri.Query) && !brokerUri.OriginalString.EndsWith(")")) { // Since the Uri class will return the end of a Query string found in a Composite Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs?rev=1201283&r1=1201282&r2=1201283&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs Sat Nov 12 16:37:43 2011 @@ -1,184 +1,185 @@ -/* - * 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. - */ - -using System; -using System.Threading; -using Apache.NMS.ActiveMQ.Commands; -using Apache.NMS.ActiveMQ.Transport; -using Apache.NMS.ActiveMQ.Transport.Mock; -using Apache.NMS.Test; -using NUnit.Framework; - -namespace Apache.NMS.ActiveMQ.Test -{ - [TestFixture] - public class NMSConnectionFactoryTest - { - private static String username = "guest"; - private static String password = "guest"; - private ConnectionInfo info = null; - - [Test] - [TestCase("tcp://${activemqhost}:61616")] - [TestCase("activemq:tcp://${activemqhost}:61616")] - [TestCase("activemq:tcp://${activemqhost}:61616/0.0.0.0:0")] - [TestCase("activemq:tcp://${activemqhost}:61616?connection.asyncclose=false")] - [TestCase("activemq:failover:tcp://${activemqhost}:61616")] - [TestCase("activemq:failover:(tcp://${activemqhost}:61616)")] - [TestCase("activemq:failover:(tcp://${activemqhost}:61616,tcp://${activemqhost}:61616)")] - [TestCase("activemq:failover://(tcp://${activemqhost}:61616)?transport.initialReconnectDelay=100")] - [TestCase("activemq:failover:(tcp://${activemqhost}:61616)?connection.asyncSend=true")] - [TestCase("activemq:failover:(tcp://${activemqhost}:61616)?transport.timeout=100&connection.asyncSend=true")] - [TestCase("activemq:failover:tcp://${activemqhost}:61616?keepAlive=false&wireFormat.maxInactivityDuration=1000")] - [TestCase("activemq:failover:(tcp://${activemqhost}:61616?keepAlive=false&wireFormat.maxInactivityDuration=1000)")] - [TestCase("activemq:failover:(tcp://${activemqhost}:61616?keepAlive=false&wireFormat.maxInactivityDuration=1000)?connection.asyncclose=false")] - -#if false - [TestCase("activemq:discovery:multicast://default")] - [TestCase("activemq:discovery:(multicast://default)")] - [TestCase("activemq:failover:discovery:multicast://default")] - [TestCase("activemq:failover:discovery:(multicast://default)")] - [TestCase("activemq:failover:(discovery:(multicast://default))")] -#endif - - [TestCase("activemq:tcp://${activemqhost}:61616/InvalidHost:0", ExpectedException = typeof(NMSConnectionException))] - [TestCase("activemq:tcp://${activemqhost}:61616/0.0.0.0:-1", ExpectedException = typeof(NMSConnectionException))] - [TestCase("tcp://InvalidHost:61616", ExpectedException = typeof(NMSConnectionException))] - [TestCase("activemq:tcp://InvalidHost:61616", ExpectedException = typeof(NMSConnectionException))] - [TestCase("activemq:tcp://InvalidHost:61616?connection.asyncclose=false", ExpectedException = typeof(NMSConnectionException))] - - [TestCase("tcp://${activemqhost}:61616?connection.InvalidParameter=true", ExpectedException = typeof(NMSConnectionException))] - [TestCase("activemq:tcp://${activemqhost}:61616?connection.InvalidParameter=true", ExpectedException = typeof(NMSConnectionException))] - [TestCase("activemq:failover:tcp://${activemqhost}:61616?connection.InvalidParameter=true", ExpectedException = typeof(NMSConnectionException))] - [TestCase("activemq:failover:(tcp://${activemqhost}:61616)?connection.InvalidParameter=true", ExpectedException = typeof(NMSConnectionException))] - [TestCase("activemq:failover:(tcp://${activemqhost}:61616,tcp://${activemqbackuphost}:61616)?connection.InvalidParameter=true", ExpectedException = typeof(NMSConnectionException))] - - [TestCase("ftp://${activemqhost}:61616", ExpectedException = typeof(NMSConnectionException))] - [TestCase("http://${activemqhost}:61616", ExpectedException = typeof(NMSConnectionException))] - [TestCase("discovery://${activemqhost}:6155", ExpectedException = typeof(NMSConnectionException))] - [TestCase("sms://${activemqhost}:61616", ExpectedException = typeof(NMSConnectionException))] - [TestCase("activemq:multicast://${activemqhost}:6155", ExpectedException = typeof(NMSConnectionException))] - [TestCase("activemq:(tcp://${activemqhost}:61616)?connection.asyncClose=false", ExpectedException = typeof(NMSConnectionException))] - - [TestCase("(tcp://${activemqhost}:61616,tcp://${activemqhost}:61616)", ExpectedException = typeof(UriFormatException))] - [TestCase("tcp://${activemqhost}:61616,tcp://${activemqhost}:61616", ExpectedException = typeof(UriFormatException))] - public void TestURI(string connectionURI) - { - NMSConnectionFactory factory = new NMSConnectionFactory(NMSTestSupport.ReplaceEnvVar(connectionURI)); - Assert.IsNotNull(factory); - Assert.IsNotNull(factory.ConnectionFactory); - using(IConnection connection = factory.CreateConnection("", "")) - { - Assert.IsNotNull(connection); - connection.Close(); - } - } - - [Test] - public void TestConnectionSendsAuthenticationData() - { - NMSConnectionFactory factory = new NMSConnectionFactory("activemq:mock://localhost:61616"); - Assert.IsNotNull(factory); - Assert.IsNotNull(factory.ConnectionFactory); - using(Connection connection = factory.CreateConnection(username, password) as Connection) - { - Assert.IsNotNull(connection); - - MockTransport transport = (MockTransport) connection.ITransport.Narrow(typeof(MockTransport)); - - transport.OutgoingCommand = new CommandHandler(OnOutgoingCommand); - - connection.Start(); - - Thread.Sleep(1000); - - Assert.IsNotNull(this.info); - Assert.AreEqual(username, info.UserName); - Assert.AreEqual(password, info.Password); - - connection.Close(); - } - } - - public void OnOutgoingCommand(ITransport transport, Command command) - { - if(command.IsConnectionInfo) - { - this.info = command as ConnectionInfo; - } - } - - [Test] - [TestCase(1, 2, 3, 4, 5)] - [TestCase(112, 212, 312, 412, 512)] - public void TestURIForPrefetchHandling(int queuePreFetch, int queueBrowserPrefetch, int topicPrefetch, int durableTopicPrefetch, int maximumPendingMessageLimit) - { - string testuri = string.Format("activemq:tcp://${{activemqhost}}:61616" + - "?nms.PrefetchPolicy.queuePrefetch={0}" + - "&nms.PrefetchPolicy.queueBrowserPrefetch={1}" + - "&nms.PrefetchPolicy.topicPrefetch={2}" + - "&nms.PrefetchPolicy.durableTopicPrefetch={3}" + - "&nms.PrefetchPolicy.maximumPendingMessageLimit={4}", - queuePreFetch, queueBrowserPrefetch, topicPrefetch, durableTopicPrefetch, maximumPendingMessageLimit); - - NMSConnectionFactory factory = new NMSConnectionFactory(NMSTestSupport.ReplaceEnvVar(testuri)); - - Assert.IsNotNull(factory); - Assert.IsNotNull(factory.ConnectionFactory); - using(IConnection connection = factory.CreateConnection("", "")) - { - Assert.IsNotNull(connection); - - Connection amqConnection = connection as Connection; - Assert.AreEqual(queuePreFetch, amqConnection.PrefetchPolicy.QueuePrefetch); - Assert.AreEqual(queueBrowserPrefetch, amqConnection.PrefetchPolicy.QueueBrowserPrefetch); - Assert.AreEqual(topicPrefetch, amqConnection.PrefetchPolicy.TopicPrefetch); - Assert.AreEqual(durableTopicPrefetch, amqConnection.PrefetchPolicy.DurableTopicPrefetch); - Assert.AreEqual(maximumPendingMessageLimit, amqConnection.PrefetchPolicy.MaximumPendingMessageLimit); - - connection.Close(); - } - } - - [Test] - [TestCase(0)] - [TestCase(1)] - [TestCase(1000)] - public void TestURIForPrefetchHandlingOfAll(int allPreFetch) - { - string testuri = string.Format("activemq:tcp://${{activemqhost}}:61616" + - "?nms.PrefetchPolicy.all={0}", allPreFetch); - - NMSConnectionFactory factory = new NMSConnectionFactory(NMSTestSupport.ReplaceEnvVar(testuri)); - - Assert.IsNotNull(factory); - Assert.IsNotNull(factory.ConnectionFactory); - using(IConnection connection = factory.CreateConnection("", "")) - { - Assert.IsNotNull(connection); - - Connection amqConnection = connection as Connection; - Assert.AreEqual(allPreFetch, amqConnection.PrefetchPolicy.QueuePrefetch); - Assert.AreEqual(allPreFetch, amqConnection.PrefetchPolicy.QueueBrowserPrefetch); - Assert.AreEqual(allPreFetch, amqConnection.PrefetchPolicy.TopicPrefetch); - Assert.AreEqual(allPreFetch, amqConnection.PrefetchPolicy.DurableTopicPrefetch); - - connection.Close(); - } - } - } -} +/* + * 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. + */ + +using System; +using System.Threading; +using Apache.NMS.ActiveMQ.Commands; +using Apache.NMS.ActiveMQ.Transport; +using Apache.NMS.ActiveMQ.Transport.Mock; +using Apache.NMS.Test; +using NUnit.Framework; + +namespace Apache.NMS.ActiveMQ.Test +{ + [TestFixture] + public class NMSConnectionFactoryTest + { + private static String username = "guest"; + private static String password = "guest"; + private ConnectionInfo info = null; + + [Test] + [TestCase("tcp://${activemqhost}:61616")] + [TestCase("activemq:tcp://${activemqhost}:61616")] + [TestCase("activemqnettx:tcp://${activemqhost}:61616")] + [TestCase("activemq:tcp://${activemqhost}:61616/0.0.0.0:0")] + [TestCase("activemq:tcp://${activemqhost}:61616?connection.asyncclose=false")] + [TestCase("activemq:failover:tcp://${activemqhost}:61616")] + [TestCase("activemq:failover:(tcp://${activemqhost}:61616)")] + [TestCase("activemq:failover:(tcp://${activemqhost}:61616,tcp://${activemqhost}:61616)")] + [TestCase("activemq:failover://(tcp://${activemqhost}:61616)?transport.initialReconnectDelay=100")] + [TestCase("activemq:failover:(tcp://${activemqhost}:61616)?connection.asyncSend=true")] + [TestCase("activemq:failover:(tcp://${activemqhost}:61616)?transport.timeout=100&connection.asyncSend=true")] + [TestCase("activemq:failover:tcp://${activemqhost}:61616?keepAlive=false&wireFormat.maxInactivityDuration=1000")] + [TestCase("activemq:failover:(tcp://${activemqhost}:61616?keepAlive=false&wireFormat.maxInactivityDuration=1000)")] + [TestCase("activemq:failover:(tcp://${activemqhost}:61616?keepAlive=false&wireFormat.maxInactivityDuration=1000)?connection.asyncclose=false")] + +#if false + [TestCase("activemq:discovery:multicast://default")] + [TestCase("activemq:discovery:(multicast://default)")] + [TestCase("activemq:failover:discovery:multicast://default")] + [TestCase("activemq:failover:discovery:(multicast://default)")] + [TestCase("activemq:failover:(discovery:(multicast://default))")] +#endif + + [TestCase("activemq:tcp://${activemqhost}:61616/InvalidHost:0", ExpectedException = typeof(NMSConnectionException))] + [TestCase("activemq:tcp://${activemqhost}:61616/0.0.0.0:-1", ExpectedException = typeof(NMSConnectionException))] + [TestCase("tcp://InvalidHost:61616", ExpectedException = typeof(NMSConnectionException))] + [TestCase("activemq:tcp://InvalidHost:61616", ExpectedException = typeof(NMSConnectionException))] + [TestCase("activemq:tcp://InvalidHost:61616?connection.asyncclose=false", ExpectedException = typeof(NMSConnectionException))] + + [TestCase("tcp://${activemqhost}:61616?connection.InvalidParameter=true", ExpectedException = typeof(NMSConnectionException))] + [TestCase("activemq:tcp://${activemqhost}:61616?connection.InvalidParameter=true", ExpectedException = typeof(NMSConnectionException))] + [TestCase("activemq:failover:tcp://${activemqhost}:61616?connection.InvalidParameter=true", ExpectedException = typeof(NMSConnectionException))] + [TestCase("activemq:failover:(tcp://${activemqhost}:61616)?connection.InvalidParameter=true", ExpectedException = typeof(NMSConnectionException))] + [TestCase("activemq:failover:(tcp://${activemqhost}:61616,tcp://${activemqbackuphost}:61616)?connection.InvalidParameter=true", ExpectedException = typeof(NMSConnectionException))] + + [TestCase("ftp://${activemqhost}:61616", ExpectedException = typeof(NMSConnectionException))] + [TestCase("http://${activemqhost}:61616", ExpectedException = typeof(NMSConnectionException))] + [TestCase("discovery://${activemqhost}:6155", ExpectedException = typeof(NMSConnectionException))] + [TestCase("sms://${activemqhost}:61616", ExpectedException = typeof(NMSConnectionException))] + [TestCase("activemq:multicast://${activemqhost}:6155", ExpectedException = typeof(NMSConnectionException))] + [TestCase("activemq:(tcp://${activemqhost}:61616)?connection.asyncClose=false", ExpectedException = typeof(NMSConnectionException))] + + [TestCase("(tcp://${activemqhost}:61616,tcp://${activemqhost}:61616)", ExpectedException = typeof(UriFormatException))] + [TestCase("tcp://${activemqhost}:61616,tcp://${activemqhost}:61616", ExpectedException = typeof(UriFormatException))] + public void TestURI(string connectionURI) + { + NMSConnectionFactory factory = new NMSConnectionFactory(NMSTestSupport.ReplaceEnvVar(connectionURI)); + Assert.IsNotNull(factory); + Assert.IsNotNull(factory.ConnectionFactory); + using(IConnection connection = factory.CreateConnection("", "")) + { + Assert.IsNotNull(connection); + connection.Close(); + } + } + + [Test] + public void TestConnectionSendsAuthenticationData() + { + NMSConnectionFactory factory = new NMSConnectionFactory("activemq:mock://localhost:61616"); + Assert.IsNotNull(factory); + Assert.IsNotNull(factory.ConnectionFactory); + using(Connection connection = factory.CreateConnection(username, password) as Connection) + { + Assert.IsNotNull(connection); + + MockTransport transport = (MockTransport) connection.ITransport.Narrow(typeof(MockTransport)); + + transport.OutgoingCommand = new CommandHandler(OnOutgoingCommand); + + connection.Start(); + + Thread.Sleep(1000); + + Assert.IsNotNull(this.info); + Assert.AreEqual(username, info.UserName); + Assert.AreEqual(password, info.Password); + + connection.Close(); + } + } + + public void OnOutgoingCommand(ITransport transport, Command command) + { + if(command.IsConnectionInfo) + { + this.info = command as ConnectionInfo; + } + } + + [Test] + [TestCase(1, 2, 3, 4, 5)] + [TestCase(112, 212, 312, 412, 512)] + public void TestURIForPrefetchHandling(int queuePreFetch, int queueBrowserPrefetch, int topicPrefetch, int durableTopicPrefetch, int maximumPendingMessageLimit) + { + string testuri = string.Format("activemq:tcp://${{activemqhost}}:61616" + + "?nms.PrefetchPolicy.queuePrefetch={0}" + + "&nms.PrefetchPolicy.queueBrowserPrefetch={1}" + + "&nms.PrefetchPolicy.topicPrefetch={2}" + + "&nms.PrefetchPolicy.durableTopicPrefetch={3}" + + "&nms.PrefetchPolicy.maximumPendingMessageLimit={4}", + queuePreFetch, queueBrowserPrefetch, topicPrefetch, durableTopicPrefetch, maximumPendingMessageLimit); + + NMSConnectionFactory factory = new NMSConnectionFactory(NMSTestSupport.ReplaceEnvVar(testuri)); + + Assert.IsNotNull(factory); + Assert.IsNotNull(factory.ConnectionFactory); + using(IConnection connection = factory.CreateConnection("", "")) + { + Assert.IsNotNull(connection); + + Connection amqConnection = connection as Connection; + Assert.AreEqual(queuePreFetch, amqConnection.PrefetchPolicy.QueuePrefetch); + Assert.AreEqual(queueBrowserPrefetch, amqConnection.PrefetchPolicy.QueueBrowserPrefetch); + Assert.AreEqual(topicPrefetch, amqConnection.PrefetchPolicy.TopicPrefetch); + Assert.AreEqual(durableTopicPrefetch, amqConnection.PrefetchPolicy.DurableTopicPrefetch); + Assert.AreEqual(maximumPendingMessageLimit, amqConnection.PrefetchPolicy.MaximumPendingMessageLimit); + + connection.Close(); + } + } + + [Test] + [TestCase(0)] + [TestCase(1)] + [TestCase(1000)] + public void TestURIForPrefetchHandlingOfAll(int allPreFetch) + { + string testuri = string.Format("activemq:tcp://${{activemqhost}}:61616" + + "?nms.PrefetchPolicy.all={0}", allPreFetch); + + NMSConnectionFactory factory = new NMSConnectionFactory(NMSTestSupport.ReplaceEnvVar(testuri)); + + Assert.IsNotNull(factory); + Assert.IsNotNull(factory.ConnectionFactory); + using(IConnection connection = factory.CreateConnection("", "")) + { + Assert.IsNotNull(connection); + + Connection amqConnection = connection as Connection; + Assert.AreEqual(allPreFetch, amqConnection.PrefetchPolicy.QueuePrefetch); + Assert.AreEqual(allPreFetch, amqConnection.PrefetchPolicy.QueueBrowserPrefetch); + Assert.AreEqual(allPreFetch, amqConnection.PrefetchPolicy.TopicPrefetch); + Assert.AreEqual(allPreFetch, amqConnection.PrefetchPolicy.DurableTopicPrefetch); + + connection.Close(); + } + } + } +} Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConnectionFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConnectionFactory.cs?rev=1201283&r1=1201282&r2=1201283&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConnectionFactory.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConnectionFactory.cs Sat Nov 12 16:37:43 2011 @@ -1,437 +1,438 @@ -/* - * 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. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Xml; - -using Apache.NMS.Util; - -namespace Apache.NMS -{ - /// - /// Provider implementation mapping class. - /// - public class ProviderFactoryInfo - { - public string assemblyFileName; - public string factoryClassName; - - public ProviderFactoryInfo(string aFileName, string fClassName) - { - assemblyFileName = aFileName; - factoryClassName = fClassName; - } - } - - /// - /// Implementation of a factory for instances. - /// - public class NMSConnectionFactory : IConnectionFactory - { - protected readonly IConnectionFactory factory; - protected static readonly Dictionary schemaProviderFactoryMap; - - /// - /// Static class constructor - /// - static NMSConnectionFactory() - { - schemaProviderFactoryMap = new Dictionary(); - schemaProviderFactoryMap["activemq"] = new ProviderFactoryInfo("Apache.NMS.ActiveMQ", "Apache.NMS.ActiveMQ.ConnectionFactory"); - schemaProviderFactoryMap["tcp"] = new ProviderFactoryInfo("Apache.NMS.ActiveMQ", "Apache.NMS.ActiveMQ.ConnectionFactory"); - schemaProviderFactoryMap["ems"] = new ProviderFactoryInfo("Apache.NMS.EMS", "Apache.NMS.EMS.ConnectionFactory"); - schemaProviderFactoryMap["msmq"] = new ProviderFactoryInfo("Apache.NMS.MSMQ", "Apache.NMS.MSMQ.ConnectionFactory"); - schemaProviderFactoryMap["stomp"] = new ProviderFactoryInfo("Apache.NMS.Stomp", "Apache.NMS.Stomp.ConnectionFactory"); - schemaProviderFactoryMap["xms"] = new ProviderFactoryInfo("Apache.NMS.XMS", "Apache.NMS.XMS.ConnectionFactory"); - schemaProviderFactoryMap["zmq"] = new ProviderFactoryInfo("Apache.NMS.ZMQ", "Apache.NMS.ZMQ.ConnectionFactory"); - } - - /// - /// The ConnectionFactory object must define a constructor that takes as a minimum a Uri object. - /// Any additional parameters are optional, but will typically include a Client ID string. - /// - /// The URI for the ActiveMQ provider. - /// Optional parameters to use when creating the ConnectionFactory. - public NMSConnectionFactory(string providerURI, params object[] constructorParams) - : this(URISupport.CreateCompatibleUri(providerURI), constructorParams) - { - } - - /// - /// The ConnectionFactory object must define a constructor that takes as a minimum a Uri object. - /// Any additional parameters are optional, but will typically include a Client ID string. - /// - /// The URI for the ActiveMQ provider. - /// Optional parameters to use when creating the ConnectionFactory. - public NMSConnectionFactory(Uri uriProvider, params object[] constructorParams) - { - this.factory = CreateConnectionFactory(uriProvider, constructorParams); - } - - /// - /// Create a connection factory that can create connections for the given scheme in the URI. - /// - /// The URI for the ActiveMQ provider. - /// Optional parameters to use when creating the ConnectionFactory. - /// A implementation that will be used. - public static IConnectionFactory CreateConnectionFactory(Uri uriProvider, params object[] constructorParams) - { - IConnectionFactory connectionFactory = null; - - try - { - Type factoryType = GetTypeForScheme(uriProvider.Scheme); - - // If an implementation was found, try to instantiate it. - if(factoryType != null) - { -#if NETCF - // Compact framework does not allow the activator ta pass parameters to a constructor. - connectionFactory = (IConnectionFactory) Activator.CreateInstance(factoryType); - connectionFactory.BrokerUri = uriProvider; -#else - object[] parameters = MakeParameterArray(uriProvider, constructorParams); - connectionFactory = (IConnectionFactory) Activator.CreateInstance(factoryType, parameters); -#endif - } - - if(null == connectionFactory) - { - throw new NMSConnectionException("No IConnectionFactory implementation found for connection URI: " + uriProvider); - } - } - catch(NMSConnectionException) - { - throw; - } - catch(Exception ex) - { - throw new NMSConnectionException("Could not create the IConnectionFactory implementation: " + ex.Message, ex); - } - - return connectionFactory; - } - - /// - /// Finds the associated with the given scheme. - /// - /// The scheme (e.g. tcp, activemq or stomp). - /// The of the ConnectionFactory that will be used - /// to create the connection for the specified . - private static Type GetTypeForScheme(string scheme) - { - string[] paths = GetConfigSearchPaths(); - string assemblyFileName; - string factoryClassName; - Type factoryType = null; - - Tracer.DebugFormat("Locating provider for scheme: {0}", scheme); - if(LookupConnectionFactoryInfo(paths, scheme, out assemblyFileName, out factoryClassName)) - { - Assembly assembly = null; - - Tracer.DebugFormat("Attempting to load provider assembly: {0}", assemblyFileName); - try - { - assembly = Assembly.Load(assemblyFileName); - if(null != assembly) - { - Tracer.Debug("Succesfully loaded provider."); - } - } - catch(Exception ex) - { - Tracer.ErrorFormat("Exception loading assembly failed: {0}", ex.Message); - assembly = null; - } - - if(null == assembly) - { - foreach(string path in paths) - { - string fullpath = Path.Combine(path, assemblyFileName) + ".dll"; - - Tracer.DebugFormat("Looking for: {0}", fullpath); - if(File.Exists(fullpath)) - { - Tracer.Debug("\tAssembly found! Attempting to load..."); - try - { - assembly = Assembly.LoadFrom(fullpath); - } - catch(Exception ex) - { - Tracer.ErrorFormat("Exception loading assembly failed: {0}", ex.Message); - assembly = null; - } - - if(null != assembly) - { - Tracer.Debug("Successfully loaded provider."); - break; - } - - Tracer.Debug("Failed to load provider. Continuing search..."); - } - } - } - - if(null != assembly) - { -#if NETCF - factoryType = assembly.GetType(factoryClassName, true); -#else - factoryType = assembly.GetType(factoryClassName, true, true); -#endif - if(null == factoryType) - { - Tracer.Fatal("Failed to load class factory from provider."); - } - } - else - { - Tracer.Fatal("Failed to load provider assembly."); - } - } - - return factoryType; - } - - /// - /// Lookup the connection factory assembly filename and class name. - /// Read an external configuration file that maps scheme to provider implementation. - /// Load XML config files named: nmsprovider-{scheme}.config - /// Following is a sample configuration file named nmsprovider-jms.config. Replace - /// the parenthesis with angle brackets for proper XML formatting. - /// - /// (?xml version="1.0" encoding="utf-8" ?) - /// (configuration) - /// (provider assembly="MyCompany.NMS.JMSProvider.dll" classFactory="MyCompany.NMS.JMSProvider.ConnectionFactory"/) - /// (/configuration) - /// - /// This configuration file would be loaded and parsed when a connection uri with a scheme of 'jms' - /// is used for the provider. In this example the connection string might look like: - /// jms://localhost:7222 - /// - /// - /// Folder paths to look in. - /// The scheme. - /// Name of the assembly file. - /// Name of the factory class. - /// true if the configuration file for the specified could - /// be found; otherwise, false. - private static bool LookupConnectionFactoryInfo(string[] paths, string scheme, out string assemblyFileName, out string factoryClassName) - { - bool foundFactory = false; - string schemeLower = scheme.ToLower(); - ProviderFactoryInfo pfi; - - // Look for a custom configuration to handle this scheme. - string configFileName = String.Format("nmsprovider-{0}.config", schemeLower); - - assemblyFileName = String.Empty; - factoryClassName = String.Empty; - - Tracer.DebugFormat("Attempting to locate provider configuration: {0}", configFileName); - foreach(string path in paths) - { - string fullpath = Path.Combine(path, configFileName); - Tracer.DebugFormat("Looking for: {0}", fullpath); - - try - { - if(File.Exists(fullpath)) - { - Tracer.DebugFormat("\tConfiguration file found in {0}", fullpath); - XmlDocument configDoc = new XmlDocument(); - - configDoc.Load(fullpath); - XmlElement providerNode = (XmlElement) configDoc.SelectSingleNode("/configuration/provider"); - - if(null != providerNode) - { - assemblyFileName = providerNode.GetAttribute("assembly"); - factoryClassName = providerNode.GetAttribute("classFactory"); - if(!String.IsNullOrEmpty(assemblyFileName) && !String.IsNullOrEmpty(factoryClassName)) - { - foundFactory = true; - Tracer.DebugFormat("Selected custom provider for {0}: {1}, {2}", schemeLower, assemblyFileName, factoryClassName); - break; - } - } - } - } - catch(Exception ex) - { - Tracer.DebugFormat("Exception while scanning {0}: {1}", fullpath, ex.Message); - } - } - - if(!foundFactory) - { - // Check for standard provider implementations. - if(schemaProviderFactoryMap.TryGetValue(schemeLower, out pfi)) - { - assemblyFileName = pfi.assemblyFileName; - factoryClassName = pfi.factoryClassName; - foundFactory = true; - Tracer.DebugFormat("Selected standard provider for {0}: {1}, {2}", schemeLower, assemblyFileName, factoryClassName); - } - } - - return foundFactory; - } - - /// - /// Get an array of search paths to look for config files. - /// - /// - /// A collection of search paths, including the current directory, the current AppDomain's - /// BaseDirectory and the current AppDomain's RelativeSearchPath. - /// - private static string[] GetConfigSearchPaths() - { - ArrayList pathList = new ArrayList(); - - // Check the current folder first. - pathList.Add(""); -#if !NETCF - try - { - AppDomain currentDomain = AppDomain.CurrentDomain; - - // Check the folder the assembly is located in. - Assembly executingAssembly = Assembly.GetExecutingAssembly(); - try - { - pathList.Add(Path.GetDirectoryName(executingAssembly.Location)); - } - catch(Exception ex) - { - Tracer.DebugFormat("Error parsing executing assembly location: {0} : {1}", executingAssembly.Location, ex.Message); - } - - if(null != currentDomain.BaseDirectory) - { - pathList.Add(currentDomain.BaseDirectory); - } - - if(null != currentDomain.RelativeSearchPath) - { - pathList.Add(currentDomain.RelativeSearchPath); - } - } - catch(Exception ex) - { - Tracer.DebugFormat("Error configuring search paths: {0}", ex.Message); - } -#endif - - return (string[]) pathList.ToArray(typeof(string)); - } - - /// - /// Converts a params object[] collection into a plain object[]s, to pass to the constructor. - /// - /// The first parameter in the collection. - /// The remaining parameters. - /// An array of instances. - private static object[] MakeParameterArray(object firstParam, params object[] varParams) - { - ArrayList paramList = new ArrayList(); - paramList.Add(firstParam); - foreach(object param in varParams) - { - paramList.Add(param); - } - - return paramList.ToArray(); - } - - /// - /// Creates a new connection. - /// - /// An created by the requested ConnectionFactory. - public IConnection CreateConnection() - { - return this.factory.CreateConnection(); - } - - /// - /// Creates a new connection with the given and credentials. - /// - /// The username to use when establishing the connection. - /// The password to use when establishing the connection. - /// An created by the requested ConnectionFactory. - public IConnection CreateConnection(string userName, string password) - { - return this.factory.CreateConnection(userName, password); - } - - /// - /// Get/or set the broker Uri. - /// - public Uri BrokerUri - { - get { return ConnectionFactory.BrokerUri; } - set { ConnectionFactory.BrokerUri = value; } - } - - /// - /// The actual IConnectionFactory implementation that is being used. This implementation - /// depends on the scheme of the URI used when constructed. - /// - public IConnectionFactory ConnectionFactory - { - get { return factory; } - } - - /// - /// Get/or Set the IRedeliveryPolicy instance using the IConnectionFactory implementation - /// that is being used. - /// - public IRedeliveryPolicy RedeliveryPolicy - { - get { return this.factory.RedeliveryPolicy; } - set { this.factory.RedeliveryPolicy = value; } - } - - /// - /// Get/or Set the ConsumerTransformerDelegate using the IConnectionFactory implementation - /// that is currently being used. - /// - public ConsumerTransformerDelegate ConsumerTransformer - { - get { return this.factory.ConsumerTransformer; } - set { this.factory.ConsumerTransformer = value; } - } - - /// - /// Get/or Set the ProducerTransformerDelegate using the IConnectionFactory implementation - /// that is currently being used. - /// - public ProducerTransformerDelegate ProducerTransformer - { - get { return this.factory.ProducerTransformer; } - set { this.factory.ProducerTransformer = value; } - } - } -} +/* + * 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. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Xml; + +using Apache.NMS.Util; + +namespace Apache.NMS +{ + /// + /// Provider implementation mapping class. + /// + public class ProviderFactoryInfo + { + public string assemblyFileName; + public string factoryClassName; + + public ProviderFactoryInfo(string aFileName, string fClassName) + { + assemblyFileName = aFileName; + factoryClassName = fClassName; + } + } + + /// + /// Implementation of a factory for instances. + /// + public class NMSConnectionFactory : IConnectionFactory + { + protected readonly IConnectionFactory factory; + protected static readonly Dictionary schemaProviderFactoryMap; + + /// + /// Static class constructor + /// + static NMSConnectionFactory() + { + schemaProviderFactoryMap = new Dictionary(); + schemaProviderFactoryMap["activemq"] = new ProviderFactoryInfo("Apache.NMS.ActiveMQ", "Apache.NMS.ActiveMQ.ConnectionFactory"); + schemaProviderFactoryMap["activemqnettx"] = new ProviderFactoryInfo("Apache.NMS.ActiveMQ", "Apache.NMS.ActiveMQ.NetTxConnectionFactory"); + schemaProviderFactoryMap["tcp"] = new ProviderFactoryInfo("Apache.NMS.ActiveMQ", "Apache.NMS.ActiveMQ.ConnectionFactory"); + schemaProviderFactoryMap["ems"] = new ProviderFactoryInfo("Apache.NMS.EMS", "Apache.NMS.EMS.ConnectionFactory"); + schemaProviderFactoryMap["msmq"] = new ProviderFactoryInfo("Apache.NMS.MSMQ", "Apache.NMS.MSMQ.ConnectionFactory"); + schemaProviderFactoryMap["stomp"] = new ProviderFactoryInfo("Apache.NMS.Stomp", "Apache.NMS.Stomp.ConnectionFactory"); + schemaProviderFactoryMap["xms"] = new ProviderFactoryInfo("Apache.NMS.XMS", "Apache.NMS.XMS.ConnectionFactory"); + schemaProviderFactoryMap["zmq"] = new ProviderFactoryInfo("Apache.NMS.ZMQ", "Apache.NMS.ZMQ.ConnectionFactory"); + } + + /// + /// The ConnectionFactory object must define a constructor that takes as a minimum a Uri object. + /// Any additional parameters are optional, but will typically include a Client ID string. + /// + /// The URI for the ActiveMQ provider. + /// Optional parameters to use when creating the ConnectionFactory. + public NMSConnectionFactory(string providerURI, params object[] constructorParams) + : this(URISupport.CreateCompatibleUri(providerURI), constructorParams) + { + } + + /// + /// The ConnectionFactory object must define a constructor that takes as a minimum a Uri object. + /// Any additional parameters are optional, but will typically include a Client ID string. + /// + /// The URI for the ActiveMQ provider. + /// Optional parameters to use when creating the ConnectionFactory. + public NMSConnectionFactory(Uri uriProvider, params object[] constructorParams) + { + this.factory = CreateConnectionFactory(uriProvider, constructorParams); + } + + /// + /// Create a connection factory that can create connections for the given scheme in the URI. + /// + /// The URI for the ActiveMQ provider. + /// Optional parameters to use when creating the ConnectionFactory. + /// A implementation that will be used. + public static IConnectionFactory CreateConnectionFactory(Uri uriProvider, params object[] constructorParams) + { + IConnectionFactory connectionFactory = null; + + try + { + Type factoryType = GetTypeForScheme(uriProvider.Scheme); + + // If an implementation was found, try to instantiate it. + if(factoryType != null) + { +#if NETCF + // Compact framework does not allow the activator ta pass parameters to a constructor. + connectionFactory = (IConnectionFactory) Activator.CreateInstance(factoryType); + connectionFactory.BrokerUri = uriProvider; +#else + object[] parameters = MakeParameterArray(uriProvider, constructorParams); + connectionFactory = (IConnectionFactory) Activator.CreateInstance(factoryType, parameters); +#endif + } + + if(null == connectionFactory) + { + throw new NMSConnectionException("No IConnectionFactory implementation found for connection URI: " + uriProvider); + } + } + catch(NMSConnectionException) + { + throw; + } + catch(Exception ex) + { + throw new NMSConnectionException("Could not create the IConnectionFactory implementation: " + ex.Message, ex); + } + + return connectionFactory; + } + + /// + /// Finds the associated with the given scheme. + /// + /// The scheme (e.g. tcp, activemq or stomp). + /// The of the ConnectionFactory that will be used + /// to create the connection for the specified . + private static Type GetTypeForScheme(string scheme) + { + string[] paths = GetConfigSearchPaths(); + string assemblyFileName; + string factoryClassName; + Type factoryType = null; + + Tracer.DebugFormat("Locating provider for scheme: {0}", scheme); + if(LookupConnectionFactoryInfo(paths, scheme, out assemblyFileName, out factoryClassName)) + { + Assembly assembly = null; + + Tracer.DebugFormat("Attempting to load provider assembly: {0}", assemblyFileName); + try + { + assembly = Assembly.Load(assemblyFileName); + if(null != assembly) + { + Tracer.Debug("Succesfully loaded provider."); + } + } + catch(Exception ex) + { + Tracer.ErrorFormat("Exception loading assembly failed: {0}", ex.Message); + assembly = null; + } + + if(null == assembly) + { + foreach(string path in paths) + { + string fullpath = Path.Combine(path, assemblyFileName) + ".dll"; + + Tracer.DebugFormat("Looking for: {0}", fullpath); + if(File.Exists(fullpath)) + { + Tracer.Debug("\tAssembly found! Attempting to load..."); + try + { + assembly = Assembly.LoadFrom(fullpath); + } + catch(Exception ex) + { + Tracer.ErrorFormat("Exception loading assembly failed: {0}", ex.Message); + assembly = null; + } + + if(null != assembly) + { + Tracer.Debug("Successfully loaded provider."); + break; + } + + Tracer.Debug("Failed to load provider. Continuing search..."); + } + } + } + + if(null != assembly) + { +#if NETCF + factoryType = assembly.GetType(factoryClassName, true); +#else + factoryType = assembly.GetType(factoryClassName, true, true); +#endif + if(null == factoryType) + { + Tracer.Fatal("Failed to load class factory from provider."); + } + } + else + { + Tracer.Fatal("Failed to load provider assembly."); + } + } + + return factoryType; + } + + /// + /// Lookup the connection factory assembly filename and class name. + /// Read an external configuration file that maps scheme to provider implementation. + /// Load XML config files named: nmsprovider-{scheme}.config + /// Following is a sample configuration file named nmsprovider-jms.config. Replace + /// the parenthesis with angle brackets for proper XML formatting. + /// + /// (?xml version="1.0" encoding="utf-8" ?) + /// (configuration) + /// (provider assembly="MyCompany.NMS.JMSProvider.dll" classFactory="MyCompany.NMS.JMSProvider.ConnectionFactory"/) + /// (/configuration) + /// + /// This configuration file would be loaded and parsed when a connection uri with a scheme of 'jms' + /// is used for the provider. In this example the connection string might look like: + /// jms://localhost:7222 + /// + /// + /// Folder paths to look in. + /// The scheme. + /// Name of the assembly file. + /// Name of the factory class. + /// true if the configuration file for the specified could + /// be found; otherwise, false. + private static bool LookupConnectionFactoryInfo(string[] paths, string scheme, out string assemblyFileName, out string factoryClassName) + { + bool foundFactory = false; + string schemeLower = scheme.ToLower(); + ProviderFactoryInfo pfi; + + // Look for a custom configuration to handle this scheme. + string configFileName = String.Format("nmsprovider-{0}.config", schemeLower); + + assemblyFileName = String.Empty; + factoryClassName = String.Empty; + + Tracer.DebugFormat("Attempting to locate provider configuration: {0}", configFileName); + foreach(string path in paths) + { + string fullpath = Path.Combine(path, configFileName); + Tracer.DebugFormat("Looking for: {0}", fullpath); + + try + { + if(File.Exists(fullpath)) + { + Tracer.DebugFormat("\tConfiguration file found in {0}", fullpath); + XmlDocument configDoc = new XmlDocument(); + + configDoc.Load(fullpath); + XmlElement providerNode = (XmlElement) configDoc.SelectSingleNode("/configuration/provider"); + + if(null != providerNode) + { + assemblyFileName = providerNode.GetAttribute("assembly"); + factoryClassName = providerNode.GetAttribute("classFactory"); + if(!String.IsNullOrEmpty(assemblyFileName) && !String.IsNullOrEmpty(factoryClassName)) + { + foundFactory = true; + Tracer.DebugFormat("Selected custom provider for {0}: {1}, {2}", schemeLower, assemblyFileName, factoryClassName); + break; + } + } + } + } + catch(Exception ex) + { + Tracer.DebugFormat("Exception while scanning {0}: {1}", fullpath, ex.Message); + } + } + + if(!foundFactory) + { + // Check for standard provider implementations. + if(schemaProviderFactoryMap.TryGetValue(schemeLower, out pfi)) + { + assemblyFileName = pfi.assemblyFileName; + factoryClassName = pfi.factoryClassName; + foundFactory = true; + Tracer.DebugFormat("Selected standard provider for {0}: {1}, {2}", schemeLower, assemblyFileName, factoryClassName); + } + } + + return foundFactory; + } + + /// + /// Get an array of search paths to look for config files. + /// + /// + /// A collection of search paths, including the current directory, the current AppDomain's + /// BaseDirectory and the current AppDomain's RelativeSearchPath. + /// + private static string[] GetConfigSearchPaths() + { + ArrayList pathList = new ArrayList(); + + // Check the current folder first. + pathList.Add(""); +#if !NETCF + try + { + AppDomain currentDomain = AppDomain.CurrentDomain; + + // Check the folder the assembly is located in. + Assembly executingAssembly = Assembly.GetExecutingAssembly(); + try + { + pathList.Add(Path.GetDirectoryName(executingAssembly.Location)); + } + catch(Exception ex) + { + Tracer.DebugFormat("Error parsing executing assembly location: {0} : {1}", executingAssembly.Location, ex.Message); + } + + if(null != currentDomain.BaseDirectory) + { + pathList.Add(currentDomain.BaseDirectory); + } + + if(null != currentDomain.RelativeSearchPath) + { + pathList.Add(currentDomain.RelativeSearchPath); + } + } + catch(Exception ex) + { + Tracer.DebugFormat("Error configuring search paths: {0}", ex.Message); + } +#endif + + return (string[]) pathList.ToArray(typeof(string)); + } + + /// + /// Converts a params object[] collection into a plain object[]s, to pass to the constructor. + /// + /// The first parameter in the collection. + /// The remaining parameters. + /// An array of instances. + private static object[] MakeParameterArray(object firstParam, params object[] varParams) + { + ArrayList paramList = new ArrayList(); + paramList.Add(firstParam); + foreach(object param in varParams) + { + paramList.Add(param); + } + + return paramList.ToArray(); + } + + /// + /// Creates a new connection. + /// + /// An created by the requested ConnectionFactory. + public IConnection CreateConnection() + { + return this.factory.CreateConnection(); + } + + /// + /// Creates a new connection with the given and credentials. + /// + /// The username to use when establishing the connection. + /// The password to use when establishing the connection. + /// An created by the requested ConnectionFactory. + public IConnection CreateConnection(string userName, string password) + { + return this.factory.CreateConnection(userName, password); + } + + /// + /// Get/or set the broker Uri. + /// + public Uri BrokerUri + { + get { return ConnectionFactory.BrokerUri; } + set { ConnectionFactory.BrokerUri = value; } + } + + /// + /// The actual IConnectionFactory implementation that is being used. This implementation + /// depends on the scheme of the URI used when constructed. + /// + public IConnectionFactory ConnectionFactory + { + get { return factory; } + } + + /// + /// Get/or Set the IRedeliveryPolicy instance using the IConnectionFactory implementation + /// that is being used. + /// + public IRedeliveryPolicy RedeliveryPolicy + { + get { return this.factory.RedeliveryPolicy; } + set { this.factory.RedeliveryPolicy = value; } + } + + /// + /// Get/or Set the ConsumerTransformerDelegate using the IConnectionFactory implementation + /// that is currently being used. + /// + public ConsumerTransformerDelegate ConsumerTransformer + { + get { return this.factory.ConsumerTransformer; } + set { this.factory.ConsumerTransformer = value; } + } + + /// + /// Get/or Set the ProducerTransformerDelegate using the IConnectionFactory implementation + /// that is currently being used. + /// + public ProducerTransformerDelegate ProducerTransformer + { + get { return this.factory.ProducerTransformer; } + set { this.factory.ProducerTransformer = value; } + } + } +}