Top Description Fields Constructors Methods
com.typesafe.config

public final Class ConfigFactory

extends Object
Class Inheritance
Imports
com.typesafe.config.impl.ConfigImpl, .Parseable, java.io.File, .Reader, java.lang.reflect.InvocationTargetException, java.net.MalformedURLException, .URL, java.util.Map, .Optional, .Properties, java.util.concurrent.Callable

Contains static methods for creating Config instances.

See also ConfigValueFactory which contains static methods for converting Java values into a ConfigObject. You can then convert a ConfigObject into a Config with ConfigObject#toConfig.

The static methods with "load" in the name do some sort of higher-level operation potentially parsing multiple resources and resolving substitutions, while the ones with "parse" in the name just create a ConfigValue from a resource and nothing else.

You can find an example app and library on GitHub. Also be sure to read the package overview which describes the big picture as shown in those examples.

Field Summary

Modifier and TypeField and Description
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static ClassLoader
public static Config

Returns:

the default application.conf or system-property-configured configuration
defaultApplication
()

Obtains the default application-specific configuration, which defaults to parsing application.conf, application.json, and application.properties on the classpath, but can also be rerouted using the config.file, config.resource, and config.url system properties.

public static Config

Returns:

the default application configuration
defaultApplication
(ClassLoader
class loader to look for resources in
loader
)

Like defaultApplication() but allows you to specify a class loader to use rather than the current context class loader.

public static Config

Returns:

the default application configuration
defaultApplication
(ConfigParseOptions
the options
options
)

Like defaultApplication() but allows you to specify parse options.

public static Config

Returns:

the default override configuration
defaultOverrides
()

Obtains the default override configuration, which currently consists of system properties.

public static Config

Returns:

the default override configuration
defaultOverrides
(ClassLoader
class loader to look for resources in
loader
)

Like defaultOverrides() but allows you to specify a class loader to use rather than the current context class loader.

public static Config

Returns:

the default reference config for context class loader
defaultReference
()

Obtains the default reference configuration, which is currently created by merging all resources "reference.conf" found on the classpath and overriding the result with system properties.

public static Config

Returns:

the default reference config for this class loader
defaultReference
(ClassLoader
class loader to look for resources in
loader
)

Like defaultReference() but allows you to specify a class loader to use rather than the current context class loader.

public static Config

Returns:

the unresolved default reference config for the context class loader
defaultReferenceUnresolved
()

Obtains the default reference configuration, which is currently created by merging all resources "reference.conf" found on the classpath and overriding the result with system properties.

public static Config

Returns:

the unresolved default reference config for this class loader
defaultReferenceUnresolved
(ClassLoader
class loader to look for resources in
loader
)

Like defaultReferenceUnresolved() but allows you to specify a class loader to use rather than the current context class loader.

public static Config

Returns:

an empty configuration
empty
()

Gets an empty configuration.

public static Config

Returns:

an empty configuration
empty
(String
description of the config
originDescription
)

Gets an empty configuration with a description to be used to create a ConfigOrigin for this Config.

private static ConfigParseOptions
private static ConfigLoadingStrategy
private static Boolean
public static void
invalidateCaches()

Reloads any cached configs, picking up changes to system properties for example.

public static Config

Returns:

configuration for an application relative to context class loader
load
(String
name (optionally without extension) of a resource on classpath
resourceBasename
)

Loads an application's configuration from the given classpath resource or classpath resource basename, sandwiches it between default reference config and default overrides, and then resolves it.

public static Config

Returns:

configuration for an application relative to given class loader
load
(ClassLoader
class loader to look for resources in
loader
,
String
basename (no .conf/.json/.properties suffix)
resourceBasename
)

Like load(String) but uses the supplied class loader instead of the current thread's context class loader.

public static Config

Returns:

configuration for an application
load
(String
the classpath resource name with optional extension
resourceBasename
,
ConfigParseOptions
options to use when parsing the resource
parseOptions
,
ConfigResolveOptions
options to use when resolving the stack
resolveOptions
)

Like load(String) but allows you to specify parse and resolve options.

public static Config

Returns:

configuration for an application
load
(ClassLoader
class loader in which to find resources (overrides loader in parse options)
loader
,
String
the classpath resource name with optional extension
resourceBasename
,
ConfigParseOptions
options to use when parsing the resource (class loader overridden)
parseOptions
,
ConfigResolveOptions
options to use when resolving the stack
resolveOptions
)

Like load(String, ConfigParseOptions, ConfigResolveOptions) but has a class loader parameter that overrides any from the ConfigParseOptions.

public static Config

Returns:

resolved configuration with overrides and fallbacks added
load
(Config
the application's portion of the configuration
config
)

Assembles a standard configuration using a custom Config object rather than loading "application.conf".

public static Config

Returns:

resolved configuration with overrides and fallbacks added
load
(ClassLoader
the class loader to use to find resources
loader
,
Config
the application's portion of the configuration
config
)

Like load(Config) but allows you to specify the class loader for looking up resources.

public static Config

Returns:

