Package org.apache.tika.plugins
Class TikaPluginManager
java.lang.Object
org.pf4j.AbstractPluginManager
org.pf4j.DefaultPluginManager
org.apache.tika.plugins.TikaPluginManager
- All Implemented Interfaces:
org.pf4j.PluginManager
public class TikaPluginManager
extends org.pf4j.DefaultPluginManager
PF4J-based plugin manager for Tika pipes components.
This manager loads plugins from configured plugin root directories and makes their extensions available for discovery.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.pf4j.AbstractPluginManager
org.pf4j.AbstractPluginManager.ResolveRecoveryStrategy -
Field Summary
Fields inherited from class org.pf4j.DefaultPluginManager
PLUGINS_DIR_CONFIG_PROPERTY_NAMEFields inherited from class org.pf4j.AbstractPluginManager
DEFAULT_PLUGINS_DIR, dependencyResolver, DEVELOPMENT_PLUGINS_DIR, exactVersionAllowed, extensionFactory, extensionFinder, MODE_PROPERTY_NAME, pluginClassLoaders, pluginDescriptorFinder, pluginFactory, pluginLoader, pluginRepository, plugins, PLUGINS_DIR_PROPERTY_NAME, pluginsRoots, pluginStateListeners, pluginStatusProvider, resolvedPlugins, resolveRecoveryStrategy, runtimeMode, startedPlugins, systemVersion, unresolvedPlugins, versionManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.pf4j.ExtensionFinderOverride to disable classpath scanning for extensions.protected org.pf4j.PluginDescriptorFinderOverride to use PropertiesPluginDescriptorFinder in development mode.protected org.pf4j.PluginRepositoryOverride to prevent scanning subdirectories in development mode.static TikaPluginManagerLoads plugin manager from a configuration file.static TikaPluginManagerload(TikaJsonConfig tikaJsonConfig) Loads plugin manager from a pre-parsed TikaJsonConfig.static TikaPluginManagerloadFromPaths(String pathsString) Loads plugin manager from a comma-separated string of paths.static voidpreExtractPlugins(TikaJsonConfig tikaJsonConfig) Pre-extracts plugin zip files without loading them.Methods inherited from class org.pf4j.DefaultPluginManager
createExtensionFactory, createPluginFactory, createPluginLoader, createPluginStatusProvider, createVersionManager, initialize, loadPluginFromPathMethods inherited from class org.pf4j.AbstractPluginManager
addPluginStateListener, checkPluginId, checkPluginState, createPluginsRoot, createPluginWrapper, deletePlugin, disablePlugin, enablePlugin, firePluginStateEvent, getExtensionClasses, getExtensionClasses, getExtensionClasses, getExtensionClasses, getExtensionClassNames, getExtensionFactory, getExtensions, getExtensions, getExtensions, getExtensions, getPlugin, getPluginClassLoader, getPluginClassLoaders, getPluginDescriptorFinder, getPluginFactory, getPluginLabel, getPluginLabel, getPluginLoader, getPlugins, getPlugins, getPluginsRoot, getPluginsRoots, getResolvedPlugins, getResolveRecoveryStrategy, getRuntimeMode, getStartedPlugins, getSystemVersion, getUnresolvedPlugins, getVersion, getVersionManager, idForPath, isExactVersionAllowed, isPluginDisabled, isPluginValid, loadPlugin, loadPlugins, removePluginStateListener, resolveDependencies, resolvePlugins, setExactVersionAllowed, setResolveRecoveryStrategy, setSystemVersion, startPlugin, startPlugins, stopPlugin, stopPlugin, stopPlugins, unloadPlugin, unloadPlugin, unloadPlugin, unloadPlugins, validatePluginDescriptor, whichPluginMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.pf4j.PluginManager
isDevelopment, isNotDevelopment
-
Constructor Details
-
TikaPluginManager
- Throws:
IOException
-
-
Method Details
-
preExtractPlugins
Pre-extracts plugin zip files without loading them.Call this method early in parent processes (e.g., AsyncProcessor, PipesParser) before spawning child processes. This ensures plugins are extracted once in the parent, so child processes don't race to extract the same plugins.
This method is synchronized to prevent concurrent extraction within the same JVM. For cross-process safety,
ThreadSafeUnzipperuses atomic rename.If plugin-roots is not specified in the config, this method does nothing.
- Parameters:
tikaJsonConfig- the configuration containing plugin-roots- Throws:
IOException- if extraction fails
-
load
public static TikaPluginManager load(TikaJsonConfig tikaJsonConfig) throws TikaConfigException, IOException Loads plugin manager from a pre-parsed TikaJsonConfig. This is the preferred method when sharing configuration across core Tika and pipes components.- Parameters:
tikaJsonConfig- the pre-parsed JSON configuration- Returns:
- the plugin manager
- Throws:
TikaConfigException- if configuration is invalidIOException- if plugin initialization fails
-
loadFromPaths
public static TikaPluginManager loadFromPaths(String pathsString) throws TikaConfigException, IOException Loads plugin manager from a comma-separated string of paths.- Parameters:
pathsString- comma-separated list of plugin root directories- Returns:
- the plugin manager
- Throws:
TikaConfigException- if configuration is invalidIOException- if reading or plugin initialization fails
-
load
Loads plugin manager from a configuration file.- Parameters:
configPath- the path to the JSON configuration file- Returns:
- the plugin manager
- Throws:
TikaConfigException- if configuration is invalidIOException- if reading or plugin initialization fails
-
createExtensionFinder
protected org.pf4j.ExtensionFinder createExtensionFinder()Override to disable classpath scanning for extensions. By default, PF4J's DefaultExtensionFinder scans both plugins AND the classpath: - LegacyExtensionFinder scans for extensions.idx files (causes errors for unpackaged JARs) - ServiceProviderExtensionFinder scans META-INF/services (finds Lombok and other libs) We only want to discover extensions from the configured plugin directories, not from the application classpath. The DefaultExtensionFinder without any additional finders will only scan the loaded plugins.- Overrides:
createExtensionFinderin classorg.pf4j.DefaultPluginManager
-
createPluginRepository
protected org.pf4j.PluginRepository createPluginRepository()Override to prevent scanning subdirectories in development mode. In development mode, the default DevelopmentPluginRepository scans for subdirectories, but we want each path in plugin-roots to be treated as a complete plugin directory.- Overrides:
createPluginRepositoryin classorg.pf4j.DefaultPluginManager
-
createPluginDescriptorFinder
protected org.pf4j.PluginDescriptorFinder createPluginDescriptorFinder()Override to use PropertiesPluginDescriptorFinder in development mode. In development mode, plugins are in target/classes with plugin.properties, not packaged JARs with META-INF/MANIFEST.MF.- Overrides:
createPluginDescriptorFinderin classorg.pf4j.DefaultPluginManager
-