Class TikaExtras
java.lang.Object
org.apache.tika.config.TikaExtras
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSystem property naming the extras directory. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringappendJarsToClasspath(String classpath) Appends theextraJars()(as absolute paths, joined with the platform path separator) to the given classpath string — for extending a forked process's-cpwith the extras jars.The*.jarfiles in the "tika.extras.dir" directory — for callers that extend a forked process's classpath rather than installing a classloader.static PathThe configured extras directory, ornullif the feature is off.static ClassLoaderinstall()If "tika.extras.dir" is set, installs a classloader over the*.jarfiles in that directory as the thread + TikaServiceLoadercontext classloader, so they join SPI discovery.
-
Field Details
-
EXTRAS_DIR_PROPERTY
System property naming the extras directory. Unset = feature off.- See Also:
-
-
Method Details
-
install
If "tika.extras.dir" is set, installs a classloader over the*.jarfiles in that directory as the thread + TikaServiceLoadercontext classloader, so they join SPI discovery. No-op (returnsnull) 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
nullif extras are off/empty
-
extraJars
The*.jarfiles 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
Appends theextraJars()(as absolute paths, joined with the platform path separator) to the given classpath string — for extending a forked process's-cpwith the extras jars. Returnsclasspathunchanged 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
The configured extras directory, ornullif the feature is off.
-