Added support for setting the provider using an App.config file, also allow for Mono...
authorMichael Barker <mike@middlesoft.co.uk>
Sat, 18 Jul 2009 16:52:20 +0000 (16:52 -0000)
committerMichael Barker <mike@middlesoft.co.uk>
Sat, 18 Jul 2009 16:52:20 +0000 (16:52 -0000)
the GAC.

svn path=/trunk/mcs/; revision=138179

12 files changed:
mcs/build/common/ChangeLog
mcs/build/common/Consts.cs.in
mcs/class/ChangeLog
mcs/class/Makefile
mcs/class/Mono.Messaging.RabbitMQ/Assembly/AssemblyInfo.cs
mcs/class/Mono.Messaging.RabbitMQ/ChangeLog
mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ_test_net_2_0.dll.config [new file with mode: 0644]
mcs/class/Mono.Messaging/Assembly/AssemblyInfo.cs
mcs/class/Mono.Messaging/ChangeLog
mcs/class/Mono.Messaging/Makefile
mcs/class/Mono.Messaging/Mono.Messaging/ChangeLog
mcs/class/Mono.Messaging/Mono.Messaging/MessagingProviderLocator.cs

index 68fa7defd69bb451d0a4f505f46275ab0bbb470e..546006b63bd552442fe9310f260df0483636194f 100644 (file)
@@ -1,3 +1,7 @@
+2009-07-18  Michael Barker  <mike@middlesoft.co.uk>
+
+       * Consts.cs.in:  Added constant for Mono.Messaging.RabbitMQ.
+
 2009-06-15  Miguel de Icaza  <miguel@novell.com>
 
        * MonoTODOAttribute.cs: Thin diet, no point in having virtual
index 629b39cf5d7f72c0628d43d20eb8027176e69b56..29bce04c7e24d581ce01deaf0512be841ea2303b 100644 (file)
@@ -109,6 +109,7 @@ internal
        public const string AssemblyMono_Http = "Mono.Http, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=0738eb9f132ed756";
        public const string AssemblyMono_Posix = "Mono.Posix, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=0738eb9f132ed756";
        public const string AssemblyMono_Security = "Mono.Security, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=0738eb9f132ed756";
+       public const string AssemblyMono_Messaging_RabbitMQ = "Mono.Messaging.RabbitMQ, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=0738eb9f132ed756";
        public const string AssemblyCorlib = "mscorlib, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b77a5c561934e089";
        public const string AssemblySystem = "System, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b77a5c561934e089";
        public const string AssemblySystem_Data = "System.Data, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b77a5c561934e089";
index 81c5beb62b2e8519a05f586309c7f8f5785fbfea..eabfefc622dcd309bd4e5a01d03def66bd88a1f3 100644 (file)
@@ -1,3 +1,8 @@
+
+2009-07-18  Michael Barker  <mike@middlesoft.co.uk>
+
+       * Makefile:  Mono.Messaging.RabbitMQ back into all assemblies.
+
 2009-07-17  Zoltan Varga  <vargaz@gmail.com>
 
        * Makefile: Applied patch from Marcus Griep <marcus@griep.us>.
index 3335414ca7aba06d1df758c7f2d6f1b2448eee53..2ee011971373e4c3c78d80aa061e767d2939dcf2 100644 (file)
@@ -76,6 +76,7 @@ common_dirs := \
        RabbitMQ.Client                 \
        Mono.Messaging                  \
        System.Messaging                \
+       Mono.Messaging.RabbitMQ         \
        System.ServiceProcess           \
        System.Drawing.Design           \
        System.Design                   \
@@ -119,8 +120,7 @@ net_2_0_dirs := \
        Mono.Management                 \
        Mono.Options                    \
        Mono.Simd                       \
-       Mono.Tasklets       \
-       Mono.Messaging.RabbitMQ
+       Mono.Tasklets       
 
 net_2_0_only_dirs := \
        System.Web.Extensions_1.0       \
