diff options
author | Michael Barker <mike@middlesoft.co.uk> | 2009-05-20 11:40:57 +0400 |
---|---|---|
committer | Michael Barker <mike@middlesoft.co.uk> | 2009-05-20 11:40:57 +0400 |
commit | 2abcb07b81bf1c54e2166dd15a634595fca8d9c6 (patch) | |
tree | a4204daf2abb2b81bb76f2bd8afb08b7eaf0a2af | |
parent | 1c1d101fed359c757d2fb6f5cf3c51a203c0efc7 (diff) |
2009-05-19 Michael Barker <mike@middlesoft.co.uk>
* RabbitMQMessagingProviderTest.cs: Added test for dynamic create of
MessagingProvider
2009-05-19 Michael Barker <mike@middlesoft.co.uk>
* RabbitMQMessageQueue.cs: Added comments.
2009-05-19 Michael Barker <mike@middlesoft.co.uk>
* Makefile: Added environment variable for the RabbitMQMessagingProvider
2009-05-19 Michael Barker <mike@middlesoft.co.uk>
* MessageBaseTest.cs: Used reflection to create Message Object
2009-05-19 Michael Barker <mike@middlesoft.co.uk>
* IMessage.cs: Added additional comments.
* IMessagingProvider.cs: Added additional comments.
* MessagingProviderLocator.cs: Added support for specifing messaging
implementation using an environment variable.
svn path=/trunk/mcs/; revision=134437
12 files changed, 105 insertions, 26 deletions
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/ChangeLog b/mcs/class/Mono.Messaging.RabbitMQ/ChangeLog index 76655db176c..7812d3ee03d 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/ChangeLog +++ b/mcs/class/Mono.Messaging.RabbitMQ/ChangeLog @@ -7,3 +7,7 @@ 2008-09-29 Michael Barker <mike@middlesoft.co.uk> * AssemblyInfo.cs: New + +2009-05-19 Michael Barker <mike@middlesoft.co.uk> + + * Makefile: Added environment variable for the RabbitMQMessagingProvider
\ No newline at end of file diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Makefile b/mcs/class/Mono.Messaging.RabbitMQ/Makefile index d4572f51099..03b5bb38f53 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Makefile +++ b/mcs/class/Mono.Messaging.RabbitMQ/Makefile @@ -12,3 +12,5 @@ TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:0618 -nowarn:219 -nowarn:169 \ /r:nunit.mocks.dll include ../../build/library.make + +export MONO_MESSAGING_PROVIDER=Mono.Messaging.RabbitMQ.RabbitMQMessagingProvider,Mono.Messaging.RabbitMQ
\ No newline at end of file diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/ChangeLog b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/ChangeLog index ab7e84e7989..c76ac7ac199 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/ChangeLog +++ b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/ChangeLog @@ -43,4 +43,8 @@ 2008-09-29 Michael Barker <mike@middlesoft.co.uk> * RabbitMQMessageQueue.cs: New - * RabbitMQMessagingProvider.cs: New
\ No newline at end of file + * RabbitMQMessagingProvider.cs: New + +2009-05-19 Michael Barker <mike@middlesoft.co.uk> + + * RabbitMQMessageQueue.cs: Added comments.
\ No newline at end of file diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageQueue.cs b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageQueue.cs index 320ad9747a2..3d5fc614ffb 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageQueue.cs +++ b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessageQueue.cs @@ -43,6 +43,11 @@ using RabbitMQ.Util; namespace Mono.Messaging.RabbitMQ { + /// <summary> + /// RabbitMQ Implementation of a message queue. Currrently this implementation + /// attempts to be as stateless as possible. Connection the AMQP server + /// are only created as needed. + /// </summary> public class RabbitMQMessageQueue : MessageQueueBase, IMessageQueue { private bool authenticate = false; diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/ChangeLog b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/ChangeLog index c8c621ede65..852578cde3f 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/ChangeLog +++ b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/ChangeLog @@ -54,3 +54,8 @@ * BasicMessagingTest.cs: New * RabbitMQMessagingProviderTest.cs: New + +2009-05-19 Michael Barker <mike@middlesoft.co.uk> + + * RabbitMQMessagingProviderTest.cs: Added test for dynamic create of + MessagingProvider diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/RabbitMQMessagingProviderTest.cs b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/RabbitMQMessagingProviderTest.cs index 31fd8f19478..7cfb8eeb135 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/RabbitMQMessagingProviderTest.cs +++ b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/RabbitMQMessagingProviderTest.cs @@ -56,5 +56,12 @@ namespace MonoTests.Mono.Messaging.RabbitMQ Assert.IsNotNull (q); } + [Test] + public void GetProvider () + { + IMessagingProvider p = MessagingProviderLocator.GetProvider (); + Assert.IsNotNull (p); + } + } } diff --git a/mcs/class/Mono.Messaging/Mono.Messaging/ChangeLog b/mcs/class/Mono.Messaging/Mono.Messaging/ChangeLog index 00af9d8d6ef..023c690a8f5 100644 --- a/mcs/class/Mono.Messaging/Mono.Messaging/ChangeLog +++ b/mcs/class/Mono.Messaging/Mono.Messaging/ChangeLog @@ -68,3 +68,10 @@ * MessagingProviderLocator.cs: New * MonoMessagingException.cs: New * QueueReference.cs: New + +2009-05-19 Michael Barker <mike@middlesoft.co.uk> + + * IMessage.cs: Added additional comments. + * IMessagingProvider.cs: Added additional comments. + * MessagingProviderLocator.cs: Added support for specifing messaging + implementation using an environment variable.
\ No newline at end of file diff --git a/mcs/class/Mono.Messaging/Mono.Messaging/IMessage.cs b/mcs/class/Mono.Messaging/Mono.Messaging/IMessage.cs index c2ad0e4cb18..a1db92beb1a 100644 --- a/mcs/class/Mono.Messaging/Mono.Messaging/IMessage.cs +++ b/mcs/class/Mono.Messaging/Mono.Messaging/IMessage.cs @@ -200,6 +200,11 @@ namespace Mono.Messaging { get; set; } + /// <summary> + /// Sets all of the information about a message after is has been + /// delivered. Implementing classes should set the values of the + /// appropriate properties in this method call. + /// </summary> void SetDeliveryInfo (Acknowledgment acknowledgment, DateTime arrivedTime, IMessageQueue destinationQueue, diff --git a/mcs/class/Mono.Messaging/Mono.Messaging/IMessagingProvider.cs b/mcs/class/Mono.Messaging/Mono.Messaging/IMessagingProvider.cs index 7293f45de83..dd226809de9 100644 --- a/mcs/class/Mono.Messaging/Mono.Messaging/IMessagingProvider.cs +++ b/mcs/class/Mono.Messaging/Mono.Messaging/IMessagingProvider.cs @@ -30,6 +30,11 @@ namespace Mono.Messaging { + /// <summary> + /// Provides access to the core implementation classes. A single instance of + /// this class will be maintained by the MessagingProviderLocator, therefore + /// any implementations of this class must be thread safe. + /// </summary> public interface IMessagingProvider { bool Exists (QueueReference qRef); diff --git a/mcs/class/Mono.Messaging/Mono.Messaging/MessagingProviderLocator.cs b/mcs/class/Mono.Messaging/Mono.Messaging/MessagingProviderLocator.cs index f267e7e19f6..f1ced06174f 100644 --- a/mcs/class/Mono.Messaging/Mono.Messaging/MessagingProviderLocator.cs +++ b/mcs/class/Mono.Messaging/Mono.Messaging/MessagingProviderLocator.cs @@ -29,37 +29,55 @@ // using System; using System.Reflection; +using System.Collections; namespace Mono.Messaging { + /// <summary> + /// The main entry point for System.Messaging to get a handle on the + /// messaging implementation. It will maintain a single instance of the + /// IMessagingProvider (i.e. a singleton) that will be shared between + /// threads, therefore any implementation of the IMessagingProvider must + /// be thread safe. + /// </summary> public class MessagingProviderLocator { - private static IMessagingProvider provider = null; - private static readonly object syncObj = new object(); public static readonly TimeSpan InfiniteTimeout = TimeSpan.MaxValue; - + + private static MessagingProviderLocator instance = new MessagingProviderLocator(); + private readonly object syncObj = new object(); + private IMessagingProvider provider = null; + + private MessagingProviderLocator () { + string providerName = System.Environment.GetEnvironmentVariable("MONO_MESSAGING_PROVIDER"); + if (providerName == null || providerName == "") + throw new Exception("Environment Variable MONO_MESSAGING_PROVIDER not defined"); + provider = CreateProvider (providerName); + } + + public static MessagingProviderLocator Instance { get { return instance; } } + public static IMessagingProvider GetProvider () { - //Assembly a = Assembly.Load("Mono.Messaging.RabbitMQ.dll"); - //Type[] ts = a.GetTypes (); + return Instance.provider; + } + + private IMessagingProvider CreateProvider (string className) + { + Type t = Type.GetType (className); + if (t == null) + throw new Exception ("Can't find class: " + className); + + ConstructorInfo ci = t.GetConstructor (BindingFlags.Public | + BindingFlags.Instance, + Type.DefaultBinder, + new Type[0], + new ParameterModifier[0]); + if (ci == null) + throw new Exception ("Can't find constructor"); - //foreach (type in ts) - // Console.WriteLine (type.GetName ()); - lock (syncObj) { - if (provider == null) { - Type t = Type.GetType ("Mono.Messaging.RabbitMQ.RabbitMQMessagingProvider, Mono.Messaging.RabbitMQ"); - if (t == null) - throw new Exception ("Can't find class"); - ConstructorInfo ci = t.GetConstructor ( - BindingFlags.Public | BindingFlags.Instance, - Type.DefaultBinder, new Type[0], - new ParameterModifier[0]); - if (ci == null) - throw new Exception ("Can't find constructor"); - provider = (IMessagingProvider) ci.Invoke (new object[0]); - } - } - return provider; + return (IMessagingProvider) ci.Invoke (new object[0]); } + } } diff --git a/mcs/class/Mono.Messaging/Test/Mono.Messaging/ChangeLog b/mcs/class/Mono.Messaging/Test/Mono.Messaging/ChangeLog index 73ad821175a..17554938557 100644 --- a/mcs/class/Mono.Messaging/Test/Mono.Messaging/ChangeLog +++ b/mcs/class/Mono.Messaging/Test/Mono.Messaging/ChangeLog @@ -2,3 +2,7 @@ * MessageBaseTest.cs: New * QueueReferenceTest.cs: New + +2009-05-19 Michael Barker <mike@middlesoft.co.uk> + + * MessageBaseTest.cs: Used reflection to create Message Object
\ No newline at end of file diff --git a/mcs/class/Mono.Messaging/Test/Mono.Messaging/MessageBaseTest.cs b/mcs/class/Mono.Messaging/Test/Mono.Messaging/MessageBaseTest.cs index 65c44f7eb4a..52a47047236 100644 --- a/mcs/class/Mono.Messaging/Test/Mono.Messaging/MessageBaseTest.cs +++ b/mcs/class/Mono.Messaging/Test/Mono.Messaging/MessageBaseTest.cs @@ -30,6 +30,8 @@ using System; using System.Messaging; +using System.Reflection; +using Mono.Messaging; using NUnit.Framework; @@ -41,7 +43,19 @@ namespace MonoTests.Mono.Messaging { [Test] public void CheckDefaultValues () { - Message m = new Message (); + Type[] types = { + typeof (IMessage), typeof (object), typeof (IMessageFormatter) + }; + + ConstructorInfo ci = typeof (Message).GetConstructor ( + BindingFlags.NonPublic | BindingFlags.Instance, + Type.DefaultBinder, types, new ParameterModifier[0]); + + if (ci == null) + throw new Exception ("ConstructorInfo is null"); + + Message m = (Message) ci.Invoke (new object[] { new MessageBase (), null, null }); + Assert.IsNull (m.Body, "Body default should be Null"); Assert.IsNull (m.Formatter, "Formatter default should null"); @@ -75,7 +89,7 @@ namespace MonoTests.Mono.Messaging { Assert.AreEqual ("", m.Label, "Label should default to \"\""); Assert.AreEqual (false, m.IsFirstInTransaction, "IsFirstInTransaction should default to false"); Assert.AreEqual (false, m.IsLastInTransaction, "IsLastInTransaction should default to false"); - Assert.AreEqual (MessagePriority.Normal, m.Priority, + Assert.AreEqual (System.Messaging.MessagePriority.Normal, m.Priority, "Priority should default to Normal"); Assert.AreEqual (false, m.Recoverable, "Recoverable should default to false"); Assert.AreEqual (null, m.ResponseQueue, "ResponseQueue should default to null"); @@ -95,6 +109,5 @@ namespace MonoTests.Mono.Messaging { "UseJournalQueue should default to false"); Assert.AreEqual (false, m.UseTracing, "UseTracing should default to false"); } - } } |