public class StdPropFileOnFilesystemLoader extends PropFileOnFilesystemLoader implements StandardLoader
.property file on the
file system. Since file systems vary, there is no default filepath
that AndHow attempts to load from.
java.util.Properties,
which silently ignores duplicate property entries
(i.e., the same key appearing multiple times). When there are duplicate
property keys in a properties file, only the last assigned value is used.
Full details on how Java parses properties files can be found in the
properties file specification.
This loader is only active if it is configured as shown below:
import org.yarnandtail.andhow.*;
import org.yarnandtail.andhow.property.StrProp;
public class UsePropertyFileOnFilesystem implements AndHowInit {
public static final StrProp MY_FILEPATH = StrProp.builder()
.desc("Path to a properties file on the file system. "
+ "If a path is configured, startup will FAIL if the file is missing.").build();
@Override
public AndHowConfiguration getConfiguration() {
return StdConfig.instance()
.setFilesystemPropFilePath(MY_FILEPATH);
}
}
MY_FILEPATH
(the name is arbitrary) which is used to configure the
StdPropFileOnFilesystemLoader with a custom property file location.
When AndHow initializes, the StdPropFileOnFilesystemLoader checks to
see if a value has been loaded for MY_FILEPATH by any prior loader.
If a value is present, the loader tries to load from the configured file
system path. If no value is configured, this loader is skipped.
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().missingFileAProblem, pathProp, pathStr, unknownPropertyAProblem| Constructor and Description |
|---|
StdPropFileOnFilesystemLoader()
There is no reason to use the constructor in production application code
because AndHow creates a single instance on demand at runtime.
|
getSpecificLoadDescription, load, loadgetConfigSamplePrinter, getEffectivePath, getInstanceConfig, getLoaderDialect, getLoaderType, isFlaggable, isMissingFileAProblem, isTrimmingRequiredForStringValues, isUnknownPropertyAProblem, loadInputStreamToProps, setFilePath, setFilePath, setMissingFileAProblem, setUnknownPropertyAProblemattemptToAdd, attemptToAdd, attemptToAdd, attemptToAddIfNotDuplicate, createValue, findDuplicateProperty, getClassConfig, mapNametoProperty, releaseResourcesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetClassConfig, getConfigSamplePrinter, getInstanceConfig, getLoaderDialect, getLoaderType, getSpecificLoadDescription, isFlaggable, isTrimmingRequiredForStringValues, load, releaseResourcesCopyright © 2022. All rights reserved.