index ed35d9aa8d18bf32aee2fbc61668015e5d7d0c14..acaa4a3fdd1c117059d3cd9f22f62f46e46851b2 100644 (file)
@@ -55,7 +55,7 @@ using System.Runtime.InteropServices;
 
 [assembly: CLSCompliant (false)]
 [assembly: AssemblyDelaySign (true)]
-[assembly: AssemblyKeyFile("../msfinal.pub")]
+[assembly: AssemblyKeyFile("../mono.pub")]
 
 #if NET_2_0
        [assembly: AssemblyFileVersion (Consts.FxFileVersion)]
index 76528499b656896bf04b059dead67b5073d67c49..836d4548d55fa5653309194db5df23ac105f05f5 100644 (file)
@@ -1,3 +1,9 @@
+2009-07-18  Michael Barker  <mike@middlesoft.co.uk>
+
+       * AssemblyInfo.cs: Switch to mono.pub certificate for signing
+       assembly.
+       * Mono.Messaging.RabbitMQ_test_net_2_0.dll.config: New
+
 2009-07-11  Michael Barker  <mike@middlesoft.co.uk>
 
        * Mono.Messaging.RabbitMQ_test.dll.sources: Moved MessageEnumeratorTest.cs
@@ -15,4 +21,4 @@
 
 2009-05-19  Michael Barker  <mike@middlesoft.co.uk>
 
-       * Makefile:  Added environment variable for the RabbitMQMessagingProvider
\ No newline at end of file
+       * Makefile:  Added environment variable for the RabbitMQMessagingProvider
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ_test_net_2_0.dll.config b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ_test_net_2_0.dll.config
new file mode 100644 (file)
index 0000000..ba80c7f
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+       <appSettings>
+               <add key="MONO_MESSAGING_PROVIDER" value="Mono.Messaging.RabbitMQ.RabbitMQMessagingProvider,Mono.Messaging.RabbitMQ"/>
+       </appSettings>
+</configuration>
\ No newline at end of file
index c3011607d85817bfba31b979137948ac1972ae8e..9ebe8b89076593c60e45c7256273554a048ae5ee 100644 (file)
@@ -55,7 +55,7 @@ using System.Runtime.InteropServices;
 
 [assembly: CLSCompliant (true)]
 [assembly: AssemblyDelaySign (true)]
-[assembly: AssemblyKeyFile("../msfinal.pub")]
+[assembly: AssemblyKeyFile("../mono.pub")]
 
 #if NET_2_0
        [assembly: AssemblyFileVersion (Consts.FxFileVersion)]
index 3e0f8ab586f42dc94aa19c593ef95d20b79af809..b422a3194a2c79a46d8a82c5b6fc4e0b8dd3c55e 100644 (file)
@@ -1,3 +1,9 @@
+2009-07-18  Michael Barker  <mike@middlesoft.co.uk>
+
+       * AssemblyInfo.cs: Switched to mono.pub for assembly signing.
+       * Makefile: Added conditional compiliation to support
+       System.Configuration for NET_2_0 profile.
+
 2009-06-11  Michael Barker  <mike@middlesoft.co.uk>
 
        * Mono.Messaging_test.dll.sources:  Moved MessageBaseTest.cs and
index bfc99895c7956d9359239fc0774108280960895e..0d019182c495239bb9a93bbd5f701bbce0b2049d 100644 (file)
@@ -3,7 +3,14 @@ SUBDIRS =
 include ../../build/rules.make
 
 LIBRARY = Mono.Messaging.dll
+
+ifdef NET_1_0
+LIB_MCS_FLAGS = /r:System.dll
+else NET_1_1
 LIB_MCS_FLAGS = /r:System.dll
+else
+LIB_MCS_FLAGS = /r:System.dll /r:System.Configuration
+endif
 
 TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:0618 -nowarn:219 -nowarn:169 /r:System.Messaging.dll /r:nunit.mocks.dll
 
