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 07A5510795 for ; Tue, 29 Oct 2013 15:48:32 +0000 (UTC) Received: (qmail 58414 invoked by uid 500); 29 Oct 2013 15:44:39 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 57881 invoked by uid 500); 29 Oct 2013 15:43:51 -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 57166 invoked by uid 99); 29 Oct 2013 15:42:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Oct 2013 15:42:33 +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; Tue, 29 Oct 2013 15:42:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E76AE23888D7; Tue, 29 Oct 2013 15:42:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1536765 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x: ./ src/main/csharp/Transport/TransportFactory.cs Date: Tue, 29 Oct 2013 15:42:07 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131029154207.E76AE23888D7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Tue Oct 29 15:42:07 2013 New Revision: 1536765 URL: http://svn.apache.org/r1536765 Log: https://issues.apache.org/jira/browse/AMQNET-456 Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/ (props changed) activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/src/main/csharp/Transport/TransportFactory.cs Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/ ------------------------------------------------------------------------------ Merged /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk:r1536764 Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/src/main/csharp/Transport/TransportFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/src/main/csharp/Transport/TransportFactory.cs?rev=1536765&r1=1536764&r2=1536765&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/src/main/csharp/Transport/TransportFactory.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/src/main/csharp/Transport/TransportFactory.cs Tue Oct 29 15:42:07 2013 @@ -22,86 +22,86 @@ using Apache.NMS.ActiveMQ.Util; namespace Apache.NMS.ActiveMQ.Transport { - public class TransportFactory - { - public static event ExceptionListener OnException; + public class TransportFactory + { + public static event ExceptionListener OnException; private static readonly FactoryFinder FACTORY_FINDER = new FactoryFinder(); - + private readonly static object TRANSPORT_FACTORY_TYPES_LOCK = new object(); private readonly static IDictionary TRANSPORT_FACTORY_TYPES = new Dictionary(); - public static void HandleException(Exception ex) - { - if(TransportFactory.OnException != null) - { - TransportFactory.OnException(ex); - } - } + public static void HandleException(Exception ex) + { + if(TransportFactory.OnException != null) + { + TransportFactory.OnException(ex); + } + } public void RegisterTransportFactory(string scheme, Type factoryType) { - lock (TRANSPORT_FACTORY_TYPES_LOCK) - { - TRANSPORT_FACTORY_TYPES[scheme] = factoryType; - } - } - - /// - /// Creates a normal transport. - /// - /// - /// the transport - public static ITransport CreateTransport(Uri location) - { - ITransportFactory tf = TransportFactory.CreateTransportFactory(location); - return tf.CreateTransport(location); - } - - public static ITransport CompositeConnect(Uri location) - { - ITransportFactory tf = TransportFactory.CreateTransportFactory(location); - return tf.CompositeConnect(location); - } - - /// - /// Create a transport factory for the scheme. If we do not support the transport protocol, - /// an NMSConnectionException will be thrown. - /// - /// - /// - private static ITransportFactory CreateTransportFactory(Uri location) - { - string scheme = location.Scheme; - - if(string.IsNullOrEmpty(scheme)) - { - throw new NMSConnectionException(String.Format("Transport scheme invalid: [{0}]", location.ToString())); - } + lock (TRANSPORT_FACTORY_TYPES_LOCK) + { + TRANSPORT_FACTORY_TYPES[scheme] = factoryType; + } + } + + /// + /// Creates a normal transport. + /// + /// + /// the transport + public static ITransport CreateTransport(Uri location) + { + ITransportFactory tf = TransportFactory.CreateTransportFactory(location); + return tf.CreateTransport(location); + } + + public static ITransport CompositeConnect(Uri location) + { + ITransportFactory tf = TransportFactory.CreateTransportFactory(location); + return tf.CompositeConnect(location); + } + + /// + /// Create a transport factory for the scheme. If we do not support the transport protocol, + /// an NMSConnectionException will be thrown. + /// + /// + /// + private static ITransportFactory CreateTransportFactory(Uri location) + { + string scheme = location.Scheme; - ITransportFactory factory = null; + if(string.IsNullOrEmpty(scheme)) + { + throw new NMSConnectionException(String.Format("Transport scheme invalid: [{0}]", location.ToString())); + } - try - { + ITransportFactory factory = null; + + try + { factory = NewInstance(scheme.ToLower()); - } - catch(NMSConnectionException) - { - throw; - } - catch(Exception e) - { - throw new NMSConnectionException("Error creating transport.", e); - } - - if(null == factory) - { - throw new NMSConnectionException("Unable to create a transport."); - } + } + catch(NMSConnectionException) + { + throw; + } + catch(Exception e) + { + throw new NMSConnectionException("Error creating transport.", e); + } - return factory; - } + if(null == factory) + { + throw new NMSConnectionException("Unable to create a transport."); + } + + return factory; + } private static ITransportFactory NewInstance(string scheme) { @@ -118,29 +118,29 @@ namespace Apache.NMS.ActiveMQ.Transport } catch(Exception ex) { - Tracer.WarnFormat("NewInstance failed to create an ITransportFactory with error: {1}", ex.Message); + Tracer.WarnFormat("NewInstance failed to create an ITransportFactory with error: {0}", ex.Message); throw; } } private static Type FindTransportFactory(string scheme) { - lock (TRANSPORT_FACTORY_TYPES_LOCK) - { - if(TRANSPORT_FACTORY_TYPES.ContainsKey(scheme)) - { - return TRANSPORT_FACTORY_TYPES[scheme]; - } - } - + lock (TRANSPORT_FACTORY_TYPES_LOCK) + { + if(TRANSPORT_FACTORY_TYPES.ContainsKey(scheme)) + { + return TRANSPORT_FACTORY_TYPES[scheme]; + } + } + try { Type factoryType = FACTORY_FINDER.FindFactoryType(scheme); - - lock (TRANSPORT_FACTORY_TYPES_LOCK) - { - TRANSPORT_FACTORY_TYPES[scheme] = factoryType; - } + + lock (TRANSPORT_FACTORY_TYPES_LOCK) + { + TRANSPORT_FACTORY_TYPES[scheme] = factoryType; + } return factoryType; } catch @@ -148,5 +148,5 @@ namespace Apache.NMS.ActiveMQ.Transport throw new NMSConnectionException("Failed to find Factory for Transport type: " + scheme); } } - } + } }