예제 #1
0
        public static void RegisterPurgeQueues(this IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            registry.AttemptRegister <PurgeQueuesModule>();
            registry.AttemptRegister <PurgeQueuesObserver>();
        }
        public static void RegisterSqlQueue(this IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, "registry");

            registry.AttemptRegister <IScriptProviderConfiguration, ScriptProviderConfiguration>();
            registry.AttemptRegister <IScriptProvider, ScriptProvider>();
        }
예제 #3
0
        public void Register(IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            registry.AttemptRegister <IDocumentQueryFactory, DocumentQueryFactory>();
            registry.AttemptRegister <IDocumentRepository, DocumentRepository>();
            registry.AttemptRegister <IDocumentQuery, DocumentQuery>();
        }
        public void Register(IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, "registry");

            registry.AttemptRegister <IScriptProviderConfiguration, ScriptProviderConfiguration>();
            registry.AttemptRegister <IScriptProvider, ScriptProvider>();

            registry.AttemptRegister <ISubscriptionConfiguration>(SubscriptionSection.Configuration());
            registry.AttemptRegister <ISubscriptionManager, SubscriptionManager>();
        }
예제 #5
0
        public void Register(IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            if (!registry.IsRegistered <IOpswatConfiguration>())
            {
                registry.RegisterInstance(OpswatSection.Configuration());
            }

            registry.AttemptRegister <IOpswatApi, OpswatApi>();
            registry.AttemptRegister <IMalwareService, OpswatMalwareService>();
        }
예제 #6
0
        public static void RegisterMessageForwarding(this IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            if (!registry.IsRegistered <IMessageForwardingConfiguration>())
            {
                registry.AttemptRegisterInstance(MessageForwardingSection.Configuration());
            }

            registry.AttemptRegister <MessageForwardingModule>();
            registry.AttemptRegister <MessageForwardingObserver>();
        }
        public static void RegisterIdempotence(this IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, "registry");

            registry.AttemptRegister <IScriptProviderConfiguration, ScriptProviderConfiguration>();
            registry.AttemptRegister <IScriptProvider, ScriptProvider>();

            if (!registry.IsRegistered <IIdempotenceConfiguration>())
            {
                registry.RegisterInstance <IIdempotenceConfiguration>(IdempotenceSection.Configuration());
            }

            registry.AttemptRegister <IIdempotenceService, IdempotenceService>();
        }
예제 #8
0
        public static void RegisterActiveTimeRange(this IComponentRegistry registry)
        {
            if (!registry.IsRegistered <IActiveTimeRangeConfiguration>())
            {
                registry.AttemptRegisterInstance(ActiveTimeRangeSection.Configuration());
            }

            registry.AttemptRegister <ActiveTimeRangeModule>();
        }
예제 #9
0
        public void Register(IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            if (_registryBootstrapCalled)
            {
                return;
            }

            _registryBootstrapCalled = true;

            if (!registry.IsRegistered <ISentinelConfiguration>())
            {
                registry.AttemptRegisterInstance(SentinelSection.Configuration());
            }

            registry.AttemptRegister <ISentinelObserver, SentinelObserver>();
            registry.AttemptRegister <IEndpointAggregator, EndpointAggregator>();
            registry.AttemptRegister <SentinelModule>();
        }
        public static void RegisterCorruptTransportMessage(this IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            if (!registry.IsRegistered <ICorruptTransportMessageConfiguration>())
            {
                registry.AttemptRegisterInstance(CorruptTransportMessageSection.Configuration());
            }

            registry.AttemptRegister <CorruptTransportMessageModule>();
        }
예제 #11
0
        public void Register(IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            if (_registryBootstrapCalled)
            {
                return;
            }

            registry.AttemptRegister <ISerializer, JsonSerializer>();

            _registryBootstrapCalled = true;
        }
예제 #12
0
        public void Register(IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            lock (Lock)
            {
                if (_initialized)
                {
                    return;
                }

                registry.RegisterCollection(typeof(IOAuthProvider), new ReflectionService().GetTypesAssignableTo <IOAuthProvider>(), Lifestyle.Singleton);
                registry.AttemptRegister <IOAuthProviderCollection, OAuthProviderCollection>();

                _initialized = true;
            }
        }
