Class ConfigTransformer

java.lang.Object
org.apache.kafka.common.config.ConfigTransformer

public class ConfigTransformer
extends Object
This class wraps a set of ConfigProvider instances and uses them to perform transformations.

The default variable pattern is of the form ${provider:[path:]key}, where the provider corresponds to a ConfigProvider instance, as passed to ConfigTransformer(Map). The pattern will extract a set of paths (which are optional) and keys and then pass them to ConfigProvider.get(String, Set) to obtain the values with which to replace the variables.

For example, if a Map consisting of an entry with a provider name "file" and provider instance FileConfigProvider is passed to the ConfigTransformer(Map), and a Properties file with contents

 fileKey=someValue
 
resides at the path "/tmp/properties.txt", then when a configuration Map which has an entry with a key "someKey" and a value "${file:/tmp/properties.txt:fileKey}" is passed to the transform(Map) method, then the transformed Map will have an entry with key "someKey" and a value "someValue".

This class only depends on ConfigProvider.get(String, Set) and does not depend on subscription support in a ConfigProvider, such as the ConfigProvider.subscribe(String, Set, ConfigChangeCallback) and ConfigProvider.unsubscribe(String, Set, ConfigChangeCallback) methods.

  • Field Details

    • DEFAULT_PATTERN

      public static final Pattern DEFAULT_PATTERN
  • Constructor Details

    • ConfigTransformer

      public ConfigTransformer​(Map<String,​ConfigProvider> configProviders)
      Creates a ConfigTransformer with the default pattern, of the form ${provider:[path:]key}.
      Parameters:
      configProviders - a Map of provider names and ConfigProvider instances.
  • Method Details