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
    Modifier and Type
    Field
    Description
    static final String
    System property: true also accepts extension factories found through META-INF/extensions.idx on the application classpath.

    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
    Extensions come from the loaded plugins only, unless CLASSPATH_PLUGINS_PROPERTY opts in to pf4j's stock finder, which also reads every META-INF/extensions.idx on the application classpath.
    protected org.pf4j.PluginDescriptorFinder
    Override to use PropertiesPluginDescriptorFinder in development mode.
    protected org.pf4j.PluginLoader
    In development mode each root is an exploded classes directory (e.g.
    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, 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
  • Field Details

    • CLASSPATH_PLUGINS_PROPERTY

      public static final String CLASSPATH_PLUGINS_PROPERTY
      System property: true also accepts extension factories found through META-INF/extensions.idx on the application classpath. Those run in the application classloader with none of the plugin isolation; whoever sets it owns the consequences. PipesForkParser sets it on its fork when there is no plugins directory.
      See Also:
  • 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()
      Extensions come from the loaded plugins only, unless CLASSPATH_PLUGINS_PROPERTY opts in to pf4j's stock finder, which also reads every META-INF/extensions.idx on the application classpath.
      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
    • 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:
      createPluginLoader 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