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 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

      protected abstract String getConfigKey()
      Returns the JSON configuration key for this component type (e.g., "fetchers", "emitters").
    • getConfigStore

      protected ConfigStore getConfigStore()
      Returns the config store used by this manager. Useful for subclasses that need direct access to the store.
    • getFactoryClass

      protected abstract Class<F> getFactoryClass()
      Returns the factory class for this component type.
    • getComponentName

      protected abstract String getComponentName()
      Returns the component name for error messages (e.g., "fetcher", "emitter").
    • createNotFoundException

      protected abstract TikaException createNotFoundException(String message)
      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:
      TikaConfigException
      IOException
    • getFactories

      protected Map<String,F> getFactories(org.pf4j.PluginManager pluginManager) throws TikaConfigException
      Throws:
      TikaConfigException
    • getComponent

      public T getComponent(String id) throws IOException, TikaException
      Gets a component by ID, lazily instantiating it if needed.
      Throws:
      IOException
      TikaException
    • saveComponent

      public void saveComponent(ExtensionConfig config) throws TikaConfigException, IOException
      Dynamically adds or updates a component configuration at runtime. The component will not be instantiated until it is first requested via getComponent(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 allowed
      IOException - if there is an error accessing the plugin manager
    • deleteComponent

      public void deleteComponent(String componentId) throws TikaConfigException
      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

      public ExtensionConfig getComponentConfig(String componentId)
      Gets the configuration for a specific component by ID.
      Parameters:
      componentId - the component ID
      Returns:
      the component configuration, or null if not found
    • getSupported

      public Set<String> getSupported()
      Returns the set of supported component IDs.
    • getComponent

      public T getComponent() throws IOException, TikaException
      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:
      IOException
      TikaException