Class ComponentRegistry

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

public class ComponentRegistry extends Object
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 Details

    • ComponentRegistry

      public ComponentRegistry(String indexFileName, ClassLoader classLoader) throws TikaConfigException
      Creates a component registry by loading the specified index file.
      Parameters:
      indexFileName - the index file name (e.g., "parsers", "detectors") without the .idx extension
      classLoader - the class loader to use for loading classes
      Throws:
      TikaConfigException - if the index file cannot be loaded
  • Method Details

    • getComponentClass

      public Class<?> getComponentClass(String name) throws TikaConfigException
      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

      public ComponentInfo getComponentInfo(String name) throws TikaConfigException
      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

      public Map<String,ComponentInfo> getAllComponents()
      Returns all registered component names.
      Returns:
      unmodifiable map of component names to component info
    • getDefaultComponents

      public Map<String,ComponentInfo> getDefaultComponents()
      Returns all components marked as defaults.
      Returns:
      unmodifiable map of component names to component info for default implementations
    • hasComponent

      public boolean hasComponent(String name)
      Checks if a component with the given name is registered.
      Parameters:
      name - the component name
      Returns:
      true if the component is registered
    • getFriendlyName

      public String getFriendlyName(Class<?> clazz)
      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