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
FieldsModifier and TypeFieldDescriptionstatic final StringSystem property:truealso accepts extension factories found throughMETA-INF/extensions.idxon the application classpath.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.ExtensionFinderExtensions come from the loaded plugins only, unlessCLASSPATH_PLUGINS_PROPERTYopts in to pf4j's stock finder, which also reads everyMETA-INF/extensions.idxon the application classpath.protected org.pf4j.PluginDescriptorFinderOverride to use PropertiesPluginDescriptorFinder in development mode.protected org.pf4j.PluginLoaderIn development mode each root is an exploded classes directory (e.g.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, 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
-
Field Details
-
CLASSPATH_PLUGINS_PROPERTY
System property:truealso accepts extension factories found throughMETA-INF/extensions.idxon the application classpath. Those run in the application classloader with none of the plugin isolation; whoever sets it owns the consequences.PipesForkParsersets it on its fork when there is no plugins directory.- See Also:
-
-
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()Extensions come from the loaded plugins only, unlessCLASSPATH_PLUGINS_PROPERTYopts in to pf4j's stock finder, which also reads everyMETA-INF/extensions.idxon the application classpath.- 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
-
createPluginLoader
protected org.pf4j.PluginLoader createPluginLoader()In development mode each root is an exploded classes directory (e.g.target/classes), so the plugin's classpath is the root itself rather than pf4j's Maven module layout, and classes resolve application-first so a test in the same JVM shares the plugin's types.- Overrides:
createPluginLoaderin 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
-