public void Bootstrap(TypeNameReference configSource, ConfigurationProviderBase initialConfig) { lock (this.syncRoot) { if (RuntimeUtils.Bootstrappable(this.State) || this.State == RunState.Bootstrapping) { this.State = RunState.Bootstrapping; if (configSource != null) { this.initialProv = initialConfig; ConfigurationFactoryBase configFinal = NameReflectionUtils.CreateInstance <ConfigurationFactoryBase>(configSource); if (configFinal != null) { if (configFinal.Initialize()) { this.provider = configFinal; this.State = RunState.Bootstrapped; return; } else { this.provider = null; } } } this.State = RunState.FailedBootstrapping; } } }
public void Bootstrap() { lock (this.syncRoot) //overhead cost is ok on this method { if (this.inner == null) { if (RuntimeUtils.Bootstrappable(this.state)) //we only bootstrap if we're created and not initialized { this.state = RunState.Bootstrapping; this.inner = this.BootstrapModule(); if (this.state == RunState.Bootstrapping && this.inner != null) { this.state = RunState.Bootstrapped; } else //state was changed by concrete class { if (this.inner != null) //we got something back but the state was changed { if (this.state == RunState.Bootstrapped) { 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.FailedBootstrapping; } else //we got no service back, so we must be failed { this.state = RunState.FailedBootstrapping; } } } } } }
public virtual void Bootstrap() { if (RuntimeUtils.Bootstrappable(this.State)) { RunState initialState = this.State; this.BootstrapImpl(); if (this.State == initialState) //allows for bootstrappable in subclass { this.State = RunState.Bootstrapped; } } }
public void Bootstrap() { lock (instance) { if (RuntimeUtils.Bootstrappable(this.State)) { string meth = "Bootstrap"; this.State = RunState.Bootstrapping; this.logger = LogManager.Instance.GetProvider(typeof(IdentityManager)); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(IdentityManager), "provider"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { TypeNameReference typeName = TypeNameReference.Parse(tName); if (typeName != null) { IdentityConfiguration iConfig = new IdentityConfiguration(); iConfig.FactoryTypeName = typeName; Bootstrap(iConfig); return; } else { Log(meth, LogLevel.Error, "Failed to parse provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get provider param"); } } else { Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider"); } this.State = RunState.FailedBootstrapping; } } }
public void Bootstrap(TypeNameReference logfactory) { lock (this.syncRoot) { if (RuntimeUtils.Bootstrappable(this.State) || this.State == RunState.Bootstrapping) { this.State = RunState.Bootstrapping; if (logfactory != null) { this.provider = new MemoryLoggerFactory(); this.provider.Initialize(); if (!logfactory.Equals(TypeNameReference.Create(typeof(MemoryLoggerFactory)))) //confirm we're not just using memory logger { LogProviderFactory configFinal = NameReflectionUtils.CreateInstance <LogProviderFactory>(logfactory); if (configFinal != null) { if (configFinal.Initialize()) { this.provider = configFinal; //for the time being foreach (LogItem cur in MemoryLoggerFactory.Items) { LogProviderBase log = this.provider.GetLogger(NameReflectionUtils.GetType(cur.TypeName)); if (log != null) { log.Log(cur.Severity, cur.Message); } } MemoryLoggerFactory.Items.Clear(); this.State = RunState.Bootstrapped; return; } } } else //permanent logger is memory logger, so do nothing else { this.State = RunState.Bootstrapped; return; } } this.provider = null; this.State = RunState.FailedBootstrapping; } } }
public void Bootstrap(IdentityConfiguration config) { lock (instance) { if (RuntimeUtils.Bootstrappable(this.State) || this.State == RunState.Bootstrapping) { this.State = RunState.Bootstrapping; string meth = "Bootstrap"; if (this.logger == null) //in case we're directly bootstrapping { this.logger = LogManager.Instance.GetProvider(typeof(IdentityManager)); Log(meth, LogLevel.Info, "Called"); } if (config != null) { TypeNameReference typ = config.FactoryTypeName; if (typ != null) { this.factory = NameReflectionUtils.CreateInstance <IdentityProviderFactory>(typ); if (this.factory != null) { Log(meth, LogLevel.Info, "Succeeded"); this.State = RunState.Bootstrapped; return; } else { Log(meth, LogLevel.Error, "Failed to create factory instance"); } } else { Log(meth, LogLevel.Error, "Failed to extract typename"); } } else { Log(meth, LogLevel.Error, "No config provided"); } this.State = RunState.FailedBootstrapping; } } }
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); }
public void Bootstrap(TypeNameReference factoryType, uint sessionDuration) { lock (instance) { if (RuntimeUtils.Bootstrappable(this.State) || this.State == RunState.Bootstrapping) { if (factoryType != null) { SessionProviderFactory fact = NameReflectionUtils.CreateInstance <SessionProviderFactory>(factoryType); if (fact != null) { this.factory = fact; this.SessionDuration = sessionDuration; this.State = RunState.Bootstrapped; return; } } this.State = RunState.FailedBootstrapping; } } }
public void Bootstrap(AuthorizationConfiguration config) { lock (instance) { if (RuntimeUtils.Bootstrappable(this.State) || this.State == RunState.Bootstrapping) { this.State = RunState.Bootstrapping; string meth = "Bootstrap"; if (this.logger == null) //in case we're directly bootstrapping { this.logger = LogManager.Instance.GetProvider(typeof(AuthorizationManager)); Log(meth, LogLevel.Info, "Called"); } if (config != null) { TypeNameReference typ = config.PermissionFactoryTypeName; if (typ != null) { this.permissionFactory = NameReflectionUtils.CreateInstance <PermissionProviderFactory>(typ); if (this.permissionFactory != null) { typ = config.RoleFactoryTypeName; if (typ != null) { this.roleFactory = NameReflectionUtils.CreateInstance <RoleProviderFactory>(typ); if (this.roleFactory != null) { this.roleFactory.LocalContext = new UserSecurityContext(new LocalSystemUser(user.Uid, user.Name, user.UserState)); this.permissionFactory.LocalContext = new UserSecurityContext(new LocalSystemUser(user.Uid, user.Name, user.UserState)); Log(meth, LogLevel.Info, "Succeeded"); this.State = RunState.Bootstrapped; return; } else { Log(meth, LogLevel.Error, "Failed to create role factory instance"); } } else { Log(meth, LogLevel.Error, "Failed to extract role typename"); } } else { Log(meth, LogLevel.Error, "Failed to create permission factory instance"); } } else { Log(meth, LogLevel.Error, "Failed to extract permission typename"); } } else { Log(meth, LogLevel.Error, "No config provided"); } this.State = RunState.FailedBootstrapping; } } }
protected override void BootstrapImpl() { lock (instance) { if (RuntimeUtils.Bootstrappable(this.State)) { string meth = "Bootstrap"; this.State = RunState.Bootstrapping; this.logger = LogManager.Instance.GetProvider(typeof(SessionManager)); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(SessionManager), "provider"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { TypeNameReference typeName = TypeNameReference.Parse(tName); if (typeName != null) { uint sessionDuration; param = config.Get(typeof(SessionManager), "duration"); if (param != null) { try { sessionDuration = (uint)(int)param.Value; if (sessionDuration == 0) { sessionDuration = 900; //default if not provided 15 minutes } this.Bootstrap(typeName, sessionDuration); return; } catch { } Log(meth, LogLevel.Error, "Failed to parse duration param value"); } else { Log(meth, LogLevel.Error, "Failed to get duration param"); } } else { Log(meth, LogLevel.Error, "Failed to parse provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get provider param"); } } else { Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider"); } this.State = RunState.FailedBootstrapping; } } }