Пример #1
0
        public ServicesManager(
            INutConfiguration configurationManager,
            Infrastructure.ConfigurationManagement.DbConfigurationSettings.Factory dbConfigurationSettingsFactory,
            IEventBus eventBus,
            IEnumerable<IReportPeriodically> pushServices,
            IEnumerable<IRemoteInvocationService> remoteInvokedServices,
            Services.IGlobalSettingsService globalSettings,
            Func<RegisteredPackagesPollingClient> packagesPollerFactory,
            Func<PollingClientCollection> pollingCollectionFactory,
            Repositories.IPackageRepository packageRepository,
            IHoardeManager hoardeManager)
        {
            _log = LogProvider.For<ServicesManager>();

            _configurationManager = configurationManager;
            _dbConfigurationSettingsFactory = dbConfigurationSettingsFactory;
            _eventBus = eventBus;
            _pushServices = pushServices;
            _remoteInvokedServices = remoteInvokedServices;
            _globalSettings = globalSettings;

            _packagesPollerFactory = packagesPollerFactory;
            _pollingCollectionFactory = pollingCollectionFactory;

            _packageRepository = packageRepository;

            _hoardeManager = hoardeManager;
        }
Пример #2
0
        /// <summary>
        /// Configuration routine of the autofac container.
        /// </summary>
        /// <param name="eventBus">The event bus.</param>
        /// <param name="hoardeManager">The hoarde manager.</param>
        /// <param name="configurationManager">The host's configuration manager.</param>
        public static void Configure(IEventBus eventBus, ServiceModel.IHoardeManager hoardeManager, INutConfiguration configurationManager)
        {
            var builder = new ContainerBuilder();

            builder.RegisterInstance(eventBus);
            builder.RegisterInstance(hoardeManager);
            builder.RegisterInstance(configurationManager);

            builder.RegisterType<ServiceModel.ServicesManager>().AsImplementedInterfaces().SingleInstance();
            builder.RegisterType<ServiceModel.PollingClientCollection>().AsSelf().SingleInstance();
            builder.RegisterType<ServiceModel.RegisteredPackagesPollingClient>().AsSelf().SingleInstance();
            builder.RegisterType<ServiceModel.ReleasesPollingClient>();
            builder.RegisterType<ConfigurationManagement.DbConfigurationSettings>();

            // we will apply most of the configuration in one or more assembly modules.
            builder.RegisterAssemblyModules(typeof(AutofacConfig).Assembly);

            switch (configurationManager.Mode)
            {
                case ExecutionMode.Development:
                    builder.RegisterType<Repositories.OnDisk.OnDiskPackageRepository>().AsImplementedInterfaces().InstancePerLifetimeScope();
                    break;
                case ExecutionMode.Production:
                    builder.RegisterType<Repositories.SQLiteRepositories.PackageRepository>().AsImplementedInterfaces().InstancePerLifetimeScope();
                    break;
                default:
                    builder.RegisterType<Repositories.SQLiteRepositories.PackageRepository>().AsImplementedInterfaces().InstancePerLifetimeScope();
                    _log.WarnFormat("Unknown execution mode '{mode}'.  Registered Sqlite Repository.", configurationManager.Mode);
                    break;
            }

            _container = builder.Build();
        }
