public virtual void Initialize()
 {
     if (RuntimeUtils.Initializable(this.State))
     {
         this.State = RunState.Initialized;
     }
 }
 public void Initialize()
 {
     lock (this.syncRoot) //overhead cost is ok on this method
     {
         if (this.inner == null)
         {
             if (RuntimeUtils.Initializable(this.state)) //we only initialize if we're created and not initialized
             {
                 this.state = RunState.Initializing;
                 this.inner = this.InitializeService();
                 if (this.state == RunState.Initializing && this.inner != null)
                 {
                     this.state = RunState.Initialized;
                 }
                 else //state was changed by concrete class
                 {
                     if (this.inner != null) //we got something back but the state was changed
                     {
                         if (this.state == RunState.Initialized)
                         {
                             return; //the implementing class set it ok, so we just ignore it
                         }
                         //something is odd, so we assume failure
                         this.inner = null;
                         this.state = RunState.FailedInitializing;
                     }
                     else //we got no service back, so we must be failed
                     {
                         this.state = RunState.FailedInitializing;
                     }
                 }
             }
         }
     }
 }
Beispiel #3
0
 public virtual void Initialize()
 {
     if (RuntimeUtils.Initializable(this.State))
     {
         RunState initialState = this.State;
         this.InitializeImpl();
         if (this.State == initialState) //allows for bootstrappable in subclass
         {
             this.State = RunState.Initialized;
         }
     }
 }