resolved configuration with overrides and fallbacks added
load
(Config
the application's portion of the configuration
config
,
ConfigResolveOptions
options for resolving the assembled config stack
resolveOptions
)

Like load(Config) but allows you to specify ConfigResolveOptions.

public static Config

Returns:

resolved configuration with overrides and fallbacks added
load
(ClassLoader
class loader to use when looking up override and reference configs
loader
,
Config
the application's portion of the configuration
config
,
ConfigResolveOptions
options for resolving the assembled config stack
resolveOptions
)

Like load(Config, ConfigResolveOptions) but allows you to specify a class loader other than the context class loader.

public static Config

Returns:

configuration for an application
load
()

Loads a default configuration, equivalent to load(defaultApplication()) in most cases.

public static Config

Returns:

configuration for an application
load
(ConfigParseOptions
Options for parsing resources
parseOptions
)

Like load() but allows specifying parse options.

public static Config

Returns:

configuration for an application
load
(final ClassLoader
class loader for finding resources
loader
)

Like load() but allows specifying a class loader other than the thread's current context class loader.

public static Config

Returns:

configuration for an application
load
(ClassLoader
class loader for finding resources (overrides any loader in parseOptions)
loader
,
ConfigParseOptions
Options for parsing resources
parseOptions
)

Like load() but allows specifying a class loader other than the thread's current context class loader and also specify parse options.

public static Config

Returns:

configuration for an application
load
(ClassLoader
class loader for finding resources
loader
,
ConfigResolveOptions
options for resolving the assembled config stack
resolveOptions
)

Like load() but allows specifying a class loader other than the thread's current context class loader and also specify resolve options.

public static Config

Returns:

configuration for an application
load
(ClassLoader
class loader for finding resources (overrides any loader in parseOptions)
loader
,
ConfigParseOptions
Options for parsing resources
parseOptions
,
ConfigResolveOptions
options for resolving the assembled config stack
resolveOptions
)

Like load() but allows specifying a class loader other than the thread's current context class loader, parse options, and resolve options.

public static Config

Returns:

configuration for an application
load
(ConfigParseOptions
Options for parsing resources
parseOptions
,
final ConfigResolveOptions
options for resolving the assembled config stack
resolveOptions
)

Like load() but allows specifying parse options and resolve options.

public static Optional<Config>

Returns:

a java.util.Optional containing any specified replacement, or Optional#empty() if none was specified.
parseApplicationReplacement
()

Parse only any application replacement (specified by one of config.{resource,file,url}), returning an empty Config if no overrides were set.

public static Optional<Config>

Returns:

a java.util.Optional containing any specified replacement, or Optional#empty() if none was specified.
parseApplicationReplacement
(ClassLoader
the class loader
loader
)

Like parseApplicationReplacement() but allows you to specify a class loader ti yse rather than the current context class loader.

public static Optional<Config>

Returns:

a java.util.Optional containing any specified replacement, or Optional#empty() if none was specified.
parseApplicationReplacement
(ConfigParseOptions
parse options
parseOptions
)

Like parseApplicationReplacement() but allows you to specify parse options.

public static Config

Returns:

the parsed configuration
parseFile
(File
the file to parse
file
,
ConfigParseOptions
parse options to control how the file is interpreted
options
)

Parses a file into a Config instance.

public static Config

Returns:

the parsed configuration
parseFile
(File
the file to parse
file
)

Parses a file into a Config instance as with parseFile(File, ConfigParseOptions) but always uses the default parse options.

public static Config

Returns:

the parsed configuration
parseFileAnySyntax
(File
a filename with or without extension
fileBasename
,
ConfigParseOptions
parse options
options
)

Parses a file with a flexible extension.

public static Config

Returns:

the parsed configuration
parseFileAnySyntax
(File
a filename with or without extension
fileBasename
)

Like parseFileAnySyntax(File, ConfigParseOptions) but always uses default parse options.

public static Config

Returns:

the map converted to a Config
parseMap
(Map<String, ? extends Object>
map from paths to plain Java objects
values
,
String
description of what this map represents, like a filename, or "default settings" (origin description is used in error messages)
originDescription
)

Creates a Config based on a java.util.Map from paths to plain Java values.

public static Config

Returns:

the map converted to a Config
parseMap
(Map<String, ? extends Object>
map from paths to plain Java values
values
)

See the other overload of parseMap(Map, String) for details, this one just uses a default origin description.

public static Config

Returns:

the parsed configuration
parseProperties
(Properties
a Java Properties object
properties
,
ConfigParseOptions
the parse options
options
)

Converts a Java java.util.Properties object to a ConfigObject using the rules documented in the HOCON spec.

public static Config

Returns:

the parsed configuration
parseProperties
(Properties
a Java Properties object
properties
)

Like parseProperties(Properties, ConfigParseOptions) but uses default parse options.

public static Config

Returns:

the parsed configuration
parseReader
(Reader
the reader to parse
reader
,
ConfigParseOptions
parse options to control how the reader is interpreted
options
)

Parses a Reader into a Config instance.

public static Config

Returns:

the parsed configuration
parseReader
(Reader
the reader to parse
reader
)

