Class EmitterManager
java.lang.Object
org.apache.tika.pipes.core.AbstractComponentManager<Emitter,EmitterFactory>
org.apache.tika.pipes.core.emitter.EmitterManager
Utility class that will apply the appropriate emitter
to the emitterString based on the prefix.
This does not allow multiple emitters supporting the same prefix. Emitters 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.voiddeleteEmitter(String emitterId) Deletes an emitter configuration by ID.protected StringReturns the component name for error messages (e.g., "fetcher", "emitter").Gets the configuration for a specific emitter by ID.protected StringReturns the JSON configuration key for this component type (e.g., "fetchers", "emitters").Convenience method that returns an emitter if only one emitter is configured.getEmitter(String emitterName) Gets an emitter by ID, lazily instantiating it if needed.protected Class<EmitterFactory>Returns the factory class for this component type.static EmitterManagerload(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig) Loads an EmitterManager without allowing runtime modifications.static EmitterManagerload(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig, boolean allowRuntimeModifications) Loads an EmitterManager with optional support for runtime modifications.static EmitterManagerload(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig, boolean allowRuntimeModifications, ConfigStore configStore) Loads an EmitterManager with optional support for runtime modifications and a custom config store.voidsaveEmitter(ExtensionConfig config) Dynamically adds or updates an emitter 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 EmitterManager load(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig) throws IOException, TikaConfigException Loads an EmitterManager without allowing runtime modifications. Useload(PluginManager, TikaJsonConfig, boolean)to enable runtime emitter additions.- Parameters:
pluginManager- the plugin managertikaJsonConfig- the configuration- Returns:
- an EmitterManager that does not allow runtime modifications
- Throws:
IOExceptionTikaConfigException
-
load
public static EmitterManager load(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig, boolean allowRuntimeModifications) throws IOException, TikaConfigException Loads an EmitterManager with optional support for runtime modifications.- Parameters:
pluginManager- the plugin managertikaJsonConfig- the configurationallowRuntimeModifications- if true, allows callingsaveEmitter(ExtensionConfig)to add emitters at runtime- Returns:
- an EmitterManager
- Throws:
IOExceptionTikaConfigException
-
load
public static EmitterManager load(org.pf4j.PluginManager pluginManager, TikaJsonConfig tikaJsonConfig, boolean allowRuntimeModifications, ConfigStore configStore) throws IOException, TikaConfigException Loads an EmitterManager with optional support for runtime modifications and a custom config store.- Parameters:
pluginManager- the plugin managertikaJsonConfig- the configurationallowRuntimeModifications- if true, allows callingsaveEmitter(ExtensionConfig)to add emitters at runtimeconfigStore- custom config store implementation, or null to use default in-memory store- Returns:
- an EmitterManager
- Throws:
IOExceptionTikaConfigException
-
getConfigKey
Description copied from class:AbstractComponentManagerReturns the JSON configuration key for this component type (e.g., "fetchers", "emitters").- Specified by:
getConfigKeyin classAbstractComponentManager<Emitter,EmitterFactory>
-
getFactoryClass
Description copied from class:AbstractComponentManagerReturns the factory class for this component type.- Specified by:
getFactoryClassin classAbstractComponentManager<Emitter,EmitterFactory>
-
getComponentName
Description copied from class:AbstractComponentManagerReturns the component name for error messages (e.g., "fetcher", "emitter").- Specified by:
getComponentNamein classAbstractComponentManager<Emitter,EmitterFactory>
-
createNotFoundException
Description copied from class:AbstractComponentManagerCreates a not-found exception for this component type.- Specified by:
createNotFoundExceptionin classAbstractComponentManager<Emitter,EmitterFactory>
-
getEmitter
Gets an emitter by ID, lazily instantiating it if needed.- Parameters:
emitterName- the emitter ID- Returns:
- the emitter
- Throws:
EmitterNotFoundException- if no emitter with the given ID existsIOException- if there's an error building the emitterTikaException- if there's a configuration error
-
getEmitter
Convenience method that returns an emitter if only one emitter is configured. If 0 or > 1 emitters are configured, this throws an IllegalArgumentException.- Returns:
- the single configured emitter
- Throws:
IOException- if there's an error building the emitterTikaException- if there's a configuration error
-
saveEmitter
Dynamically adds or updates an emitter configuration at runtime. The emitter will not be instantiated until it is first requested viagetEmitter(String). This allows for dynamic configuration without the overhead of immediate instantiation. If an emitter with the same ID already exists, it will be replaced and the cached instance cleared.This method is only available if the EmitterManager was loaded with
load(PluginManager, TikaJsonConfig, boolean)with allowRuntimeModifications=true.Only authorized/authenticated users should be allowed to modify emitters. BE CAREFUL.
- Parameters:
config- the extension configuration for the emitter- Throws:
TikaConfigException- if the emitter type is unknown or if runtime modifications are not allowedIOException- if there is an error accessing the plugin manager
-
deleteEmitter
Deletes an emitter configuration by ID.- Parameters:
emitterId- the emitter ID to delete- Throws:
TikaConfigException- if runtime modifications are not allowed or emitter not found
-
getConfig
Gets the configuration for a specific emitter by ID.- Parameters:
emitterId- the emitter ID- Returns:
- the emitter configuration, or null if not found
-