Example #1
0
            /// <summary>Provides package descriptor</summary>
            /// <param name="name">Mnemonic name of the package (i.e. application name)</param>
            /// <param name="source">Source directory where to take files from</param>
            /// <param name="relPath">Relative path which is appended to the root path where files will be placed</param>
            public PackageInfo(string name, FileSystemDirectory source, string relPath)
            {
                Name         = name ?? CoreConsts.UNKNOWN;
                Source       = source;
                RelativePath = relPath;

                ConfigSectionNode manifest = null;
                var mFile = source.GetFile(ManifestUtils.MANIFEST_FILE_NAME);

                if (mFile != null)
                {
                    try
                    {
                        manifest = LaconicConfiguration.CreateFromString(mFile.ReadAllText()).Root;
                    }
                    catch (Exception error)
                    {
                        throw new AzosIOException(StringConsts.LOCAL_INSTALL_INSTALL_SET_PACKAGE_MANIFEST_READ_ERROR.Args(Name, error.ToMessageWithType()), error);
                    }
                }

                if (manifest == null)
                {
                    throw new AzosIOException(StringConsts.LOCAL_INSTALL_INSTALL_SET_PACKAGE_WITHOUT_MANIFEST_ERROR.Args(Name, ManifestUtils.MANIFEST_FILE_NAME));
                }

                manifest.AttrByName(ManifestUtils.CONFIG_NAME_ATTR, true).Value       = name;
                manifest.AttrByName(ManifestUtils.CONFIG_LOCAL_PATH_ATTR, true).Value = relPath;
                manifest.ResetModified();

                Manifest = manifest;
            }
Example #2
0
 public void InjectConfig_ConfigSectionNode(int x, int y, ConfigSectionNode log)
 {
     Aver.AreEqual(15, x);
     Aver.AreEqual(25, y);
     Aver.IsNotNull(log);
     Aver.AreEqual(2, log.AttrCount);
     Aver.IsTrue(log.AttrByName("good").ValueAsBool(false));
     Aver.AreEqual(23.78f, log.AttrByName("k").ValueAsFloat());
 }
Example #3
0
        public virtual void SaveConfiguration(ConfigSectionNode node)
        {
            if (node == null)
            {
                throw new AzosException("{0}.SaveConfiguration(node==null)".Args(this.Name));
            }

            node.AttrByName(CONFIG_WIDTH_ATTR, true).Value  = this.Width.AsString();
            node.AttrByName(CONFIG_HEIGHT_ATTR, true).Value = this.Height.AsString();
            node.AttrByName(CONFIG_LEFT_ATTR, true).Value   = this.Left.AsString();
            node.AttrByName(CONFIG_TOP_ATTR, true).Value    = this.Top.AsString();
            node.AttrByName(CONFIG_STATE_ATTR, true).Value  = this.WindowState.AsString();
        }
Example #4
0
        private void checkIncludeInvariants(ConfigSectionNode conf)
        {
            Console.WriteLine(conf.ToLaconicString(Azos.CodeAnalysis.Laconfig.LaconfigWritingOptions.PrettyPrint));

            Aver.AreEqual(3, conf.ChildCount);

            Aver.AreEqual(129, conf.AttrByName("age").ValueAsInt());
            Aver.AreEqual("all", conf.AttrByName("_override").Value);

            Aver.AreEqual("Alex", conf.Navigate("/WithNewName/people/a").Value);
            Aver.AreEqual("Boris", conf.Navigate("/WithNewName/people/b").Value);

            Aver.AreEqual("Cleveland", conf.Navigate("/city/$name").Value);

            Aver.AreEqual("Alex", conf.Navigate("/people/a").Value);
            Aver.AreEqual("Boris", conf.Navigate("/people/b").Value);
        }
