Class FetcherManager
java.lang.Object
org.apache.tika.pipes.core.AbstractComponentManager<Fetcher,FetcherFactory>
org.apache.tika.pipes.core.fetcher.FetcherManager
Utility class to hold multiple fetchers.
This forbids multiple fetchers with the same pluginId. Fetchers are instantiated lazily on first use.
-
Field Summary
Fields inherited from class org.apache.tika.pipes.core.AbstractComponentManager
pluginManager -
Method Summary
Modifier and TypeMethodDescriptionprotected TikaExceptioncreateNotFoundException(String message) Creates a not-found exception for this component type.voiddeleteFetcher(String fetcherId) Deletes a fetcher configuration by ID.protected StringReturns the component name for error messages (e.g., "fetcher", "emitter").Gets the configuration for a specific fetcher by ID.protected StringReturns the JSON configuration key for this component type (e.g., "fetchers", "emitters").protected Class<FetcherFactory>Returns the factory class for this component type.Convenience method that returns a fetcher if only one fetcher is configured.getFetcher(String id) Gets a fetcher by ID, lazily instantiating it if needed.static FetcherManagerload(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig) Loads a FetcherManager without allowing runtime modifications.static FetcherManagerload(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig, boolean allowRuntimeModifications) Loads a FetcherManager with optional support for runtime modifications.static FetcherManagerload(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig, boolean allowRuntimeModifications, ConfigStore configStore) Loads a FetcherManager with optional support for runtime modifications and a custom config store.voidsaveFetcher(ExtensionConfig config) Dynamically adds or updates a fetcher configuration at runtime.Methods inherited from class org.apache.tika.pipes.core.AbstractComponentManager
deleteComponent, getComponent, getComponent, getComponentConfig, getConfigStore, getFactories, getSupported, saveComponent, validateAndCollectConfigs
-
Method Details
-
load
public static FetcherManager load(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig) throws TikaConfigException, IOException Loads a FetcherManager without allowing runtime modifications. Useload(PluginManager, TikaJsonConfig, boolean)to enable runtime fetcher additions.- Parameters:
pluginManager- the plugin managertikaJsonConfig- the configuration- Returns:
- a FetcherManager that does not allow runtime modifications
- Throws:
TikaConfigExceptionIOException
-
load
public static FetcherManager load(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig, boolean allowRuntimeModifications) throws TikaConfigException, IOException Loads a FetcherManager with optional support for runtime modifications.- Parameters:
pluginManager- the plugin managertikaJsonConfig- the configurationallowRuntimeModifications- if true, allows callingsaveFetcher(ExtensionConfig)to add fetchers at runtime- Returns:
- a FetcherManager
- Throws:
TikaConfigExceptionIOException
-
load
public static FetcherManager load(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig, boolean allowRuntimeModifications, ConfigStore configStore) throws TikaConfigException, IOException Loads a FetcherManager with optional support for runtime modifications and a custom config store.- Parameters:
pluginManager- the plugin managertikaJsonConfig- the configurationallowRuntimeModifications- if true, allows callingsaveFetcher(ExtensionConfig)to add fetchers at runtimeconfigStore- custom config store implementation, or null to use default in-memory store- Returns:
- a FetcherManager
- Throws:
TikaConfigExceptionIOException
-
getConfigKey
Description copied from class:AbstractComponentManagerReturns the JSON configuration key for this component type (e.g., "fetchers", "emitters").- Specified by:
getConfigKeyin classAbstractComponentManager<Fetcher,FetcherFactory>
-
getFactoryClass
Description copied from class:AbstractComponentManagerReturns the factory class for this component type.- Specified by:
getFactoryClassin classAbstractComponentManager<Fetcher,FetcherFactory>
-
getComponentName
Description copied from class:AbstractComponentManagerReturns the component name for error messages (e.g., "fetcher", "emitter").- Specified by:
getComponentNamein classAbstractComponentManager<Fetcher,FetcherFactory>
-
createNotFoundException
Description copied from class:AbstractComponentManagerCreates a not-found exception for this component type.- Specified by:
createNotFoundExceptionin classAbstractComponentManager<Fetcher,FetcherFactory>
-
getFetcher
Gets a fetcher by ID, lazily instantiating it if needed.- Parameters:
id- the fetcher ID- Returns:
- the fetcher
- Throws:
FetcherNotFoundException- if no fetcher with the given ID existsIOException- if there's an error building the fetcherTikaException- if there's a configuration error
-
getFetcher
Convenience method that returns a fetcher if only one fetcher is configured. If 0 or > 1 fetchers are configured, this throws an IllegalArgumentException.- Returns:
- the single configured fetcher
- Throws:
IOException- if there's an error building the fetcherTikaException- if there's a configuration error
-
saveFetcher
Dynamically adds or updates a fetcher configuration at runtime. The fetcher will not be instantiated until it is first requested viagetFetcher(String). This allows for dynamic configuration without the overhead of immediate instantiation. If a fetcher with the same ID already exists, it will be replaced and the cached instance cleared.This method is only available if the FetcherManager was loaded with
load(PluginManager, TikaJsonConfig, boolean)with allowRuntimeModifications=true.Only authorized/authenticated users should be allowed to modify fetchers. BE CAREFUL.
- Parameters:
config- the extension configuration for the fetcher- Throws:
TikaConfigException- if the fetcher type is unknown or if runtime modifications are not allowedIOException- if there is an error accessing the plugin manager
-
deleteFetcher
Deletes a fetcher configuration by ID.- Parameters:
fetcherId- the fetcher ID to delete- Throws:
TikaConfigException- if runtime modifications are not allowed or fetcher not found
-
getConfig
Gets the configuration for a specific fetcher by ID.- Parameters:
fetcherId- the fetcher ID- Returns:
- the fetcher configuration, or null if not found
-