예제 #13
0
        protected void Boostrap(IComponentRegistry registry)
        {
            registry.RegisterInstance <ITransactionScopeFactory>(new DefaultTransactionScopeFactory(false, IsolationLevel.Unspecified, TimeSpan.Zero));

#if (NETCOREAPP2_1 || NETSTANDARD2_0)
            DbProviderFactories.RegisterFactory("System.Data.SqlClient", System.Data.SqlClient.SqlClientFactory.Instance);

            var connectionConfigurationProvider = new Mock <IConnectionConfigurationProvider>();

            connectionConfigurationProvider.Setup(m => m.Get(It.IsAny <string>())).Returns(
                (string name) =>
                name.Equals("EventStoreProjection")
                        ? new ConnectionConfiguration(
                    "EventStoreProjection",
                    "System.Data.SqlClient",
                    "Data Source=.\\sqlexpress;Initial Catalog=ShuttleProjection;Integrated Security=SSPI;")
                        : new ConnectionConfiguration(
                    name,
                    "System.Data.SqlClient",
                    "Data Source=.\\sqlexpress;Initial Catalog=Shuttle;Integrated Security=SSPI;"));

            registry.AttemptRegisterInstance(connectionConfigurationProvider.Object);

            registry.RegisterInstance <IProjectionConfiguration>(new ProjectionConfiguration
            {
                EventProjectionConnectionString =
                    connectionConfigurationProvider.Object.Get("EventStoreProjection").ConnectionString,
                EventProjectionProviderName =
                    connectionConfigurationProvider.Object.Get("EventStoreProjection").ProviderName,
                EventStoreConnectionString = connectionConfigurationProvider.Object.Get("Shuttle").ConnectionString,
                EventStoreProviderName     = connectionConfigurationProvider.Object.Get("Shuttle").ProviderName
            });
#else
            registry.AttemptRegister <IConnectionConfigurationProvider, ConnectionConfigurationProvider>();
#endif
        }
예제 #14
0
        public void Register(IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, "registry");

            registry.AttemptRegister <IProjectionConfiguration>(ProjectionSection.Configuration());

            registry.AttemptRegister <IScriptProviderConfiguration, ScriptProviderConfiguration>();
            registry.AttemptRegister <IScriptProvider, ScriptProvider>();

            registry.AttemptRegister <IDatabaseContextCache, ThreadStaticDatabaseContextCache>();
            registry.AttemptRegister <IDatabaseContextFactory, DatabaseContextFactory>();
            registry.AttemptRegister <IDbConnectionFactory, DbConnectionFactory>();
            registry.AttemptRegister <IDbCommandFactory, DbCommandFactory>();
            registry.AttemptRegister <IDatabaseGateway, DatabaseGateway>();
            registry.AttemptRegister <IQueryMapper, QueryMapper>();
            registry.AttemptRegister <IProjectionRepository, ProjectionRepository>();
            registry.AttemptRegister <IProjectionQueryFactory, ProjectionQueryFactory>();
            registry.AttemptRegister <IPrimitiveEventRepository, PrimitiveEventRepository>();
            registry.AttemptRegister <IPrimitiveEventQueryFactory, PrimitiveEventQueryFactory>();
            registry.AttemptRegister <IKeyStoreQueryFactory, KeyStoreQueryFactory>();
            registry.AttemptRegister <IKeyStore, KeyStore>();

            registry.AttemptRegister <EventProcessingObserver, EventProcessingObserver>();
            registry.AttemptRegister <EventProcessingModule, EventProcessingModule>();
        }