Example #5
0
        /// <summary>
        /// Executes a SET statement configuration script (StopWatch is passed along to track timout adherence)
        /// </summary>
        protected virtual void DoSET(Stopwatch sw, ConfigSectionNode setStatement)
        {
            InitStatement(setStatement);

            var path = setStatement.AttrByName("path").Value ?? CoreConsts.NULL_STRING;
            var to   = setStatement.AttrByName("to").Value;

            to = EvaluateAnyExpression(setStatement, to);

            var target = setStatement.Navigate(path);

            if (!target.Exists)
            {
                throw new ConfigException(StringConsts.CONFIGURATION_SCRIPT_SET_PATH_ERROR.Args(setStatement.RootPath, path));
            }

            target.Value = to;
        }
        /// <summary>
        /// Processes all include pragmas if they are specified in the root `process-includes` attribute.
        /// This method is called for auto-loaded entry point config automatically.
        /// You may call this method for configs acquired from external sources prior to
        /// passing it to application .ctor
        /// </summary>
        public static void ProcessAllExistingConfigurationIncludes(ConfigSectionNode appConfigRoot)
        {
            appConfigRoot.NonNull(nameof(appConfigRoot));
            var includePragma = appConfigRoot.AttrByName(CONFIG_PROCESS_INCLUDES).Value;

            if (includePragma.IsNotNullOrWhiteSpace())
            {
                appConfigRoot.ProcessAllExistingIncludes(nameof(CommonApplicationLogic), includePragma);
            }
        }
Example #7
0
        private void doSET(Stopwatch sw, ConfigSectionNode setStatement)
        {
            initStatement(setStatement);

                                var path = setStatement.AttrByName("path").Value ?? StringConsts.NULL_STRING;
                                var to =  setStatement.AttrByName("to").Value;

                                to = evaluateAnyExpression(setStatement, to);

                                var target = setStatement.Navigate(path);
                                if (!target.Exists)
                                    throw new ConfigException(StringConsts.CONFIGURATION_SCRIPT_SET_PATH_ERROR.Args(setStatement.RootPath, path) );

                                target.Value = to;
        }
