public class StdEnvVarLoader extends BaseMapLoader implements StandardLoader
Property value loading is based on a 'first win' strategy, so the first loader to find a non-null value for a property sets the value.
An application might receive all or some of its configuration from OS defined environmental variables that are passed to the JVM when the JVM starts. Environment variables can be set in the OS and augmented in a startup script, which could be customized for each environment. Similar to Java system properties, this provides a relatively easy way for deployment automation or system administrators to control application configuration values across many servers.
QuotedSpacePreservingTrimmer.
Non-String values are always trimmed to null.
This loader loads values from System.getenv().
Those environmental values are provided by the host environment (the OS)
as a static String-to-String map snapshot when the JVM starts up.
The underlying OS environment variables can change, however, the JVM will be
unaware of it. Similarly, AndHow property values never change once loaded.
For FlgProp properties (true/false flags), the StdEnvVarLoader
will set the Property's value to true if a matching environment variable is
found, even if the value of the property is empty.
The Windows OS uses ALL CAPS for environment variables, while all others OS's are case sensitive - This is the primary reason AndHow is case insensitive by default. Each OS has a different way to set an environmental variables
StandardLoader's, this loader is intended to be auto-created
by AndHow. The set of standard loaders and their order can bet set
via the AndHowConfiguration.setStandardLoaders() methods.
Other loaders which don't implement the StandardLoader interface can
be inserted into the load order via the
AndHowConfiguration.insertLoaderBefore/After().unknownPropertyAProblem| Constructor and Description |
|---|
StdEnvVarLoader()
There is no reason to use the constructor in production application code
because AndHow creates a single instance on demand at runtime.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getLoaderType()
The type of the loader, such as JNDI, PropertyFile, SystemProperty,
etc..
|
String |
getSpecificLoadDescription()
For this particular load, where was info loaded from?
This may vary from run to run based on config params.
|
boolean |
isTrimmingRequiredForStringValues()
If true, values for string properties are trimmed by the Trimmer of
the property they are associated with.
|
LoaderValues |
load(PropertyConfigurationInternal runtimeDef,
LoaderEnvironment environment,
ValidatedValuesWithContext existingValues)
Builds up a list of LoaderValues by loading property values from a configuration source.
|
getLoaderDialect, isFlaggable, isUnknownPropertyAProblem, load, setUnknownPropertyAProblemattemptToAdd, attemptToAdd, attemptToAdd, attemptToAddIfNotDuplicate, createValue, findDuplicateProperty, getClassConfig, getConfigSamplePrinter, getInstanceConfig, mapNametoProperty, releaseResourcesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetClassConfig, getConfigSamplePrinter, getInstanceConfig, getLoaderDialect, isFlaggable, releaseResourcespublic StdEnvVarLoader()
public LoaderValues load(PropertyConfigurationInternal runtimeDef, LoaderEnvironment environment, ValidatedValuesWithContext existingValues)
LoaderLoaders find and load values and associate them with the correct Property. If there is a problem while doing that, they register one or more LoaderProblems in the returned LoaderValues.
Validation of Property values is not Loader's responsibility and will be handled outside this method.
load in interface LoaderruntimeDef - The definition of all known Properties and naming metadata.environment - The environment (System Props, Env vars, fixed values) as
known to the Loader.existingValues - The values already set by prior loaders, which may configure
the behavior of this loader.public String getSpecificLoadDescription()
LoadergetSpecificLoadDescription in interface LoadergetSpecificLoadDescription in class BaseMapLoaderpublic boolean isTrimmingRequiredForStringValues()
LoaderisTrimmingRequiredForStringValues in interface LoaderisTrimmingRequiredForStringValues in class BaseMapLoaderpublic String getLoaderType()
LoadergetLoaderType in interface LoadergetLoaderType in class BaseMapLoaderCopyright © 2022. All rights reserved.