Class SimpleConfigurationFactory
java.lang.Object
org.jpos.q2.SimpleConfigurationFactory
- All Implemented Interfaces:
ConfigurationFactory
Default
ConfigurationFactory that builds a SimpleConfiguration
from <property> children, with optional inclusion of YAML or
.properties files (and per-environment overlays).-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor; no instance state to initialise. -
Method Summary
Modifier and TypeMethodDescriptiongetConfiguration(org.jdom2.Element e) Builds a Configuration from the given XML element.Builds the list of candidate file names: the base file plus per-environment overlays.protected voidprocessFile(Properties props, String baseFile, boolean isEnv) LoadsbaseFile(and optional per-environment overlays) intoprops.protected voidprocessProperty(Properties props, String name, String value) Addsvaluetopropsundername, promoting the entry to aString[]when more than one value has been registered for the same key.protected booleanreadPropertyFile(Properties props, String fileName) Loads a Java.propertiesfile intoprops.protected booleanreadYAML(Properties props, String fileName) Loads a YAML file intoprops, flattening nested maps into dotted keys.protected booleanreadYamlFile(Properties props, String fileName) Loads the contents offileNameintoprops, dispatching by extension.
-
Constructor Details
-
SimpleConfigurationFactory
public SimpleConfigurationFactory()Default constructor; no instance state to initialise.
-
-
Method Details
-
getConfiguration
Description copied from interface:ConfigurationFactoryBuilds a Configuration from the given XML element.- Specified by:
getConfigurationin interfaceConfigurationFactory- Parameters:
e- XML configuration element- Returns:
- the resulting Configuration
- Throws:
ConfigurationException- on invalid configuration
-
processProperty
Addsvaluetopropsundername, promoting the entry to aString[]when more than one value has been registered for the same key.- Parameters:
props- target propertiesname- property namevalue- property value to add
-
processFile
protected void processFile(Properties props, String baseFile, boolean isEnv) throws ConfigurationException LoadsbaseFile(and optional per-environment overlays) intoprops.- Parameters:
props- target propertiesbaseFile- path to the base file (resolved against theEnvironment)isEnv- whentrue, also loadsbaseFile-<env>.yml/.propertiesoverlays- Throws:
ConfigurationException- if no matching file can be loaded
-
getFiles
Builds the list of candidate file names: the base file plus per-environment overlays.- Parameters:
baseFile- base file nameenvironmnents- comma-separated list of environment names to overlay- Returns:
- ordered list of candidate file names to attempt loading
-
readYamlFile
Loads the contents offileNameintoprops, dispatching by extension.- Parameters:
props- target propertiesfileName- path to a.ymlor.propertiesfile- Returns:
trueif the file existed and was read,falseotherwise- Throws:
ConfigurationException- if the file is present but cannot be parsed
-
readPropertyFile
Loads a Java.propertiesfile intoprops.- Parameters:
props- target propertiesfileName- path to the properties file- Returns:
trueif the file existed and was read,falseotherwise- Throws:
IOException- if the file cannot be read
-
readYAML
Loads a YAML file intoprops, flattening nested maps into dotted keys.- Parameters:
props- target propertiesfileName- path to the YAML file- Returns:
trueif the file existed and was read,falseotherwise- Throws:
IOException- if the file cannot be read
-