Interface RoutesBuilderLoader

All Superinterfaces:
AutoCloseable, CamelContextAware, HasCamelContext, Service, StaticService
All Known Subinterfaces:
ExtendedRoutesBuilderLoader

public interface RoutesBuilderLoader extends StaticService, CamelContextAware
SPI that loads RoutesBuilder instances from a Resource identified by file extension.

Implementations are keyed by the extension they support (e.g. java, xml, yaml, kts) and are discovered at path FACTORY_PATH. At startup, CamelContext iterates over the configured route resource locations, selects the appropriate loader via isSupportedExtension(String), and calls loadRoutesBuilder(Resource) to obtain one or more RoutesBuilders that are then added to the context. Before routes are loaded, preParseRoute(Resource) may be called to extract camel.main.* bootstrap configuration from the DSL source without fully loading the routes; this allows the context to apply route-shaping settings (e.g. component overrides) before the full load.

Since:
3.8
See Also:
  • Field Details

    • FACTORY_PATH

      static final String FACTORY_PATH
      Service factory base path for language specific loaders.
      See Also:
  • Method Details

    • getSupportedExtension

      String getSupportedExtension()
      The supported file extension.

      Implementations should support a single extension only.

    • isSupportedExtension

      default boolean isSupportedExtension(String extension)
      Whether the file extension is supported
    • loadRoutesBuilder

      RoutesBuilder loadRoutesBuilder(Resource resource) throws Exception
      Parameters:
      resource - the resource to be loaded.
      Returns:
      a RoutesBuilder
      Throws:
      Exception
    • preParseRoute

      default void preParseRoute(Resource resource) throws Exception
      Pre-parses the RoutesBuilder from Resource. This is used during bootstrap, to eager detect configurations from route DSL resources which makes it possible to specify configurations that affect the bootstrap, such as by camel-jbang and camel-yaml-dsl.
      Parameters:
      resource - the resource to be pre parsed.
      Throws:
      Exception