Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactored registration to remove extra conditions placed on containe…

…r implementations.

Introduced IBusContainerBuilder, yes it's one class, but it's easy to follow.
Implemented StructureMap, still needs testing.
  • Loading branch information...
commit feeda0357b16628f8ea5973ef95dc7c08c3fb9ec 1 parent c70d1c9
@CoreyKaylor CoreyKaylor authored
Showing with 4,907 additions and 633 deletions.
  1. +350 −0 Rhino.ServiceBus.Castle/CastleBuilder.cs
  2. +0 −58 Rhino.ServiceBus.Castle/Config/BusConfiguration.cs
  3. +0 −74 Rhino.ServiceBus.Castle/Config/LoadBalancerConfiguration.cs
  4. +0 −35 Rhino.ServiceBus.Castle/Config/LoadBalancerEndpointConfiguration.cs
  5. +0 −35 Rhino.ServiceBus.Castle/Config/LoggingConfiguration.cs
  6. +0 −65 Rhino.ServiceBus.Castle/Config/MsmqConfiguration.cs
  7. +0 −68 Rhino.ServiceBus.Castle/Config/OneWayBusConfiguration.cs
  8. +0 −50 Rhino.ServiceBus.Castle/Config/RhinoQueuesConfiguration.cs
  9. +0 −70 Rhino.ServiceBus.Castle/Config/SecurityConfiguration.cs
  10. +1 −76 Rhino.ServiceBus.Castle/Extensions.cs
  11. +1 −8 Rhino.ServiceBus.Castle/Rhino.ServiceBus.Castle.csproj
  12. +36 −0 Rhino.ServiceBus.StructureMap/ConsumerInterceptor.cs
  13. +19 −0 Rhino.ServiceBus.StructureMap/Extensions.cs
  14. +71 −0 Rhino.ServiceBus.StructureMap/Rhino.ServiceBus.StructureMap.csproj
  15. +18 −0 Rhino.ServiceBus.StructureMap/SingletonConvention.cs
  16. +79 −0 Rhino.ServiceBus.StructureMap/StructureMapBootStrapper.cs
  17. +224 −0 Rhino.ServiceBus.StructureMap/StructureMapBuilder.cs
  18. +51 −0 Rhino.ServiceBus.StructureMap/StructureMapServiceLocator.cs
  19. +10 −0 Rhino.ServiceBus.sln
  20. +1 −1  Rhino.ServiceBus/Config/IBusConfigurationAware.cs
  21. +22 −0 Rhino.ServiceBus/Config/IBusContainerBuilder.cs
  22. +28 −0 Rhino.ServiceBus/Config/LoadBalancerConfiguration.cs
  23. +12 −6 Rhino.ServiceBus/Config/{LoadBalancerConfigurationReader.cs → LoadBalancerEndpointConfiguration.cs}
  24. +31 −0 Rhino.ServiceBus/Config/LoggingConfiguration.cs
  25. +0 −27 Rhino.ServiceBus/Config/LoggingConfigurationReader.cs
  26. +5 −25 Rhino.ServiceBus/Config/MsmqTransportConfigurationAware.cs
  27. +34 −0 Rhino.ServiceBus/Config/OneWayBusConfiguration.cs
  28. +3 −13 Rhino.ServiceBus/Config/RhinoQueuesConfigurationAware.cs
  29. +9 −5 Rhino.ServiceBus/Config/{SecurityConfigurationReader.cs → SecurityConfiguration.cs}
  30. +13 −12 Rhino.ServiceBus/Impl/AbstractRhinoServiceBusFacility.cs
  31. +3 −2 Rhino.ServiceBus/Impl/OnewayRhinoServiceBusFacility.cs
  32. +6 −0 Rhino.ServiceBus/Impl/RhinoServiceBusFacility.cs
  33. +6 −3 Rhino.ServiceBus/Rhino.ServiceBus.csproj
  34. BIN  SharedLibs/StructureMap.dll
  35. +3,874 −0 SharedLibs/StructureMap.xml
