- java.lang.Object
-
- io.rxmicro.config.Configs.Builder
-
-
Constructor Summary
Constructors Constructor Description Builder()
Creates defaultConfigs.Builder
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
build()
Creates a new immutable instance of theConfigs
manager.void
buildIfNotConfigured()
Creates a new immutable instance of theConfigs
manager only if it not be created before.Configs.Builder
withAllConfigSources()
Enables all supported config sources according to natural order.Configs.Builder
withCommandLineArguments(String... args)
Enables the config reading from command line arguments.Configs.Builder
withConfig(String namespace, Config config)
Allows adding the configuration using java classes with custom namespace.Configs.Builder
withConfigs(Config... configs)
Allows adding configurations using java classes with default namespace.Configs.Builder
withConfigs(Map<String,Config> configs)
Allows adding the configuration using java classes with custom namespace.Configs.Builder
withContainerConfigSources()
Enables config sources according to recommended order for docker or kubernetes environments.Configs.Builder
withOrderedConfigSources(ConfigSource... sources)
Allows changing the order of the configuration reading.Configs.Builder
withoutAnyConfigSources()
Disables all configuration sources.
-
-
-
Constructor Detail
-
Builder
public Builder()
Creates defaultConfigs.Builder
instance.
-
-
Method Detail
-
withConfig
public Configs.Builder withConfig(String namespace, Config config)
Allows adding the configuration using java classes with custom namespace.- Parameters:
namespace
- the custom namespaceconfig
- the created by developer config instance- Returns:
- the reference to this
Configs.Builder
instance
-
withConfigs
public Configs.Builder withConfigs(Config... configs)
Allows adding configurations using java classes with default namespace.The RxMicro framework uses
Config.getDefaultNameSpace(Class)
method to define a default namespace.- Parameters:
configs
- the var args of config instances- Returns:
- the reference to this
Configs.Builder
instance
-
withConfigs
public Configs.Builder withConfigs(Map<String,Config> configs)
Allows adding the configuration using java classes with custom namespace.- Parameters:
configs
- the map that contains entries with custom namespaces and config instances.- Returns:
- the reference to this
Configs.Builder
instance
-
withOrderedConfigSources
public Configs.Builder withOrderedConfigSources(ConfigSource... sources)
Allows changing the order of the configuration reading.- Parameters:
sources
- the custom order of the configuration reading- Returns:
- the reference to this
Configs.Builder
instance
-
withoutAnyConfigSources
public Configs.Builder withoutAnyConfigSources()
Disables all configuration sources.This method can be useful for tests.
- Returns:
- the reference to this
Configs.Builder
instance
-
withAllConfigSources
public Configs.Builder withAllConfigSources()
Enables all supported config sources according to natural order.Natural order is defined by
ConfigSource
enum.- Returns:
- the reference to this
Configs.Builder
instance
-
withContainerConfigSources
public Configs.Builder withContainerConfigSources()
Enables config sources according to recommended order for docker or kubernetes environments.Recommended order for docker or kubernetes environments:
- Hardcoded config using annotations.
- Config from env variables.
- Config from file:
~/.rxmicro/${name_space}.properties
- Returns:
- the reference to this
Configs.Builder
instance
-
withCommandLineArguments
public Configs.Builder withCommandLineArguments(String... args)
Enables the config reading from command line arguments.This type of configuration has the highest priority and overrides all other types.
(Except of configuration using Java classes.)
- Parameters:
args
- command line arguments- Returns:
- the reference to this
Configs.Builder
instance
-
build
public void build()
Creates a new immutable instance of theConfigs
manager.Each subsequent invocation of this method overrides all configuration manager settings.
(In any microservice project there is only one configuration manager object!)
It means that if the developer creates several
Configs.Builder
instances, it will be the last invocation of the build method that matters, the others will be ignored.
-
buildIfNotConfigured
public void buildIfNotConfigured()
Creates a new immutable instance of theConfigs
manager only if it not be created before.
-
-