index d10ef8bab69605713ea414532ac2e39b5dc84d00..900d2c11b56589a8a2b8a42f2abb78f2f7d1e2fa 100644 (file)
@@ -1,3 +1,13 @@
+2009-07-18  Michael Barker  <mike@middlesoft.co.uk>
+
+       * MessagingProviderLocator.cs: Changed to cleanly support loading of
+       Provider classes from the GAC.
+
+2009-07-14  Michael Barker  <mike@middlesoft.co.uk>
+
+       * MessagingProviderLocator.cs: Added support for a rabbitmq alias that
+       mean the full classname is not required.
+
 2009-07-11  Michael Barker  <mike@middlesoft.co.uk>
 
        * MessagingProviderLocator.cs:  Removed unessecary fields, made fields
index e6f65da5388ebacc799074f5056a61863d7e35d3..ab324352e5cac96edd9a98a5e096af447dc419de 100644 (file)
@@ -43,14 +43,14 @@ namespace Mono.Messaging
        public class MessagingProviderLocator 
        {
                public static readonly TimeSpan InfiniteTimeout = TimeSpan.MaxValue;
-               private static readonly MessagingProviderLocator instance = new MessagingProviderLocator();             
+               private static readonly MessagingProviderLocator instance = new MessagingProviderLocator();
                private readonly IMessagingProvider provider;
-               
+               private const string MESSAGING_PROVIDER_KEY = "MONO_MESSAGING_PROVIDER";
                
                private MessagingProviderLocator () {
-                       string providerName = System.Environment.GetEnvironmentVariable("MONO_MESSAGING_PROVIDER");
+                       string providerName = GetProviderClassName ();
                        if (providerName == null || providerName == "")
-                               throw new Exception("Environment Variable MONO_MESSAGING_PROVIDER not defined");
+                               throw new Exception("Configuration/Environment Variable MONO_MESSAGING_PROVIDER not defined");
                        provider = CreateProvider (providerName);
                }
                
@@ -63,9 +63,22 @@ namespace Mono.Messaging
                        return Instance.provider;
                }
                
+#if NET_2_0 || BOOTSTRAP_NET_2_0 || NET_3_0 || NET_2_1 || NET_3_0 || NET_3_5 || NET_4_0 || BOOTSTRAP_NET_4_0
+               private string GetProviderClassName ()
+               {
+                       string className = System.Configuration.ConfigurationSettings.AppSettings[MESSAGING_PROVIDER_KEY];
+                       return className != null ? className : System.Environment.GetEnvironmentVariable(MESSAGING_PROVIDER_KEY);
+               }
+#else
+               private string GetProviderClassName ()
+               {
+                       return System.Environment.GetEnvironmentVariable(MESSAGING_PROVIDER_KEY);
+               }
+#endif
+               
                private IMessagingProvider CreateProvider (string className)
                {
-                       Type t = Type.GetType (className);
+                       Type t = ResolveType (className);                       
                        if (t == null)
                                throw new Exception ("Can't find class: " + className);
                        
@@ -78,6 +91,17 @@ namespace Mono.Messaging
                        
                        return (IMessagingProvider) ci.Invoke (new object[0]);
                }
-               
+
+               private Type ResolveType (string classNameOrAlias)
+               {
+                       switch (classNameOrAlias) {
+                       case "rabbitmq":
+                       case "Mono.Messaging.RabbitMQ.RabbitMQMessagingProvider,Mono.Messaging.RabbitMQ":
+                               Assembly a = Assembly.Load (Consts.AssemblyMono_Messaging_RabbitMQ);
+                               return a.GetType ("Mono.Messaging.RabbitMQ.RabbitMQMessagingProvider");
+                       default:
+                               throw new MonoMessagingException ("Unknown MessagingProvider class name or alias: " + classNameOrAlias);
+                       }
+               }
        }
 }