View
350 Rhino.ServiceBus.Castle/CastleBuilder.cs
@@ -0,0 +1,350 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Messaging;
+using Castle.Core;
+using Castle.Core.Configuration;
+using Castle.MicroKernel.Registration;
+using Castle.MicroKernel.Resolvers.SpecializedResolvers;
+using Castle.Windsor;
+using Rhino.Queues;
+using Rhino.ServiceBus.Actions;
+using Rhino.ServiceBus.Config;
+using Rhino.ServiceBus.Convertors;
+using Rhino.ServiceBus.DataStructures;
+using Rhino.ServiceBus.Exceptions;
+using Rhino.ServiceBus.Impl;
+using Rhino.ServiceBus.Internal;
+using Rhino.ServiceBus.LoadBalancer;
+using Rhino.ServiceBus.MessageModules;
+using Rhino.ServiceBus.Msmq;
+using Rhino.ServiceBus.Msmq.TransportActions;
+using Rhino.ServiceBus.RhinoQueues;
+using Rhino.ServiceBus.Sagas;
+using ErrorAction = Rhino.ServiceBus.Msmq.TransportActions.ErrorAction;
+
+namespace Rhino.ServiceBus.Castle
+{
+ public class CastleBuilder : IBusContainerBuilder
+ {
+ private readonly IWindsorContainer container;
+ private readonly AbstractRhinoServiceBusFacility config;
+
+ public CastleBuilder(IWindsorContainer container, AbstractRhinoServiceBusFacility config)
+ {
+ this.container = container;
+ this.config = config;
+ this.config.BuildWith(this);
+ }
+
+ public void RegisterDefaultServices()
+ {
+ if (!container.Kernel.HasComponent(typeof(IWindsorContainer)))
+ container.Register(Component.For<IWindsorContainer>().Instance(container));
+
+ container.Register(Component.For<IServiceLocator>().ImplementedBy<CastleServiceLocator>());
+
+ container.Register(
+ AllTypes.FromAssembly(typeof(IServiceBus).Assembly)
+ .BasedOn<IBusConfigurationAware>()
+ );
+
+ foreach (var configurationAware in container.ResolveAll<IBusConfigurationAware>())
+ {
+ configurationAware.Configure(config, this);
+ }
+
+ container.Kernel.ComponentModelCreated += Kernel_OnComponentModelCreated;
+ container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
+
+ foreach (var type in config.MessageModules)
+ {
+ if (container.Kernel.HasComponent(type) == false)
+ container.Register(Component.For(type).Named(type.FullName));
+ }
+
+ container.Register(
+ Component.For<IReflection>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .ImplementedBy<DefaultReflection>(),
+
+ Component.For<IMessageSerializer>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .ImplementedBy(config.SerializerType),
+ Component.For<IEndpointRouter>()
+ .ImplementedBy<EndpointRouter>()
+ );
+ }
+
+ private static void Kernel_OnComponentModelCreated(ComponentModel model)
+ {
+ if (typeof(IMessageConsumer).IsAssignableFrom(model.Implementation) == false)
+ return;
+
+ var interfaces = model.Implementation.GetInterfaces()
+ .Where(x => x.IsGenericType && x.IsGenericTypeDefinition == false)
+ .Select(x => x.GetGenericTypeDefinition())
+ .ToList();
+
+ if (interfaces.Contains(typeof(InitiatedBy<>)) &&
+ interfaces.Contains(typeof(ISaga<>)) == false)
+ {
+ throw new InvalidUsageException("Message consumer: " + model.Implementation + " implements InitiatedBy<TMsg> but doesn't implment ISaga<TState>. " + Environment.NewLine +
+ "Did you forget to inherit from ISaga<TState> ?");
+ }
+
+ if (interfaces.Contains(typeof(InitiatedBy<>)) == false &&
+ interfaces.Contains(typeof(Orchestrates<>)))
+ {
+ throw new InvalidUsageException("Message consumer: " + model.Implementation + " implements Orchestrates<TMsg> but doesn't implment InitiatedBy<TState>. " + Environment.NewLine +
+ "Did you forget to inherit from InitiatedBy<TState> ?");
+ }
+
+ model.LifestyleType = LifestyleType.Transient;
+ }
+
+ public void RegisterBus()
+ {
+ var busConfig = (RhinoServiceBusFacility) config;
+
+ container.Register(
+ Component.For<IDeploymentAction>()
+ .ImplementedBy<CreateLogQueueAction>(),
+ Component.For<IDeploymentAction>()
+ .ImplementedBy<CreateQueuesAction>(),
+ Component.For<IServiceBus, IStartableServiceBus>()
+ .ImplementedBy<DefaultServiceBus>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .DependsOn(new
+ {
+ messageOwners = busConfig.MessageOwners.ToArray()
+ })
+ .Parameters(
+ Parameter.ForKey("modules").Eq(CreateModuleConfigurationNode(busConfig.MessageModules))
+ )
+ );
+ }
+
+ private static IConfiguration CreateModuleConfigurationNode(IEnumerable<Type> messageModules)
+ {
+ var config = new MutableConfiguration("array");
+ foreach (Type type in messageModules)
+ {
+ config.CreateChild("item", "${" + type.FullName + "}");
+ }
+ return config;
+ }
+
+ public void RegisterPrimaryLoadBalancer()
+ {
+ var loadBalancerConfig = (LoadBalancerFacility) config;
+ container.Register(Component.For<MsmqLoadBalancer>()
+ .ImplementedBy(loadBalancerConfig.LoadBalancerType)
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .DependsOn(new
+ {
+ endpoint = loadBalancerConfig.Endpoint,
+ threadCount = loadBalancerConfig.ThreadCount,
+ primaryLoadBalancer = loadBalancerConfig.PrimaryLoadBalancer,
+ transactional = loadBalancerConfig.Transactional
+ }));
+
+ container.Register(
+ Component.For<IDeploymentAction>()
+ .ImplementedBy<CreateLoadBalancerQueuesAction>()
+ );
+ }
+
+ public void RegisterSecondaryLoadBalancer()
+ {
+ var loadBalancerConfig = (LoadBalancerFacility) config;
+ container.Register(Component.For<MsmqLoadBalancer>()
+ .ImplementedBy(loadBalancerConfig.LoadBalancerType)
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .DependsOn(new
+ {
+ endpoint = loadBalancerConfig.Endpoint,
+ threadCount = loadBalancerConfig.ThreadCount,
+ primaryLoadBalancer = loadBalancerConfig.PrimaryLoadBalancer,
+ transactional = loadBalancerConfig.Transactional,
+ secondaryLoadBalancer = loadBalancerConfig.SecondaryLoadBalancer,
+ }));
+
+ container.Register(
+ Component.For<IDeploymentAction>()
+ .ImplementedBy<CreateLoadBalancerQueuesAction>()
+ );
+ }
+
+ public void RegisterReadyForWork()
+ {
+ var loadBalancerConfig = (LoadBalancerFacility) config;
+ container.Register(Component.For<MsmqReadyForWorkListener>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .DependsOn(new
+ {
+ endpoint = loadBalancerConfig.ReadyForWork,
+ threadCount = loadBalancerConfig.ThreadCount,
+ transactional = loadBalancerConfig.Transactional
+ }));
+ container.Register(
+ Component.For<IDeploymentAction>()
+ .ImplementedBy<CreateReadyForWorkQueuesAction>()
+ );
+ }
+
+ public void RegisterLoadBalancerEndpoint(Uri loadBalancerEndpoint)
+ {
+ container.Register(
+ Component.For<LoadBalancerMessageModule>()
+ .DependsOn(new {loadBalancerEndpoint})
+ );
+ }
+
+ public void RegisterLoggingEndpoint(Uri logEndpoint)
+ {
+ container.Register(
+ Component.For<MessageLoggingModule>()
+ .DependsOn(new {logQueue = logEndpoint})
+ );
+ }
+
+ public void RegisterMsmqTransport(Type queueStrategyType)
+ {
+ container.Kernel.Register(
+ Component.For<IQueueStrategy>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .ImplementedBy(queueStrategyType)
+ .DependsOn(new { endpoint = config.Endpoint }),
+ Component.For<IMsmqTransportAction>()
+ .ImplementedBy<ErrorAction>()
+ .DependsOn(new { numberOfRetries = config.NumberOfRetries}),
+ Component.For<ISubscriptionStorage>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .ImplementedBy(typeof(MsmqSubscriptionStorage))
+ .DependsOn(new
+ {
+ queueBusListensTo = config.Endpoint
+ }),
+ Component.For<ITransport>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .ImplementedBy(typeof(MsmqTransport))
+ .DependsOn(new
+ {
+ threadCount = config.ThreadCount,
+ endpoint = config.Endpoint,
+ queueIsolationLevel = config.IsolationLevel,
+ numberOfRetries = config.NumberOfRetries,
+ transactional = config.Transactional,
+ consumeInTransaction = config.ConsumeInTransaction,
+ }),
+ AllTypes.FromAssembly(typeof(IMsmqTransportAction).Assembly)
+ .BasedOn<IMsmqTransportAction>()
+ .Unless(x => x == typeof(ErrorAction))
+ .WithService.FirstInterface()
+ .Configure(registration =>
+ registration.LifeStyle.Is(LifestyleType.Singleton))
+ );
+ }
+
+ public void RegisterQueueCreation()
+ {
+ container.Kernel.Register(Component.For<QueueCreationModule>());
+ }
+
+ public void RegisterMsmqOneWay()
+ {
+ var oneWayConfig = (OnewayRhinoServiceBusFacility) config;
+ container.Register(
+ Component.For<IMessageBuilder<Message>>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .ImplementedBy<MsmqMessageBuilder>(),
+ Component.For<IOnewayBus>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .ImplementedBy<MsmqOnewayBus>()
+ .DependsOn(new { messageOwners = oneWayConfig.MessageOwners }));
+ }
+
+ public void RegisterRhinoQueuesTransport(string path, string name)
+ {
+ container.Register(
+ Component.For<ISubscriptionStorage>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .ImplementedBy(typeof(PhtSubscriptionStorage))
+ .DependsOn(new
+ {
+ subscriptionPath = Path.Combine(path, name + "_subscriptions.esent")
+ }),
+ Component.For<ITransport>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .ImplementedBy(typeof(RhinoQueuesTransport))
+ .DependsOn(new
+ {
+ threadCount = config.ThreadCount,
+ endpoint = config.Endpoint,
+ queueIsolationLevel = config.IsolationLevel,
+ numberOfRetries = config.NumberOfRetries,
+ path = Path.Combine(path, name + ".esent")
+ }),
+ Component.For<IMessageBuilder<MessagePayload>>()
+ .ImplementedBy<RhinoQueuesMessageBuilder>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ );
+ }
+
+ public void RegisterRhinoQueuesOneWay()
+ {
+ var oneWayConfig = (OnewayRhinoServiceBusFacility) config;
+ container.Register(
+ Component.For<IMessageBuilder<MessagePayload>>()
+ .ImplementedBy<RhinoQueuesMessageBuilder>()
+ .LifeStyle.Is(LifestyleType.Singleton),
+ Component.For<IOnewayBus>()
+ .LifeStyle.Is(LifestyleType.Singleton)
+ .ImplementedBy<RhinoQueuesOneWayBus>()
+ .DependsOn(new
+ {
+ messageOwners = oneWayConfig.MessageOwners.ToArray(),
+ })
+ );
+ }
+
+ public void RegisterSecurity(byte[] key)
+ {
+ container.Register(
+ Component.For<IEncryptionService>()
+ .ImplementedBy<RijndaelEncryptionService>()
+ .DependsOn(new
+ {
+ key,
+ })
+ .Named("esb.security")
+ );
+
+ container.Register(
+ Component.For<IValueConvertor<WireEcryptedString>>()
+ .ImplementedBy<WireEcryptedStringConvertor>()
+ .ServiceOverrides(ServiceOverride.ForKey("encryptionService").Eq("esb.security"))
+ );
+
+ container.Register(
+ Component.For<IElementSerializationBehavior>()
+ .ImplementedBy<WireEncryptedMessageConvertor>()
+ .ServiceOverrides(ServiceOverride.ForKey("encryptionService").Eq("esb.security"))
+ );
+ }
+
+ public void RegisterNoSecurity()
+ {
+ container.Register(
+ Component.For<IValueConvertor<WireEcryptedString>>()
+ .ImplementedBy<ThrowingWireEcryptedStringConvertor>()
+ );
+ container.Register(
+ Component.For<IElementSerializationBehavior>()
+ .ImplementedBy<ThrowingWireEncryptedMessageConvertor>()
+ );
+ }
+ }
+}
View
58 Rhino.ServiceBus.Castle/Config/BusConfiguration.cs
@@ -1,58 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Castle.Core;
-using Castle.Core.Configuration;
-using Castle.MicroKernel.Registration;
-using Castle.Windsor;
-using Rhino.ServiceBus.Actions;
-using Rhino.ServiceBus.Config;
-using Rhino.ServiceBus.Impl;
-
-namespace Rhino.ServiceBus.Castle.Config
-{
- public class BusConfiguration : IBusConfigurationAware
- {
- private readonly IWindsorContainer container;
-
- public BusConfiguration(IWindsorContainer container)
- {
- this.container = container;
- }
-
- public void Configure(AbstractRhinoServiceBusFacility config)
- {
- var busConfiguration = config as RhinoServiceBusFacility;
- if (busConfiguration == null)
- return;
- busConfiguration.ConfigurationComplete += () =>
- container.Register(
- Component.For<IDeploymentAction>()
- .ImplementedBy<CreateLogQueueAction>(),
- Component.For<IDeploymentAction>()
- .ImplementedBy<CreateQueuesAction>(),
- Component.For<IServiceBus, IStartableServiceBus>()
- .ImplementedBy<DefaultServiceBus>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .DependsOn(new
- {
- messageOwners = busConfiguration.MessageOwners.ToArray()
- })
- .Parameters(
- Parameter.ForKey("modules").Eq(CreateModuleConfigurationNode(busConfiguration.MessageModules))
- )
- );
- }
-
-
- private static IConfiguration CreateModuleConfigurationNode(IEnumerable<Type> messageModules)
- {
- var config = new MutableConfiguration("array");
- foreach (Type type in messageModules)
- {
- config.CreateChild("item", "${" + type.FullName + "}");
- }
- return config;
- }
- }
-}
View
74 Rhino.ServiceBus.Castle/Config/LoadBalancerConfiguration.cs
@@ -1,74 +0,0 @@
-using Castle.Core;
-using Castle.MicroKernel.Registration;
-using Castle.Windsor;
-using Rhino.ServiceBus.Actions;
-using Rhino.ServiceBus.Config;
-using Rhino.ServiceBus.Impl;
-using Rhino.ServiceBus.LoadBalancer;
-
-namespace Rhino.ServiceBus.Castle.Config
-{
- public class LoadBalancerConfiguration : IBusConfigurationAware
- {
- private readonly IWindsorContainer container;
-
- public LoadBalancerConfiguration(IWindsorContainer container)
- {
- this.container = container;
- }
-
- public void Configure(AbstractRhinoServiceBusFacility config)
- {
- var loadBalancerConfig = config as LoadBalancerFacility;
- if (loadBalancerConfig == null)
- return;
- if (loadBalancerConfig.SecondaryLoadBalancer != null)
- {
- container.Register(Component.For<MsmqLoadBalancer>()
- .ImplementedBy(loadBalancerConfig.LoadBalancerType)
- .LifeStyle.Is(LifestyleType.Singleton)
- .DependsOn(new
- {
- endpoint = loadBalancerConfig.Endpoint,
- threadCount = loadBalancerConfig.ThreadCount,
- primaryLoadBalancer = loadBalancerConfig.PrimaryLoadBalancer,
- transactional = loadBalancerConfig.Transactional,
- secondaryLoadBalancer = loadBalancerConfig.SecondaryLoadBalancer,
- }));
- }
- else
- {
- container.Register(Component.For<MsmqLoadBalancer>()
- .ImplementedBy(loadBalancerConfig.LoadBalancerType)
- .LifeStyle.Is(LifestyleType.Singleton)
- .DependsOn(new
- {
- endpoint = loadBalancerConfig.Endpoint,
- threadCount = loadBalancerConfig.ThreadCount,
- primaryLoadBalancer = loadBalancerConfig.PrimaryLoadBalancer,
- transactional = loadBalancerConfig.Transactional
- }));
- }
- container.Register(
- Component.For<IDeploymentAction>()
- .ImplementedBy<CreateLoadBalancerQueuesAction>()
- );
-
- if (loadBalancerConfig.ReadyForWork != null)
- {
- container.Register(Component.For<MsmqReadyForWorkListener>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .DependsOn(new
- {
- endpoint = loadBalancerConfig.ReadyForWork,
- threadCount = loadBalancerConfig.ThreadCount,
- transactional = loadBalancerConfig.Transactional
- }));
- container.Register(
- Component.For<IDeploymentAction>()
- .ImplementedBy<CreateReadyForWorkQueuesAction>()
- );
- }
- }
- }
-}
View
35 Rhino.ServiceBus.Castle/Config/LoadBalancerEndpointConfiguration.cs
@@ -1,35 +0,0 @@
-using Castle.MicroKernel.Registration;
-using Castle.Windsor;
-using Rhino.ServiceBus.Config;
-using Rhino.ServiceBus.Impl;
-using Rhino.ServiceBus.MessageModules;
-
-namespace Rhino.ServiceBus.Castle.Config
-{
- public class LoadBalancerEndpointConfiguration : IBusConfigurationAware
- {
- private readonly IWindsorContainer container;
-
- public LoadBalancerEndpointConfiguration(IWindsorContainer container)
- {
- this.container = container;
- }
-
- public void Configure(AbstractRhinoServiceBusFacility config)
- {
- var busConfig = config as RhinoServiceBusFacility;
- if (busConfig == null)
- return;
- var loadBalancerReader = new LoadBalancerConfigurationReader(config);
- if (loadBalancerReader.LoadBalancerEndpoint == null)
- return;
-
- var endpoint = new Endpoint { Uri = loadBalancerReader.LoadBalancerEndpoint };
- container.Register(
- Component.For<LoadBalancerMessageModule>()
- .DependsOn(new { loadBalancerEndpoint = endpoint.Uri })
- );
- config.AddMessageModule<LoadBalancerMessageModule>();
- }
- }
-}
View
35 Rhino.ServiceBus.Castle/Config/LoggingConfiguration.cs
@@ -1,35 +0,0 @@
-using Castle.MicroKernel.Registration;
-using Castle.Windsor;
-using Rhino.ServiceBus.Config;
-using Rhino.ServiceBus.Impl;
-using Rhino.ServiceBus.MessageModules;
-
-namespace Rhino.ServiceBus.Castle.Config
-{
- public class LoggingConfiguration : IBusConfigurationAware
- {
- private readonly IWindsorContainer container;
-
- public LoggingConfiguration(IWindsorContainer container)
- {
- this.container = container;
- }
-
- public void Configure(AbstractRhinoServiceBusFacility config)
- {
- var busConfig = config as RhinoServiceBusFacility;
- if (busConfig == null)
- return;
-
- var logReader = new LoggingConfigurationReader(config);
- if (logReader.LogEndpoint == null)
- return;
-
- container.Register(
- Component.For<MessageLoggingModule>()
- .DependsOn(new {logQueue = logReader.LogEndpoint})
- );
- config.InsertMessageModuleAtFirst<MessageLoggingModule>();
- }
- }
-}
View
65 Rhino.ServiceBus.Castle/Config/MsmqConfiguration.cs
@@ -1,65 +0,0 @@
-using System;
-using System.Transactions;
-using Castle.Core;
-using Castle.MicroKernel.Registration;
-using Castle.Windsor;
-using Rhino.ServiceBus.Config;
-using Rhino.ServiceBus.Internal;
-using Rhino.ServiceBus.Msmq;
-using Rhino.ServiceBus.Msmq.TransportActions;
-
-namespace Rhino.ServiceBus.Castle.Config
-{
- public class MsmqConfiguration : MsmqTransportConfigurationAware
- {
- private readonly IWindsorContainer container;
-
- public MsmqConfiguration(IWindsorContainer container)
- {
- this.container = container;
- }
-
- protected override void RegisterQueueCreationModule()
- {
- container.Kernel.Register(Component.For<QueueCreationModule>());
- }
-
- protected override void RegisterTransportServices(int threadCount, Uri endpoint, IsolationLevel queueIsolationLevel, int numberOfRetries, TransactionalOptions transactionalOptions, bool consumeInTransaction)
- {
- container.Kernel.Register(
- Component.For<IQueueStrategy>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .ImplementedBy(QueueStrategyType)
- .DependsOn(new { endpoint }),
- Component.For<IMsmqTransportAction>()
- .ImplementedBy<ErrorAction>()
- .DependsOn(new { numberOfRetries }),
- Component.For<ISubscriptionStorage>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .ImplementedBy(typeof(MsmqSubscriptionStorage))
- .DependsOn(new
- {
- queueBusListensTo = endpoint
- }),
- Component.For<ITransport>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .ImplementedBy(typeof(MsmqTransport))
- .DependsOn(new
- {
- threadCount,
- endpoint,
- queueIsolationLevel,
- numberOfRetries,
- transactional = transactionalOptions,
- consumeInTransaction,
- }),
- AllTypes.FromAssembly(typeof(IMsmqTransportAction).Assembly)
- .BasedOn<IMsmqTransportAction>()
- .Unless(x => x == typeof(ErrorAction))
- .WithService.FirstInterface()
- .Configure(registration =>
- registration.LifeStyle.Is(LifestyleType.Singleton))
- );
- }
- }
-}
View
68 Rhino.ServiceBus.Castle/Config/OneWayBusConfiguration.cs
@@ -1,68 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Messaging;
-using Castle.Core;
-using Castle.MicroKernel.Registration;
-using Castle.Windsor;
-using Rhino.Queues;
-using Rhino.ServiceBus.Config;
-using Rhino.ServiceBus.Impl;
-using Rhino.ServiceBus.Internal;
-using Rhino.ServiceBus.Msmq;
-using Rhino.ServiceBus.RhinoQueues;
-
-namespace Rhino.ServiceBus.Castle.Config
-{
- public class OneWayBusConfiguration : IBusConfigurationAware
- {
- private readonly IWindsorContainer container;
-
- public OneWayBusConfiguration(IWindsorContainer container)
- {
- this.container = container;
- }
-
- public void Configure(AbstractRhinoServiceBusFacility config)
- {
- var oneWayConfig = config as OnewayRhinoServiceBusFacility;
- if (oneWayConfig == null)
- return;
-
- var messageOwners = new List<MessageOwner>();
- var messageOwnersReader = new MessageOwnersConfigReader(config.ConfigurationSection, messageOwners);
- messageOwnersReader.ReadMessageOwners();
- if (IsRhinoQueues(messageOwnersReader.EndpointScheme))
- {
- container.Register(
- Component.For<IMessageBuilder<MessagePayload>>()
- .ImplementedBy<RhinoQueuesMessageBuilder>()
- .LifeStyle.Is(LifestyleType.Singleton),
- Component.For<IOnewayBus>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .ImplementedBy<RhinoQueuesOneWayBus>()
- .DependsOn(new
- {
- messageOwners = messageOwners.ToArray(),
- })
- );
- }
- else
- {
- container.Register(
- Component.For<IMessageBuilder<Message>>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .ImplementedBy<MsmqMessageBuilder>(),
- Component.For<IOnewayBus>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .ImplementedBy<MsmqOnewayBus>()
- .DependsOn(new {messageOwners = messageOwners.ToArray()}));
-
- }
- }
-
- private static bool IsRhinoQueues(string endpointScheme)
- {
- return endpointScheme.Equals("rhino.queues", StringComparison.InvariantCultureIgnoreCase);
- }
- }
-}
View
50 Rhino.ServiceBus.Castle/Config/RhinoQueuesConfiguration.cs
@@ -1,50 +0,0 @@
-using System;
-using System.IO;
-using System.Transactions;
-using Castle.Core;
-using Castle.MicroKernel.Registration;
-using Castle.Windsor;
-using Rhino.Queues;
-using Rhino.ServiceBus.Config;
-using Rhino.ServiceBus.Internal;
-using Rhino.ServiceBus.RhinoQueues;
-
-namespace Rhino.ServiceBus.Castle.Config
-{
- public class RhinoQueuesConfiguration : RhinoQueuesConfigurationAware
- {
- private readonly IWindsorContainer container;
-
- public RhinoQueuesConfiguration(IWindsorContainer container)
- {
- this.container = container;
- }
-
- protected override void RegisterTransportServices(int threadCount, Uri endpoint, IsolationLevel queueIsolationLevel, int numberOfRetries, string path, string name)
- {
- container.Register(
- Component.For<ISubscriptionStorage>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .ImplementedBy(typeof(PhtSubscriptionStorage))
- .DependsOn(new
- {
- subscriptionPath = Path.Combine(path, name + "_subscriptions.esent")
- }),
- Component.For<ITransport>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .ImplementedBy(typeof(RhinoQueuesTransport))
- .DependsOn(new
- {
- threadCount,
- endpoint,
- queueIsolationLevel,
- numberOfRetries,
- path = Path.Combine(path, name + ".esent")
- }),
- Component.For<IMessageBuilder<MessagePayload>>()
- .ImplementedBy<RhinoQueuesMessageBuilder>()
- .LifeStyle.Is(LifestyleType.Singleton)
- );
- }
- }
-}
View
70 Rhino.ServiceBus.Castle/Config/SecurityConfiguration.cs
@@ -1,70 +0,0 @@
-using Castle.MicroKernel.Registration;
-using Castle.Windsor;
-using Rhino.ServiceBus.Config;
-using Rhino.ServiceBus.Convertors;
-using Rhino.ServiceBus.DataStructures;
-using Rhino.ServiceBus.Impl;
-using Rhino.ServiceBus.Internal;
-
-namespace Rhino.ServiceBus.Castle.Config
-{
- public class SecurityConfiguration : IBusConfigurationAware
- {
- private readonly IWindsorContainer container;
-
- public SecurityConfiguration(IWindsorContainer container)
- {
- this.container = container;
- }
-
- private void RegisterNoSecurity()
- {
- container.Register(
- Component.For<IValueConvertor<WireEcryptedString>>()
- .ImplementedBy<ThrowingWireEcryptedStringConvertor>()
- );
- container.Register(
- Component.For<IElementSerializationBehavior>()
- .ImplementedBy<ThrowingWireEncryptedMessageConvertor>()
- );
- }
-
- private void RegisterSecurity(byte[] key)
- {
- container.Register(
- Component.For<IEncryptionService>()
- .ImplementedBy<RijndaelEncryptionService>()
- .DependsOn(new
- {
- key,
- })
- .Named("esb.security")
- );
-
- container.Register(
- Component.For<IValueConvertor<WireEcryptedString>>()
- .ImplementedBy<WireEcryptedStringConvertor>()
- .ServiceOverrides(ServiceOverride.ForKey("encryptionService").Eq("esb.security"))
- );
-
- container.Register(
- Component.For<IElementSerializationBehavior>()
- .ImplementedBy<WireEncryptedMessageConvertor>()
- .ServiceOverrides(ServiceOverride.ForKey("encryptionService").Eq("esb.security"))
- );
- }
-
- public void Configure(AbstractRhinoServiceBusFacility config)
- {
- var busConfig = config as RhinoServiceBusFacility;
- if (busConfig == null)
- return;
-
- var securityReader = new SecurityConfigurationReader(config);
- if (securityReader.Key == null)
- RegisterNoSecurity();
- else
- RegisterSecurity(securityReader.Key);
- }
- }
-}
View
77 Rhino.ServiceBus.Castle/Extensions.cs
@@ -1,15 +1,6 @@
-using System;
-using System.Linq;
-using Castle.Core;
-using Castle.MicroKernel.Registration;
-using Castle.MicroKernel.Resolvers.SpecializedResolvers;
using Castle.Windsor;
using Rhino.ServiceBus.Castle;
-using Rhino.ServiceBus.Config;
-using Rhino.ServiceBus.Exceptions;
using Rhino.ServiceBus.Impl;
-using Rhino.ServiceBus.Internal;
-using Rhino.ServiceBus.Sagas;
namespace Rhino.ServiceBus
{
@@ -22,74 +13,8 @@ public static AbstractRhinoServiceBusFacility UseCastleWindsor(this AbstractRhin
public static AbstractRhinoServiceBusFacility UseCastleWindsor(this AbstractRhinoServiceBusFacility configuration, IWindsorContainer container)
{
- configuration.ConfigurationStarted += () => SetupDefaultRegistration(container, configuration);
+ new CastleBuilder(container, configuration);
return configuration;
}
-
- private static void SetupDefaultRegistration(IWindsorContainer container, AbstractRhinoServiceBusFacility configuration)
- {
- if (!container.Kernel.HasComponent(typeof(IWindsorContainer)))
- container.Register(Component.For<IWindsorContainer>().Instance(container));
-
- container.Register(Component.For<IServiceLocator>().ImplementedBy<CastleServiceLocator>());
-
- container.Register(
- AllTypes.FromAssembly(typeof(Extensions).Assembly)
- .BasedOn<IBusConfigurationAware>()
- );
-
- foreach (var configurationAware in container.ResolveAll<IBusConfigurationAware>())
- {
- configurationAware.Configure(configuration);
- }
-
- container.Kernel.ComponentModelCreated += Kernel_OnComponentModelCreated;
- container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
-
- foreach (var type in configuration.MessageModules)
- {
- if (container.Kernel.HasComponent(type) == false)
- container.Register(Component.For(type).Named(type.FullName));
- }
-
- container.Register(
- Component.For<IReflection>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .ImplementedBy<DefaultReflection>(),
-
- Component.For<IMessageSerializer>()
- .LifeStyle.Is(LifestyleType.Singleton)
- .ImplementedBy(configuration.SerializerType),
- Component.For<IEndpointRouter>()
- .ImplementedBy<EndpointRouter>()
- );
- }
-
- private static void Kernel_OnComponentModelCreated(ComponentModel model)
- {
- if (typeof(IMessageConsumer).IsAssignableFrom(model.Implementation) == false)
- return;
-
- var interfaces = model.Implementation.GetInterfaces()
- .Where(x => x.IsGenericType && x.IsGenericTypeDefinition == false)
- .Select(x => x.GetGenericTypeDefinition())
- .ToList();
-
- if (interfaces.Contains(typeof(InitiatedBy<>)) &&
- interfaces.Contains(typeof(ISaga<>)) == false)
- {
- throw new InvalidUsageException("Message consumer: " + model.Implementation + " implements InitiatedBy<TMsg> but doesn't implment ISaga<TState>. " + Environment.NewLine +
- "Did you forget to inherit from ISaga<TState> ?");
- }
-
- if (interfaces.Contains(typeof(InitiatedBy<>)) == false &&
- interfaces.Contains(typeof(Orchestrates<>)))
- {
- throw new InvalidUsageException("Message consumer: " + model.Implementation + " implements Orchestrates<TMsg> but doesn't implment InitiatedBy<TState>. " + Environment.NewLine +
- "Did you forget to inherit from InitiatedBy<TState> ?");
- }
-
- model.LifestyleType = LifestyleType.Transient;
- }
}
}
View
9 Rhino.ServiceBus.Castle/Rhino.ServiceBus.Castle.csproj
@@ -54,15 +54,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CastleBootStrapper.cs" />
+ <Compile Include="CastleBuilder.cs" />
<Compile Include="CastleServiceLocator.cs" />
- <Compile Include="Config\BusConfiguration.cs" />
- <Compile Include="Config\LoadBalancerConfiguration.cs" />
- <Compile Include="Config\LoadBalancerEndpointConfiguration.cs" />
- <Compile Include="Config\LoggingConfiguration.cs" />
- <Compile Include="Config\MsmqConfiguration.cs" />
- <Compile Include="Config\RhinoQueuesConfiguration.cs" />
- <Compile Include="Config\SecurityConfiguration.cs" />
- <Compile Include="Config\OneWayBusConfiguration.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="CastleLoadBalancerBootStrapper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
View
36 Rhino.ServiceBus.StructureMap/ConsumerInterceptor.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Linq;
+using Rhino.ServiceBus.Exceptions;
+using Rhino.ServiceBus.Sagas;
+using StructureMap;
+using StructureMap.Interceptors;
+
+namespace Rhino.ServiceBus.StructureMap
+{
+ public class ConsumerInterceptor : InstanceInterceptor
+ {
+ public object Process(object target, IContext context)
+ {
+ var consumerType = target.GetType();
+ var interfaces = consumerType.GetInterfaces()
+ .Where(x => x.IsGenericType && x.IsGenericTypeDefinition == false)
+ .Select(x => x.GetGenericTypeDefinition())
+ .ToList();
+
+ if (interfaces.Contains(typeof(InitiatedBy<>)) &&
+ interfaces.Contains(typeof(ISaga<>)) == false)
+ {
+ throw new InvalidUsageException("Message consumer: " + consumerType + " implements InitiatedBy<TMsg> but doesn't implment ISaga<TState>. " + Environment.NewLine +
+ "Did you forget to inherit from ISaga<TState> ?");
+ }
+
+ if (interfaces.Contains(typeof(InitiatedBy<>)) == false &&
+ interfaces.Contains(typeof(Orchestrates<>)))
+ {
+ throw new InvalidUsageException("Message consumer: " + consumerType + " implements Orchestrates<TMsg> but doesn't implment InitiatedBy<TState>. " + Environment.NewLine +
+ "Did you forget to inherit from InitiatedBy<TState> ?");
+ }
+ return target;
+ }
+ }
+}
View
19 Rhino.ServiceBus.StructureMap/Extensions.cs
@@ -0,0 +1,19 @@
+using Rhino.ServiceBus.Impl;
+using StructureMap;
+
+namespace Rhino.ServiceBus.StructureMap
+{
+ public static class Extensions
+ {
+ public static AbstractRhinoServiceBusFacility UseStructureMap(this AbstractRhinoServiceBusFacility configuration)
+ {
+ return UseStructureMap(configuration, ObjectFactory.Container);
+ }
+
+ public static AbstractRhinoServiceBusFacility UseStructureMap(this AbstractRhinoServiceBusFacility configuration, IContainer container)
+ {
+ new StructureMapBuilder(configuration, container);
+ return configuration;
+ }
+ }
+}
View
71 Rhino.ServiceBus.StructureMap/Rhino.ServiceBus.StructureMap.csproj
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{C0B1E3BD-3481-4E0E-866F-5BEC471C2F4C}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Rhino.ServiceBus.StructureMap</RootNamespace>
+ <AssemblyName>Rhino.ServiceBus.StructureMap</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Rhino.Queues, Version=1.2.0.0, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL" />
+ <Reference Include="StructureMap">
+ <HintPath>..\SharedLibs\StructureMap.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Messaging" />
+ <Reference Include="System.Transactions" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ConsumerInterceptor.cs" />
+ <Compile Include="Extensions.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="SingletonConvention.cs" />
+ <Compile Include="StructureMapBootStrapper.cs" />
+ <Compile Include="StructureMapBuilder.cs" />
+ <Compile Include="StructureMapServiceLocator.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Rhino.ServiceBus\Rhino.ServiceBus.csproj">
+ <Project>{1B21C8A5-5E0E-412B-A7F4-9F28B4427F21}</Project>
+ <Name>Rhino.ServiceBus</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
18 Rhino.ServiceBus.StructureMap/SingletonConvention.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Linq;
+using StructureMap.Configuration.DSL;
+using StructureMap.Graph;
+using StructureMap.TypeRules;
+
+namespace Rhino.ServiceBus.StructureMap
+{
+ internal class SingletonConvention<TPluginFamily> : IRegistrationConvention
+ {
+ public void Process(Type type, Registry registry)
+ {
+ if (!type.IsConcrete() || !type.CanBeCreated() || !type.AllInterfaces().Contains(typeof(TPluginFamily))) return;
+
+ registry.For(typeof(TPluginFamily)).Singleton().Use(type);
+ }
+ }
+}
View
79 Rhino.ServiceBus.StructureMap/StructureMapBootStrapper.cs
@@ -0,0 +1,79 @@
+using Rhino.ServiceBus.Actions;
+using Rhino.ServiceBus.Hosting;
+using Rhino.ServiceBus.Impl;
+using Rhino.ServiceBus.Internal;
+using StructureMap;
+
+namespace Rhino.ServiceBus.StructureMap
+{
+ public class StructureMapBootStrapper : AbstractBootStrapper
+ {
+ private IContainer container;
+
+ public StructureMapBootStrapper()
+ {
+ }
+
+ public StructureMapBootStrapper(IContainer container)
+ {
+ this.container = container;
+ }
+
+ protected IContainer Container
+ {
+ get { return container; }
+ }
+
+ protected override void ConfigureBusFacility(AbstractRhinoServiceBusFacility facility)
+ {
+ facility.UseStructureMap(container);
+ base.ConfigureBusFacility(facility);
+ }
+
+ public override void CreateContainer()
+ {
+ if (container == null)
+ container = ObjectFactory.Container;
+
+ ConfigureContainer();
+ }
+
+ private void ConfigureContainer()
+ {
+ container.Configure(c => c.Scan(s =>
+ {
+ s.Assembly(typeof(StructureMapBootStrapper).Assembly);
+ s.AddAllTypesOf(typeof(IMessageConsumer)).NameBy(t => t.FullName);
+ s.Exclude(t => typeof(IOccasionalMessageConsumer).IsAssignableFrom(t) == false);
+ s.AddAllTypesOf<IDeploymentAction>();
+ s.AddAllTypesOf<IEnvironmentValidationAction>();
+ }));
+ }
+
+ public override void ExecuteDeploymentActions(string user)
+ {
+ foreach (var action in container.GetAllInstances<IDeploymentAction>())
+ {
+ action.Execute(user);
+ }
+ }
+
+ public override void ExecuteEnvironmentValidationActions()
+ {
+ foreach (var action in container.GetAllInstances<IEnvironmentValidationAction>())
+ {
+ action.Execute();
+ }
+ }
+
+ public override T GetInstance<T>()
+ {
+ return container.GetInstance<T>();
+ }
+
+ public override void Dispose()
+ {
+ container.Dispose();
+ }
+ }
+}
View
224 Rhino.ServiceBus.StructureMap/StructureMapBuilder.cs
@@ -0,0 +1,224 @@
+using System;
+using System.IO;
+using System.Linq;
+using System.Messaging;
+using System.Transactions;
+using Rhino.Queues;
+using Rhino.ServiceBus.Actions;
+using Rhino.ServiceBus.Config;
+using Rhino.ServiceBus.Convertors;
+using Rhino.ServiceBus.DataStructures;
+using Rhino.ServiceBus.Impl;
+using Rhino.ServiceBus.Internal;
+using Rhino.ServiceBus.LoadBalancer;
+using Rhino.ServiceBus.MessageModules;
+using Rhino.ServiceBus.Msmq;
+using Rhino.ServiceBus.Msmq.TransportActions;
+using Rhino.ServiceBus.RhinoQueues;
+using StructureMap;
+using ErrorAction = Rhino.ServiceBus.Msmq.TransportActions.ErrorAction;
+
+namespace Rhino.ServiceBus.StructureMap
+{
+ public class StructureMapBuilder : IBusContainerBuilder
+ {
+ private readonly AbstractRhinoServiceBusFacility config;
+ private readonly IContainer container;
+
+ public StructureMapBuilder(AbstractRhinoServiceBusFacility config, IContainer container)
+ {
+ this.config = config;
+ this.container = container;
+ config.BuildWith(this);
+ }
+
+ public void RegisterDefaultServices()
+ {
+ container.Configure(c =>
+ {
+ c.For<IServiceLocator>().Use<StructureMapServiceLocator>();
+ c.Scan(s =>
+ {
+ s.AssemblyContainingType(typeof(IServiceBus));
+ s.AddAllTypesOf<IBusConfigurationAware>();
+ });
+ });
+
+ foreach (var busConfigurationAware in container.GetAllInstances<IBusConfigurationAware>())
+ {
+ busConfigurationAware.Configure(config, this);
+ }
+
+ container.Configure(c =>
+ {
+ foreach (var messageModule in config.MessageModules)
+ {
+ Type module = messageModule;
+ c.For(typeof(IMessageModule)).Singleton().Use(module).Named(typeof(IMessageModule).FullName);
+ }
+
+ c.For<IMessageConsumer>().AlwaysUnique().InterceptWith(new ConsumerInterceptor());
+ c.For<IReflection>().Singleton().Use<DefaultReflection>();
+ c.For(typeof(IMessageSerializer)).Singleton().Use(config.SerializerType);
+ c.For<IEndpointRouter>().Singleton().Use<EndpointRouter>();
+ });
+ }
+
+ public void RegisterBus()
+ {
+ var busConfig = (RhinoServiceBusFacility) config;
+ container.Configure(c =>
+ {
+ c.For<IDeploymentAction>().Use<CreateLogQueueAction>();
+ c.For<IDeploymentAction>().Use<CreateQueuesAction>();
+ c.For<IStartableServiceBus>().Singleton().Use<DefaultServiceBus>()
+ .Ctor<MessageOwner[]>().Is(busConfig.MessageOwners.ToArray());
+ c.Forward<IStartableServiceBus, IServiceBus>();
+ });
+ }
+
+ public void RegisterPrimaryLoadBalancer()
+ {
+ var loadBalancerConfig = (LoadBalancerFacility) config;
+ container.Configure(c =>
+ {
+ c.For(typeof (MsmqLoadBalancer)).Singleton().Use(loadBalancerConfig.LoadBalancerType)
+ .Child("threadCount").Is(loadBalancerConfig.ThreadCount)
+ .Child("primaryLoadBalancer").Is(loadBalancerConfig.PrimaryLoadBalancer)
+ .Child("transactional").Is(loadBalancerConfig.Transactional)
+ .Child("endpoint").Is(loadBalancerConfig.Endpoint);
+ c.For<IDeploymentAction>().Use<CreateLoadBalancerQueuesAction>();
+ });
+ }
+
+ public void RegisterSecondaryLoadBalancer()
+ {
+ var loadBalancerConfig = (LoadBalancerFacility) config;
+ container.Configure(c =>
+ {
+ c.For(typeof (MsmqLoadBalancer)).Singleton().Use(loadBalancerConfig.LoadBalancerType)
+ .Child("threadCount").Is(loadBalancerConfig.ThreadCount)
+ .Child("primaryLoadBalancer").Is(loadBalancerConfig.PrimaryLoadBalancer)
+ .Child("transactional").Is(loadBalancerConfig.Transactional)
+ .Child("endpoint").Is(loadBalancerConfig.Endpoint)
+ .Child("secondaryLoadBalancer").Is(loadBalancerConfig.SecondaryLoadBalancer);
+ c.For<IDeploymentAction>().Use<CreateLoadBalancerQueuesAction>();
+ });
+ }
+
+ public void RegisterReadyForWork()
+ {
+ var loadBalancerConfig = (LoadBalancerFacility) config;
+ container.Configure(c =>
+ {
+ c.For<MsmqReadyForWorkListener>().Singleton().Use<MsmqReadyForWorkListener>()
+ .Ctor<Uri>().Is(loadBalancerConfig.ReadyForWork)
+ .Ctor<int>().Is(loadBalancerConfig.ThreadCount)
+ .Ctor<TransactionalOptions>().Is(loadBalancerConfig.Transactional);
+ c.For<IDeploymentAction>().Use<CreateReadyForWorkQueuesAction>();
+ });
+ }
+
+ public void RegisterLoadBalancerEndpoint(Uri loadBalancerEndpoint)
+ {
+ container.Configure(c => c.For<LoadBalancerMessageModule>().Singleton().Use<LoadBalancerMessageModule>()
+ .Ctor<Uri>().Is(loadBalancerEndpoint));
+ }
+
+ public void RegisterLoggingEndpoint(Uri logEndpoint)
+ {
+ container.Configure(c => c.For<MessageLoggingModule>().Singleton().Use<MessageLoggingModule>()
+ .Ctor<Uri>().Is(logEndpoint));
+ }
+
+ public void RegisterMsmqTransport(Type queueStrategyType)
+ {
+ container.Configure(c =>
+ {
+ c.For(typeof (IQueueStrategy)).Singleton().Use(queueStrategyType)
+ .Child("endpoint").Is(config.Endpoint);
+ c.For<IMsmqTransportAction>().Singleton().Use<ErrorAction>()
+ .Ctor<int>().Is(config.NumberOfRetries);
+ c.For<ISubscriptionStorage>().Singleton().Use<MsmqSubscriptionStorage>()
+ .Ctor<Uri>().Is(config.Endpoint);
+ c.For<ITransport>().Singleton().Use<MsmqTransport>()
+ .Ctor<int>("threadCount").Is(config.ThreadCount)
+ .Ctor<Uri>().Is(config.Endpoint)
+ .Ctor<IsolationLevel>().Is(config.IsolationLevel)
+ .Ctor<int>("numberOfRetries").Is(config.NumberOfRetries)
+ .Ctor<TransactionalOptions>().Is(config.Transactional)
+ .Ctor<bool>().Is(config.ConsumeInTransaction);
+ c.Scan(s =>
+ {
+ s.Assembly(typeof(IMsmqTransportAction).Assembly);
+ s.With(new SingletonConvention<IMsmqTransportAction>());
+ s.AddAllTypesOf<IMsmqTransportAction>();
+ });
+ });
+ }
+
+ public void RegisterQueueCreation()
+ {
+ container.Configure(c => c.For<QueueCreationModule>().Singleton().Use<QueueCreationModule>());
+ }
+
+ public void RegisterMsmqOneWay()
+ {
+ var oneWayConfig = (OnewayRhinoServiceBusFacility) config;
+ container.Configure(c =>
+ {
+ c.For<IMessageBuilder<Message>>().Singleton().Use<MsmqMessageBuilder>();
+ c.For<IOnewayBus>().Singleton().Use<MsmqOnewayBus>()
+ .Ctor<MessageOwner[]>().Is(oneWayConfig.MessageOwners);
+ });
+ }
+
+ public void RegisterRhinoQueuesTransport(string path, string name)
+ {
+ container.Configure(c =>
+ {
+ c.For<ISubscriptionStorage>().Singleton().Use<PhtSubscriptionStorage>()
+ .Ctor<string>().Is(Path.Combine(path, name + "_subscriptions.esent"));
+ c.For<ITransport>().Singleton().Use<RhinoQueuesTransport>()
+ .Ctor<int>("threadCount").Is(config.ThreadCount)
+ .Ctor<Uri>().Is(config.Endpoint)
+ .Ctor<IsolationLevel>().Is(config.IsolationLevel)
+ .Ctor<int>("numberOfRetries").Is(config.NumberOfRetries)
+ .Ctor<string>().Is(Path.Combine(path, name + ".esent"));
+ c.For<IMessageBuilder<MessagePayload>>().Singleton().Use<RhinoQueuesMessageBuilder>();
+ });
+ }
+
+ public void RegisterRhinoQueuesOneWay()
+ {
+ var oneWayConfig = (OnewayRhinoServiceBusFacility) config;
+
+ container.Configure(c =>
+ {
+ c.For<IMessageBuilder<MessagePayload>>().Singleton().Use<RhinoQueuesMessageBuilder>();
+ c.For<IOnewayBus>().Singleton().Use<RhinoQueuesOneWayBus>()
+ .Ctor<MessageOwner[]>().Is(oneWayConfig.MessageOwners);
+ });
+ }
+
+ public void RegisterSecurity(byte[] key)
+ {
+ container.Configure(c =>
+ {
+ c.For<IEncryptionService>().Singleton().Use<RijndaelEncryptionService>()
+ .Ctor<byte[]>().Is(key);
+ c.For<IValueConvertor<WireEcryptedString>>().Singleton().Use<WireEcryptedStringConvertor>();
+ c.For<IElementSerializationBehavior>().Singleton().Use<WireEncryptedMessageConvertor>();
+ });
+ }
+
+ public void RegisterNoSecurity()
+ {
+ container.Configure(c =>
+ {
+ c.For<IValueConvertor<WireEcryptedString>>().Singleton().Use<ThrowingWireEcryptedStringConvertor>();
+ c.For<IElementSerializationBehavior>().Singleton().Use<ThrowingWireEncryptedMessageConvertor>();
+ });
+ }
+ }
+}
View
51 Rhino.ServiceBus.StructureMap/StructureMapServiceLocator.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Rhino.ServiceBus.Impl;
+using Rhino.ServiceBus.Internal;
+using StructureMap;
+
+namespace Rhino.ServiceBus.StructureMap
+{
+ public class StructureMapServiceLocator : IServiceLocator
+ {
+ private readonly IContainer container;
+
+ public StructureMapServiceLocator(IContainer container)
+ {
+ this.container = container;
+ }
+
+ public T Resolve<T>()
+ {
+ return container.GetInstance<T>();
+ }
+
+ public object Resolve(Type type)
+ {
+ return container.GetInstance(type);
+ }
+
+ public bool CanResolve(Type type)
+ {
+ return container.Model.HasDefaultImplementationFor(type);
+ }
+
+ public IEnumerable<T> ResolveAll<T>()
+ {
+ return container.GetAllInstances<T>();
+ }
+
+ public IEnumerable<IHandler> GetAllHandlersFor(Type type)
+ {
+ return from h in container.Model.InstancesOf(type)
+ select (IHandler)
+ new DefaultHandler(h.PluginType, h.ConcreteType, () => container.GetInstance(h.ConcreteType));
+ }
+
+ public void Release(object item)
+ {
+ //Not needed for StructureMap it doesn't keep references beyond the life cycle that was configured.
+ }
+ }
+}
View
10 Rhino.ServiceBus.sln
@@ -15,6 +15,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Starbucks.Tests", "Samples\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rhino.ServiceBus.Castle", "Rhino.ServiceBus.Castle\Rhino.ServiceBus.Castle.csproj", "{4D65E756-C0C9-42AA-9B73-75E85E77EA7B}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rhino.ServiceBus.StructureMap", "Rhino.ServiceBus.StructureMap\Rhino.ServiceBus.StructureMap.csproj", "{C0B1E3BD-3481-4E0E-866F-5BEC471C2F4C}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Containers", "Containers", "{2271E8BF-21FF-40B1-A284-F707951F5EA2}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -45,6 +49,10 @@ Global
{4D65E756-C0C9-42AA-9B73-75E85E77EA7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D65E756-C0C9-42AA-9B73-75E85E77EA7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D65E756-C0C9-42AA-9B73-75E85E77EA7B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C0B1E3BD-3481-4E0E-866F-5BEC471C2F4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C0B1E3BD-3481-4E0E-866F-5BEC471C2F4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C0B1E3BD-3481-4E0E-866F-5BEC471C2F4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C0B1E3BD-3481-4E0E-866F-5BEC471C2F4C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -52,5 +60,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{0FC43226-8030-46FC-A2AB-D064207FF364} = {64DC50EF-F634-4E75-8375-ACC6D42E2DB4}
{EBCAD5F6-F6A4-47C8-B8B5-F92E26CBACDA} = {64DC50EF-F634-4E75-8375-ACC6D42E2DB4}
+ {4D65E756-C0C9-42AA-9B73-75E85E77EA7B} = {2271E8BF-21FF-40B1-A284-F707951F5EA2}
+ {C0B1E3BD-3481-4E0E-866F-5BEC471C2F4C} = {2271E8BF-21FF-40B1-A284-F707951F5EA2}
EndGlobalSection
EndGlobal
View
2  Rhino.ServiceBus/Config/IBusConfigurationAware.cs
@@ -4,6 +4,6 @@ namespace Rhino.ServiceBus.Config
{
public interface IBusConfigurationAware
{
- void Configure(AbstractRhinoServiceBusFacility config);
+ void Configure(AbstractRhinoServiceBusFacility config, IBusContainerBuilder builder);
}
}
View
22 Rhino.ServiceBus/Config/IBusContainerBuilder.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace Rhino.ServiceBus.Config
+{
+ public interface IBusContainerBuilder
+ {
+ void RegisterDefaultServices();
+ void RegisterBus();
+ void RegisterPrimaryLoadBalancer();
+ void RegisterSecondaryLoadBalancer();
+ void RegisterReadyForWork();
+ void RegisterLoadBalancerEndpoint(Uri loadBalancerEndpoint);
+ void RegisterLoggingEndpoint(Uri logEndpoint);
+ void RegisterMsmqTransport(Type queueStrategyType);
+ void RegisterQueueCreation();
+ void RegisterMsmqOneWay();
+ void RegisterRhinoQueuesTransport(string path, string name);
+ void RegisterRhinoQueuesOneWay();
+ void RegisterSecurity(byte[] key);
+ void RegisterNoSecurity();
+ }
+}
View
28 Rhino.ServiceBus/Config/LoadBalancerConfiguration.cs
@@ -0,0 +1,28 @@
+using Rhino.ServiceBus.Impl;
+using Rhino.ServiceBus.LoadBalancer;
+
+namespace Rhino.ServiceBus.Config
+{
+ public class LoadBalancerConfiguration : IBusConfigurationAware
+ {
+ public void Configure(AbstractRhinoServiceBusFacility config, IBusContainerBuilder builder)
+ {
+ var loadBalancerConfig = config as LoadBalancerFacility;
+ if (loadBalancerConfig == null)
+ return;
+ if (loadBalancerConfig.SecondaryLoadBalancer != null)
+ {
+ builder.RegisterSecondaryLoadBalancer();
+ }
+ else
+ {
+ builder.RegisterPrimaryLoadBalancer();
+ }
+
+ if (loadBalancerConfig.ReadyForWork != null)
+ {
+ builder.RegisterReadyForWork();
+ }
+ }
+ }
+}
View
18 ...viceBus/Config/LoadBalancerConfigurationReader.cs → ...ceBus/Config/LoadBalancerEndpointConfiguration.cs
@@ -1,14 +1,19 @@
using System;
using System.Configuration;
using Rhino.ServiceBus.Impl;
+using Rhino.ServiceBus.MessageModules;
namespace Rhino.ServiceBus.Config
{
- public class LoadBalancerConfigurationReader
+ public class LoadBalancerEndpointConfiguration : IBusConfigurationAware
{
- public LoadBalancerConfigurationReader(AbstractRhinoServiceBusFacility configuration)
+ public void Configure(AbstractRhinoServiceBusFacility config, IBusContainerBuilder builder)
{
- var busElement = configuration.ConfigurationSection.Bus;
+ var busConfig = config as RhinoServiceBusFacility;
+ if (busConfig == null)
+ return;
+
+ var busElement = config.ConfigurationSection.Bus;
if (busElement == null)
return;
@@ -27,9 +32,10 @@ public LoadBalancerConfigurationReader(AbstractRhinoServiceBusFacility configura
throw new ConfigurationErrorsException(
"Attribute 'loadBalancerEndpoint' on 'bus' has an invalid value '" + loadBalancerEndpointAsString + "'");
}
- LoadBalancerEndpoint = loadBalancerEndpoint;
- }
- public Uri LoadBalancerEndpoint { get; private set; }
+ var endpoint = new Endpoint { Uri = loadBalancerEndpoint };
+ builder.RegisterLoadBalancerEndpoint(endpoint.Uri);
+ config.AddMessageModule<LoadBalancerMessageModule>();
+ }
}
}
View
31 Rhino.ServiceBus/Config/LoggingConfiguration.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Configuration;
+using Rhino.ServiceBus.Impl;
+using Rhino.ServiceBus.MessageModules;
+
+namespace Rhino.ServiceBus.Config
+{
+ public class LoggingConfiguration : IBusConfigurationAware
+ {
+ public void Configure(AbstractRhinoServiceBusFacility config, IBusContainerBuilder builder)
+ {
+ var busConfig = config as RhinoServiceBusFacility;
+ if (busConfig == null)
+ return;
+
+ Uri logEndpoint;
+
+ var uriString = config.ConfigurationSection.Bus.LogEndpoint;
+ if (string.IsNullOrEmpty(uriString))
+ return;
+
+ if (Uri.TryCreate(uriString, UriKind.Absolute, out logEndpoint) == false)
+ {
+ throw new ConfigurationErrorsException(
+ "Attribute 'logEndpoint' on 'bus' has an invalid value '" + uriString + "'");
+ }
+ builder.RegisterLoggingEndpoint(logEndpoint);
+ config.InsertMessageModuleAtFirst<MessageLoggingModule>();
+ }
+ }
+}
View
27 Rhino.ServiceBus/Config/LoggingConfigurationReader.cs
@@ -1,27 +0,0 @@
-using System;
-using System.Configuration;
-using Rhino.ServiceBus.Impl;
-
-namespace Rhino.ServiceBus.Config
-{
- public class LoggingConfigurationReader
- {
- public LoggingConfigurationReader(AbstractRhinoServiceBusFacility configuration)
- {
- Uri logEndpoint;
-
- var uriString = configuration.ConfigurationSection.Bus.LogEndpoint;
- if (string.IsNullOrEmpty(uriString))
- return;
-
- if (Uri.TryCreate(uriString, UriKind.Absolute, out logEndpoint) == false)
- {
- throw new ConfigurationErrorsException(
- "Attribute 'logEndpoint' on 'bus' has an invalid value '" + uriString + "'");
- }
- LogEndpoint = logEndpoint;
- }
-
- public Uri LogEndpoint { get; private set; }
- }
-}
View
30 Rhino.ServiceBus/Config/MsmqTransportConfigurationAware.cs
@@ -1,12 +1,11 @@
using System;
-using System.Transactions;
using Rhino.ServiceBus.Impl;
using Rhino.ServiceBus.LoadBalancer;
using Rhino.ServiceBus.Msmq;
namespace Rhino.ServiceBus.Config
{
- public abstract class MsmqTransportConfigurationAware : IBusConfigurationAware
+ public class MsmqTransportConfigurationAware : IBusConfigurationAware
{
private Type queueStrategyImpl = typeof(SubQueueStrategy);
@@ -21,17 +20,12 @@ private void DetectQueueStrategy()
}
}
- protected Type QueueStrategyType
- {
- get { return queueStrategyImpl; }
- }
-
- protected MsmqTransportConfigurationAware()
+ public MsmqTransportConfigurationAware()
{
DetectQueueStrategy();
}
- public void Configure(AbstractRhinoServiceBusFacility facility)
+ public void Configure(AbstractRhinoServiceBusFacility facility, IBusContainerBuilder builder)
{
if (!(facility is RhinoServiceBusFacility) && !(facility is LoadBalancerFacility))
return;
@@ -46,24 +40,10 @@ public void Configure(AbstractRhinoServiceBusFacility facility)
if (facility.DisableAutoQueueCreation == false)
{
- RegisterQueueCreationModule();
+ builder.RegisterQueueCreation();
}
- RegisterTransportServices(facility.ThreadCount,
- facility.Endpoint,
- facility.IsolationLevel,
- facility.NumberOfRetries,
- facility.Transactional,
- facility.consumeInTxn);
+ builder.RegisterMsmqTransport(queueStrategyImpl);
}
-
- protected abstract void RegisterQueueCreationModule();
-
- protected abstract void RegisterTransportServices(int threadCount,
- Uri endpoint,
- IsolationLevel queueIsolationLevel,
- int numberOfRetries,
- TransactionalOptions transactionalOptions,
- bool consumeInTransaction);
}
}
View
34 Rhino.ServiceBus/Config/OneWayBusConfiguration.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using Rhino.ServiceBus.Impl;
+
+namespace Rhino.ServiceBus.Config
+{
+ public class OneWayBusConfiguration : IBusConfigurationAware
+ {
+ public void Configure(AbstractRhinoServiceBusFacility config, IBusContainerBuilder builder)
+ {
+ var oneWayConfig = config as OnewayRhinoServiceBusFacility;
+ if (oneWayConfig == null)
+ return;
+
+ var messageOwners = new List<MessageOwner>();
+ var messageOwnersReader = new MessageOwnersConfigReader(config.ConfigurationSection, messageOwners);
+ messageOwnersReader.ReadMessageOwners();
+ oneWayConfig.MessageOwners = messageOwners.ToArray();
+ if (IsRhinoQueues(messageOwnersReader.EndpointScheme))
+ {
+ builder.RegisterRhinoQueuesOneWay();
+ }
+ else
+ {
+ builder.RegisterMsmqOneWay();
+ }
+ }
+
+ private static bool IsRhinoQueues(string endpointScheme)
+ {
+ return endpointScheme.Equals("rhino.queues", StringComparison.InvariantCultureIgnoreCase);
+ }
+ }
+}
View
16 Rhino.ServiceBus/Config/RhinoQueuesConfigurationAware.cs
@@ -1,14 +1,13 @@
using System;
using System.Configuration;
using System.IO;
-using System.Transactions;
using Rhino.ServiceBus.Impl;
namespace Rhino.ServiceBus.Config
{
- public abstract class RhinoQueuesConfigurationAware : IBusConfigurationAware
+ public class RhinoQueuesConfigurationAware : IBusConfigurationAware
{
- public void Configure(AbstractRhinoServiceBusFacility facility)
+ public void Configure(AbstractRhinoServiceBusFacility facility, IBusContainerBuilder builder)
{
var busConfig = facility as RhinoServiceBusFacility;
if (busConfig == null)
@@ -26,16 +25,7 @@ public void Configure(AbstractRhinoServiceBusFacility facility)
var path = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory);
- RegisterTransportServices(facility.ThreadCount,
- facility.Endpoint,
- facility.IsolationLevel,
- facility.NumberOfRetries,
- path,
- busConfigSection.Name);
+ builder.RegisterRhinoQueuesTransport(path, busConfigSection.Name);
}
-
- protected abstract void RegisterTransportServices(int threadCount, Uri endpoint,
- IsolationLevel queueIsolationLevel, int numberOfRetries,
- string path, string name);
}
}
View
14 ....ServiceBus/Config/SecurityConfigurationReader.cs → Rhino.ServiceBus/Config/SecurityConfiguration.cs
@@ -4,12 +4,18 @@
namespace Rhino.ServiceBus.Config
{
- public class SecurityConfigurationReader
+ public class SecurityConfiguration : IBusConfigurationAware
{
- public SecurityConfigurationReader(AbstractRhinoServiceBusFacility config)
+ public void Configure(AbstractRhinoServiceBusFacility config, IBusContainerBuilder builder)
{
+ var busConfig = config as RhinoServiceBusFacility;
+ if (busConfig == null)
+ return;
if (config.ConfigurationSection.Security.Key == null)
+ {
+ builder.RegisterNoSecurity();
return;
+ }
var key = config.ConfigurationSection.Security.Key;
if (string.IsNullOrEmpty(key))
@@ -17,9 +23,7 @@ public SecurityConfigurationReader(AbstractRhinoServiceBusFacility config)
var keyBuffer = Convert.FromBase64String(key);
- Key = keyBuffer;
+ builder.RegisterSecurity(keyBuffer);
}
-
- public byte[] Key { get; private set; }
}
}
View
25 Rhino.ServiceBus/Impl/AbstractRhinoServiceBusFacility.cs
@@ -18,6 +18,7 @@ public abstract class AbstractRhinoServiceBusFacility
public bool consumeInTxn = true;
private BusConfigurationSection configurationSection;
private Action readConfiguration;
+ private IBusContainerBuilder busContainerBuilder;
protected AbstractRhinoServiceBusFacility()
@@ -43,15 +44,16 @@ protected AbstractRhinoServiceBusFacility()
public TransactionalOptions Transactional { get; set; }
- public event Action ConfigurationStarted;
-
- public event Action ConfigurationComplete;
-
public BusConfigurationSection ConfigurationSection
{
get { return configurationSection; }
}
+ protected IBusContainerBuilder Builder
+ {
+ get { return busContainerBuilder; }
+ }
+
public IsolationLevel IsolationLevel
{
get { return queueIsolationLevel; }
@@ -86,19 +88,13 @@ public AbstractRhinoServiceBusFacility InsertMessageModuleAtFirst<TModule>()
return this;
}
- public void Configure()
+ public virtual void Configure()
{
ReadBusConfiguration();
ApplyConfiguration();
- var copy = ConfigurationStarted;
- if (copy != null)
- copy();
-
- var complete = ConfigurationComplete;
- if (complete != null)
- complete();
+ Builder.RegisterDefaultServices();
}
protected abstract void ApplyConfiguration();
@@ -140,5 +136,10 @@ public AbstractRhinoServiceBusFacility DisableQueueAutoCreation()
DisableAutoQueueCreation = true;
return this;
}
+
+ public void BuildWith(IBusContainerBuilder builder)
+ {
+ busContainerBuilder = builder;
+ }
}
}
View
5 Rhino.ServiceBus/Impl/OnewayRhinoServiceBusFacility.cs
@@ -3,8 +3,9 @@ namespace Rhino.ServiceBus.Impl
public class OnewayRhinoServiceBusFacility : AbstractRhinoServiceBusFacility
{
protected override void ApplyConfiguration()
- {
-
+ {
}
+
+ public MessageOwner[] MessageOwners { get; set; }
}
}
View
6 Rhino.ServiceBus/Impl/RhinoServiceBusFacility.cs
@@ -64,6 +64,12 @@ protected override void ApplyConfiguration()
}
}
+ public override void Configure()
+ {
+ base.Configure();
+ Builder.RegisterBus();
+ }
+
public AbstractRhinoServiceBusFacility UseFlatQueueStructure()
{
UseFlatQueue = true;
View
9 Rhino.ServiceBus/Rhino.ServiceBus.csproj
@@ -73,11 +73,14 @@
<Compile Include="Config\BusElement.cs" />
<Compile Include="Config\IBusConfigurationAware.cs" />
<Compile Include="Config\KeyElement.cs" />
+ <Compile Include="Config\LoadBalancerConfiguration.cs" />
<Compile Include="Config\LoadBalancerElement.cs" />
- <Compile Include="Config\LoggingConfigurationReader.cs" />
+ <Compile Include="Config\LoadBalancerEndpointConfiguration.cs" />
+ <Compile Include="Config\LoggingConfiguration.cs" />
<Compile Include="Config\MessageOwnerElement.cs" />
<Compile Include="Config\MessageOwnerElementCollection.cs" />
- <Compile Include="Config\SecurityConfigurationReader.cs" />
+ <Compile Include="Config\OneWayBusConfiguration.cs" />
+ <Compile Include="Config\SecurityConfiguration.cs" />
<Compile Include="Config\SecurityElement.cs" />
<Compile Include="ConsumerOf.cs" />
<Compile Include="Convertors\ThrowingWireEcryptedStringConvertor.cs" />
@@ -101,6 +104,7 @@
<Compile Include="Impl\DefaultHandler.cs" />
<Compile Include="Impl\EndpointRouter.cs" />
<Compile Include="Endpoint.cs" />
+ <Compile Include="Config\IBusContainerBuilder.cs" />
<Compile Include="Internal\IEndpointRouter.cs" />
<Compile Include="Internal\IHandler.cs" />
<Compile Include="Internal\IServiceLocator.cs" />
@@ -188,7 +192,6 @@
<Compile Include="Actions\CreateReadyForWorkQueuesAction.cs" />
<Compile Include="Actions\IDeploymentAction.cs" />
<Compile Include="Actions\IEnvironmentValidationAction.cs" />
- <Compile Include="Config\LoadBalancerConfigurationReader.cs" />
<Compile Include="Config\MsmqTransportConfigurationAware.cs" />
<Compile Include="Config\RhinoQueuesConfigurationAware.cs" />
<Compile Include="Consumer.cs" />
View
BIN  SharedLibs/StructureMap.dll
Binary file not shown
View
3,874 SharedLibs/StructureMap.xml
3,874 additions, 0 deletions not shown
Please sign in to comment.
Something went wrong with that request. Please try again.