예제 #1
0
        /// <summary>
        /// Executes the installer.
        /// </summary>
        /// <param name="identity">The user for whom permissions will be given.</param>
        public void Install(string identity)
        {
            if (RunInstaller)
            {
                var configSection = Configure.GetConfigSection <TimeoutPersisterConfig>();

                if (configSection != null)
                {
                    if (configSection.NHibernateProperties.Count == 0)
                    {
                        throw new InvalidOperationException(
                                  "No NHibernate properties found. Please specify NHibernateProperties in your TimeoutPersisterConfig section");
                    }

                    foreach (var property in configSection.NHibernateProperties.ToProperties())
                    {
                        ConfigureNHibernate.TimeoutPersisterProperties[property.Key] = property.Value;
                    }
                }

                ConfigureNHibernate.ThrowIfRequiredPropertiesAreMissing(ConfigureNHibernate.TimeoutPersisterProperties);

                var configuration = ConfigureNHibernate.CreateConfigurationWith(ConfigureNHibernate.TimeoutPersisterProperties);
                ConfigureNHibernate.AddMappings <TimeoutEntityMap>(configuration);
                new SchemaUpdate(configuration).Execute(false, true);
            }
        }
        /// <summary>
        /// Called when the feature should perform its initialization. This call will only happen if the feature is enabled.
        /// </summary>
        protected override void Setup(FeatureConfigurationContext context)
        {
            var properties = new ConfigureNHibernate(context.Settings).GatewayDeduplicationProperties;

            ConfigureNHibernate.ThrowIfRequiredPropertiesAreMissing(properties);

            var configuration = context.Settings.GetOrDefault <Configuration>("NHibernate.GatewayDeduplication.Configuration") ?? context.Settings.GetOrDefault <Configuration>("StorageConfiguration");

            if (configuration == null)
            {
                configuration = new Configuration()
                                .SetProperties(properties);
            }

            ConfigureNHibernate.AddMappings <DeduplicationMessageMap>(configuration);

            Deduplication.NHibernate.Installer.Installer.configuration = configuration;

            if (context.Settings.HasSetting("NHibernate.GatewayDeduplication.AutoUpdateSchema"))
            {
                Deduplication.NHibernate.Installer.Installer.RunInstaller = context.Settings.Get <bool>("NHibernate.GatewayDeduplication.AutoUpdateSchema");
            }
            else
            {
                Deduplication.NHibernate.Installer.Installer.RunInstaller = context.Settings.Get <bool>("NHibernate.Common.AutoUpdateSchema");
            }

            context.Container.ConfigureComponent <Deduplication.NHibernate.GatewayDeduplication>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(p => p.SessionFactory, configuration.BuildSessionFactory());
        }
        /// <summary>
        /// Called when the feature should perform its initialization. This call will only happen if the feature is enabled.
        /// </summary>
        protected override void Setup(FeatureConfigurationContext context)
        {
            var configuration = context.Settings.GetOrDefault <Configuration>("NHibernate.Subscriptions.Configuration") ?? context.Settings.GetOrDefault <Configuration>("StorageConfiguration");

            if (configuration == null)
            {
                var properties = new ConfigureNHibernate(context.Settings).SubscriptionStorageProperties;
                configuration = new Configuration().SetProperties(properties);
            }
            ConfigureNHibernate.ThrowIfRequiredPropertiesAreMissing(configuration.Properties);

            ConfigureNHibernate.AddMappings <SubscriptionMap>(configuration);

            context.Container.ConfigureComponent <Unicast.Subscriptions.NHibernate.Installer.Installer>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(x => x.Configuration, configuration)
            .ConfigureProperty(x => x.RunInstaller, RunInstaller(context));

            var sessionSource = new SubscriptionStorageSessionProvider(configuration.BuildSessionFactory());

            context.Container.RegisterSingleton(sessionSource);

            if (context.Settings.HasSetting("NHibernate.Subscriptions.CacheExpiration"))
            {
                context.Container.RegisterSingleton <ISubscriptionStorage>(new CachedSubscriptionPersister(sessionSource, context.Settings.Get <TimeSpan>("NHibernate.Subscriptions.CacheExpiration")));
            }
            else
            {
                context.Container.ConfigureComponent <SubscriptionPersister>(DependencyLifecycle.InstancePerCall);
            }
        }