Пример #3
0
        public override bool Startup(INutConfiguration configurationManager)
        {
            _log.Info("Samples - App Three Online.");
            _log.Info("App Three should be immediately shutdown because it returns false.");

            base.Startup(configurationManager);

            return false;
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReleasesPollingClient" /> class.
 /// </summary>
 /// <param name="packageId">The package identifier.</param>
 /// <param name="dbConfigurationSettingsFactory">The database configuration settings factory.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="globalSettingsService">The global settings service.</param>
 /// <param name="packageService">The package service.</param>
 /// <param name="eventBus">The event bus.</param>
 public ReleasesPollingClient(string packageId,
     Infrastructure.ConfigurationManagement.DbConfigurationSettings.Factory dbConfigurationSettingsFactory,
     INutConfiguration configurationManager,
     Services.IGlobalSettingsService globalSettingsService,
     Services.IPackageService packageService,
     IEventBus eventBus)
 {
     _packageId = packageId;
     _dbConfigurationSettingsFactory = dbConfigurationSettingsFactory;
     _configurationManager = configurationManager;
     _globalSettingsService = globalSettingsService;
     _packageService = packageService;
     _eventBus = eventBus;
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DbConfigurationSettings" /> class.
        /// </summary>
        /// <param name="hostApplicationConfiguration">The host application configuration.</param>
        /// <param name="packageSettingRepository">The package setting repository.</param>
        /// <param name="connectionStringsRepository">The connection strings repository.</param>
        /// <param name="packageId">The package identifier.</param>
        public DbConfigurationSettings(INutConfiguration hostApplicationConfiguration,
            IPackageSettingRepository packageSettingRepository,
            IConnectionStringRepository connectionStringsRepository,
            string packageId)
        {
            _hostApplicationConfiguration = hostApplicationConfiguration;
            _packageId = packageId;

            _globalSettingsRepository = new Repositories.SQLiteRepositories.GlobalSettingsRepository(this);
            _applicationSettingsService = new Sponsor<IApplicationSettings>(new Services.ApplicationSettingsService(_packageId, packageSettingRepository));
            _connectionStringsService = new Sponsor<IConnectionStrings>(new Services.ConnectionStringsService(_packageId, connectionStringsRepository));

            _log.Debug("Created db configuration settings provider");
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ControlPanelServiceControl"/> class.
        /// </summary>
        /// <param name="mode">
        /// Which mode is the system running in?
        /// <list type="table">
        /// <item><term>Production</term><description>Drey will use its normal package detail information to load packages into the runtime for execution.</description></item>
        /// <item><term>Development</term><description>Drey will discover packages in the ~/Hoarde folder and load them for execution. This prevents the need to package your system for every build.</description></item>
        /// </list>
        /// </param>
        /// <param name="configureLogging">An action that gets run at the startup of every package which configures the logging provider for that package.</param>
        /// <param name="logVerbosity">How much logging should be captured?  Pass a compatible string here that works with your chosen framework, and parse it within the configureLogging method.</param>
        public ControlPanelServiceControl(ExecutionMode mode = ExecutionMode.Production, Action<INutConfiguration> configureLogging = null, string logVerbosity = "Info")
        {
            _configurationManager = new ApplicationHostNutConfiguration() { Mode = mode, LogVerbosity = logVerbosity };
            _executionMode = mode;

            if (configureLogging != null)
            {
                _configureLogging = configureLogging;
                _configureLogging.Invoke(_configurationManager);
            }

            _log = LogProvider.For<ControlPanelServiceControl>();
            _appFactory = new Sponsor<ShellFactory>(new ShellFactory());
        }
Пример #7
0
        public override bool Startup(INutConfiguration configurationManager)
        {
            _log.Info("Samples - Third Party Integrations Proof of Concept online.");
            if (!base.Startup(configurationManager)) { return false; }

            try
            {
                var bin = GetType().Assembly.GetDirectoryLocation();
                var configPath = Path.Combine(bin, "Config", "Services.config");
                _log.InfoFormat("Attempting to read Services.config from '{path}'", configPath);
                using (var fReader = new StreamReader(configPath))
                    _serviceConfiguration = fReader.ReadToEnd();
            }
            catch (Exception)
            {
                _log.Fatal("Could not load Services.config from disc.");
                return false;
            }

            var cb = new ContainerBuilder();

            cb.RegisterType<CoreWriter>()
                .As<IToImplement>();

            var ms = new MemoryStream(Encoding.UTF8.GetBytes(_serviceConfiguration));
            var reader = XmlReader.Create(ms);
            var xmlConfigModule = new XmlConfigurationSettingsReader(reader);
            cb.RegisterModule(xmlConfigModule);

            _container = cb.Build();

            IEnumerable<IToImplement> allWriters = _container.Resolve<IEnumerable<IToImplement>>();

            allWriters.ToList().ForEach(w => w.WriteMessage(_log.Info));
            return true;
        }
Пример #8
0
 public override bool Startup(INutConfiguration configurationManager)
 {
     _log.Info("Samples - App Two Online");
     return base.Startup(configurationManager);
 }
Пример #9
0
        /// <summary>
        /// The startup routine for the applet.  Think of this like `static main(string args[]) { ... }`.
        /// </summary>
        /// <param name="configurationManager">The configuration manager.</param>
        public virtual bool Startup(INutConfiguration configurationManager)
        {
            Log.InfoFormat("{packageName} is starting in {mode}.", this.Id, configurationManager.Mode);
            ConfigurationManager = configurationManager;
            if (ConfigureLogging != null)
            {
                ConfigureLogging(configurationManager);
            }

            _Log.Info("Registering default app settings.");
            AppSettingDefaults.Apply((DefaultAppSetting setting) =>
            {
                if (!configurationManager.ApplicationSettings.Exists(setting.Key)) { configurationManager.ApplicationSettings.Register(setting.Key, setting.Value); }
            });

            _Log.Info("Registering default connection string(s).");
            ConnectionStringDefaults.Apply((DefaultConnectionString connStr) =>
            {
                if (!configurationManager.ConnectionStrings.Exists(connStr.Name)) { configurationManager.ConnectionStrings.Register(connStr.Name, connStr.ConnectionString, connStr.ProviderName); }
            });

            _Log.Info("Setting up Server Certificate Validation.");
            ConfigurationManager.CertificateValidator.Initialize();

            return true;
        }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GlobalSettingsRepository"/> class.
 /// <remarks>Used by IoC container.</remarks>
 /// </summary>
 /// <param name="configurationManager">The configuration manager.</param>
 public GlobalSettingsRepository(INutConfiguration configurationManager) : base(configurationManager) { }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PackageRepository"/> class.
 /// <remarks>Used by the IoC container.</remarks>
 /// </summary>
 /// <param name="configurationManager">The configuration manager.</param>
 public PackageRepository(INutConfiguration configurationManager) : base(configurationManager) { }
Пример #12
0
 public ReportHealthService(INutConfiguration configurationManager)
 {
     _configurationManager = configurationManager;
 }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectionStringRepository"/> class.
 /// <remarks>Used by IoC container.</remarks>
 /// </summary>
 /// <param name="configurationManager">The configuration manager.</param>
 public ConnectionStringRepository(INutConfiguration configurationManager) : base(configurationManager) { }