Class ConfigMerger
java.lang.Object
org.apache.tika.pipes.core.config.ConfigMerger
Utility for merging configuration overrides with existing Tika JSON configuration.
This class centralizes the config generation logic that was previously duplicated in:
- PipesForkParser.generateJsonConfig()
- TikaServerProcess.createDefaultConfig() and ensureServerComponents()
- TikaAsyncCLI.PluginsWriter and ensurePluginRoots()
Key design decisions:
- Uses UUID-based names for internal fetchers/emitters to avoid conflicts with user-configured components
- Returns a MergeResult containing the config path and generated names so callers can use them
- Preserves existing config sections when merging
- Creates temp files that are marked for deletion on JVM exit
Example usage:
ConfigOverrides overrides = ConfigOverrides.builder()
.addFetcher("my-fetcher", "file-system-fetcher",
Map.of("basePath", "/tmp/input"))
.setPipesConfig(4, null)
.setEmitStrategy(EmitStrategy.PASSBACK_ALL)
.build();
MergeResult result = ConfigMerger.mergeOrCreate(existingConfigPath, overrides);
// Use result.configPath() for PipesParser.load()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of a config merge operation. -
Method Summary
Modifier and TypeMethodDescriptionstatic ConfigMerger.MergeResultmergeOrCreate(Path existingConfig, ConfigOverrides overrides) Merges overrides with an existing config, or creates a new config if none exists.
-
Method Details
-
mergeOrCreate
public static ConfigMerger.MergeResult mergeOrCreate(Path existingConfig, ConfigOverrides overrides) throws IOException Merges overrides with an existing config, or creates a new config if none exists.For fetchers and emitters without explicit IDs in the overrides, UUID-based names are generated to avoid conflicts with user-configured components.
- Parameters:
existingConfig- path to existing config (may be null)overrides- the overrides to apply- Returns:
- MergeResult containing path to merged config and generated fetcher ID
- Throws:
IOException- if file operations fail
-