BaseConfiguration

Overview

QBO3 provides many configuration classes and corresponding files as part of a standard install. These configuration classes are configured to merge configuration data from their corresponding configuration file with configuration data stored in a SQL 'ConfigurationEntry' table. The BaseConfiguration class provides the ability to monitor this ConfigurationEntry table on a time, allowing site owners to push real-time configuration updates to all servers participating in a server farm.

The key components involved with this include:
  • qbo.Application.ConfigurationEntry: a class file that manages interaction with the ConfigurationEntry table
  • qbo.Application.Configuration.BaseConfiguration: a class that can apply ConfigurationEntry changes in real time
  • qbo.Application.Configuration.BaseConfiguration<T>: a generic class that handles loading and caching of configuration sections
  • qbo.ApplicationWeb.ConfigurationMonitor: a class that polls the ConfigurationEntry table for changes, calling BaseConfiguration.Monitor with any changes found
This is how it works:
  • ConfigurationMonitor calls ConfigurationEntry.Monitor() on a timer
  • ConfigurationEntry.Monitor calls BaseConfiguration.Monitor()
  • BaseConfiguration.Monitor matches the ConfigurationEntry.Source to a configuration section in memory, and if found, calls BaseConfiguration.Update()
    • BaseConfiguration<T>.Load will 'register' a configuration section with BaseConfiguration.RegisteredConfigs as it loads
  • BaseConfiguration.Update is overridden by derived classes, and process the ConfigurationEntry item passed to it

Using BaseConfiguration<T> and DbConfigurationElementCollection

Generally, custom configuration classes in QBO3 follow this pattern:
  • {Handler}Configuration.cs: this handles the entire configuration section
    • this should derive from BaseConfiguration<{Handler}Configuration>
    • e.g. FileObjectConfiguration: BaseConfiguration<FileObjectConfiguration>
    • e.g. CacheConfiguration: BaseConfiguration<CacheConfiguration>
  • {HandlerProperty}Collection.cs: this handles repeating properties (e.g. DbStatements, FileObjects, Queues)
    • this should derive from DbConfigurationElementCollection; this will load custom entries in the collection from the ConfigurationEntry table
  • {HandlerProperty}.cs: this handle a custom properties
When creating a class based on BaseConfiguration<T>, ensure you:
  • override the Update method to handle your class-specific properties
    • this will accept new ConfigurationEntry items, and update the appropriate configuration property in memory
  • create a new SectionName, to establish the default section name for your class
  • override the Initialize method, if your class needs to execute post-load processing to be ready for use
For examples, see:
  • qbo.Application.Configuration.CacheConfiguration
  • qbo.Attachment.Configuration.FileObjectConfiguration

Comments