Example #8
0
        protected virtual void DoInitApplication()
        {
            const string FROM = "app.init";

            ConfigAttribute.Apply(this, m_ConfigRoot);

            m_Name = m_ConfigRoot.AttrByName(CONFIG_APP_NAME_ATTR).ValueAsString(GetType().FullName);

            Debugging.DefaultDebugAction = Debugging.ReadDefaultDebugActionFromConfig();
            Debugging.TraceDisabled      = Debugging.ReadTraceDisableFromConfig();

            var node = m_ConfigRoot[CONFIG_LOG_SECTION];

            if (node.Exists)
            {
                try
                {
                    m_Log = FactoryUtils.MakeAndConfigure(node, typeof(LogService)) as ILogImplementation;

                    if (m_Log == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Log made");

                    BeforeLogStart(m_Log);

                    if (m_Log is Service)
                    {
                        if (((Service)m_Log).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "Log started, msg times are localized of machine-local time until time source starts");
                        }
                    }
                }
                catch (Exception error)
                {
                    throw new NFXException(StringConsts.APP_LOG_INIT_ERROR + error.ToMessageWithType(), error);
                }
            }


            node = m_ConfigRoot[CONFIG_TIMESOURCE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_TimeSource = FactoryUtils.MakeAndConfigure(node, null) as ITimeSourceImplementation;

                    if (m_TimeSource == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "TimeSource made");

                    BeforeTimeSourceStart(m_TimeSource);

                    if (m_TimeSource is Service)
                    {
                        if (((Service)m_TimeSource).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "TimeSource started");
                        }
                    }

                    WriteLog(MessageType.Info, FROM, "Log msg time is time source-supplied now");

                    m_StartTime = LocalizedTime;
                    WriteLog(MessageType.Info, FROM, "App start time is {0}".Args(m_StartTime));
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_TIMESOURCE_INIT_ERROR + error.ToMessageWithType();
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }
            else
            {
                WriteLog(MessageType.Info, FROM, "Using default time source");

                m_StartTime = LocalizedTime;
                WriteLog(MessageType.Info, FROM, "App start time is {0}".Args(m_StartTime));
            }


            node = m_ConfigRoot[CONFIG_EVENT_TIMER_SECTION];
            //20150827 DKh event timer must allocate even if it is absent in config
            //// if (node.Exists)
            {
                try
                {
                    m_EventTimer = FactoryUtils.MakeAndConfigure(node, typeof(EventTimer)) as IEventTimerImplementation;

                    if (m_EventTimer == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "EventTimer made");

                    BeforeEventTimerStart(m_EventTimer);

                    if (m_EventTimer is Service)
                    {
                        if (((Service)m_EventTimer).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "EventTimer started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_EVENT_TIMER_INIT_ERROR + error.ToMessageWithType();
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }



            node = m_ConfigRoot[CONFIG_SECURITY_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_SecurityManager = FactoryUtils.MakeAndConfigure(node, typeof(ConfigSecurityManager)) as ISecurityManagerImplementation;

                    if (m_SecurityManager == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Security Manager made");

                    BeforeSecurityManagerStart(m_SecurityManager);

                    if (m_SecurityManager is Service)
                    {
                        if (((Service)m_SecurityManager).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "Security Manager started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_SECURITY_MANAGER_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }

            try
            {
                Behavior.ApplyConfiguredBehaviors(this, m_ConfigRoot);
            }
            catch (Exception error)
            {
                var msg = StringConsts.APP_APPLY_BEHAVIORS_ERROR + error;
                WriteLog(MessageType.Error, FROM, msg, error);
                throw new NFXException(msg, error);
            }


            node = m_ConfigRoot[CONFIG_INSTRUMENTATION_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_Instrumentation = FactoryUtils.MakeAndConfigure(node, typeof(InstrumentationService)) as IInstrumentationImplementation;

                    if (m_Instrumentation == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Instrumentation made");

                    BeforeInstrumentationStart(m_Instrumentation);

                    if (m_Instrumentation is Service)
                    {
                        if (((Service)m_Instrumentation).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "Instrumentation started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_INSTRUMENTATION_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }


            node = m_ConfigRoot[CONFIG_THROTTLING_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_Throttling = FactoryUtils.MakeAndConfigure(node, typeof(ThrottlingService)) as IThrottlingImplementation;

                    if (m_Throttling == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Throttling made");

                    BeforeThrottlingStart(m_Throttling);

                    if (m_Throttling is Service)
                    {
                        if (((Service)m_Throttling).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "Throttling started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_THROTTLING_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }



            node = m_ConfigRoot[CONFIG_DATA_STORE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_DataStore = FactoryUtils.MakeAndConfigure(node) as IDataStoreImplementation;

                    if (m_DataStore == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "DataStore made");


                    BeforeDataStoreStart(m_DataStore);

                    if (m_DataStore is Service)
                    {
                        if (((Service)m_DataStore).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "DataStore started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_DATA_STORE_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }

            node = m_ConfigRoot[CONFIG_OBJECT_STORE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_ObjectStore = FactoryUtils.MakeAndConfigure(node, typeof(ObjectStoreService)) as IObjectStoreImplementation;

                    if (m_ObjectStore == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "ObjectStore made");

                    BeforeObjectStoreStart(m_ObjectStore);

                    if (m_ObjectStore is Service)
                    {
                        if (((Service)m_ObjectStore).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "ObjectStore started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_OBJECT_STORE_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }

            node = m_ConfigRoot[CONFIG_GLUE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_Glue = FactoryUtils.MakeAndConfigure(node, typeof(NFX.Glue.Implementation.GlueService)) as IGlueImplementation;

                    if (m_Glue == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Glue made");

                    BeforeGlueStart(m_Glue);

                    if (m_Glue is Service)
                    {
                        if (((Service)m_Glue).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "Glue started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_GLUE_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }



            WriteLog(MessageType.Info, FROM, "Common application initialized in '{0}' time location".Args(this.TimeLocation));
            WriteLog(MessageType.Info, FROM, "Component dump:");
            foreach (var cmp in ApplicationComponent.AllComponents)
            {
                WriteLog(MessageType.Info, FROM, "  -> Component: {0}  '{1}'  '{2}' ".Args(cmp.ComponentSID, cmp.GetType().FullName, cmp.ComponentCommonName));
            }
        }
Example #9
0
        protected virtual void DoInitApplication()
        {
            ExecutionContext.__SetApplicationLevelContext(this, null, null, NOPSession.Instance);

            const string FROM = "app.init";

            ConfigAttribute.Apply(this, m_ConfigRoot);

            m_Name = m_ConfigRoot.AttrByName(CONFIG_APP_NAME_ATTR).ValueAsString(GetType().FullName);

            Debugging.DefaultDebugAction = Debugging.ReadDefaultDebugActionFromConfig();
            Debugging.TraceDisabled      = Debugging.ReadTraceDisableFromConfig();

            var node = m_ConfigRoot[CONFIG_LOG_SECTION];

            if (node.Exists)
            {
                try
                {
                    m_Log = FactoryUtils.MakeAndConfigure(node, typeof(LogService)) as ILogImplementation;

                    if (m_Log == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Log made");

                    BeforeLogStart(m_Log);

                    if (m_Log is Service)
                    {
                        ((Service)m_Log).Start();
                        WriteLog(MessageType.Info, FROM, "Log started, msg times are localized of machine-local time until time source starts");
                    }
                }
                catch (Exception error)
                {
                    throw new NFXException(StringConsts.APP_LOG_INIT_ERROR + error);
                }
            }


            node = m_ConfigRoot[CONFIG_TIMESOURCE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_TimeSource = FactoryUtils.MakeAndConfigure(node, null) as ITimeSourceImplementation;

                    if (m_TimeSource == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "TimeSource made");

                    BeforeTimeSourceStart(m_TimeSource);

                    if (m_TimeSource is Service)
                    {
                        ((Service)m_TimeSource).Start();
                        WriteLog(MessageType.Info, FROM, "TimeSource started");
                    }

                    WriteLog(MessageType.Info, FROM, "Log msg time is time source-supplied now");
                }
                catch (Exception error)
                {
                    throw new NFXException(StringConsts.APP_TIMESOURCE_INIT_ERROR + error);
                }
            }

            try
            {
                m_StartTime = LocalizedTime;
                WriteLog(MessageType.Info, FROM, "App start time is {0}".Args(m_StartTime));
            }
            catch (Exception error)
            {
                throw new NFXException(StringConsts.APP_TIMESOURCE_INIT_ERROR + error);
            }


            node = m_ConfigRoot[CONFIG_EVENT_TIMER_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_EventTimer = FactoryUtils.MakeAndConfigure(node, typeof(EventTimer)) as IEventTimerImplementation;

                    if (m_EventTimer == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "EventTimer made");

                    BeforeEventTimerStart(m_EventTimer);

                    if (m_EventTimer is Service)
                    {
                        ((Service)m_EventTimer).Start();
                        WriteLog(MessageType.Info, FROM, "EventTimer started");
                    }
                }
                catch (Exception error)
                {
                    throw new NFXException(StringConsts.APP_EVENT_TIMER_INIT_ERROR + error);
                }
            }



            node = m_ConfigRoot[CONFIG_SECURITY_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_SecurityManager = FactoryUtils.MakeAndConfigure(node, typeof(ConfigSecurityManager)) as ISecurityManagerImplementation;

                    if (m_SecurityManager == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Security Manager made");

                    BeforeSecurityManagerStart(m_SecurityManager);

                    if (m_SecurityManager is Service)
                    {
                        ((Service)m_SecurityManager).Start();
                        WriteLog(MessageType.Info, FROM, "Security Manager started");
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_SECURITY_MANAGER_INIT_ERROR + error;
                    WriteLog(MessageType.Error, FROM, msg);
                    throw new NFXException(msg);
                }
            }

            try
            {
                Behavior.ApplyConfiguredBehaviors(this, m_ConfigRoot);
            }
            catch (Exception error)
            {
                var msg = StringConsts.APP_APPLY_BEHAVIORS_ERROR + error;
                WriteLog(MessageType.Error, FROM, msg);
                throw new NFXException(msg, error);
            }


            node = m_ConfigRoot[CONFIG_INSTRUMENTATION_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_Instrumentation = FactoryUtils.MakeAndConfigure(node, typeof(InstrumentationService)) as IInstrumentationImplementation;

                    if (m_Instrumentation == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Instrumentation made");

                    BeforeInstrumentationStart(m_Instrumentation);

                    if (m_Instrumentation is Service)
                    {
                        ((Service)m_Instrumentation).Start();
                        WriteLog(MessageType.Info, FROM, "Instrumentation started");
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_INSTRUMENTATION_INIT_ERROR + error;
                    WriteLog(MessageType.Error, FROM, msg);
                    throw new NFXException(msg);
                }
            }


            node = m_ConfigRoot[CONFIG_THROTTLING_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_Throttling = FactoryUtils.MakeAndConfigure(node, typeof(ThrottlingService)) as IThrottlingImplementation;

                    if (m_Throttling == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Throttling made");

                    BeforeThrottlingStart(m_Throttling);

                    if (m_Throttling is Service)
                    {
                        ((Service)m_Throttling).Start();
                        WriteLog(MessageType.Info, FROM, "Throttling started");
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_THROTTLING_INIT_ERROR + error;
                    WriteLog(MessageType.Error, FROM, msg);
                    throw new NFXException(msg);
                }
            }



            node = m_ConfigRoot[CONFIG_DATA_STORE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_DataStore = FactoryUtils.MakeAndConfigure(node) as IDataStoreImplementation;

                    if (m_DataStore == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "DataStore made");


                    BeforeDataStoreStart(m_DataStore);

                    if (m_DataStore is Service)
                    {
                        ((Service)m_DataStore).Start();
                        WriteLog(MessageType.Info, FROM, "DataStore started");
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_DATA_STORE_INIT_ERROR + error;
                    WriteLog(MessageType.Error, FROM, msg);
                    throw new NFXException(msg);
                }
            }



            node = m_ConfigRoot[CONFIG_OBJECT_STORE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_ObjectStore = FactoryUtils.MakeAndConfigure(node, typeof(ObjectStoreService)) as IObjectStoreImplementation;

                    if (m_ObjectStore == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "ObjectStore made");

                    BeforeObjectStoreStart(m_ObjectStore);

                    if (m_ObjectStore is Service)
                    {
                        ((Service)m_ObjectStore).Start();
                        WriteLog(MessageType.Info, FROM, "ObjectStore started");
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_OBJECT_STORE_INIT_ERROR + error;
                    WriteLog(MessageType.Error, FROM, msg);
                    throw new NFXException(msg);
                }
            }

            node = m_ConfigRoot[CONFIG_GLUE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_Glue = FactoryUtils.MakeAndConfigure(node, typeof(NFX.Glue.Implementation.GlueService)) as IGlueImplementation;

                    if (m_Glue == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Glue made");

                    BeforeGlueStart(m_Glue);

                    if (m_Glue is Service)
                    {
                        ((Service)m_Glue).Start();
                        WriteLog(MessageType.Info, FROM, "Glue started");
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_GLUE_INIT_ERROR + error;
                    WriteLog(MessageType.Error, FROM, msg);
                    throw new NFXException(msg);
                }
            }



            WriteLog(MessageType.Info, FROM, "Common application initialized");
            WriteLog(MessageType.Info, FROM, "Time localization information follows");
            WriteLog(MessageType.Info, FROM, "    Application: " + this.TimeLocation.ToString());
            WriteLog(MessageType.Info, FROM, "    Log: " + this.Log.TimeLocation.ToString());
            WriteLog(MessageType.Info, FROM, "    Glue: " + this.Glue.TimeLocation.ToString());
            WriteLog(MessageType.Info, FROM, "    Instrumentation: " + this.Instrumentation.TimeLocation.ToString());
            WriteLog(MessageType.Info, FROM, "    ObjStore: " + this.ObjectStore.TimeLocation.ToString());
        }
Example #10
0
 public VolumeMetadataBuilder SetVersion(int major, int minor)
 {
     SectionSystem.AttrByName(VolumeMetadata.CONFIG_VERSION_MAJOR_ATTR, true).Value = major.ToString();
     SectionSystem.AttrByName(VolumeMetadata.CONFIG_VERSION_MINOR_ATTR, true).Value = minor.ToString();
     return(this);
 }