Package org.apache.tika.config.loader
Class LoaderContext
java.lang.Object
org.apache.tika.config.loader.LoaderContext
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for lazy access to cross-component dependencies. -
Constructor Summary
ConstructorsConstructorDescriptionLoaderContext(ClassLoader classLoader, com.fasterxml.jackson.databind.ObjectMapper objectMapper, LoaderContext.DependencyProvider dependencyProvider) -
Method Summary
Modifier and TypeMethodDescription<T> TGet a dependency by class type.Get the EncodingDetector for injection into parsers.com.fasterxml.jackson.databind.ObjectMapperGet the Renderer for injection into rendering parsers.<T> Tinstantiate(String name, com.fasterxml.jackson.databind.JsonNode configNode) Instantiate a component by name and config.
-
Constructor Details
-
LoaderContext
public LoaderContext(ClassLoader classLoader, com.fasterxml.jackson.databind.ObjectMapper objectMapper, LoaderContext.DependencyProvider dependencyProvider)
-
-
Method Details
-
getClassLoader
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
get
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
Get the EncodingDetector for injection into parsers.- Returns:
- the encoding detector
- Throws:
TikaConfigException- if loading fails
-
getRenderer
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
-