Package org.apache.tika.config.loader
Class ParserLoader
java.lang.Object
org.apache.tika.config.loader.AbstractSpiComponentLoader<Parser>
org.apache.tika.config.loader.ParserLoader
- All Implemented Interfaces:
ComponentLoader<Parser>
Loader for parsers with support for:
- SPI fallback via "default-parser" marker with exclusions
- Mime type filtering decorations (_mime-include, _mime-exclude)
- EncodingDetector, Renderer and content-enricher dependency injection
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ParsercreateDefaultComposite(Set<Class<? extends Parser>> exclusions, LoaderContext context) Create the SPI-backed default composite with exclusions.protected ParserdecorateDefaultComposite(Parser parser, com.fasterxml.jackson.databind.JsonNode configNode, LoaderContext context) Decorate the default composite with additional behavior.protected Parserfinish(Parser root, LoaderContext context) Content enrichers are settled once, over the whole tree: the configured list, or with none, one engine per type resolved from the enrichers among the loaded parsers.The set of keys permitted inside a marker config (e.g., insidedefault-parser).protected ParserloadComponent(String name, com.fasterxml.jackson.databind.JsonNode configNode, LoaderContext context) Load a single component from config.protected ParserpostProcess(Parser parser, LoaderContext context) Post-process a single component (e.g., inject dependencies).unwrapClass(Parser component) Unwrap a component to get the underlying class for auto-exclusion purposes.protected ParserwrapInComposite(List<Parser> parsers, LoaderContext context) Wrap a list of components in a composite.Methods inherited from class org.apache.tika.config.loader.AbstractSpiComponentLoader
getComponentClass, getDefaultMarkerName, getSectionName, handleSpecialName, load, postProcessList
-
Constructor Details
-
ParserLoader
public ParserLoader()
-
-
Method Details
-
loadComponent
protected Parser loadComponent(String name, com.fasterxml.jackson.databind.JsonNode configNode, LoaderContext context) throws TikaConfigException Description copied from class:AbstractSpiComponentLoaderLoad a single component from config. The default instantiates the named component from its config; subclasses override to apply decorations (e.g., mime filtering for parsers).- Overrides:
loadComponentin classAbstractSpiComponentLoader<Parser>- Parameters:
name- the component name (friendly name or FQCN)configNode- the JSON configuration for this componentcontext- the loader context- Returns:
- the loaded component
- Throws:
TikaConfigException- if loading fails
-
createDefaultComposite
protected Parser createDefaultComposite(Set<Class<? extends Parser>> exclusions, LoaderContext context) Description copied from class:AbstractSpiComponentLoaderCreate the SPI-backed default composite with exclusions. E.g., new DefaultParser(..., exclusions) or new DefaultDetector(..., exclusions)- Specified by:
createDefaultCompositein classAbstractSpiComponentLoader<Parser>- Parameters:
exclusions- classes to exclude from SPI loadingcontext- the loader context- Returns:
- the default composite
-
getAllowedMarkerKeys
Description copied from class:AbstractSpiComponentLoaderThe set of keys permitted inside a marker config (e.g., insidedefault-parser). Subclasses extend this when they consume additional framework-level decorators on the marker.Default: just
"exclude". ParserLoader adds the mime-filter decorators.- Overrides:
getAllowedMarkerKeysin classAbstractSpiComponentLoader<Parser>
-
decorateDefaultComposite
protected Parser decorateDefaultComposite(Parser parser, com.fasterxml.jackson.databind.JsonNode configNode, LoaderContext context) throws TikaConfigException Description copied from class:AbstractSpiComponentLoaderDecorate the default composite with additional behavior. E.g., for parsers, apply mime filtering from _mime-include/_mime-exclude. Default: returns the composite unchanged.- Overrides:
decorateDefaultCompositein classAbstractSpiComponentLoader<Parser>- Parameters:
parser- the default compositeconfigNode- the JSON configuration for the default marker (may be null)context- the loader context- Returns:
- the decorated composite
- Throws:
TikaConfigException- if decoration fails
-
wrapInComposite
Description copied from class:AbstractSpiComponentLoaderWrap a list of components in a composite. E.g., new CompositeParser(registry, list) or new CompositeDetector(registry, list)- Specified by:
wrapInCompositein classAbstractSpiComponentLoader<Parser>- Parameters:
parsers- the list of componentscontext- the loader context- Returns:
- the composite component
-
unwrapClass
Description copied from class:AbstractSpiComponentLoaderUnwrap a component to get the underlying class for auto-exclusion purposes. When a component is wrapped in a decorator (e.g., ParserDecorator for mime filtering), we need to exclude the underlying class from SPI, not the decorator class. Subclasses can override this for type-specific unwrapping.- Overrides:
unwrapClassin classAbstractSpiComponentLoader<Parser>
-
postProcess
Description copied from class:AbstractSpiComponentLoaderPost-process a single component (e.g., inject dependencies). Default: returns the component unchanged.- Overrides:
postProcessin classAbstractSpiComponentLoader<Parser>- Parameters:
parser- the component to post-processcontext- the loader context- Returns:
- the post-processed component
- Throws:
TikaConfigException- if post-processing fails
-
finish
Content enrichers are settled once, over the whole tree: the configured list, or with none, one engine per type resolved from the enrichers among the loaded parsers. Either way everyEnrichingParsergets a composite (possibly empty), the effective engines are logged, and every engine under"parsers", the deprecated shape, is called out with what the entry does today.- Overrides:
finishin classAbstractSpiComponentLoader<Parser>- Parameters:
root- the fully assembled componentcontext- the loader context- Returns:
- the component to hand out
- Throws:
TikaConfigException- if finishing fails
-