Exemple #1
0
        IBus CreateBus(string serviceName, WindsorContainerAdapter containerAdapter)
        {
            DropCollection(SubscriptionsCollectionName);

            var inputQueueName = GetEndpoint(serviceName);

            var queue = messageQueueFactory.GetQueue(inputQueueName);

            var sagaPersister = new MongoDbSagaPersister(ConnectionString)
                .SetCollectionName<CheckCreditSagaData>(CreditSagasCollectionName)
                .SetCollectionName<CheckSomeLegalStuffSagaData>(LegalSagasCollectionName)
                .SetCollectionName<CustomerInformationSagaData>(CustomerInformationSagasCollectionName);

            var bus = new RebusBus(containerAdapter, queue.Item1, queue.Item2,
                                   new MongoDbSubscriptionStorage(ConnectionString, SubscriptionsCollectionName),
                                   sagaPersister, this,
                                   new JsonMessageSerializer(), new TrivialPipelineInspector(),
                                   new ErrorTracker("error"),
                                   null,
                                   new ConfigureAdditionalBehavior());

            stuffToDispose.Add(bus);

            containerAdapter.Container.Register(Component.For<IBus>().Instance(bus));

            return bus.Start(3);
        }
Exemple #2
0
 static void ConfigureNCommon()
 {
     var adapter = new WindsorContainerAdapter(_container);
     NCommon.Configure.Using(adapter)
         .ConfigureState<DefaultStateConfiguration>()
         .ConfigureData<NHConfiguration>(config => config.WithSessionFactory(() => _sessionFactory))
         .ConfigureUnitOfWork<DefaultUnitOfWorkConfiguration>(config => config.AutoCompleteScope());
 }
Exemple #3
0
        static void ConfigureNCommon()
        {
            var adapter = new WindsorContainerAdapter(_container);

            NCommon.Configure.Using(adapter)
            .ConfigureState <DefaultStateConfiguration>()
            .ConfigureData <NHConfiguration>(config => config.WithSessionFactory(() => _sessionFactory))
            .ConfigureUnitOfWork <DefaultUnitOfWorkConfiguration>(config => config.AutoCompleteScope());
        }
Exemple #4
0
        /// <summary>
        /// Configure the container with the necessary routes for your ServiceStack application.
        /// </summary>
        /// <param name="container">The built-in IoC used with ServiceStack.</param>
        public override void Configure(Container container)
        {
            WindsorContainerAdapter adapter = new WindsorContainerAdapter((IWindsorContainer)Bootstrapper.Container);
            container.Adapter = adapter;

            SetConfig(new HostConfig {
                DebugMode = true,
                WsdlServiceNamespace = Consts.Namespace,
                EnableFeatures = Feature.Metadata | Feature.Json | Feature.Xml | Feature.Jsv | Feature.Html
            });
        }
Exemple #5
0
        /// <summary>
        /// Configure the container with the necessary routes for your ServiceStack application.
        /// </summary>
        /// <param name="container">The built-in IoC used with ServiceStack.</param>
        public override void Configure(Container container)
        {
            WindsorContainerAdapter adapter = new WindsorContainerAdapter((IWindsorContainer)Bootstrapper.Container);

            container.Adapter = adapter;

            SetConfig(new HostConfig {
                DebugMode            = true,
                WsdlServiceNamespace = Consts.Namespace,
                EnableFeatures       = Feature.Metadata | Feature.Json | Feature.Xml | Feature.Jsv | Feature.Html
            });
        }
        public void AddAdapterToFactory()
        {
            IContainerAdapterAccessor adapterAccessor = new ContainerAdapterAccessor();
            string newAdapterKey = Guid.NewGuid().ToString();

            IContainerAdapter adapter = adapterAccessor.GetAdapter(newAdapterKey);
            Assert.IsNull(adapter);
            IWindsorContainer container = new WindsorContainer();
            IContainerAdapter addedAdapter = new WindsorContainerAdapter(container);
            adapterAccessor.AddAdapter(newAdapterKey, addedAdapter);

            IContainerAdapterAccessor newAdapterAccessor = new ContainerAdapterAccessor();
            IContainerAdapter newAdapter = newAdapterAccessor.GetAdapter(newAdapterKey);
            Assert.IsNotNull(newAdapter);
            Assert.AreEqual(addedAdapter, newAdapter);
        }
Exemple #7
0
        public void ExtendedRegistration()
        {
            IWindsorContainer container = new WindsorContainer();
            IContainerAdapter adapter   = new WindsorContainerAdapter(Guid.NewGuid().ToString(), container);

            /*var registration = new ComponentRegistration();
             * registration.Register<IDependantClass, ISuperDependantClass>().As<DependantClass>();*/

            var registration = adapter.CreateComponentRegistration <ComponentRegistration>()
                               .Register <IDependantClass, ISuperDependantClass>()
                               .As <DependantClass>();

            adapter.Register(registration);
            Assert.AreEqual(adapter.Resolve <IDependantClass>().GetType(), adapter.Resolve <ISuperDependantClass>().GetType());
            Assert.AreEqual(typeof(DependantClass), adapter.Resolve <ISuperDependantClass>().GetType());
            Assert.AreEqual(typeof(DependantClass), adapter.Resolve <IDependantClass>().GetType());
        }
        public void AddAdapterToFactory()
        {
            IContainerAdapterAccessor adapterAccessor = new ContainerAdapterAccessor();
            string newAdapterKey = Guid.NewGuid().ToString();

            IContainerAdapter adapter = adapterAccessor.GetAdapter(newAdapterKey);

            Assert.IsNull(adapter);
            IWindsorContainer container    = new WindsorContainer();
            IContainerAdapter addedAdapter = new WindsorContainerAdapter(container);

            adapterAccessor.AddAdapter(newAdapterKey, addedAdapter);

            IContainerAdapterAccessor newAdapterAccessor = new ContainerAdapterAccessor();
            IContainerAdapter         newAdapter         = newAdapterAccessor.GetAdapter(newAdapterKey);

            Assert.IsNotNull(newAdapter);
            Assert.AreEqual(addedAdapter, newAdapter);
        }
Exemple #9
0
        public void HandlersAreReleasesCorrectly()
        {
            var c = new WindsorContainer();

            c.Register(Component.For <IHandleMessages <Message> >().ImplementedBy <Handler>().LifeStyle.Transient);

            var activator         = new WindsorContainerAdapter(c);
            var pipelineInspector = new RearrangeHandlersPipelineInspector();
            var dispatcher        = new Dispatcher(new InMemorySagaPersister(),
                                                   activator,
                                                   new InMemorySubscriptionStorage(),
                                                   pipelineInspector,
                                                   new DeferredMessageHandlerForTesting());


            var message = new Message();

            dispatcher.Dispatch(message);
            message.MyHandlerWasDisposed.ShouldBe(true);
        }