Beispiel #4
0
        protected override void InitializeImpl()
        {
            lock (instance)
            {
                if (RuntimeUtils.Initializable(this.State))
                {
                    string meth = "Initialize";
                    this.State  = RunState.Initializing;
                    this.logger = LogManager.Instance.GetProvider(typeof(InstrumentManager));
                    Log(meth, LogLevel.Info, "Called");

                    ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
                    if (config != null)
                    {
                        ConfigurationParameter param = config.Get(typeof(InstrumentManager), "provider");
                        if (param != null)
                        {
                            string tName = param.Value as string;
                            if (!string.IsNullOrEmpty(tName))
                            {
                                TypeNameReference typeName = TypeNameReference.Parse(tName);
                                if (typeName != null)
                                {
                                    this.Initialize(typeName);
                                    return;
                                }
                                else
                                {
                                    Log(meth, LogLevel.Error, "Failed to parse role provider param value");
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to get role provider param value");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to get role provider param");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
                    }


                    this.State = RunState.FailedInitializing;
                }
            }
        }
Beispiel #5
0
        protected override void InitializeImpl()
        {
            lock (instance)
            {
                if (RuntimeUtils.Initializable(this.State))
                {
                    string meth = "Initialize";
                    this.State  = RunState.Initializing;
                    this.logger = LogManager.Instance.GetProvider(typeof(EntityBundleManager));
                    Log(meth, LogLevel.Info, "Called");

                    ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
                    if (config != null)
                    {
                        ConfigurationParameter param = config.Get(typeof(EntityBundleProvider), "connectionString");
                        if (param != null)
                        {
                            string tName = param.Value as string;
                            if (!string.IsNullOrEmpty(tName))
                            {
                                if (NpgSqlCommandUtils.TestConnection(tName))
                                {
                                    Db.ConnectionString = tName;
                                    Log(meth, LogLevel.Info, "Succeeded");
                                    this.State = RunState.Initialized;
                                    return;
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to get connectionString param value");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to get connectionString param");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
                    }


                    this.State = RunState.FailedInitializing;
                }
            }
        }
Beispiel #6
0
        protected override void InitializeImpl()
        {
            lock (instance)
            {
                if (RuntimeUtils.Initializable(this.State))
                {
                    string meth = "Initialize";
                    this.State  = RunState.Initializing;
                    this.logger = LogManager.Instance.GetProvider(typeof(UserAffilationSecurityManager));
                    Log(meth, LogLevel.Info, "Called");

                    ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
                    if (config != null)
                    {
                        ConfigurationParameter param = config.Get(NameReflectionUtils.GetType(TypeNameReference.Parse("Osrs.WellKnown.FieldActivities.Providers.PgFieldActivityProviderFactory, Osrs.WellKnown.FieldActivities.Providers.Postgres")), "connectionString");
                        if (param != null)
                        {
                            string tName = param.Value as string;
                            if (!string.IsNullOrEmpty(tName))
                            {
                                if (NpgSqlCommandUtils.TestConnection(tName))
                                {
                                    Db.ConnectionString = tName;
                                    this.initialized    = true;
                                    this.State          = RunState.Initialized;
                                    return;
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to get connectionString param value");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to get connectionString param");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
                    }


                    this.State = RunState.FailedInitializing;
                }
            }
        }
Beispiel #7
0
        public void Initialize(TypeNameReference providerFactory)
        {
            lock (instance)
            {
                if (RuntimeUtils.Initializable(this.State) || this.State == RunState.Initializing)
                {
                    this.State = RunState.Initializing;
                    string meth = "Initialize";
                    if (this.logger == null)                     //in case we're directly bootstrapping
                    {
                        this.logger = LogManager.Instance.GetProvider(typeof(InstrumentManager));
                        Log(meth, LogLevel.Info, "Called");
                    }

                    if (providerFactory != null)
                    {
                        this.factory = NameReflectionUtils.CreateInstance <InstrumentProviderFactoryBase>(providerFactory);
                        if (this.factory != null)
                        {
                            if (this.factory.Initialize())
                            {
                                this.factory.LocalContext = new UserSecurityContext(new LocalSystemUser(user.Uid, user.Name, user.UserState));
                                Log(meth, LogLevel.Info, "Succeeded");
                                this.State = RunState.Initialized;
                                return;
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to initialize provider factory instance");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to create permission factory instance");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "No typename provided");
                    }
                    this.State = RunState.FailedInitializing;
                }
            }
        }
Beispiel #8
0
 internal static bool InitConfigAndLog()
 {
     //Do checks since when running under AppHost,that will initialize config/logging for us
     if (ConfigurationManager.Instance.State != RunState.Running)
     {
         if (RuntimeUtils.Bootstrappable(ConfigurationManager.Instance.State))
         {
             ConfigurationManager.Instance.Bootstrap();
         }
         if (RuntimeUtils.Initializable(ConfigurationManager.Instance.State))
         {
             ConfigurationManager.Instance.Initialize();
         }
         if (RuntimeUtils.Startable(ConfigurationManager.Instance.State))
         {
             ConfigurationManager.Instance.Start();
         }
     }
     if (ConfigurationManager.Instance.State == RunState.Running)
     {
         if (LogManager.Instance.State != RunState.Running)
         {
             if (RuntimeUtils.Bootstrappable(LogManager.Instance.State))
             {
                 LogManager.Instance.Bootstrap();
             }
             if (RuntimeUtils.Initializable(LogManager.Instance.State))
             {
                 LogManager.Instance.Initialize();
             }
             if (RuntimeUtils.Startable(LogManager.Instance.State))
             {
                 LogManager.Instance.Start();
             }
         }
         if (LogManager.Instance.State == RunState.Running)
         {
             logger = LogManager.Instance.GetProvider(typeof(OncorServer));
             return(true);
         }
     }
     return(false);
 }
Beispiel #9
0
        protected override void InitializeImpl()
        {
            lock (instance)
            {
                if (RuntimeUtils.Initializable(this.State))
                {
                    string meth = "Initialize";
                    this.State  = RunState.Initializing;
                    this.logger = LogManager.Instance.GetProvider(typeof(DetProcessorManager));
                    Log(meth, LogLevel.Info, "Called");
                    if (DetRegistry.Instance.Init())
                    {
                        this.State = RunState.Initialized;
                        return;
                    }

                    this.State = RunState.FailedInitializing;
                }
            }
        }