Class TikaExtras

java.lang.Object
org.apache.tika.config.TikaExtras

public final class TikaExtras extends Object
Opt-in mechanism for adding user-supplied "extras" jars (extra EncodingDetectors, Parsers, etc.) to Tika's SPI discovery without repackaging the application.

Off by default. Nothing is loaded unless the "tika.extras.dir" system property points at a directory; then every *.jar in it is made visible to service-loading. There is no implicit or default directory — the feature is off unless the property is set. (A relative property value is resolved against the process working directory, like any path.)

Security: this is a trusted code directory — anything in it runs with the full privileges of the Tika process. Treat write access to it exactly like write access to lib/; it must not be writable by less-trusted principals (for servers, not reachable by request handling). Being opt-in keeps "we are now loading extra code" an explicit, auditable choice.

  • Field Details

    • EXTRAS_DIR_PROPERTY

      public static final String EXTRAS_DIR_PROPERTY
      System property naming the extras directory. Unset = feature off.
      See Also:
  • Method Details

    • install

      public static ClassLoader install()
      If "tika.extras.dir" is set, installs a classloader over the *.jar files in that directory as the thread + Tika ServiceLoader context classloader, so they join SPI discovery. No-op (returns null) when the property is unset or the directory is missing/empty. Call exactly once at startup, before any Tika component is loaded: each call builds a new classloader, so repeated calls stack them and leave the earlier ones' open jar handles dangling.
      Returns:
      the installed classloader, or null if extras are off/empty
    • extraJars

      public static List<Path> extraJars()
      The *.jar files in the "tika.extras.dir" directory — for callers that extend a forked process's classpath rather than installing a classloader. Empty when the property is unset or the directory is missing/has no jars.
    • appendJarsToClasspath

      public static String appendJarsToClasspath(String classpath)
      Appends the extraJars() (as absolute paths, joined with the platform path separator) to the given classpath string — for extending a forked process's -cp with the extras jars. Returns classpath unchanged when the feature is off or the directory has no jars.
      Parameters:
      classpath - the base classpath to extend
      Returns:
      the classpath with any extras jars appended
    • extrasDir

      public static Path extrasDir()
      The configured extras directory, or null if the feature is off.