예제 #15
0
        public static void Register(IComponentRegistry registry, IEventStoreConfiguration configuration)
        {
            Guard.AgainstNull(registry, nameof(registry));
            Guard.AgainstNull(configuration, nameof(configuration));

            registry.AttemptRegisterInstance(configuration);

            registry.RegistryBoostrap();

            registry.AttemptRegister <IEventMethodInvokerConfiguration, EventMethodInvokerConfiguration>();
            registry.AttemptRegister <IEventMethodInvoker, DefaultEventMethodInvoker>();
            registry.AttemptRegister <ISerializer, DefaultSerializer>();
            registry.AttemptRegister <IConcurrenyExceptionSpecification, DefaultConcurrenyExceptionSpecification>();

            registry.AttemptRegister <IProjectionEventProvider, ProjectionEventProvider>();
            registry.AttemptRegister <IProjectionProvider, ProjectionProvider>();

            registry.AttemptRegister <ITransactionScopeObserver, TransactionScopeObserver>();

            if (!registry.IsRegistered <ITransactionScopeFactory>())
            {
                var transactionScopeConfiguration =
                    configuration.TransactionScope ?? new TransactionScopeConfiguration();

                registry.AttemptRegisterInstance <ITransactionScopeFactory>(
                    new DefaultTransactionScopeFactory(transactionScopeConfiguration.Enabled,
                                                       transactionScopeConfiguration.IsolationLevel,
                                                       TimeSpan.FromSeconds(transactionScopeConfiguration.TimeoutSeconds)));
            }

            registry.AttemptRegister <IPipelineFactory, DefaultPipelineFactory>();

            var reflectionService = new ReflectionService();

            foreach (var type in reflectionService.GetTypesAssignableTo <IPipeline>(typeof(EventStore).Assembly))
            {
                if (type.IsInterface || type.IsAbstract || registry.IsRegistered(type))
                {
                    continue;
                }

                registry.Register(type, type, Lifestyle.Transient);
            }

            foreach (var type in reflectionService.GetTypesAssignableTo <IPipelineObserver>(typeof(EventStore).Assembly))
            {
                if (type.IsInterface || type.IsAbstract)
                {
                    continue;
                }

                var interfaceType = type.InterfaceMatching($"I{type.Name}");

                if (interfaceType != null)
                {
                    if (registry.IsRegistered(type))
                    {
                        continue;
                    }

                    registry.Register(interfaceType, type, Lifestyle.Singleton);
                }
                else
                {
                    throw new ApplicationException(string.Format(Resources.ObserverInterfaceMissingException, type.Name));
                }
            }

            registry.AttemptRegister <IEventStore, EventStore>();
            registry.AttemptRegister <IEventProcessor, EventProcessor>();
        }
예제 #16
0
        public void Register(IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            registry.AttemptRegister <IMediator, Mediator>();
        }
예제 #17
0
        public static void RegisterEventProcessing(this IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            if (!registry.IsRegistered <IProjectionConfiguration>())
            {
                registry.AttemptRegisterInstance <IProjectionConfiguration>(ProjectionSection.Configuration(new ConnectionConfigurationProvider()));
            }

            registry.AttemptRegister <IScriptProviderConfiguration, ScriptProviderConfiguration>();
            registry.AttemptRegister <IScriptProvider, ScriptProvider>();

            registry.AttemptRegister <IDatabaseContextCache, ThreadStaticDatabaseContextCache>();
            registry.AttemptRegister <IDatabaseContextFactory, DatabaseContextFactory>();
            registry.AttemptRegister <IDbConnectionFactory, DbConnectionFactory>();
            registry.AttemptRegister <IDbCommandFactory, DbCommandFactory>();
            registry.AttemptRegister <IDatabaseGateway, DatabaseGateway>();
            registry.AttemptRegister <IQueryMapper, QueryMapper>();
            registry.AttemptRegister <IProjectionRepository, ProjectionRepository>();
            registry.AttemptRegister <IProjectionQueryFactory, ProjectionQueryFactory>();

            registry.AttemptRegister <EventProcessingObserver, EventProcessingObserver>();
            registry.AttemptRegister <EventProcessingModule, EventProcessingModule>();
        }
예제 #18
0
        public void Register(IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            registry.AttemptRegister <IRabbitMQConfiguration, RabbitMQConfiguration>();
        }
