JSON Configuration File Format
With the implementation of the Common Component Specification (CCS) compliant AppServerStartupManager we have introduced a new JSON based session configuration file format. The file supports inheritance (a customer's specific configuration may be inheriting defaults provided by Consultingwerk). The file format supports configuration of:
service.xml Files loaded during the session startup
factory.xml Files providing configuration to the default IFactory implementation
CCS Managers loaded by the IStartupManager
Database Connections
Database Aliases
Name of the Application Config file (.applicationsettings, .restapplicationsettings)
Static Properties (e.g. FrameworkSettings:DebugMode)
SESSION:EXPORT
The logging stream used by the LogManager (e.g. NDJSON log files)
The AppServerStartupManager uses exactly one configuration file during session initialization. But this configuration file may be "basedOn" another configuration file, which recursively may also be based on another configuration file.
Configuration objects like the list of the services.xml files, CCS managers, database aliases, static properties and custom log entries may be set only in a configuration file high up in the stack or be inherited from the configuration it is based on. In which case array entries or nested properties are merged.
Sample configuration files
Consultingwerk/Framework/Server/startup_rest_appserver.json
{
"basedOn": "",
"inheritStaticProperties": false,
"staticProperties": {},
"applicationSettings": ".restapplicationsettings",
"inheritLoadServices": false,
"loadServices": [
"Consultingwerk/Framework/Server/rest_services.xml",
"Consultingwerk/SmartFramework/services_server.xml"],
"loadFactories": [
"Consultingwerk/Framework/factory.xml"],
"inheritManagers": false,
"managers": {
"Ccs.Common.IServiceManager": "Consultingwerk.Framework.CcsServiceManager"},
"inheritCustomLogEntries": false,
"customLogEntries": [],
"inheritAliases": false,
"aliases": null,
"sessionExport": null
}Consultingwerk/SmartComponentsDemo/Web2/startup_rest_appserver.json
{
"basedOn": "Consultingwerk/Framework/Server/startup_rest_appserver.json",
"inheritStaticProperties": true,
"staticProperties": {
"Consultingwerk.Framework.FrameworkSettings:DebugMode": true,
"Consultingwerk.OERA.DataAccess:LogFetchDataDetails": true
},
"inheritLoadServices": true,
"loadServices": [
"Consultingwerk/SmartComponentsDemo/Web2/demo_services.xml",
"Consultingwerk/OERA/TableStatistics/services_request_monitor.xml"],
"inheritCustomLogEntries": true,
"customLogEntries": [
"ServiceInterface",
"DataAccess",
"ServiceLoader",
"ConfigurationProvider",
"ServiceNameMappingService",
"SmartWebHandlerRequest",
"SmartHybridRealm",
"SmartRepositoryService",
"ContextDatasetStore"],
"inheritAliases": true,
"aliases": {
"sports2000": ["dictdb", "appdb"],
"icfdb": "afdb"
}
}Resulting configuration
{
"staticProperties": {
"Consultingwerk.Framework.FrameworkSettings:DebugMode": true,
"Consultingwerk.OERA.DataAccess:LogFetchDataDetails": true
},
"applicationSettings": ".restapplicationsettings",
"loadServices": [
"Consultingwerk/Framework/Server/rest_services.xml",
"Consultingwerk/SmartFramework/services_server.xml",
"Consultingwerk/SmartComponentsDemo/Web2/demo_services.xml",
"Consultingwerk/OERA/TableStatistics/services_request_monitor.xml"
],
"loadFactories": [
"Consultingwerk/Framework/factory.xml"],
"managers": {
"Ccs.Common.IServiceManager": "Consultingwerk.Framework.CcsServiceManager"
},
"customLogEntries": [
"ServiceInterface",
"DataAccess",
"ServiceLoader",
"ConfigurationProvider",
"ServiceNameMappingService",
"SmartWebHandlerRequest",
"SmartHybridRealm",
"SmartRepositoryService",
"ContextDatasetStore"
],
"aliases": {
"sports2000": [
"dictdb",
"appdb"
],
"icfdb": "afdb"
},
"sessionExport": null
}Application Settings
The Application Settings (ConfigurationProvider) can be configured in two ways:
Either as a single JSON string value, providing the name of the JSON configuration file (e.g. .applicationsettings or .restapplicationsettings)
As a JSON Object, providing name/value pairs with the configuration values, basically embedding the .applicationsettings/.restapplicationsettings file into the JSON configuration file.
Database Connections
"inheritDatabases": false,
"databases": {
"sports2000": "-db C:/Work/SmartComponents4NET/121_64/DB/Sports2000/sports2000.db",
"icfdb": "-db C:/Work/SmartComponents4NET/121_64/DB/icfdb/icfdb",
"SmartDB": "-db c:/Work/SmartComponents4NET/121_64/DB/SmartDB/SmartDB"
}Services
The loadServices array can define services in two ways, combinations are supported:
as JSON Strings referencing the names of service.xml files
as JSON Objects directly referencing services, see below. Services in the JSON Object configuration in one JSON Configuration file may override settings for the same Interface in a base JSON Configuration file thus allowing overriding individual service definitions - which is not supported by service.xml files.
"loadServices": [
{
"Package.Subpackage.IInterfaceName1": "Package.Subpackage.ServiceImplementation1",
"Package.Subpackage.IInterfaceName2": "Package.Subpackage.ServiceImplementation2"
}
]Variable Substitution
String values in the JSON configuration file (including string elements of arrays) support substitution variables using the OpenEdge TokenResolver token syntax ${group.arg}. The substitution is performed by the ConfigurationFileParser after the configuration file inheritance has been merged. The most common use case is referencing environment variables, e.g. in container deployments:
${env.NAME}- replaced with the value of the environment variable NAME. When the environment variable is not set, the token remains unchanged in the configuration value.${?env.NAME}- optional token: when the environment variable is not set, the value?is substituted.${env.NAME:defaultValue}- token with a default value (SmartComponent Library extension, SCL-5415): when the environment variable is set, its value is substituted; when it is not set, the default value following the first colon is substituted.
All other token groups of the OpenEdge TokenResolver (session, guid, t/time, ver/version, ...) are supported as well.
{
"staticProperties": {
"Consultingwerk.Framework.FrameworkSettings:DebugMode": "${env.DEBUG_MODE:false}"
},
"databases": {
"SmartDB": "-db SmartDB -H ${env.DB_HOST:localhost} -S ${env.SMARTDB_PORT}"
}
}Validation of Substitution Variables (validateSubstitutionVariables)
When an environment variable is not set, the literal ${env.NAME} token remains in the configuration value and the session starts with the token text as the value - failures then surface later with unrelated errors, far from the actual cause. To fail fast at startup instead, set the boolean property validateSubstitutionVariables at the root level of the JSON configuration file (available since SCL-5415). The default is false - when the property is not defined in the JSON configuration file, no validation is performed:
{
"validateSubstitutionVariables": true,
...
}When
true, theConfigurationFileParserraises anUnresolvedSubstitutionVariableExceptionwhen any unresolved${env.*}token remains after the variable substitution. The error message names the unresolved token(s) and the configuration file, so a missing or misspelled environment variable fails the session startup instead of causing a downstream error.When the property is absent or
false(the default), the behavior is unchanged: unresolved tokens remain in the configuration values.The property participates in the configuration file inheritance - it can be set in a basedOn base configuration file and then applies to the merged result.
The validation is scoped to the
envtoken group to avoid false positives on values legitimately containing${...}text or tokens intended for later resolution.Tokens with a default value (
${env.NAME:defaultValue}) and optional tokens (${?env.NAME}) always resolve and therefore never fail the validation.
Application Profiler
The following JSON Entry can be used to enable the Application Profiler
"profiler": {
"enabled": true,
"outputFileName": "c:/Work_STREAM/SmartComponentLibrary/Develop/smartpas_stream/work/profiler.prof",
"description": "AppServer Profiler Session",
"debugListingDirectory": "c:/Work_STREAM/SmartComponentLibrary/Develop/smartpas_stream/work",
"traceFilter": "*"
}Logging Stream
The optional loggingStream entry replaces the logging stream (Consultingwerk.Util.LoggingStream.ILoggingStream) the Consultingwerk.Util.LogManager writes to (available since SCL-5876) - for example to write a structured NDJSON log file in addition to or instead of the AppServer agent log. When the entry is not defined in the JSON configuration file, or set to null, the LogManager writes to the ABL LOG-MANAGER using the LogManagerLoggingStream.
{
"loggingStream": {
"factory": "Consultingwerk.Util.LoggingStream.NdjsonLoggingStreamFactory",
"keepCurrentStream": true,
"configuration": {
"fileName": "${env.CATALINA_BASE}/logs/smartpas_stream.ndjson",
"append": true,
"uniqueFileName": true,
"context": {
"application": "Sports2000"
}
}
}
}factory(required): the name of a class implementingConsultingwerk.Util.LoggingStream.ILoggingStreamFactory. The factory is created with its parameterless constructor and creates the logging stream.keepCurrentStream(optional, defaultfalse): whentrue, the current logging stream (usually the agent or client log file) keeps receiving all messages in addition to the new logging stream.configuration(optional): a JSON object passed to the factory. Its properties are defined by the factory, see below.
Property names are case-insensitive. The entry participates in the configuration file inheritance, and substitution variables such as ${env.NAME} are resolved before the factory receives its configuration. A configuration file disables a logging stream inherited from its base configuration file by setting the entry to null:
{
"basedOn": "Consultingwerk/Framework/Server/startup_common_appserver.json",
"loggingStream": null
}Evaluation during the session startup
The AppServerStartupManager (and the GuiClientStartupManager) evaluates the loggingStream entry directly after the configuration file has been parsed, before any other entry is processed. The active custom log entries are applied to the new logging stream, and a message naming the new logging stream is written to the previous one. The messages written while the configuration file is parsed are written to the previous logging stream; the startup logging that follows (startup header, configuration, managers, services, ...) is written to the new logging stream.
As the factory runs before the other entries are processed, the factory class and the logging stream class have to be found in the initial PROPATH of the session - entries added through environment / applicationPropath are not yet available. The factory cannot use services, database connections or the static properties of the configuration file; its settings come from the configuration object or from environment variables.
When the factory class is not found, does not implement ILoggingStreamFactory or raises an error (for example because a required property is missing), the error is written to the log file and the session startup fails. A factory may return the unknown value (?) to keep the current logging stream.
NdjsonLoggingStreamFactory
Consultingwerk.Util.LoggingStream.NdjsonLoggingStreamFactory creates a NdjsonLoggingStream, which writes one JSON object per log record (newline delimited JSON):
Property | Required | Default | Description |
|---|---|---|---|
| yes | - | The name of the NDJSON file |
| no |
| When |
| no |
| When |
| no | - | A JSON object with properties that are written into every log record (e.g. the application or environment name) |
FileLoggingStreamFactory
Consultingwerk.Util.LoggingStream.FileLoggingStreamFactory creates a FileLoggingStream, which writes a text log file:
Property | Required | Default | Description |
|---|---|---|---|
| yes | - | The name of the log file |
| no |
| When |
{
"loggingStream": {
"factory": "Consultingwerk.Util.LoggingStream.FileLoggingStreamFactory",
"configuration": {
"fileName": "${env.TEMP}/reference-client.log"
}
}
}With uniqueFileName set to true, _<guid> is appended to the file name (before the file extension) in AppServer, PASOE multi-session agent and WebSpeed sessions, so that every session writes its own file - for example smartpas_stream_<guid>.ndjson. In other sessions the file name is used unchanged.
Custom logging stream factories
Applications can provide their own factory by implementing Consultingwerk.Util.LoggingStream.ILoggingStreamFactory or by inheriting the abstract Consultingwerk.Util.LoggingStream.LoggingStreamFactory, which provides case-insensitive access to the properties of the configuration object:
interface Consultingwerk.Util.LoggingStream.ILoggingStreamFactory:
method public ILoggingStream CreateLoggingStream (poConfiguration as JsonObject) .
end interface.AppServer Startup
The procedure Consultingwerk/Framework/Server/ccs_startup.p implements an AppServer startup based on the Common Component Specification (CCS) compliant AppServerStartupManager.
The AppServer session startup procedure parameter points to the JSON Configuration file.