Package org.apache.tika.pipes.core
Class AbstractComponentManager<T extends TikaExtension,F extends TikaExtensionFactory<T>>
java.lang.Object
org.apache.tika.pipes.core.AbstractComponentManager<T,F>
- Type Parameters:
T- the component type (e.g., Fetcher, Emitter)F- the factory type for creating components
- Direct Known Subclasses:
EmitterManager,FetcherManager
public abstract class AbstractComponentManager<T extends TikaExtension,F extends TikaExtensionFactory<T>>
extends Object
Abstract base class for managing Tika components (Fetchers, Emitters, etc.).
Provides lazy instantiation, early validation, and optional runtime modifications.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractComponentManager(org.pf4j.PluginManager pluginManager, Map<String, ExtensionConfig> componentConfigs, boolean allowRuntimeModifications) protectedAbstractComponentManager(org.pf4j.PluginManager pluginManager, Map<String, ExtensionConfig> componentConfigs, boolean allowRuntimeModifications, ConfigStore configStore) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TikaExceptioncreateNotFoundException(String message) Creates a not-found exception for this component type.voiddeleteComponent(String componentId) Deletes a component configuration by ID.Convenience method that returns a component if only one component is configured.getComponent(String id) Gets a component by ID, lazily instantiating it if needed.getComponentConfig(String componentId) Gets the configuration for a specific component by ID.protected abstract StringReturns the component name for error messages (e.g., "fetcher", "emitter").protected abstract StringReturns the JSON configuration key for this component type (e.g., "fetchers", "emitters").protected ConfigStoreReturns the config store used by this manager.getFactories(org.pf4j.PluginManager pluginManager) Returns the factory class for this component type.Returns the set of supported component IDs.voidsaveComponent(ExtensionConfig config) Dynamically adds or updates a component configuration at runtime.protected Map<String,ExtensionConfig> validateAndCollectConfigs(org.pf4j.PluginManager pluginManager, com.fasterxml.jackson.databind.JsonNode configNode) Validates the configuration and collects component configs without instantiating.
-
Field Details
-
pluginManager
protected final org.pf4j.PluginManager pluginManager
-
-
Constructor Details
-
AbstractComponentManager
protected AbstractComponentManager(org.pf4j.PluginManager pluginManager, Map<String, ExtensionConfig> componentConfigs, boolean allowRuntimeModifications) -
AbstractComponentManager
protected AbstractComponentManager(org.pf4j.PluginManager pluginManager, Map<String, ExtensionConfig> componentConfigs, boolean allowRuntimeModifications, ConfigStore configStore)
-
-
Method Details
-
getConfigKey
Returns the JSON configuration key for this component type (e.g., "fetchers", "emitters"). -
getConfigStore
Returns the config store used by this manager. Useful for subclasses that need direct access to the store. -
getFactoryClass
Returns the factory class for this component type. -
getComponentName
Returns the component name for error messages (e.g., "fetcher", "emitter"). -
createNotFoundException
Creates a not-found exception for this component type. -
validateAndCollectConfigs
protected Map<String,ExtensionConfig> validateAndCollectConfigs(org.pf4j.PluginManager pluginManager, com.fasterxml.jackson.databind.JsonNode configNode) throws TikaConfigException, IOException Validates the configuration and collects component configs without instantiating.- Throws:
TikaConfigExceptionIOException
-
getFactories
protected Map<String,F> getFactories(org.pf4j.PluginManager pluginManager) throws TikaConfigException - Throws:
TikaConfigException
-
getComponent
Gets a component by ID, lazily instantiating it if needed.- Throws:
IOExceptionTikaException
-
saveComponent
Dynamically adds or updates a component configuration at runtime. The component will not be instantiated until it is first requested viagetComponent(String). If a component with the same ID already exists, it will be replaced and the cached instance cleared.This method is only available if the manager was loaded with allowRuntimeModifications=true.
Only authorized/authenticated users should be allowed to modify components. BE CAREFUL.
- Parameters:
config- the extension configuration for the component- Throws:
TikaConfigException- if the component type is unknown or if runtime modifications are not allowedIOException- if there is an error accessing the plugin manager
-
deleteComponent
Deletes a component configuration by ID. Clears the cached instance and removes the configuration.- Parameters:
componentId- the component ID to delete- Throws:
TikaConfigException- if runtime modifications are not allowed or component not found
-
getComponentConfig
Gets the configuration for a specific component by ID.- Parameters:
componentId- the component ID- Returns:
- the component configuration, or null if not found
-
getSupported
Returns the set of supported component IDs. -
getComponent
Convenience method that returns a component if only one component is configured. If 0 or > 1 components are configured, this throws an IllegalArgumentException.- Returns:
- the single configured component
- Throws:
IOExceptionTikaException
-