Package org.forgerock.config.resolvers
Class PropertyResolvers
java.lang.Object
org.forgerock.config.resolvers.PropertyResolvers
A utility class that gives access to the default property resolvers for a product.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PropertyResolver
bootstrapPropertyResolver
(String productKey, PropertyResolver productPathResolver) Get the standard bootstrap property resolver, which is defined as a resolver that checks in turn: The product paths resolver Environment variables System properties Any external sources defined in the <productKey>.envconfig.dirs system property, or (if it does not exist) the <PRODUCTKEY>_ENVCONFIG_DIRS environment variable, which is treated as a comma-separated list of source directories, where the files in a directory are resolved in a non-deterministic order, and are checked for duplicate keys.static PropertyResolver
Returns an empty resolver that always return the default value.static PropertyResolver
Construct a newEnvironmentVariableResolver
.static PropertyResolver
jsonResolver
(File jsonFile) Construct a newJsonValueResolver
using a given file.static PropertyResolver
jsonResolver
(String filename) Construct a newJsonValueResolver
using the given filename.static PropertyResolver
jsonResolver
(String name, JsonValue json) Construct a newJsonValueResolver
using a given aJsonValue
.static PropertyResolver
jsonResolver
(Path path) Construct a newJsonValueResolver
using a file at the given path.static PropertyResolver
jsonResolver
(JsonValue json) Construct a newJsonValueResolver
using a given aJsonValue
.static PropertyResolver
pathPropertyResolver
(Map<String, Path> directories) Constructs a path resolver to expose paths and associated URLs.static PropertyResolver
prefixed
(String prefix, PropertyResolver delegate) Constructs a prefixedPropertyResolver
.static PropertyResolver
productPathPropertyResolver
(String productKey, Path instanceDirectory) Constructs a path resolver to expose a product instance directory.static PropertyResolver
propertiesResolver
(File propertiesFile) Creates aPropertiesResolver
given a file object.static PropertyResolver
propertiesResolver
(String filename) Creates aPropertiesResolver
given a file location.static PropertyResolver
propertiesResolver
(String name, Properties properties) Creates aPropertiesResolver
given aProperties
object.static PropertyResolver
propertiesResolver
(Path filename) Creates aPropertiesResolver
given a file location.static PropertyResolver
propertiesResolver
(Properties properties) Creates aPropertiesResolver
given aProperties
object.static PropertyResolver
secretsPropertyResolver
(SecretsProvider secretsProvider) Constructs a resolver that looks upGenericSecret
s from the givenSecretsProvider
and converts them to UTF-8 strings.static PropertyResolver
singletonPropertyResolver
(String key, String value) Returns a resolver that knows only to resolve the given key.static PropertyResolver
Construct a newSystemPropertyResolver
.
-
Method Details
-
defaultingPropertyResolver
Returns an empty resolver that always return the default value.- Returns:
- an empty resolver that always return the default value.
-
singletonPropertyResolver
Returns a resolver that knows only to resolve the given key.- Parameters:
key
- the only resolvable keyvalue
- the key's value- Returns:
- a resolver that knows only to resolve the given key.
-
bootstrapPropertyResolver
public static PropertyResolver bootstrapPropertyResolver(String productKey, PropertyResolver productPathResolver) Get the standard bootstrap property resolver, which is defined as a resolver that checks in turn:- The product paths resolver
- Environment variables
- System properties
- Any external sources defined in the <productKey>.envconfig.dirs system property, or (if it does not exist) the <PRODUCTKEY>_ENVCONFIG_DIRS environment variable, which is treated as a comma-separated list of source directories, where the files in a directory are resolved in a non-deterministic order, and are checked for duplicate keys. The sources are used in the order specified (i.e. the first source has the highest precedence).
- Parameters:
productKey
- Product key (AM, IG, lowercased) to get the appropriate .envconfig.dirs value.productPathResolver
- A resolver that resolves the product installation details, etc. This resolver might also provide a value for the <productKey>.envconfig.dirs, if the product has an additional mechanism for obtaining that value.- Returns:
- a property resolver that can be passed to the
SubstitutionService(PropertyResolver)
constructor, or extended by a product as required.
-
environmentVariablePropertyResolver
Construct a newEnvironmentVariableResolver
.- Returns:
- a
EnvironmentVariableResolver
-
systemPropertyResolver
Construct a newSystemPropertyResolver
.- Returns:
- a
SystemPropertyResolver
-
jsonResolver
Construct a newJsonValueResolver
using the given filename.- Parameters:
filename
- The name of the file to obtain the JSON from.- Returns:
- a
JsonValueResolver
-
jsonResolver
Construct a newJsonValueResolver
using a file at the given path.- Parameters:
path
- The path of the file to obtain the JSON from.- Returns:
- a
JsonValueResolver
-
jsonResolver
Construct a newJsonValueResolver
using a given file.- Parameters:
jsonFile
- the file to obtain the JSON from.- Returns:
- a
JsonValueResolver
-
jsonResolver
Construct a newJsonValueResolver
using a given aJsonValue
.- Parameters:
json
- TheJsonValue
for this resolver- Returns:
- a
JsonValueResolver
-
jsonResolver
Construct a newJsonValueResolver
using a given aJsonValue
.- Parameters:
name
- The name of theJsonValueResolver
json
- TheJsonValue
for this resolver- Returns:
- a
JsonValueResolver
-
propertiesResolver
Creates aPropertiesResolver
given a file location.- Parameters:
filename
- the file to obtain theProperties
from.- Returns:
- a
PropertiesResolver
-
propertiesResolver
Creates aPropertiesResolver
given a file location.- Parameters:
filename
- the file to obtain theProperties
from.- Returns:
- a
PropertiesResolver
-
propertiesResolver
Creates aPropertiesResolver
given a file object.- Parameters:
propertiesFile
- the properties file as aFile
object.- Returns:
- a
PropertiesResolver
-
propertiesResolver
Creates aPropertiesResolver
given aProperties
object.- Parameters:
properties
- the properties as aProperties
object.- Returns:
- a
PropertiesResolver
-
propertiesResolver
Creates aPropertiesResolver
given aProperties
object.- Parameters:
name
- the name of thePropertiesResolver
.properties
- the properties as aProperties
object.- Returns:
- a
PropertiesResolver
-
prefixed
Constructs a prefixedPropertyResolver
.- Parameters:
prefix
- prefix (notnull
)delegate
- delegate resolver (notnull
)- Returns:
- a resolver that handle prefixed keys
-
pathPropertyResolver
Constructs a path resolver to expose paths and associated URLs.- Parameters:
directories
- The directories to expose, cannot benull
.- Returns:
- a
ProductPathResolver
-
productPathPropertyResolver
public static PropertyResolver productPathPropertyResolver(String productKey, Path instanceDirectory) Constructs a path resolver to expose a product instance directory.- Parameters:
productKey
- Used as a prefix for computed key names (lowercased)instanceDirectory
- The instance directory of this product, cannot benull
.- Returns:
- a
ProductPathResolver
-
secretsPropertyResolver
Constructs a resolver that looks upGenericSecret
s from the givenSecretsProvider
and converts them to UTF-8 strings. Callers should take care to periodically reload configuration values to ensure that the latest version is picked up when secrets are rotated. ThePurpose
used to look up secrets will have a label corresponding to the config property name.- Parameters:
secretsProvider
- the secrets provider to resolve secrets from. Must not be null.- Returns:
- a property resolver for secrets.
-