/// <summary> /// Configure a newly created LogOutput instance using the supplied /// XML configuration. /// </summary> /// <param name="operationalContext"> /// Operational context used to configure this LogOutput object. /// </param> public override void Configure(IOperationalContext operationalContext) { base.Configure(operationalContext); string loggerName = operationalContext.LogName; Logger = LogManager.GetLogger(loggerName); }
private static void VerifyDefaultConfig(IOperationalContext opCtx) { Assert.IsTrue(opCtx.EditionName == DefaultOperationalContext.DEFAULT_EDITION_NAME); Assert.IsTrue(opCtx.FilterMap.Count == 2); Assert.IsInstanceOf(typeof(CompressionFilter), opCtx.FilterMap["gzip"]); Assert.IsInstanceOf(typeof(DefaultIdentityAsserter), opCtx.IdentityAsserter); Assert.IsInstanceOf(typeof(DefaultIdentityTransformer), opCtx.IdentityTransformer); Assert.IsNotNull(opCtx.LocalMember, "opCtx.LocalMember"); Assert.IsNotNull(opCtx.LocalMember.MachineName, "opCtx.LocalMember.MachineName"); Assert.IsTrue(StringUtils.IsNullOrEmpty(opCtx.LocalMember.MemberName), "StringUtils.IsNullOrEmpty(opCtx.LocalMember.MemberName"); Assert.IsNotNull(opCtx.LocalMember.ProcessName, "opCtx.LocalMember.ProcessName"); Assert.IsTrue(StringUtils.IsNullOrEmpty(opCtx.LocalMember.RackName), "StringUtils.IsNullOrEmpty(opCtx.LocalMember.RackName)"); Assert.IsNotNull(opCtx.LocalMember.RoleName, "opCtx.LocalMember.RoleName"); Assert.IsTrue(opCtx.IsPrincipalScopingEnabled, "opCtx.IsPrincipalScopingEnabled"); }
/// <summary> /// Factory method: create and configure a new /// <see cref="IConnectionInitiator"/> for the given configuration. /// </summary> /// <param name="xml"> /// The <b>IXmlElement</b> used to create and configure a new /// <b>IConnectionInitiator</b>. /// </param> /// <param name="ctx"> /// The <b>IOperationalContext</b> used to configure a new <b>Peer</b>. /// </param> /// <returns> /// A new <b>IConnectionInitiator</b>. /// </returns> /// <exception cref="ArgumentException"> /// If the given <b>IXmlElement</b> is not a valid /// <b>IConnectionInitiator</b> configuration element. /// </exception> /// <seealso cref="FindInitiatorConfig"/> public static IConnectionInitiator CreateInitiator(IXmlElement xml, IOperationalContext ctx) { IConnectionInitiator initiator; if (xml.GetElement("tcp-initiator") != null) { initiator = (IConnectionInitiator)Activator.CreateInstance(typeof(TcpInitiator)); } else { throw new ArgumentException("unsupported \"initiator-config\":\n" + xml); } initiator.OperationalContext = ctx; initiator.Configure(xml); return(initiator); }
public PersistedGrantService(IOperationalContext context, IScopeStore scopeStore, IClientStore clientStore) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (!(context is DbContext)) { throw new ArgumentException("Operational context is not a Database Context", nameof(context)); } if (scopeStore == null) { throw new ArgumentNullException(nameof(scopeStore)); } if (clientStore == null) { throw new ArgumentNullException(nameof(clientStore)); } _context = context; _scopeStore = scopeStore; _clientStore = clientStore; }
private static void VerifyCustomConfig(IOperationalContext opCtx) { Assert.IsTrue(opCtx.FilterMap.Count == 5); Assert.IsNotNull(opCtx.FilterMap["foo"]); Assert.IsNotNull(opCtx.FilterMap["bar"]); Assert.IsNotNull(opCtx.FilterMap["baz"]); Assert.IsInstanceOf(typeof(CompressionFilter), opCtx.FilterMap["gzip"]); Assert.IsInstanceOf(typeof(ConfigurableSerializerFactory), opCtx.SerializerMap["pof"]); Assert.IsInstanceOf(typeof(ConfigurableAddressProviderFactory), opCtx.AddressProviderMap["ap1"]); Assert.IsInstanceOf(typeof(TestIdentityAsserter), opCtx.IdentityAsserter); Assert.IsInstanceOf(typeof(TestIdentityTransformer), opCtx.IdentityTransformer); Assert.IsNotNull(opCtx.LocalMember); Assert.AreEqual(opCtx.LocalMember.MachineName, "test-machine"); Assert.AreEqual(opCtx.LocalMember.MemberName, "test-member"); Assert.AreEqual(opCtx.LocalMember.ProcessName, "test-process"); Assert.AreEqual(opCtx.LocalMember.RackName, "test-rack"); Assert.AreEqual(opCtx.LocalMember.RoleName, "test-role"); Assert.AreEqual(opCtx.LocalMember.SiteName, "test-site"); Assert.IsTrue(opCtx.IsPrincipalScopingEnabled); Assert.AreEqual(opCtx.LogLevel, 6); }
/// <summary> /// Configure a newly created LogOutput instance using the supplied /// OperationalContext. /// </summary> /// <param name="operationalContext"> /// Operational context used to configure this LogOutput object. /// </param> public override void Configure(IOperationalContext operationalContext) { base.Configure(operationalContext); TextWriter stream = null; string destination = operationalContext.LogDestination; string error = null; if (StringUtils.IsNullOrEmpty(destination) || destination.ToLower().Equals("stderr")) { stream = Console.Error; } else if (destination.ToLower().Equals("stdout")) { stream = Console.Out; } else { try { if (Directory.Exists(destination)) { error = "\nThe specified log file \"" + destination + "\" refers to a directory"; } else { FileStream fs; FileInfo file = new FileInfo(destination); if (!file.Exists) { if (!file.Directory.Exists) { file.Directory.Create(); } fs = file.Create(); fs.Close(); } fs = file.Open(FileMode.Append, FileAccess.Write, FileShare.Read); stream = new StreamWriter(fs); } } catch (Exception e) { error = "\nError opening the specified log file \"" + destination + "\" (" + e.Message + ")"; } if (stream == null) { if (error != null) { error += "; using Console.Error for log output instead.\n"; Console.Error.WriteLine(error); } stream = Console.Error; } } PrintStream = stream; }
///<summary> /// constructor takes IOperationalContext ///</summary> ///<param name="operationalContext"> /// The OperationalContext for ScopedReferenceStore. /// </param> public ScopedReferenceStore(IOperationalContext operationalContext) { m_operationalContext = operationalContext; }
/// <summary> /// Configure a newly created Logger instance using the supplied /// OperationalContext. /// </summary> /// <remarks> /// destination /// -specifies the output device used by the logging system; can be /// one of Error, Out, a file name /// <p/> /// severity-level /// -specifies which logged messages are to be displayed /// <p/> /// message-format /// -specifies how messages that have a logging level specified will /// be formatted in the Log /// <p/> /// character-limit /// -specifies the maximum number of characters that the logger /// daemon will process from the message queue before discarding all /// remaining messages in the queue /// <p/> /// See the coherence.xsd for additional documentation for each of /// these parameters. /// </remarks> public virtual void Configure(IOperationalContext operationalContext) { string destination = operationalContext.LogDestination; string format = operationalContext.LogMessageFormat; int level = operationalContext.LogLevel; int limit = operationalContext.LogCharacterLimit; // validate the log level if (level < LEVEL_NONE) { level = LEVEL_NONE; } else if (level > LEVEL_ALL) { level = LEVEL_ALL; } // validate the log level if (limit <= 0) { limit = Int32.MaxValue; } // create a LogOutput of the appropriate type LogOutput output; try { if ("common-logger" == destination.ToLower()) { output = new CommonLoggingLogger(); } else { output = new Standard(); } output.Configure(operationalContext); } catch (Exception e) { output = new Standard(); output.Log(GetInteger(LEVEL_ERROR), e, "Error configuring logger; using default settings."); } Destination = destination; Format = format; Level = level; Limit = limit; LogOutput = output; Edition = operationalContext.EditionName; Assembly assembly = Assembly.GetExecutingAssembly(); Copyright = ((AssemblyCopyrightAttribute)assembly.GetCustomAttributes( typeof(AssemblyCopyrightAttribute), true)[0]).Copyright; BuildType = ((AssemblyConfigurationAttribute)assembly.GetCustomAttributes( typeof(AssemblyConfigurationAttribute), true)[0]).Configuration; Product = ((AssemblyProductAttribute)assembly.GetCustomAttributes( typeof(AssemblyProductAttribute), true)[0]).Product; // N.N.N.N [DPR|RC|Internal|] Build NNNNN string description = ((AssemblyDescriptionAttribute)assembly.GetCustomAttributes( typeof(AssemblyDescriptionAttribute), true)[0]).Description; int i = description.IndexOf("Build"); if (i == -1) { BuildInfo = "0"; Version = description.Trim(); } else { BuildInfo = description.Substring(i + 5).Trim(); Version = description.Substring(0, i).Trim(); } i = Version.IndexOf(" "); if (i > 0) { Version = StringUtils.ToOracleVersion(assembly.GetName().Version) + Version.Substring(i); } else { Version = Version.IndexOf('.') > 0 ? StringUtils.ToOracleVersion(assembly.GetName().Version) : StringUtils.ToOracleVersion(assembly.GetName().Version) + " " + Version; } if (Parameters == null) { Parameters = DefaultParameters; } }
/// <summary> /// Configure the CacheFactory. /// </summary> /// <param name="factory"> /// The rquired singleton <see cref="IConfigurableCacheFactory"/>. /// </param> /// <param name="ctx"> /// An optional <see cref="IOperationalContext"/> that contains /// operational configuration information. /// </param> /// <since>Coherence 3.7</since> public static void Configure(IConfigurableCacheFactory factory, IOperationalContext ctx) { // validate input parameters if (factory == null) { throw new ArgumentNullException("factory"); } lock (typeof(CacheFactory)) { IConfigurableCacheFactory factoryOld = s_factory; if (factoryOld != null) { // shutdown the old factory factoryOld.Shutdown(); } Logger logger = s_logger; if (ctx != null && logger != null) { // switch to a new logger logger.Shutdown(); logger = null; } if (logger == null) { // create, configure, and start a new logger if (ctx == null) { ctx = new DefaultOperationalContext(); } logger = new Logger(); logger.Configure(ctx); logger.Start(); // output the product startup banner logger.Log((int)LogLevel.Always, string.Format("\n{0} Version {1} Build {2}\n {3} Build\n{4}\n", logger.Product, logger.Version, logger.BuildInfo, logger.Edition + " " + logger.BuildType, logger.Copyright), null); IList initLogMessages = s_initLogMessages; lock (initLogMessages) { foreach (object[] logMessage in initLogMessages) { var message = (string)logMessage[0]; var exc = (Exception)logMessage[1]; var severity = (LogLevel)logMessage[2]; logger.Log((int)severity, exc, message, null); } initLogMessages.Clear(); } } if (factory.Config is IXmlDocument) { IXmlDocument doc = (IXmlDocument)factory.Config; doc.IterateThroughAllNodes(PreprocessProp); factory.Config = doc; } else { XmlDocument tempDoc = new XmlDocument(); tempDoc.LoadXml(factory.Config.GetString()); IXmlDocument doc = XmlHelper.ConvertDocument(tempDoc); doc.IterateThroughAllNodes(PreprocessProp); factory.Config = doc; } // update all singletons s_factory = factory; s_logger = logger; } }
//CLOVER:OFF /// <summary> /// Configure a newly created LogOutput instance using the supplied /// OperationalContext. /// </summary> /// <param name="operationalContext"> /// Operational context used to configure this LogOutput object. /// </param> public virtual void Configure(IOperationalContext operationalContext) { }