Class LoaderContext

java.lang.Object
org.apache.tika.config.loader.LoaderContext

public class LoaderContext extends Object
Shared context passed to ComponentLoaders.

Provides access to dependencies and utilities without tight coupling. Component loaders can use this to:

  • Access the ClassLoader for SPI loading
  • Use the ObjectMapper for JSON deserialization
  • Get cross-component dependencies (e.g., EncodingDetector for parsers)
  • Instantiate components via the shared ComponentInstantiator
  • Constructor Details

  • Method Details

    • getClassLoader

      public ClassLoader getClassLoader()
    • getObjectMapper

      public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • get

      public <T> T get(Class<T> componentClass) throws TikaConfigException
      Get a dependency by class type. Uses lazy loading to avoid circular dependencies.
      Parameters:
      componentClass - the component class to get
      Returns:
      the component instance
      Throws:
      TikaConfigException - if loading fails
    • getEncodingDetector

      public EncodingDetector getEncodingDetector() throws TikaConfigException
      Get the EncodingDetector for injection into parsers.
      Returns:
      the encoding detector
      Throws:
      TikaConfigException - if loading fails
    • getRenderer

      public Renderer getRenderer() throws TikaConfigException
      Get the Renderer for injection into rendering parsers.
      Returns:
      the renderer
      Throws:
      TikaConfigException - if loading fails
    • instantiate

      public <T> T instantiate(String name, com.fasterxml.jackson.databind.JsonNode configNode) throws TikaConfigException
      Instantiate a component by name and config.
      Parameters:
      name - the component name (friendly name or FQCN)
      configNode - the JSON configuration for the component
      Returns:
      the instantiated component
      Throws:
      TikaConfigException - if instantiation fails