Package org.apache.tika.config.loader
Class ComponentRegistry
java.lang.Object
org.apache.tika.config.loader.ComponentRegistry
Registry for looking up Tika component classes by name.
Loads component name-to-class mappings from META-INF/tika/*.idx files
generated by the
@TikaComponent annotation processor.
The registry tracks:
- Component class
- Whether the component is self-configuring (implements
SelfConfiguring) - Optional explicit context key for ParseContext
Modules that can't use @TikaComponent (due to dependency constraints) can provide their own META-INF/tika/*.idx files to register components.
-
Constructor Summary
ConstructorsConstructorDescriptionComponentRegistry(String indexFileName, ClassLoader classLoader) Creates a component registry by loading the specified index file. -
Method Summary
Modifier and TypeMethodDescriptionReturns all registered component names.Class<?>getComponentClass(String name) Looks up a component class by name.getComponentInfo(String name) Looks up full component information by name.Returns all components marked as defaults.getFriendlyName(Class<?> clazz) Looks up a component's friendly name by its class.booleanhasComponent(String name) Checks if a component with the given name is registered.
-
Constructor Details
-
ComponentRegistry
Creates a component registry by loading the specified index file.- Parameters:
indexFileName- the index file name (e.g., "parsers", "detectors") without the .idx extensionclassLoader- the class loader to use for loading classes- Throws:
TikaConfigException- if the index file cannot be loaded
-
-
Method Details
-
getComponentClass
Looks up a component class by name.- Parameters:
name- the component name (e.g., "pdf-parser")- Returns:
- the component class
- Throws:
TikaConfigException- if the component name is not found
-
getComponentInfo
Looks up full component information by name.- Parameters:
name- the component name (e.g., "pdf-parser")- Returns:
- the component info including class, selfConfiguring flag, and contextKey
- Throws:
TikaConfigException- if the component name is not found
-
getAllComponents
Returns all registered component names.- Returns:
- unmodifiable map of component names to component info
-
getDefaultComponents
Returns all components marked as defaults.- Returns:
- unmodifiable map of component names to component info for default implementations
-
hasComponent
Checks if a component with the given name is registered.- Parameters:
name- the component name- Returns:
- true if the component is registered
-
getFriendlyName
Looks up a component's friendly name by its class. Uses class name (not Class object) for lookup to handle classloader differences.- Parameters:
clazz- the component class- Returns:
- the friendly name, or null if not registered
-