Example #1
0
        protected Node m_Node; //[A]ddress

        #endregion Fields

        #region Constructors

        //used by conf
        protected EndPoint(IGlue glue)
        {
            if (glue == null)
                glue = ExecutionContext.Application.Glue;

            m_Glue = (IGlueImplementation)glue;
        }
Example #2
0
 protected Provider(IGlueImplementation glue, string name = null) : base(glue, name)
 {
     if (string.IsNullOrWhiteSpace(Name))
     {
         throw new GlueException(StringConsts.CONFIGURATION_ENTITY_NAME_ERROR + this.GetType().FullName);
     }
     Glue.RegisterProvider(this);
 }
Example #3
0
        protected EndPoint(IGlue glue, Node node, Binding binding)
        {
            if (glue == null)
                glue = ExecutionContext.Application.Glue;

            m_Glue = (IGlueImplementation)glue;

            m_Node = node;
            m_Binding = binding ?? m_Glue.GetNodeBinding(node);
        }
Example #4
0
        protected Binding(IGlueImplementation glue, string name = null, Provider provider = null)
            : base(glue, name)
        {
            m_Provider = provider;
            if (string.IsNullOrWhiteSpace(Name))
            {
                throw new GlueException(StringConsts.CONFIGURATION_ENTITY_NAME_ERROR + this.GetType().FullName);
            }
            Glue.RegisterBinding(this);

            for (var i = 0; i < m_ClientTransportAllocatorLocks.Length; i++)
            {
                m_ClientTransportAllocatorLocks[i] = new object();
            }
        }
Example #5
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];
        //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)
            {
              ((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 #6
0
 //used by configuration
 internal ServerEndPoint(IGlueImplementation glue, string name) : base(glue)
 {
     ctor(name, null);
 }
Example #7
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 #8
0
 /// <summary>
 /// Override to prep glue implementation i.e. inject something programmaticaly 
 /// </summary>
 protected virtual void BeforeGlueStart(IGlueImplementation glueImplementation)
 {
 
 }
Example #9
0
 protected Binding(IGlueImplementation glue, string name = null, Provider provider = null)
     : base(glue, name)
 {
     m_Provider = provider;
     __ctor();
 }
Example #10
0
 /// <summary>
 /// Override to prep glue implementation i.e. inject something programmaticaly
 /// </summary>
 protected virtual void BeforeGlueStart(IGlueImplementation glueImplementation)
 {
 }
Example #11
0
 public ServerHandler(IGlueImplementation glue) : base(glue)
 {
    
 }
Example #12
0
            public MpxBinding(IGlueImplementation glue, string name) : base(glue, name)
            {

            }
Example #13
0
 public ServerHandler(IGlueImplementation glue) : base(glue)
 {
 }
Example #14
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 #15
0
 public AppTermBinding(IGlueImplementation glue, string name) : base(glue, name)
 {
 }
Example #16
0
 public SyncBinding(IGlueImplementation glue, string name = null, Provider provider = null) : base(glue, name, provider)
 {
 }
Example #17
0
 protected Provider(IGlueImplementation glue, string name = null) : base(glue, name)
 {
     __ctor();
 }
Example #18
0
 public MpxBinding(IGlueImplementation glue, string name) : base(glue, name)
 {
 }
Example #19
0
 public AppTermBinding(IGlueImplementation glue, string name, Provider provider = null) : base(glue, name, provider)
 {
 }