Parses a reader into a Config instance as with parseReader(Reader, ConfigParseOptions) but always uses the default parse options.

public static Config

Returns:

the parsed configuration
parseResources
(Class<?>
klass.getClassLoader() will be used to load resources, and non-absolute resource names will have this class's package added
klass
,
String
resource to look up, relative to klass's package or absolute starting with a "/"
resource
,
ConfigParseOptions
parse options
options
)

Parses all resources on the classpath with the given name and merges them into a single Config.

public static Config

Returns:

the parsed configuration
parseResources
(Class<?>
klass.getClassLoader() will be used to load resources, and non-absolute resource names will have this class's package added
klass
,
String
resource to look up, relative to klass's package or absolute starting with a "/"
resource
)

Like parseResources(Class, String, ConfigParseOptions) but always uses default parse options.

public static Config

Returns:

the parsed configuration
parseResources
(ClassLoader
will be used to load resources by setting this loader on the provided options
loader
,
String
resource to look up
resource
,
ConfigParseOptions
parse options (class loader is ignored)
options
)

Parses all resources on the classpath with the given name and merges them into a single Config.

public static Config

Returns:

the parsed configuration
parseResources
(ClassLoader
will be used to load resources
loader
,
String
resource to look up in the loader
resource
)

Like parseResources(ClassLoader, String, ConfigParseOptions) but always uses default parse options.

public static Config

Returns:

the parsed configuration
parseResources
(String
the resource name
resource
,
ConfigParseOptions
parse options
options
)

Like parseResources(ClassLoader, String, ConfigParseOptions) but uses thread's current context class loader if none is set in the ConfigParseOptions.

public static Config

Returns:

the parsed configuration
parseResources
(String
the resource name
resource
)

Like parseResources(ClassLoader, String) but uses thread's current context class loader.

public static Config

Returns:

the parsed configuration
parseResourcesAnySyntax
(Class<?>
class which determines the ClassLoader and the package for relative resource names
klass
,
String
a resource name as in java.lang.Class#getResource, with or without extension
resourceBasename
,
ConfigParseOptions
parse options (class loader is ignored in favor of the one from klass)
options
)

Parses classpath resources with a flexible extension.

public static Config

Returns:

the parsed configuration
parseResourcesAnySyntax
(Class<?>
klass.getClassLoader() will be used to load resources, and non-absolute resource names will have this class's package added
klass
,
String
a resource name as in java.lang.Class#getResource, with or without extension
resourceBasename
)

Like parseResourcesAnySyntax(Class, String, ConfigParseOptions) but always uses default parse options.

public static Config

Returns:

the parsed configuration
parseResourcesAnySyntax
(ClassLoader
class loader to look up resources in, will be set on options
loader
,
String
a resource name as in java.lang.ClassLoader#getResource, with or without extension
resourceBasename
,
ConfigParseOptions
parse options (class loader ignored)
options
)

Parses classpath resources with a flexible extension.

public static Config

Returns:

the parsed configuration
parseResourcesAnySyntax
(ClassLoader
will be used to load resources
loader
,
String
a resource name as in java.lang.ClassLoader#getResource, with or without extension
resourceBasename
)

Like parseResourcesAnySyntax(ClassLoader, String, ConfigParseOptions) but always uses default parse options.

public static Config

Returns:

the parsed configuration
parseResourcesAnySyntax
(String
the resource basename (no file type suffix)
resourceBasename
,
ConfigParseOptions
parse options
options
)

Like parseResourcesAnySyntax(ClassLoader, String, ConfigParseOptions) but uses thread's current context class loader.

public static Config

Returns:

the parsed configuration
parseResourcesAnySyntax
(String
the resource basename (no file type suffix)
resourceBasename
)

Like parseResourcesAnySyntax(ClassLoader, String) but uses thread's current context class loader.

public static Config

Returns:

the parsed configuration
parseString
(String
string to parse
s
,
ConfigParseOptions
parse options
options
)

Parses a string (which should be valid HOCON or JSON by default, or the syntax specified in the options otherwise).

public static Config

Returns:

the parsed configuration
parseString
(String
string to parse
s
)

Parses a string (which should be valid HOCON or JSON).

public static Config

Returns:

the parsed configuration
parseURL
(URL
the url to parse
url
,
ConfigParseOptions
parse options to control how the url is interpreted
options
)

Parses a URL into a Config instance.

public static Config

Returns:

the parsed configuration
parseURL
(URL
the url to parse
url
)

Parses a url into a Config instance as with parseURL(URL, ConfigParseOptions) but always uses the default parse options.

public static Config

Returns:

system environment variables parsed into a Config
systemEnvironment
()

Gets a Config containing the system's environment variables.

public static Config

Returns:

system environment variable overrides parsed into a Config
systemEnvironmentOverrides
()

Gets a Config containing the system's environment variables used to override configuration keys.

public static Config

Returns:

system properties parsed into a Config
systemProperties
()

Gets a Config containing the system properties from java.lang.System#getProperties(), parsed and converted as with parseProperties.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait