Class BootstrapConfigurationSource

java.lang.Object
io.inverno.mod.configuration.source.CompositeConfigurationSource
io.inverno.mod.configuration.source.BootstrapConfigurationSource
All Implemented Interfaces:
ConfigurationSource<CompositeConfigurationSource.CompositeConfigurationQuery,CompositeConfigurationSource.CompositeExecutableConfigurationQuery,CompositeConfigurationSource.CompositeListConfigurationQuery>

public class BootstrapConfigurationSource extends CompositeConfigurationSource

A configuration source that considers multiple local sources to load the bootstrap configuration of an application.

It resolves configuration properties from the following sources in that order:

  • command line arguments
  • system properties
  • system environment variables
  • the configuration.cprops file in ./conf/ or ${inverno.config.path}/ directories if one exists (if the first one exists the second one is ignored)
  • the configuration.cprops file in ${java.home}/conf/ directory if it exists
  • the configuration.cprops file in the application module if it exists

This source is typically created in a main method to load the application configuration at startup.


 public class Application {

     public static void main(String[] args) {
         BootstrapConfigurationSource source = new BootstrapConfigurationSource(App.class.getModule(), args);

         // Load configuration
         ApplicationConfiguration configuration = ConfigurationLoader
             .withConfiguration(ApplicationConfiguration.class)
             .withSource(source)
             .load()
             .block();

         // Start the application with the configuration
         ...
     }
 }
 
Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Constructor Details

    • BootstrapConfigurationSource

      public BootstrapConfigurationSource(Module module, String... args) throws IOException

      Creates a bootstrap configuration source for the specified application module and with the specified command line arguments.

      Parameters:
      module - the application module
      args - the command line arguments
      Throws:
      IOException - if something goes wrong creating the configuration source