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 Details

  • Method Details

    • getConfiguration

      public Configuration getConfiguration(org.jdom2.Element e) throws ConfigurationException
      Description copied from interface: ConfigurationFactory
      Builds a Configuration from the given XML element.
      Specified by:
      getConfiguration in interface ConfigurationFactory
      Parameters:
      e - XML configuration element
      Returns:
      the resulting Configuration
      Throws:
      ConfigurationException - on invalid configuration
    • processProperty

      protected void processProperty(Properties props, String name, String value)
      Adds value to props under name, promoting the entry to a String[] when more than one value has been registered for the same key.
      Parameters:
      props - target properties
      name - property name
      value - property value to add
    • processFile

      protected void processFile(Properties props, String baseFile, boolean isEnv) throws ConfigurationException
      Loads baseFile (and optional per-environment overlays) into props.
      Parameters:
      props - target properties
      baseFile - path to the base file (resolved against the Environment)
      isEnv - when true, also loads baseFile-<env>.yml/.properties overlays
      Throws:
      ConfigurationException - if no matching file can be loaded
    • getFiles

      protected List<String> getFiles(String baseFile, String environmnents)
      Builds the list of candidate file names: the base file plus per-environment overlays.
      Parameters:
      baseFile - base file name
      environmnents - comma-separated list of environment names to overlay
      Returns:
      ordered list of candidate file names to attempt loading
    • readYamlFile

      protected boolean readYamlFile(Properties props, String fileName) throws ConfigurationException
      Loads the contents of fileName into props, dispatching by extension.
      Parameters:
      props - target properties
      fileName - path to a .yml or .properties file
      Returns:
      true if the file existed and was read, false otherwise
      Throws:
      ConfigurationException - if the file is present but cannot be parsed
    • readPropertyFile

      protected boolean readPropertyFile(Properties props, String fileName) throws IOException
      Loads a Java .properties file into props.
      Parameters:
      props - target properties
      fileName - path to the properties file
      Returns:
      true if the file existed and was read, false otherwise
      Throws:
      IOException - if the file cannot be read
    • readYAML

      protected boolean readYAML(Properties props, String fileName) throws IOException
      Loads a YAML file into props, flattening nested maps into dotted keys.
      Parameters:
      props - target properties
      fileName - path to the YAML file
      Returns:
      true if the file existed and was read, false otherwise
      Throws:
      IOException - if the file cannot be read