Interface FactoryFinder


public interface FactoryFinder
Looks up and instantiates SPI factory classes declared in resource files on the classpath, following the META-INF/services/org/apache/camel/ service-file convention used throughout Camel.

Each service file contains the fully-qualified class name of a factory implementation. Given a lookup key, the finder appends the key to getResourcePath(), reads the file, loads the named class via the ClassResolver, and instantiates it. This mechanism lets components and modules ship their implementations without explicit registration; Camel discovers them automatically at startup via this discovery contract.

FactoryFinderResolver creates and caches FactoryFinder instances per resource path, so each distinct path has exactly one finder for the lifetime of the CamelContext.

See Also:
  • Field Details

  • Method Details

    • getResourcePath

      String getResourcePath()
      Gets the resource classpath.
      Returns:
      the resource classpath.
    • newInstance

      Optional<Object> newInstance(String key)
      Creates a new class instance using the key to lookup
      Parameters:
      key - is the key to add to the path to find a text file containing the factory name
      Returns:
      a newly created instance (if exists)
    • newInstance

      <T> Optional<T> newInstance(String key, Class<T> type)
      Creates a new class instance using the key to lookup
      Parameters:
      key - is the key to add to the path to find a text file containing the factory name
      type - the class type
      Returns:
      a newly created instance (if exists)
    • findClass

      Optional<Class<?>> findClass(String key)
      Finds the given factory class using the key to lookup.
      Parameters:
      key - is the key to add to the path to find a text file containing the factory name
      Returns:
      the factory class
    • findOptionalClass

      Optional<Class<?>> findOptionalClass(String key)
      Finds the optional factory class using the key to lookup.
      Parameters:
      key - is the key to add to the path to find a text file containing the factory name
      Returns:
      the factory class if found, or null if no class existed
    • clear

      void clear()
      Clear the resolver state from previous scans.