Class DefaultConfigurationSupplier

java.lang.Object
dev.getelements.elements.config.DefaultConfigurationSupplier
All Implemented Interfaces:
Supplier<Properties>

public class DefaultConfigurationSupplier extends Object implements Supplier<Properties>
Implements the default configuration scheme. In addition to providing a set of Properties that has a set of "out of the box" defaults, this will attempt to load properties from either system properties or a properties file defined by the system properties. Created by patricktwohig on 5/9/17.
  • Constructor Details

    • DefaultConfigurationSupplier

      public DefaultConfigurationSupplier()
      Uses all default configuration. This scans the classpath using the ClassLoader from ClassLoader.getSystemClassLoader() to scan for defaults and will load properties according to the default configuration .
    • DefaultConfigurationSupplier

      public DefaultConfigurationSupplier(Properties properties)
      This scans the classpath using the ClassLoader from ClassLoader.getSystemClassLoader() to scan for defaults and will use the supplied properties. The configured properties are loaded using loadProperties()
      Parameters:
      properties - the
    • DefaultConfigurationSupplier

      public DefaultConfigurationSupplier(ClassLoader classLoader)
    • DefaultConfigurationSupplier

      public DefaultConfigurationSupplier(ClassLoader classLoader, Properties properties)
  • Method Details

    • loadProperties

      public static Properties loadProperties()
      Loads and returns properties using a variety of fallbacks. This first attempts to read from the default the default properties file. If no such file exists, this will use the value of System.getProperties() as the application configuration. The order of properties loading is as follows, meaning that items farther down in the list overwrite the ones above it.
      • All Environment variables
      • All JVM System Properties
      • All values from the file $ELEMENTS_HOME/conf/elements-configuration.properties
      • One of the following:
        • ENV dev.getelements.elements.configuration.properties
        • -D dev.getelements.elements.configuration.properties
        • The file in the current working directory "socialengine-configuration.properties"
        • ENV com.namazustudios.elements.configuration.properties
        • -D com.namazustudios.elements.configuration.properties
        • The file in the current working directory "elements-configuration.properties"
      Returns:
      the Properties used to configure the application.
    • loadProperties

      public static Properties loadProperties(Properties properties, Path... paths)
      Loads and accumulates multiple Paths containing the contents Properties.
      Parameters:
      properties - the initial Properties
      paths - all paths to load
      Returns:
      the Properties loaded from each path
    • get

      public Properties get()
      Specified by:
      get in interface Supplier<Properties>
    • getDefaultProperties

      public Properties getDefaultProperties()
      Returns a copy of the loaded system default properties.
      Returns:
      the default properties.