Package dev.getelements.elements.config
Class DefaultConfigurationSupplier
java.lang.Object
dev.getelements.elements.config.DefaultConfigurationSupplier
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionUses all default configuration.DefaultConfigurationSupplier
(ClassLoader classLoader) DefaultConfigurationSupplier
(ClassLoader classLoader, Properties properties) DefaultConfigurationSupplier
(Properties properties) This scans the classpath using theClassLoader
fromClassLoader.getSystemClassLoader()
to scan for defaults and will use the supplied properties. -
Method Summary
Modifier and TypeMethodDescriptionget()
Returns a copy of the loaded system default properties.static Properties
Loads and returns properties using a variety of fallbacks.static Properties
loadProperties
(Properties properties, Path... paths) Loads and accumulates multiplePaths
containing the contentsProperties
.
-
Constructor Details
-
DefaultConfigurationSupplier
public DefaultConfigurationSupplier()Uses all default configuration. This scans the classpath using theClassLoader
fromClassLoader.getSystemClassLoader()
to scan for defaults and will load properties according to the default configuration . -
DefaultConfigurationSupplier
This scans the classpath using theClassLoader
fromClassLoader.getSystemClassLoader()
to scan for defaults and will use the supplied properties. The configured properties are loaded usingloadProperties()
- Parameters:
properties
- the
-
DefaultConfigurationSupplier
-
DefaultConfigurationSupplier
-
-
Method Details
-
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 ofSystem.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
Loads and accumulates multiplePaths
containing the contentsProperties
.- Parameters:
properties
- the initialProperties
paths
- all paths to load- Returns:
- the
Properties
loaded from each path
-
get
- Specified by:
get
in interfaceSupplier<Properties>
-
getDefaultProperties
Returns a copy of the loaded system default properties.- Returns:
- the default properties.
-