Class DefaultPluginsDir

java.lang.Object
org.apache.tika.pipes.core.config.DefaultPluginsDir

public final class DefaultPluginsDir extends Object
Resolves the default plugins directory when plugin-roots is not configured (TIKA-4864). The probe order matches the install layouts Tika ships:
  1. next to the jar the anchor class was loaded from (a flat install, tika-grpc's docker image);
  2. next to that directory's parent (the unpacked distributions and the tika-server docker image load classes from lib/, the plugins sit beside lib/);
  3. a plugins directory in the current working directory.
The result is always absolute: the forked pipes server resolves the configured value against its own working directory, which need not be the parent's, so a relative default would make the two processes disagree.
  • Field Details

    • PLUGINS_DIR_NAME

      public static final String PLUGINS_DIR_NAME
      The directory name probed in each location.
      See Also:
  • Method Details

    • resolve

      public static String resolve(Class<?> anchor)
      Resolves the default plugins directory for the install layout of the given class.
      Parameters:
      anchor - the class whose code source anchors the probe, usually the caller
      Returns:
      the absolute path of the first plugins directory found, or the absolute path of plugins in the working directory if none exists yet
    • find

      public static Optional<Path> find(Class<?> anchor)
      The same probe as resolve(Class), but empty rather than a warning and a fallback path when no plugins directory exists.
    • needsDefault

      public static boolean needsDefault(com.fasterxml.jackson.databind.JsonNode pluginRoots)
      Parameters:
      pluginRoots - the configured plugin-roots node, or null
      Returns:
      true when it is absent or still a placeholder token copied from an example config, so the caller should install the default
    • resolve

      public static Path resolve(Path codeSourceDir, Path cwd)
      The probe itself, separated from the code-source lookup for testing.
      Parameters:
      codeSourceDir - the directory holding the anchor's jar, or null
      cwd - the working directory to fall back to
      Returns:
      the absolute path of the resolved directory
    • find

      public static Optional<Path> find(Path codeSourceDir, Path cwd)
      Returns:
      the first existing plugins directory: beside the code source, beside its parent, or in cwd; empty when there is none