Interface Configuration

All Known Implementing Classes:
BasicConfiguration

public interface Configuration
Manage the configuration of the interpreter. Configuration parameters can be requested from the implementing class. Configuration is read from input stream, properties files.

When requesting individual configuration keys the implementation can look for the values in different sources. Typical implementation will look up values in the system properties and environment first before searching the configuration properties.

Author:
Peter Verhas date Jul 23, 2012
  • Method Details

    • setConfigProperties

      void setConfigProperties(Properties configProperties)
      Configuration of the script engine comes from standard Java properties. Calling this method the caller can set the properties for the configuration. The properties passed as argument will be used as configuration solely and will NOT be merged with the keys and values of other property files.

      The fact that all other, possibly already loaded properties are not taken into account does not affect the fact that the configuration implementation itself may search other sources in addition to the properties to locate values for certain configuration keys.

      Parameters:
      configProperties - the properties to be used as configuration properties.
    • getConfigValue

      Optional<String> getConfigValue(String key)
      Get the value of the key.
      Parameters:
      key - the configuration key for which the value is looked up.
      Returns:
      the string value of the configuration or null if the key is not configured.
    • getConfigValue

      default Optional<String> getConfigValue(String key, int i)
      Get an indexed value. The indexed value is simple associated with the key.i property.
      Parameters:
      key - the string key
      i - the index value usually goes from zero
      Returns:
      the configuration value
    • getConfigValueStream

      default Stream<String> getConfigValueStream(String key)
      Return the configuration values assigned to a keys 'key.0', 'key.1'... 'key.n' as a stream.
      Parameters:
      key - the key to which the values are assigned using the numberic key postfix
      Returns:
      the stream of the values
    • getConfigValueList

      List<String> getConfigValueList(String key)
      Returns a list of strings that are the values assigned to the key in the configuration. List of strings in the configuration should be defined using the notation key'.n' where 'n' starts with zero and should increment by one continuously.
      Parameters:
      key - parameter
      Returns:
      the list of configured strings
    • loadDefaultConfiguration

      void loadDefaultConfiguration()
      Load the default configuration. The implementation should define some default properties file to load the configuration from.
    • loadConfiguration

      void loadConfiguration(InputStream is)
      Load the configuration from an input stream.
      Parameters:
      is - the input stream that is used to read the content of the properties file.
    • set

      void set(String name, String value)
      Set the property value in the configuration. This method is available for host application to configure the interpreter programmatically.
      Parameters:
      name - configuration property name
      value - configuration property value
    • set

      void set(String command)
      Set the property value in the configuration. This method is available for host application to configure the interpreter programmatically.
      Parameters:
      command - the name and the value separated by '='
    • getConfigProperties

      Properties getConfigProperties()
      Returns:
      the properties object that stores the configuration