Class PropertyFileConfigurationSource

java.lang.Object
io.inverno.mod.configuration.internal.AbstractConfigurationSource<io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashConfigurationQuery<String,PropertyFileConfigurationSource>,io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashExecutableConfigurationQuery<String,PropertyFileConfigurationSource>,io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashListConfigurationQuery<String,PropertyFileConfigurationSource>,String,PropertyFileConfigurationSource>
io.inverno.mod.configuration.internal.AbstractHashConfigurationSource<String,PropertyFileConfigurationSource>
io.inverno.mod.configuration.source.PropertyFileConfigurationSource
All Implemented Interfaces:
ConfigurationSource, DefaultableConfigurationSource

public class PropertyFileConfigurationSource extends io.inverno.mod.configuration.internal.AbstractHashConfigurationSource<String,PropertyFileConfigurationSource>

A configuration source that looks up properties in a regular property file.

This source supports parameterized configuration properties defined in a configuration file as follows:


 web.server_port=8080
 web.server_port[profile="ssl"]=8443
 db.url[env="dev"]=jdbc:oracle:thin:@dev.db.server:1521:sid
 db.url[env="prod",zone="eu"]=jdbc:oracle:thin:@prod_eu.db.server:1521:sid
 db.url[env="prod",zone="us"]=jdbc:oracle:thin:@prod_us.db.server:1521:sid
 
Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • AbstractHashConfigurationSource
  • Constructor Details

    • PropertyFileConfigurationSource

      public PropertyFileConfigurationSource(Path propertyFile)

      Creates a property file configuration source with the .properties file at the specified path.

      Parameters:
      propertyFile - the path to the .properties file
    • PropertyFileConfigurationSource

      public PropertyFileConfigurationSource(Path propertyFile, SplittablePrimitiveDecoder<String> decoder)

      Creates a property file configuration source with the .properties file at the specified path and the specified string value decoder.

      Parameters:
      propertyFile - the path to the .properties file
      decoder - a string decoder
    • PropertyFileConfigurationSource

      public PropertyFileConfigurationSource(InputStream propertyInput)

      Creates a property file configuration source with the specified input stream.

      Parameters:
      propertyInput - the .properties input
    • PropertyFileConfigurationSource

      public PropertyFileConfigurationSource(InputStream propertyInput, SplittablePrimitiveDecoder<String> decoder)

      Creates a property file configuration source with the specified input stream and string value decoder.

      Parameters:
      propertyInput - the .properties input
      decoder - a string decoder
    • PropertyFileConfigurationSource

      public PropertyFileConfigurationSource(Resource propertyResource)

      Creates a property file configuration source with the specified resource

      Parameters:
      propertyResource - the .properties resource
    • PropertyFileConfigurationSource

      public PropertyFileConfigurationSource(Resource propertyResource, SplittablePrimitiveDecoder<String> decoder)

      Creates a property file configuration source with the specified resource and string value decoder.

      Parameters:
      propertyResource - the .properties resource
      decoder - a string decoder
  • Method Details

    • withParameters

      Description copied from interface: ConfigurationSource

      Defines parameters that specify the context in which configuration properties are to be retrieved.

      Specified by:
      withParameters in interface ConfigurationSource
      Specified by:
      withParameters in class io.inverno.mod.configuration.internal.AbstractConfigurationSource<io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashConfigurationQuery<String,PropertyFileConfigurationSource>,io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashExecutableConfigurationQuery<String,PropertyFileConfigurationSource>,io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashListConfigurationQuery<String,PropertyFileConfigurationSource>,String,PropertyFileConfigurationSource>
      Parameters:
      parameters - a list of parameters
      Returns:
      the executable configuration query
      Throws:
      IllegalArgumentException - if parameters were specified more than once
    • withDefaultingStrategy

      public PropertyFileConfigurationSource withDefaultingStrategy(DefaultingStrategy defaultingStrategy)
      Description copied from interface: DefaultableConfigurationSource

      Returns a proxy of the defaultable configuration source instance using the specified defaulting strategy.

      Parameters:
      defaultingStrategy - a defaulting strategy
      Returns:
      a new defaultable configuration source
    • setPropertiesTTL

      public void setPropertiesTTL(Duration ttl)

      Sets the time-to-live duration of the properties loaded with load().

      If set to null, which is the default, properties are cached indefinitely.

      Note that this ttl doesn't apply to a source created with an InputStream which is cached indefinitely since the steam can't be read twice.

      Parameters:
      ttl - the properties time-to-live or null to cache properties indefinitely
    • getPropertiesTTL

      public Duration getPropertiesTTL()

      Returns the time-to-live duration of the properties loaded with load().

      Returns:
      the properties time-to-live or null if properties are cached indefinitely
    • load

      protected Mono<List<ConfigurationProperty>> load()
      Description copied from class: io.inverno.mod.configuration.internal.AbstractHashConfigurationSource

      Loads the configuration properties.

      Specified by:
      load in class io.inverno.mod.configuration.internal.AbstractHashConfigurationSource<String,PropertyFileConfigurationSource>
      Returns:
      A mono emitting the list of configuration properties