예제 #4
0
        /// <summary>
        /// Executes the installer.
        /// </summary>
        /// <param name="identity">The user for whom permissions will be given.</param>
        public void Install(string identity)
        {
            if (RunInstaller)
            {
                ConfigureNHibernate.ThrowIfRequiredPropertiesAreMissing(ConfigureNHibernate.GatewayPersisterProperties);

                var configuration = ConfigureNHibernate.CreateConfigurationWith(ConfigureNHibernate.GatewayPersisterProperties);
                ConfigureNHibernate.AddMappings <GatewayMessageMap>(configuration);
                new SchemaUpdate(configuration).Execute(false, true);
            }
        }
예제 #5
0
        static Configure UseNHibernateTimeoutPersisterInternal(this Configure config, Configuration configuration, bool autoUpdateSchema)
        {
            ConfigureNHibernate.ThrowIfRequiredPropertiesAreMissing(ConfigureNHibernate.TimeoutPersisterProperties);

            TimeoutPersisters.NHibernate.Installer.Installer.RunInstaller = autoUpdateSchema;
            ConfigureNHibernate.AddMappings <TimeoutEntityMap>(configuration);

            config.Configurer.ConfigureComponent <TimeoutStorage>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(p => p.SessionFactory, configuration.BuildSessionFactory());

            return(config);
        }
        private static Configure UseNHibernateGatewayPersisterInternal(this Configure config, Configuration configuration)
        {
            ConfigureNHibernate.ThrowIfRequiredPropertiesAreMissing(configuration.Properties);

            GatewayPersister.NHibernate.Installer.Installer.RunInstaller = true;

            ConfigureNHibernate.AddMappings <GatewayMessageMap>(configuration);

            config.Configurer.ConfigureComponent <GatewayPersister.NHibernate.GatewayPersister>(
                DependencyLifecycle.SingleInstance)
            .ConfigureProperty(p => p.SessionFactory, configuration.BuildSessionFactory());

            return(config.RunGateway());
        }
        static Configure UseNHibernateSubscriptionPersisterInternal(this Configure config, Configuration configuration, bool autoUpdateSchema)
        {
            ConfigureNHibernate.ThrowIfRequiredPropertiesAreMissing(ConfigureNHibernate.SubscriptionStorageProperties);

            Unicast.Subscriptions.NHibernate.Installer.Installer.RunInstaller = autoUpdateSchema;

            ConfigureNHibernate.AddMappings <SubscriptionMap>(configuration);

            var sessionSource = new SubscriptionStorageSessionProvider(configuration.BuildSessionFactory());

            config.Configurer.RegisterSingleton <ISubscriptionStorageSessionProvider>(sessionSource);
            config.Configurer.ConfigureComponent <SubscriptionStorage>(DependencyLifecycle.InstancePerCall);

            return(config);
        }
        /// <summary>
        /// Called when the feature should perform its initialization. This call will only happen if the feature is enabled.
        /// </summary>
        protected override void Setup(FeatureConfigurationContext context)
        {
            var properties = new ConfigureNHibernate(context.Settings)
                             .TimeoutPersisterProperties;

            ConfigureNHibernate.ThrowIfRequiredPropertiesAreMissing(properties);

            var configuration = context.Settings.GetOrDefault <Configuration>("NHibernate.Timeouts.Configuration") ?? context.Settings.GetOrDefault <Configuration>("StorageConfiguration");

            if (configuration == null)
            {
                configuration = new Configuration()
                                .SetProperties(properties);
            }

            ConfigureNHibernate.AddMappings <TimeoutEntityMap>(configuration);

            TimeoutPersisters.NHibernate.Installer.Installer.configuration = configuration;

            if (context.Settings.HasSetting("NHibernate.Timeouts.AutoUpdateSchema"))
            {
                TimeoutPersisters.NHibernate.Installer.Installer.RunInstaller = context.Settings.Get <bool>("NHibernate.Timeouts.AutoUpdateSchema");
            }
            else
            {
                TimeoutPersisters.NHibernate.Installer.Installer.RunInstaller = context.Settings.Get <bool>("NHibernate.Common.AutoUpdateSchema");
            }

            string connString;

            if (!configuration.Properties.TryGetValue(Environment.ConnectionString, out connString))
            {
                string connStringName;

                if (configuration.Properties.TryGetValue(Environment.ConnectionStringName, out connStringName))
                {
                    var connectionStringSettings = System.Configuration.ConfigurationManager.ConnectionStrings[connStringName];

                    connString = connectionStringSettings.ConnectionString;
                }
            }

            context.Container.ConfigureComponent <TimeoutPersister>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(p => p.ConnectionString, connString)
            .ConfigureProperty(p => p.SessionFactory, configuration.BuildSessionFactory())
            .ConfigureProperty(p => p.EndpointName, context.Settings.EndpointName());
        }
        /// <summary>
        /// Called when the feature should perform its initialization. This call will only happen if the feature is enabled.
        /// </summary>
        protected override void Setup(FeatureConfigurationContext context)
        {
            var configuration = context.Settings.GetOrDefault <Configuration>("NHibernate.GatewayDeduplication.Configuration") ?? context.Settings.GetOrDefault <Configuration>("StorageConfiguration");

            if (configuration == null)
            {
                var properties = new ConfigureNHibernate(context.Settings).GatewayDeduplicationProperties;
                configuration = new Configuration().SetProperties(properties);
            }
            ConfigureNHibernate.ThrowIfRequiredPropertiesAreMissing(configuration.Properties);

            ConfigureNHibernate.AddMappings <DeduplicationMessageMap>(configuration);

            context.Container.ConfigureComponent <Deduplication.NHibernate.Installer.Installer>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(x => x.Configuration, configuration)
            .ConfigureProperty(x => x.RunInstaller, RunInstaller(context));

            context.Container.ConfigureComponent <Deduplication.NHibernate.GatewayDeduplication>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(p => p.SessionFactory, configuration.BuildSessionFactory());
        }
