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_NAME

    Fields 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
    Constructor
    Description
    TikaPluginManager(List<Path> pluginRoots)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.pf4j.ExtensionFinder
    Override to disable classpath scanning for extensions.
    protected org.pf4j.PluginDescriptorFinder
    Override to use PropertiesPluginDescriptorFinder in development mode.
    protected org.pf4j.PluginRepository
    Override to prevent scanning subdirectories in development mode.
    load(Path configPath)
    Loads plugin manager from a configuration file.
    load(TikaJsonConfig tikaJsonConfig)
    Loads plugin manager from a pre-parsed TikaJsonConfig.
    loadFromPaths(String pathsString)
    Loads plugin manager from a comma-separated string of paths.
    static void
    Pre-extracts plugin zip files without loading them.

    Methods inherited from class org.pf4j.DefaultPluginManager

    createExtensionFactory, createPluginFactory, createPluginLoader, createPluginStatusProvider, createVersionManager, initialize, loadPluginFromPath

    Methods 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, whichPlugin

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.pf4j.PluginManager

    isDevelopment, isNotDevelopment
  • Constructor Details

  • Method Details

    • preExtractPlugins

      public static void preExtractPlugins(TikaJsonConfig tikaJsonConfig) throws IOException
      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, ThreadSafeUnzipper uses 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 invalid
      IOException - 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 invalid
      IOException - if reading or plugin initialization fails
    • load

      public static TikaPluginManager load(Path configPath) throws TikaConfigException, IOException
      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 invalid
      IOException - 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:
      createExtensionFinder in class org.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:
      createPluginRepository in class org.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:
      createPluginDescriptorFinder in class org.pf4j.DefaultPluginManager