Package io.deephaven.configuration
Class Configuration
java.lang.Object
io.deephaven.configuration.PropertyFile
io.deephaven.configuration.Configuration
Utility class to provide an enhanced view and common access point for java properties files, as well as common
configuration pieces.
-
Field Summary
Fields inherited from class io.deephaven.configuration.PropertyFile
properties
-
Constructor Summary
ModifierConstructorDescriptionprotected
Configuration
(@NotNull Supplier<ConfigurationContext> contextSupplier) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract String
static String
expandLinuxPath
(String path) Expand the Linux-style path.@NotNull Collection<String>
Return the configuration contexts for this process.static Configuration
Get the default Configuration instance.static Configuration
Get theConfiguration
for the specified name.protected void
init()
Initialize the configuration.lookupPath
(String propertyName) Treat the system property propertyName as a path, and perform substitution withexpandLinuxPath(String)
.static void
The following main method compares two directories of prop files and outputs a CSV report of the differences.static Configuration
Create a new, non-cached, default Configuration instance.static Configuration
newStandaloneConfiguration
(@NotNull String name) Create a new, non-cached, named Configuration instance.static Configuration
newStandaloneConfiguration
(@NotNull String name, @NotNull Supplier<ConfigurationContext> contextSupplier) Create a new, non-cached, named Configuration instance.static Configuration
newStandaloneConfiguration
(@NotNull Supplier<ConfigurationContext> contextSupplier) Create a new, non-cached, default Configuration instance.Reload properties, then update with all system properties (properties set in System take precedence).static void
reset()
Clear all currently loaded Configurations so that they may be loaded anew.static void
Clear the specified named Configuration so it may be loaded anew.Methods inherited from class io.deephaven.configuration.PropertyFile
getBitSet, getBoolean, getBoolean, getBooleanForClass, getBooleanForClassWithDefault, getBooleanWithDefault, getChar, getClassParams, getClassParams, getClassParams, getClassParams, getDouble, getDouble, getDoubleForClass, getDoubleForClassWithDefault, getDoubleWithDefault, getIntArrayForClass, getInteger, getInteger, getIntegerArray, getIntegerForClass, getIntegerForClassWithDefault, getIntegerWithDefault, getIntHashSetForClass, getIntHashSetFromProperty, getLong, getLong, getLongArray, getLongForClass, getLongForClassWithDefault, getLongWithDefault, getNameStringMapFromProperty, getNameStringSetFromProperty, getNonNegativeIntSetWithRangeSupport, getPositiveInteger, getPossibleIntegerWithDefault, getPossibleStringWithDefault, getProperties, getProperties, getProperty, getShort, getShort, getShortForClass, getShortWithDefault, getString, getStringArrayFromProperty, getStringArrayFromPropertyWithDefault, getStringForClass, getStringForClassWithDefault, getStringIntHashMap, getStringSetFromProperty, getStringSetFromPropertyForClass, getStringSetFromPropertyWithDefault, getStringWithDefault, hasProperty, setProperty
-
Field Details
-
QUIET_PROPERTY
- See Also:
-
-
Constructor Details
-
Configuration
-
-
Method Details
-
getInstance
Get the default Configuration instance.- Returns:
- the single instance of Configuration allowed in an application
-
getNamed
Get theConfiguration
for the specified name.- Parameters:
name
- the name of the configuration to load- Returns:
- the named configuration.
- Throws:
ConfigurationException
- if the named configuration could not be loaded.
-
reset
public static void reset()Clear all currently loaded Configurations so that they may be loaded anew. -
reset
Clear the specified named Configuration so it may be loaded anew.- Parameters:
name
- the Configuration to clear.
-
newStandaloneConfiguration
Create a new, non-cached, default Configuration instance.- Returns:
- a new Configuration instance, guaranteed to not be cached.
-
newStandaloneConfiguration
public static Configuration newStandaloneConfiguration(@NotNull @NotNull Supplier<ConfigurationContext> contextSupplier) Create a new, non-cached, default Configuration instance.- Parameters:
contextSupplier
- the supplier forConfigurationContext
- Returns:
- a new Configuration instance, guaranteed to not be cached.
-
newStandaloneConfiguration
Create a new, non-cached, named Configuration instance.- Parameters:
name
- the configuration name- Returns:
- a new Configuration instance, guaranteed to not be cached.
-
newStandaloneConfiguration
public static Configuration newStandaloneConfiguration(@NotNull @NotNull String name, @NotNull @NotNull Supplier<ConfigurationContext> contextSupplier) Create a new, non-cached, named Configuration instance.- Parameters:
name
- the configuration namecontextSupplier
- the supplier forConfigurationContext
- Returns:
- a new Configuration instance, guaranteed to not be cached.
-
init
protected void init()Initialize the configuration. This will be sensitive to any system properties that configure the property file path. -
getContextKeyValues
Return the configuration contexts for this process. This is the list of properties that may have been used to parse the configuration file. If the configuration has not been parsed, this collection may be empty. This collection will be immutable.- Returns:
- the configuration contexts.
-
lookupPath
Treat the system property propertyName as a path, and perform substitution withexpandLinuxPath(String)
.- Parameters:
propertyName
- system property containing a path- Returns:
- The value of property propertyName after the manipulations.
-
expandLinuxPath
Expand the Linux-style path.- Change linux-style absolute paths to platform independent absolute. If the path starts with "/", replace "/" with the current directory's root (e.g. "C:\" on Windows.
- If the path begins with "~/", then replace the ~ with the user.home system property.
- If the path does not begin with "~/", then replace all occurrences of ~ with system property user.name.
- Make sure the path ends in File.separator.
- Parameters:
path
- the path to be adjusted- Returns:
- the path with substitutions performed
-
getServerTimezone
- Returns:
- the TimeZone the server is running in
-
reloadProperties
Reload properties, then update with all system properties (properties set in System take precedence).- Returns:
- the property file used
- Throws:
IOException
- if the property stream cannot be processedConfigurationException
- if the property stream cannot be opened
-
determinePropertyFile
-
main
The following main method compares two directories of prop files and outputs a CSV report of the differences. Usually run before the release of a new version into prod- Parameters:
args
- dir1 dir2 outFile.csv
-