예제 #10
0
        /// <summary>
        /// Called when the feature should perform its initialization. This call will only happen if the feature is enabled.
        /// </summary>
        protected override void Setup(FeatureConfigurationContext context)
        {
            var configuration = context.Settings.GetOrDefault <Configuration>("NHibernate.Timeouts.Configuration") ?? context.Settings.GetOrDefault <Configuration>("StorageConfiguration");

            if (configuration == null)
            {
                var properties = new ConfigureNHibernate(context.Settings).TimeoutPersisterProperties;
                configuration = new Configuration().SetProperties(properties);
            }
            ConfigureNHibernate.ThrowIfRequiredPropertiesAreMissing(configuration.Properties);

            ConfigureNHibernate.AddMappings <TimeoutEntityMap>(configuration);

            context.Container.ConfigureComponent <TimeoutPersisters.NHibernate.Installer.Installer>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(x => x.Configuration, configuration)
            .ConfigureProperty(x => x.RunInstaller, RunInstaller(context));


            string connString;

            if (!configuration.Properties.TryGetValue(Environment.ConnectionString, out connString))
            {
                string connStringName;

                if (configuration.Properties.TryGetValue(Environment.ConnectionStringName, out connStringName))
                {
                    var connectionStringSettings = System.Configuration.ConfigurationManager.ConnectionStrings[connStringName];

                    connString = connectionStringSettings.ConnectionString;
                }
            }

            var timeoutsCleanupExecutionInterval =
                context.Settings.GetOrDefault <TimeSpan?>("NHibernate.Timeouts.CleanupExecutionInterval") ?? TimeSpan.FromMinutes(2);

            context.Container.ConfigureComponent <TimeoutPersister>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(p => p.ConnectionString, connString)
            .ConfigureProperty(p => p.SessionFactory, configuration.BuildSessionFactory())
            .ConfigureProperty(p => p.EndpointName, context.Settings.EndpointName())
            .ConfigureProperty(p => p.TimeoutsCleanupExecutionInterval, timeoutsCleanupExecutionInterval);
        }