
public.javadoc.org.spincast.plugins.config.ConfigFinder.ConfigFinderBuilder.html Maven / Gradle / Ivy
Show all versions of spincast-website Show documentation
ConfigFinder.ConfigFinderBuilder (org.spincast:spincast-framework 1.7.1 API)
org.spincast.plugins.config
Class ConfigFinder.ConfigFinderBuilder
- java.lang.Object
-
- org.spincast.plugins.config.ConfigFinder.ConfigFinderBuilder
-
- Enclosing class:
- ConfigFinder
public static class ConfigFinder.ConfigFinderBuilder
extends Object
-
-
Constructor Summary
Constructors
Constructor and Description
ConfigFinderBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
ConfigFinder
build()
ConfigFinder.ConfigFinderBuilder
classpathFile(String classpathYamlFilePath)
A .yaml config file to search on the classpath.
ConfigFinder.ConfigFinderBuilder
environmentVariablesPrefixes(List<String> prefixes)
The allowed prefixes an environment variable can have
to be used as a configuration.
ConfigFinder.ConfigFinderBuilder
environmentVariablesStripPrefix(boolean strip)
Should the prefix of an environment variable be stripped?
For example, if environmentVariablesPrefixes
indicate
that "app." is an environment variable prefix, then "app.admin.email"
would result in a "admin.email" key.
ConfigFinder.ConfigFinderBuilder
externalFile(String externalYamlFilePath)
A .yaml config file to search to be found outside the application.
ConfigFinder.ConfigFinderBuilder
externalFile(String externalYamlFilePath,
boolean overrideEnvironmentVariables)
A .yaml config file to search to be found outside the application.
ConfigFinder.ConfigFinderBuilder
systemPropertiesPrefixes(List<String> prefixes)
The allowed prefixes a system property can have
to be used as a configuration.
ConfigFinder.ConfigFinderBuilder
systemPropertiesStripPrefix(boolean strip)
Should the prefix of an system property be stripped?
For example, if systemPropertiesPrefixes
indicate
that "app." is an system property prefix, then "app.admin.email"
would result in a "admin.email" key.
ConfigFinder.ConfigFinderBuilder
throwExceptionIfSpecifiedClasspathConfigFileIsNotFound(boolean enable)
Should an exception be thrown if a classpath config file is specified
(is not null
) but is not found.
ConfigFinder.ConfigFinderBuilder
throwExceptionIfSpecifiedExternalConfigFileIsNotFound(boolean enable)
Should an exception be thrown if an external config file is specified
(is not null
) but is not found.
-
-
Method Detail
-
classpathFile
public ConfigFinder.ConfigFinderBuilder classpathFile(String classpathYamlFilePath)
A .yaml config file to search on the classpath. This is where you would put
the default values of your configurations that can be overriden externally.
This file would be provided in the resources of your application, for example :
src/main/resources/app-config.yaml
-
externalFile
public ConfigFinder.ConfigFinderBuilder externalFile(String externalYamlFilePath)
A .yaml config file to search to be found outside the application.
This can be a relative or an absolute path. If the application is ran
from the executable .jar, a relative path is relative to this .jar file.
Important : a relative path MUST start with ".", otherwise the path will be
considered as being absolute. For example, if your configuration file
is called "app-config.yaml" and is next to the executable jar, you would
use "./app-config.yaml" as the path.
-
externalFile
public ConfigFinder.ConfigFinderBuilder externalFile(String externalYamlFilePath,
boolean overrideEnvironmentVariables)
A .yaml config file to search to be found outside the application.
This can be a relative or an absolute path. If the application is ran
from the executable .jar, a relative path is relative to this .jar file.
- Parameters:
overrideEnvironmentVariables
- If environment variables
are used too, should the configs from this file override them? The default
is false
: environment variables override the configs
from the external file.
-
environmentVariablesPrefixes
public ConfigFinder.ConfigFinderBuilder environmentVariablesPrefixes(List<String> prefixes)
The allowed prefixes an environment variable can have
to be used as a configuration.
Those prefixes will be stripped to produce the configuration
keys!
Multiple prefixes are allowed so you can have configurations
specific to an application, but also configurations common to
multiple applications on the same server.
-
environmentVariablesStripPrefix
public ConfigFinder.ConfigFinderBuilder environmentVariablesStripPrefix(boolean strip)
Should the prefix of an environment variable be stripped?
For example, if environmentVariablesPrefixes
indicate
that "app." is an environment variable prefix, then "app.admin.email"
would result in a "admin.email" key.
Defaults to false
.
-
systemPropertiesPrefixes
public ConfigFinder.ConfigFinderBuilder systemPropertiesPrefixes(List<String> prefixes)
The allowed prefixes a system property can have
to be used as a configuration.
Those prefixes will be stripped to produce the configuration
keys!
Multiple prefixes are allowed so you can have configurations
specific to an application, but also configurations common to
multiple applications on the same server.
-
systemPropertiesStripPrefix
public ConfigFinder.ConfigFinderBuilder systemPropertiesStripPrefix(boolean strip)
Should the prefix of an system property be stripped?
For example, if systemPropertiesPrefixes
indicate
that "app." is an system property prefix, then "app.admin.email"
would result in a "admin.email" key.
Defaults to false
.
-
throwExceptionIfSpecifiedClasspathConfigFileIsNotFound
public ConfigFinder.ConfigFinderBuilder throwExceptionIfSpecifiedClasspathConfigFileIsNotFound(boolean enable)
Should an exception be thrown if a classpath config file is specified
(is not null
) but is not found.
If set to false
, a message will be logged but no
exception will be thrown.
Defaults to false
.
-
throwExceptionIfSpecifiedExternalConfigFileIsNotFound
public ConfigFinder.ConfigFinderBuilder throwExceptionIfSpecifiedExternalConfigFileIsNotFound(boolean enable)
Should an exception be thrown if an external config file is specified
(is not null
) but is not found.
If set to false
, a message will be logged but no
exception will be thrown.
Defaults to false
.
-
build
public ConfigFinder build()
Copyright © 2019. All rights reserved.