Permalink
Browse files

Removed log4net dependency in favor of Common.Logging

  • Loading branch information...
1 parent b2bd5b0 commit 3bc5fbc1ffc9ebe13f9fac4038da2aaf574fcac0 @CoreyKaylor CoreyKaylor committed Aug 3, 2012
Showing with 172 additions and 30,398 deletions.
  1. +1 −1 Rhino.ServiceBus.Host/Program.cs
  2. +2 −2 Rhino.ServiceBus.Host/Rhino.ServiceBus.Host.csproj
  3. +1 −1 Rhino.ServiceBus.Spring/Rhino.ServiceBus.Spring.csproj
  4. +128 −129 Rhino.ServiceBus.Tests/Bugs/When_transaction_rolled_back_nested_transactions_fail.cs
  5. +3 −8 Rhino.ServiceBus.Tests/MsmqTestBase.cs
  6. +1 −4 Rhino.ServiceBus.Tests/Rhino.ServiceBus.Tests.csproj
  7. +3 −7 Rhino.ServiceBus.Tests/RhinoQueues/WithDebugging.cs
  8. +1 −8 Rhino.ServiceBus/Hosting/DefaultHost.cs
  9. +1 −1 Rhino.ServiceBus/Hosting/RemoteAppDomainHost.cs
  10. +1 −1 Rhino.ServiceBus/Impl/DefaultReflection.cs
  11. +1 −1 Rhino.ServiceBus/Impl/DefaultServiceBus.cs
  12. +1 −1 Rhino.ServiceBus/LoadBalancer/LoadBalancerConfiguration.cs
  13. +1 −1 Rhino.ServiceBus/LoadBalancer/MsmqLoadBalancer.cs
  14. +1 −1 Rhino.ServiceBus/LoadBalancer/MsmqReadyForWorkListener.cs
  15. +1 −1 Rhino.ServiceBus/LoadBalancer/MsmqSecondaryLoadBalancer.cs
  16. +1 −1 Rhino.ServiceBus/MessageModules/LoadBalancerMessageModule.cs
  17. +1 −1 Rhino.ServiceBus/Msmq/AbstractMsmqListener.cs
  18. +1 −1 Rhino.ServiceBus/Msmq/FlatQueueStrategy.cs
  19. +5 −5 Rhino.ServiceBus/Msmq/MsmqMessageBuilder.cs
  20. +1 −1 Rhino.ServiceBus/Msmq/MsmqSubscriptionStorage.cs
  21. +1 −1 Rhino.ServiceBus/Msmq/MsmqTransport.cs
  22. +1 −1 Rhino.ServiceBus/Msmq/OpenedQueue.cs
  23. +1 −1 Rhino.ServiceBus/Msmq/TransportActions/ErrorAction.cs
  24. +1 −1 Rhino.ServiceBus/Msmq/TransportActions/TimeoutAction.cs
  25. +3 −3 Rhino.ServiceBus/Rhino.ServiceBus.csproj
  26. +1 −1 Rhino.ServiceBus/RhinoQueues/PhtSubscriptionStorage.cs
  27. +1 −1 Rhino.ServiceBus/RhinoQueues/RhinoQueuesTransport.cs
  28. +1 −1 Rhino.ServiceBus/RhinoQueues/TimeoutAction.cs
  29. +1 −1 Rhino.ServiceBus/Transport/MessageHandlingCompletion.cs
  30. +2 −2 Samples/Starbucks.Tests/Starbucks.Tests.csproj
  31. +2 −2 Samples/Starbucks/Starbucks.csproj
  32. BIN SharedLibs/3.5/Common.Logging.dll
  33. BIN SharedLibs/3.5/Rhino.Queues.dll
  34. BIN SharedLibs/3.5/Rhino.Queues.pdb
  35. BIN SharedLibs/4.0/Common.Logging.dll
  36. BIN SharedLibs/4.0/Rhino.Queues.dll
  37. BIN SharedLibs/4.0/Rhino.Queues.pdb
  38. BIN SharedLibs/Common.Logging.dll
  39. BIN SharedLibs/log4net.dll
  40. +0 −30,205 SharedLibs/log4net.xml
  41. +0 −2 default.ps1
  42. +1 −0 packaging/rhino.servicebus.nuspec
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.IO;
using CommandLine;
-using log4net;
+using Common.Logging;
using Rhino.ServiceBus.Host.Actions;
namespace Rhino.ServiceBus.Host
@@ -112,8 +112,8 @@
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<ItemGroup>
- <Reference Include="log4net">
- <HintPath>..\SharedLibs\log4net.dll</HintPath>
+ <Reference Include="Common.Logging">
+ <HintPath>..\SharedLibs\3.5\Common.Logging.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
@@ -109,7 +109,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Common.Logging">
- <HintPath>..\SharedLibs\Common.Logging.dll</HintPath>
+ <HintPath>..\SharedLibs\3.5\Common.Logging.dll</HintPath>
</Reference>
<Reference Include="Rhino.Queues, Version=1.2.0.0, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
<HintPath>$(LibDir)Rhino.Queues.dll</HintPath>
@@ -5,9 +5,8 @@
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Castle.Windsor.Configuration.Interpreters;
-using log4net;
-using log4net.Appender;
-using log4net.Repository.Hierarchy;
+using Common.Logging;
+using Common.Logging.Simple;
using Rhino.ServiceBus.Impl;
using Rhino.ServiceBus.Internal;
using Rhino.ServiceBus.MessageModules;
@@ -16,143 +15,143 @@
namespace Rhino.ServiceBus.Tests.Bugs
{
// ReSharper disable InconsistentNaming
- public class When_transaction_rolled_back_nested_transactions_fail
- {
- private readonly MemoryAppender memoryAppender;
- public static ManualResetEvent wait;
-
- public When_transaction_rolled_back_nested_transactions_fail()
- {
- log4net.Config.BasicConfigurator.Configure();
- memoryAppender = new MemoryAppender();
- var hierarchy = (Hierarchy)LogManager.GetRepository();
- hierarchy.Root.RemoveAllAppenders();
- hierarchy.Root.AddAppender(memoryAppender);
- }
-
- private static IWindsorContainer SetupBusForMsmq()
- {
- var container = new WindsorContainer(new XmlInterpreter());
- new RhinoServiceBusConfiguration()
- .UseCastleWindsor(container)
- .UseStandaloneConfigurationFile("BusOnTransactionalQueue.config")
- .AddMessageModule<TestMessageModule>()
- .Configure();
- return container;
- }
-
- private static IWindsorContainer SetupBusForRhinoQueues()
+ public class When_transaction_rolled_back_nested_transactions_fail
{
- var container = new WindsorContainer(new XmlInterpreter());
- new RhinoServiceBusConfiguration()
- .UseCastleWindsor(container)
- .UseStandaloneConfigurationFile("RhinoQueues/RhinoQueues.config")
- .AddMessageModule<TestMessageModule>()
- .Configure();
- return container;
- }
+ private CapturingLoggerFactoryAdapter adapter;
+ public static ManualResetEvent wait;
- [Fact]
- public void Should_allow_nested_transaction_to_be_rolled_back_using_msmq()
- {
- var container = SetupBusForMsmq();
- container.Register(Component.For<TestConsumer>());
-
- bool signalled;
- using (var bus = container.Resolve<IStartableServiceBus>())
- {
- wait = new ManualResetEvent(false);
- bus.Start();
- bus.SendToSelf(new TestMessage());
- signalled = wait.WaitOne(TimeSpan.FromSeconds(5), false);
- }
-
- Assert.True(signalled);
- AssertThatNestedTransactionExceptionHasNotBeenThrown();
- }
-
- [Fact]
- public void Should_allow_nested_transaction_to_be_rolled_back_using_rhino_queues()
- {
- var container = SetupBusForRhinoQueues();
- container.Register(Component.For<TestConsumer>());
-
- bool signalled;
- using (var bus = container.Resolve<IStartableServiceBus>())
- {
- wait = new ManualResetEvent(false);
- bus.Start();
- bus.SendToSelf(new TestMessage());
- signalled = wait.WaitOne(TimeSpan.FromSeconds(5), false);
- }
-
- Assert.True(signalled);
- AssertThatNestedTransactionExceptionHasNotBeenThrown();
- }
-
- private void AssertThatNestedTransactionExceptionHasNotBeenThrown()
- {
- var transactionExceptions = memoryAppender.GetEvents().Where(entry =>
- entry.ExceptionObject is InvalidOperationException &&
- entry.ExceptionObject.Message.ToLower().Contains("transactionscope nested incorrectly"));
+ public When_transaction_rolled_back_nested_transactions_fail()
+ {
+ adapter = new CapturingLoggerFactoryAdapter();
+ LogManager.Adapter = adapter;
+ }
- Assert.True(transactionExceptions.Count() == 0, "'TransactionScope nested incorrectly' exception was thrown");
- }
+ private static IWindsorContainer SetupBusForMsmq()
+ {
+ var container = new WindsorContainer(new XmlInterpreter());
+ new RhinoServiceBusConfiguration()
+ .UseCastleWindsor(container)
+ .UseStandaloneConfigurationFile("BusOnTransactionalQueue.config")
+ .AddMessageModule<TestMessageModule>()
+ .Configure();
+ return container;
+ }
- public class TestMessage
- {
- }
+ private static IWindsorContainer SetupBusForRhinoQueues()
+ {
+ var container = new WindsorContainer(new XmlInterpreter());
+ new RhinoServiceBusConfiguration()
+ .UseCastleWindsor(container)
+ .UseStandaloneConfigurationFile("RhinoQueues/RhinoQueues.config")
+ .AddMessageModule<TestMessageModule>()
+ .Configure();
+ return container;
+ }
- public class TestConsumer : ConsumerOf<TestMessage>
- {
- public void Consume(TestMessage message)
- {
- throw new Exception("ERROR");
- }
- }
+ [Fact]
+ public void Should_allow_nested_transaction_to_be_rolled_back_using_msmq()
+ {
+ var container = SetupBusForMsmq();
+ container.Register(Component.For<TestConsumer>());
+
+ bool signalled;
+ using (var bus = container.Resolve<IStartableServiceBus>())
+ {
+ wait = new ManualResetEvent(false);
+ bus.Start();
+ bus.SendToSelf(new TestMessage());
+ signalled = wait.WaitOne(TimeSpan.FromSeconds(5), false);
+ }
+
+ Assert.True(signalled);
+ AssertThatNestedTransactionExceptionHasNotBeenThrown();
+ }
- public class TestMessageModule : IMessageModule
- {
- [ThreadStatic]
- private static TransactionScope NestedTransactionScope;
-
- public void Init(ITransport transport, IServiceBus bus)
- {
- transport.MessageArrived += MessageArrived;
- transport.BeforeMessageTransactionRollback += BeforeMessageTransactionRollback;
- }
-
- public void Stop(ITransport transport, IServiceBus bus)
- {
- transport.MessageArrived -= MessageArrived;
- transport.BeforeMessageTransactionRollback -= BeforeMessageTransactionRollback;
- }
-
- private bool MessageArrived(CurrentMessageInformation arg)
- {
- if (NestedTransactionScope == null)
+ [Fact]
+ public void Should_allow_nested_transaction_to_be_rolled_back_using_rhino_queues()
{
- NestedTransactionScope = new TransactionScope(TransactionScopeOption.Suppress);
+ var container = SetupBusForRhinoQueues();
+ container.Register(Component.For<TestConsumer>());
+
+ bool signalled;
+ using (var bus = container.Resolve<IStartableServiceBus>())
+ {
+ wait = new ManualResetEvent(false);
+ bus.Start();
+ bus.SendToSelf(new TestMessage());
+ signalled = wait.WaitOne(TimeSpan.FromSeconds(5), false);
+ }
+
+ Assert.True(signalled);
+ AssertThatNestedTransactionExceptionHasNotBeenThrown();
}
- return false;
- }
+ private void AssertThatNestedTransactionExceptionHasNotBeenThrown()
+ {
+ var transactionExceptions = adapter.LoggerEvents.Where(entry =>
+ entry.Exception is
+ InvalidOperationException &&
+ entry.Exception.Message.ToLower().
+ Contains(
+ "transactionscope nested incorrectly"));
+
+ Assert.True(transactionExceptions.Count() == 0, "'TransactionScope nested incorrectly' exception was thrown");
+ }
- private void BeforeMessageTransactionRollback(CurrentMessageInformation obj)
- {
- DisposeNestedTransaction();
- wait.Set();
- }
+ public class TestMessage
+ {
+ }
- private void DisposeNestedTransaction()
- {
- if (NestedTransactionScope == null)
- return;
+ public class TestConsumer : ConsumerOf<TestMessage>
+ {
+ public void Consume(TestMessage message)
+ {
+ throw new Exception("ERROR");
+ }
+ }
- NestedTransactionScope.Dispose();
- NestedTransactionScope = null;
- }
+ public class TestMessageModule : IMessageModule
+ {
+ [ThreadStatic] private static TransactionScope NestedTransactionScope;
+
+ public void Init(ITransport transport, IServiceBus bus)
+ {
+ transport.MessageArrived += MessageArrived;
+ transport.BeforeMessageTransactionRollback += BeforeMessageTransactionRollback;
+ }
+
+ public void Stop(ITransport transport, IServiceBus bus)
+ {
+ transport.MessageArrived -= MessageArrived;
+ transport.BeforeMessageTransactionRollback -= BeforeMessageTransactionRollback;
+ }
+
+ private bool MessageArrived(CurrentMessageInformation arg)
+ {
+ if (NestedTransactionScope == null)
+ {
+ NestedTransactionScope = new TransactionScope(TransactionScopeOption.Suppress);
+ }
+
+ return false;
+ }
+
+ private void BeforeMessageTransactionRollback(CurrentMessageInformation obj)
+ {
+ DisposeNestedTransaction();
+ wait.Set();
+ }
+
+ private void DisposeNestedTransaction()
+ {
+ if (NestedTransactionScope == null)
+ return;
+
+ NestedTransactionScope.Dispose();
+ NestedTransactionScope = null;
+ }
+ }
}
- }
- // ReSharper restore InconsistentNaming
+
+ // ReSharper restore InconsistentNaming
}
@@ -1,10 +1,8 @@
using System;
using System.Messaging;
-using Castle.MicroKernel;
using Castle.Windsor;
-using log4net.Appender;
-using log4net.Config;
-using log4net.Layout;
+using Common.Logging;
+using Common.Logging.Simple;
using Rhino.ServiceBus.Castle;
using Rhino.ServiceBus.Impl;
using Rhino.ServiceBus.Internal;
@@ -19,10 +17,7 @@ public class MsmqTestBase : IDisposable
{
static MsmqTestBase()
{
- BasicConfigurator.Configure(new DebugAppender
- {
- Layout = new SimpleLayout()
- });
+ LogManager.Adapter = new ConsoleOutLoggerFactoryAdapter();
}
private readonly string subscriptionQueuePath;
@@ -107,10 +107,7 @@
<HintPath>$(LibDir)Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="Common.Logging">
- <HintPath>..\SharedLibs\Common.Logging.dll</HintPath>
- </Reference>
- <Reference Include="log4net">
- <HintPath>..\SharedLibs\log4net.dll</HintPath>
+ <HintPath>..\SharedLibs\3.5\Common.Logging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation">
<HintPath>..\SharedLibs\Microsoft.Practices.ServiceLocation.dll</HintPath>
@@ -1,17 +1,13 @@
-using log4net.Appender;
-using log4net.Config;
-using log4net.Layout;
+using Common.Logging;
+using Common.Logging.Simple;
namespace Rhino.ServiceBus.Tests.RhinoQueues
{
public class WithDebugging
{
static WithDebugging()
{
- BasicConfigurator.Configure(new DebugAppender
- {
- Layout = new SimpleLayout()
- });
+ LogManager.Adapter = new ConsoleOutLoggerFactoryAdapter();
}
}
}
@@ -2,8 +2,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
-using log4net;
-using log4net.Config;
+using Common.Logging;
using Rhino.ServiceBus.Config;
using Rhino.ServiceBus.Internal;
@@ -46,16 +45,10 @@ public void Start(string asmName)
private void InitailizeBus(string asmName)
{
- string logfile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config");
-
- XmlConfigurator.ConfigureAndWatch(new FileInfo(logfile));
-
assemblyName = asmName;
CreateBootStrapper();
- log4net.GlobalContext.Properties["BusName"] = bootStrapper.GetType().Namespace;
-
InitializeContainer();
bootStrapper.BeginStart();
Oops, something went wrong.

0 comments on commit 3bc5fbc

Please sign in to comment.