Package dev.agenor.core.config
Interface ConfigurationLoader
- All Known Implementing Classes:
DefaultConfigurationLoader
public interface ConfigurationLoader
Contract for loading and validating Agenor configuration.
Implementations live in agenor-runtime or agenor-adapters.
-
Method Summary
Modifier and TypeMethodDescriptionLoads configuration using the default lookup strategy:agenor.ymlin the working directoryagenor.ymlon the classpath Built-in defaults viaAgenorConfiguration.defaults()loadFromClasspath(String resourcePath) Loads configuration from a classpath resource.loadFromFile(String path) Loads configuration from a file on the filesystem.loadFromStream(InputStream inputStream, String format) Loads configuration from anInputStream.voidvalidate(AgenorConfiguration configuration) Validates the given configuration, checking for required fields and well-formed values.
-
Method Details
-
loadFromFile
Loads configuration from a file on the filesystem. Supports YAML (.yml,.yaml) and JSON (.json) formats. Environment variable substitution (${VAR}and${VAR:default}) is applied.- Parameters:
path- absolute or relative path to the configuration file, not null or empty- Returns:
- the loaded configuration
- Throws:
ConfigurationException- if the file is not found, not readable, or cannot be parsed
-
loadFromClasspath
Loads configuration from a classpath resource. Supports YAML (.yml,.yaml) and JSON (.json) formats. Environment variable substitution (${VAR}and${VAR:default}) is applied.- Parameters:
resourcePath- classpath-relative path to the resource, not null or empty- Returns:
- the loaded configuration
- Throws:
ConfigurationException- if the resource is not found or cannot be parsed
-
loadFromStream
Loads configuration from anInputStream. Environment variable substitution (${VAR}and${VAR:default}) is applied.- Parameters:
inputStream- the stream to read from, not nullformat- the format hint:"json"for JSON, anything else defaults to YAML- Returns:
- the loaded configuration
- Throws:
ConfigurationException- if the stream is null or its content cannot be parsed
-
loadDefault
AgenorConfiguration loadDefault()Loads configuration using the default lookup strategy:agenor.ymlin the working directoryagenor.ymlon the classpath- Built-in defaults via
AgenorConfiguration.defaults()
- Returns:
- the loaded configuration, never null
-
validate
Validates the given configuration, checking for required fields and well-formed values. Logs warnings for non-critical issues (e.g. unknown environment name, missing scan packages).- Parameters:
configuration- the configuration to validate, not null- Throws:
ConfigurationException- ifconfigurationis null,runtime.nameis empty, or any scan-package name is invalid
-