Package org.forgerock.config.resolvers
Class PropertyResolvers
- java.lang.Object
-
- org.forgerock.config.resolvers.PropertyResolvers
-
public final class PropertyResolvers extends Object
A utility class that gives access to the default property resolvers for a product.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PropertyResolverbootstrapPropertyResolver(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 PropertyResolverdefaultingPropertyResolver()Returns an empty resolver that always return the default value.static PropertyResolverenvironmentVariablePropertyResolver()Construct a newEnvironmentVariableResolver.static PropertyResolverjsonResolver(File jsonFile)Construct a newJsonValueResolverusing a given file.static PropertyResolverjsonResolver(String filename)Construct a newJsonValueResolverusing the given filename.static PropertyResolverjsonResolver(String name, JsonValue json)Construct a newJsonValueResolverusing a given aJsonValue.static PropertyResolverjsonResolver(Path path)Construct a newJsonValueResolverusing a file at the given path.static PropertyResolverjsonResolver(JsonValue json)Construct a newJsonValueResolverusing a given aJsonValue.static PropertyResolverpathPropertyResolver(Map<String,Path> directories)Constructs a path resolver to expose paths and associated URLs.static PropertyResolverprefixed(String prefix, PropertyResolver delegate)Constructs a prefixedPropertyResolver.static PropertyResolverproductPathPropertyResolver(String productKey, Path instanceDirectory)Constructs a path resolver to expose a product instance directory.static PropertyResolverpropertiesResolver(File propertiesFile)Creates aPropertiesResolvergiven a file object.static PropertyResolverpropertiesResolver(String filename)Creates aPropertiesResolvergiven a file location.static PropertyResolverpropertiesResolver(String name, Properties properties)Creates aPropertiesResolvergiven aPropertiesobject.static PropertyResolverpropertiesResolver(Path filename)Creates aPropertiesResolvergiven a file location.static PropertyResolverpropertiesResolver(Properties properties)Creates aPropertiesResolvergiven aPropertiesobject.static PropertyResolversecretsPropertyResolver(SecretsProvider secretsProvider)Constructs a resolver that looks upGenericSecrets from the givenSecretsProviderand converts them to UTF-8 strings.static PropertyResolversingletonPropertyResolver(String key, String value)Returns a resolver that knows only to resolve the given key.static PropertyResolversystemPropertyResolver()Construct a newSystemPropertyResolver.
-
-
-
Method Detail
-
defaultingPropertyResolver
public static PropertyResolver defaultingPropertyResolver()
Returns an empty resolver that always return the default value.- Returns:
- an empty resolver that always return the default value.
-
singletonPropertyResolver
public static PropertyResolver singletonPropertyResolver(String key, String value)
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
public static PropertyResolver environmentVariablePropertyResolver()
Construct a newEnvironmentVariableResolver.- Returns:
- a
EnvironmentVariableResolver
-
systemPropertyResolver
public static PropertyResolver systemPropertyResolver()
Construct a newSystemPropertyResolver.- Returns:
- a
SystemPropertyResolver
-
jsonResolver
public static PropertyResolver jsonResolver(String filename)
Construct a newJsonValueResolverusing the given filename.- Parameters:
filename- The name of the file to obtain the JSON from.- Returns:
- a
JsonValueResolver
-
jsonResolver
public static PropertyResolver jsonResolver(Path path)
Construct a newJsonValueResolverusing a file at the given path.- Parameters:
path- The path of the file to obtain the JSON from.- Returns:
- a
JsonValueResolver
-
jsonResolver
public static PropertyResolver jsonResolver(File jsonFile)
Construct a newJsonValueResolverusing a given file.- Parameters:
jsonFile- the file to obtain the JSON from.- Returns:
- a
JsonValueResolver
-
jsonResolver
public static PropertyResolver jsonResolver(JsonValue json)
Construct a newJsonValueResolverusing a given aJsonValue.- Parameters:
json- TheJsonValuefor this resolver- Returns:
- a
JsonValueResolver
-
jsonResolver
public static PropertyResolver jsonResolver(String name, JsonValue json)
Construct a newJsonValueResolverusing a given aJsonValue.- Parameters:
name- The name of theJsonValueResolverjson- TheJsonValuefor this resolver- Returns:
- a
JsonValueResolver
-
propertiesResolver
public static PropertyResolver propertiesResolver(Path filename)
Creates aPropertiesResolvergiven a file location.- Parameters:
filename- the file to obtain thePropertiesfrom.- Returns:
- a
PropertiesResolver
-
propertiesResolver
public static PropertyResolver propertiesResolver(String filename)
Creates aPropertiesResolvergiven a file location.- Parameters:
filename- the file to obtain thePropertiesfrom.- Returns:
- a
PropertiesResolver
-
propertiesResolver
public static PropertyResolver propertiesResolver(File propertiesFile)
Creates aPropertiesResolvergiven a file object.- Parameters:
propertiesFile- the properties file as aFileobject.- Returns:
- a
PropertiesResolver
-
propertiesResolver
public static PropertyResolver propertiesResolver(Properties properties)
Creates aPropertiesResolvergiven aPropertiesobject.- Parameters:
properties- the properties as aPropertiesobject.- Returns:
- a
PropertiesResolver
-
propertiesResolver
public static PropertyResolver propertiesResolver(String name, Properties properties)
Creates aPropertiesResolvergiven aPropertiesobject.- Parameters:
name- the name of thePropertiesResolver.properties- the properties as aPropertiesobject.- Returns:
- a
PropertiesResolver
-
prefixed
public static PropertyResolver prefixed(String prefix, PropertyResolver delegate)
Constructs a prefixedPropertyResolver.- Parameters:
prefix- prefix (notnull)delegate- delegate resolver (notnull)- Returns:
- a resolver that handle prefixed keys
-
pathPropertyResolver
public static PropertyResolver pathPropertyResolver(Map<String,Path> directories)
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
public static PropertyResolver secretsPropertyResolver(SecretsProvider secretsProvider)
Constructs a resolver that looks upGenericSecrets from the givenSecretsProviderand 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. ThePurposeused 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.
-
-