activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r984203 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConnectionFactory.cs
Date Tue, 10 Aug 2010 20:36:53 GMT
Author: jgomes
Date: Tue Aug 10 20:36:53 2010
New Revision: 984203

URL: http://svn.apache.org/viewvc?rev=984203&view=rev
Log:
Modify load search order to look for config file first before using default provider assembly
information.  This allows better run-time configuration flexibility.
Fixes [AMQNET-262]. (See https://issues.apache.org/activemq/browse/AMQNET-262)

Modified:
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConnectionFactory.cs

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=984203&r1=984202&r2=984203&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 Tue
Aug 10 20:36:53 2010
@@ -243,55 +243,56 @@ namespace Apache.NMS
 			string schemeLower = scheme.ToLower();
 			ProviderFactoryInfo pfi;
 
-			// 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);
-			}
-			else
-			{
-				// Look for a custom configuration to handle this scheme.
-				string configFileName = String.Format("nmsprovider-{0}.config", schemeLower);
+			// Look for a custom configuration to handle this scheme.
+			string configFileName = String.Format("nmsprovider-{0}.config", schemeLower);
 
-				assemblyFileName = String.Empty;
-				factoryClassName = String.Empty;
+			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);
+			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
+				try
+				{
+					if(File.Exists(fullpath))
 					{
-						if(File.Exists(fullpath))
-						{
-							Tracer.DebugFormat("\tConfiguration file found in {0}", fullpath);
-							XmlDocument configDoc = new XmlDocument();
+						Tracer.DebugFormat("\tConfiguration file found in {0}", fullpath);
+						XmlDocument configDoc = new XmlDocument();
 
-							configDoc.Load(fullpath);
-							XmlElement providerNode = (XmlElement) configDoc.SelectSingleNode("/configuration/provider");
+						configDoc.Load(fullpath);
+						XmlElement providerNode = (XmlElement) configDoc.SelectSingleNode("/configuration/provider");
 
-							if(null != providerNode)
+						if(null != providerNode)
+						{
+							assemblyFileName = providerNode.GetAttribute("assembly");
+							factoryClassName = providerNode.GetAttribute("classFactory");
+							if(!String.IsNullOrEmpty(assemblyFileName) && !String.IsNullOrEmpty(factoryClassName))
 							{
-								assemblyFileName = providerNode.GetAttribute("assembly");
-								factoryClassName = providerNode.GetAttribute("classFactory");
-								if(String.Empty != assemblyFileName && String.Empty != factoryClassName)
-								{
-									foundFactory = true;
-									Tracer.DebugFormat("Selected custom provider for {0}: {1}, {2}", schemeLower, assemblyFileName,
factoryClassName);
-									break;
-								}
+								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);
-					}
+				}
+				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);
 				}
 			}
 



Mime
View raw message