예제 #19
0
        public static void Register(IComponentRegistry registry, IServiceBusConfiguration configuration)
        {
            Guard.AgainstNull(registry, nameof(registry));
            Guard.AgainstNull(configuration, nameof(configuration));

            registry.RegistryBoostrap();

            registry.AttemptRegister(configuration);

            registry.AttemptRegister <IServiceBusEvents, ServiceBusEvents>();
            registry.AttemptRegister <ISerializer, DefaultSerializer>();
            registry.AttemptRegister <IServiceBusPolicy, DefaultServiceBusPolicy>();
            registry.AttemptRegister <IMessageRouteProvider, DefaultMessageRouteProvider>();
            registry.AttemptRegister <IIdentityProvider, DefaultIdentityProvider>();
            registry.AttemptRegister <IMessageHandlerInvoker, DefaultMessageHandlerInvoker>();
            registry.AttemptRegister <IMessageHandlingAssessor, DefaultMessageHandlingAssessor>();
            registry.AttemptRegister <IUriResolver, DefaultUriResolver>();
            registry.AttemptRegister <IQueueManager, QueueManager>();
            registry.AttemptRegister <IWorkerAvailabilityManager, WorkerAvailabilityManager>();
            registry.AttemptRegister <ISubscriptionManager, NullSubscriptionManager>();
            registry.AttemptRegister <IIdempotenceService, NullIdempotenceService>();

            registry.AttemptRegister <ITransactionScopeObserver, TransactionScopeObserver>();

            if (!registry.IsRegistered <ITransactionScopeFactory>())
            {
                var transactionScopeConfiguration = configuration.TransactionScope ??
                                                    new TransactionScopeConfiguration();

                registry.AttemptRegister <ITransactionScopeFactory>(
                    new DefaultTransactionScopeFactory(transactionScopeConfiguration.Enabled,
                                                       transactionScopeConfiguration.IsolationLevel,
                                                       TimeSpan.FromSeconds(transactionScopeConfiguration.TimeoutSeconds)));
            }

            registry.AttemptRegister <IPipelineFactory, DefaultPipelineFactory>();
            registry.AttemptRegister <ITransportMessageFactory, DefaultTransportMessageFactory>();

            var reflectionService = new ReflectionService();

            foreach (var type in reflectionService.GetTypes <IPipeline>(typeof(ServiceBus).Assembly))
            {
                if (type.IsInterface || type.IsAbstract || registry.IsRegistered(type))
                {
                    continue;
                }

                registry.Register(type, type, Lifestyle.Transient);
            }

            var observers = new List <Type>();

            foreach (var type in reflectionService.GetTypes <IPipelineObserver>(typeof(ServiceBus).Assembly))
            {
                if (type.IsInterface || type.IsAbstract)
                {
                    continue;
                }

                var interfaceType = type.InterfaceMatching($"I{type.Name}");

                if (interfaceType != null)
                {
                    if (registry.IsRegistered(type))
                    {
                        continue;
                    }

                    registry.Register(interfaceType, type, Lifestyle.Singleton);
                }
                else
                {
                    throw new EsbConfigurationException(string.Format(Resources.ObserverInterfaceMissingException, type.Name));
                }

                observers.Add(type);
            }

            registry.RegisterCollection(typeof(IPipelineObserver), observers, Lifestyle.Singleton);

            if (configuration.RegisterHandlers)
            {
                foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    foreach (var type in reflectionService.GetTypes(MessageHandlerType, assembly))
                    {
                        foreach (var @interface in type.GetInterfaces())
                        {
                            if ([email protected](MessageHandlerType))
                            {
                                continue;
                            }

                            var genericType = MessageHandlerType.MakeGenericType(@interface.GetGenericArguments()[0]);

                            if (!registry.IsRegistered(genericType))
                            {
                                registry.Register(genericType, type, Lifestyle.Transient);
                            }
                        }
                    }
                }
            }

            var queueFactoryType = typeof(IQueueFactory);
            var queueFactoryImplementationTypes = new List <Type>();

            void AddQueueFactoryImplementationType(Type type)
            {
                if (queueFactoryImplementationTypes.Contains(type))
                {
                    return;
                }

                queueFactoryImplementationTypes.Add(type);
            }

            if (configuration.ScanForQueueFactories)
            {
                foreach (var type in new ReflectionService().GetTypes <IQueueFactory>())
                {
                    AddQueueFactoryImplementationType(type);
                }
            }

            foreach (var type in configuration.QueueFactoryTypes)
            {
                AddQueueFactoryImplementationType(type);
            }

            registry.RegisterCollection(queueFactoryType, queueFactoryImplementationTypes, Lifestyle.Singleton);

            registry.AttemptRegister <IServiceBus, ServiceBus>();
        }
        public void Register(IComponentRegistry registry)
        {
            Guard.AgainstNull(registry, nameof(registry));

            registry.AttemptRegister <IScriptProviderConfiguration, ScriptProviderConfiguration>();
            registry.AttemptRegister <IScriptProvider, ScriptProvider>();

            registry.AttemptRegister <IDatabaseContextCache, ThreadStaticDatabaseContextCache>();
            registry.AttemptRegister <IDatabaseContextFactory, DatabaseContextFactory>();
            registry.AttemptRegister <IDbConnectionFactory, DbConnectionFactory>();
            registry.AttemptRegister <IDbCommandFactory, DbCommandFactory>();
            registry.AttemptRegister <IDatabaseGateway, DatabaseGateway>();
            registry.AttemptRegister <IQueryMapper, QueryMapper>();
            registry.AttemptRegister <IPrimitiveEventRepository, PrimitiveEventRepository>();
            registry.AttemptRegister <IPrimitiveEventQueryFactory, PrimitiveEventQueryFactory>();
            registry.AttemptRegister <IKeyStoreQueryFactory, KeyStoreQueryFactory>();
            registry.AttemptRegister <IKeyStore, KeyStore>();
        }